mecze soe by dodac jakas fizyke pilki ale nie moge nic wymyslic

This commit is contained in:
knmarcin 2018-11-21 22:28:10 +01:00
parent 63d9932607
commit 9984e8af4d
2 changed files with 68 additions and 42 deletions

BIN
Pong

Binary file not shown.

106
Pong.go
View File

@ -28,7 +28,7 @@ func main() {
SpawnEverything()
for !GameOver {
Ball()
Loop()
}
}
func SpawnEverything() {
@ -73,7 +73,7 @@ func PrintBoard() {
func SpawnBall() {
x = 4
y = 14
gameBoard[x][y] = "o"
gameBoard[x][y] = " "
}
func SpawnPlayers() {
for i = 0; i < 10; i++ {
@ -95,6 +95,7 @@ func Loop() {
P2index=3
for !GameOver {
c:=getch()
switch {
case bytes.Equal(c, []byte{3}):
@ -139,33 +140,33 @@ func Loop() {
}
}
func Ball() {
BallX = 2
BallY = 14
BallDirX = 4
BallDirY = 0
for BallX!=BallDirX && BallY!=BallDirY {
func Ball() {
BallX = 7
BallY = 14
BallDirX = 8
BallDirY = 1
for BallX!=BallDirX || BallY!=BallDirY {
if BallX>BallDirX {
gameBoard[BallX][BallY] = " "
BallX--
gameBoard[BallX][BallY] = "o"
PrintBoard()
if BallY>BallDirY {
gameBoard[BallX][BallY] = " "
BallY--
gameBoard[BallX][BallY] = "o"
PrintBoard()
time.Sleep(1 * time.Second)
}
if BallY<BallDirY {
gameBoard[BallX][BallY] = " "
BallY++
gameBoard[BallX][BallY] = "o"
PrintBoard()
time.Sleep(1 * time.Second)
}
}
if BallY>BallDirY {
gameBoard[BallX][BallY] = " "
BallY--
gameBoard[BallX][BallY] = "o"
PrintBoard()
time.Sleep(1 * time.Second)
}
if BallY<BallDirY {
gameBoard[BallX][BallY] = " "
BallY++
gameBoard[BallX][BallY] = "o"
PrintBoard()
time.Sleep(1 * time.Second)
}
if BallX < BallDirX {
gameBoard[BallX][BallY] = " "
@ -173,21 +174,6 @@ func Ball() {
gameBoard[BallX][BallY] = "o"
PrintBoard()
time.Sleep(1 * time.Second)
if BallY < BallDirY {
gameBoard[BallX][BallY] = " "
BallY++
gameBoard[BallX][BallY] = "o"
PrintBoard()
time.Sleep(1 * time.Second)
}
if BallY > BallDirY {
gameBoard[BallX][BallY] = " "
BallY--
gameBoard[BallX][BallY] = "o"
PrintBoard()
time.Sleep(1 * time.Second)
}
}
if BallX==BallDirX {
if BallY < BallDirY {
@ -196,18 +182,58 @@ func Ball() {
gameBoard[BallX][BallY] = "o"
PrintBoard()
time.Sleep(1 * time.Second)
}
}
if BallY > BallDirY {
gameBoard[BallX][BallY] = " "
BallY--
gameBoard[BallX][BallY] = "o"
PrintBoard()
time.Sleep(1 * time.Second)
}
}
}
if gameBoard[BallX][BallY-1] == " " {
GameOver = true
fmt.Print("Game Over!\n")
}
}
}
func TickBall() {
BallX = 4
BallY = 14
for !GameOver {
if GoesUP {
if BallX < 9 {
BallX++
if GoesLEFT {
BallY--
}
if Bally == 9 {
GoesUP = false
}
}
if !GoesUP {
if BallX > 1 {
BallX--
if GoesLeft {
BallY++
}
}
}
}
}
}
func Parallelize(functions ...func()) {
var waitGroup sync.WaitGroup
waitGroup.Add(len(functions))