Mozliwosc poruszania sie graczem pierwszym. Jeszcze trzeba zmieniec aby nie trzeba bylo potwierdzac enterem.
This commit is contained in:
parent
373a8f0dbb
commit
312c95fd17
22
Pong.go
22
Pong.go
@ -16,7 +16,7 @@ var Ball [10][30]string
|
|||||||
var BallDirection [10][30]string
|
var BallDirection [10][30]string
|
||||||
var BallSpeed int
|
var BallSpeed int
|
||||||
var GameOver bool = false
|
var GameOver bool = false
|
||||||
var LastPressedKey string
|
var LastPressedKey rune
|
||||||
func main() {
|
func main() {
|
||||||
CreateBoard()
|
CreateBoard()
|
||||||
SpawnPlayers()
|
SpawnPlayers()
|
||||||
@ -76,13 +76,27 @@ func Loop() {
|
|||||||
i = 5
|
i = 5
|
||||||
P1index=3
|
P1index=3
|
||||||
for GameOver == false {
|
for GameOver == false {
|
||||||
fmt.Scanf("%s", &LastPressedKey)
|
fmt.Scanf("%c", &LastPressedKey)
|
||||||
if LastPressedKey == "w" {
|
if LastPressedKey == 'w' {
|
||||||
|
if P1index != 0 {
|
||||||
P1index--
|
P1index--
|
||||||
gameBoard[P1index][0] = "|"
|
gameBoard[P1index][0] = "|"
|
||||||
gameBoard[P1index + 3][0] = " "
|
gameBoard[P1index + 3][0] = " "
|
||||||
PrintBoard()
|
PrintBoard()
|
||||||
|
|
||||||
|
} else {
|
||||||
|
PrintBoard()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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