Mozliwosc poruszania sie graczem pierwszym. Jeszcze trzeba zmieniec aby nie trzeba bylo potwierdzac enterem.
This commit is contained in:
parent
373a8f0dbb
commit
312c95fd17
24
Pong.go
24
Pong.go
@ -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()
|
||||
}
|
||||
}
|
||||
if LastPressedKey=='s' {
|
||||
if P1index!=7 {
|
||||
gameBoard[P1index][0] = " "
|
||||
P1index++
|
||||
gameBoard[P1index + 2][0] = "|"
|
||||
PrintBoard()
|
||||
} else {
|
||||
PrintBoard()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user