Mozliwosc poruszania sie graczem pierwszym. Jeszcze trzeba zmieniec aby nie trzeba bylo potwierdzac enterem.

This commit is contained in:
knmarcin 2018-11-17 09:03:08 +01:00
parent 373a8f0dbb
commit 312c95fd17
2 changed files with 18 additions and 4 deletions

BIN
Pong

Binary file not shown.

22
Pong.go
View File

@ -16,7 +16,7 @@ var Ball [10][30]string
var BallDirection [10][30]string
var BallSpeed int
var GameOver bool = false
var LastPressedKey string
var LastPressedKey rune
func main() {
CreateBoard()
SpawnPlayers()
@ -76,13 +76,27 @@ func Loop() {
i = 5
P1index=3
for GameOver == false {
fmt.Scanf("%s", &LastPressedKey)
if LastPressedKey == "w" {
fmt.Scanf("%c", &LastPressedKey)
if LastPressedKey == 'w' {
if P1index != 0 {
P1index--
gameBoard[P1index][0] = "|"
gameBoard[P1index + 3][0] = " "
PrintBoard()
} else {
PrintBoard()
}
}
PrintBoard()
if LastPressedKey=='s' {
if P1index!=7 {
gameBoard[P1index][0] = " "
P1index++
gameBoard[P1index + 2][0] = "|"
PrintBoard()
} else {
PrintBoard()
}
}
}
}