Dodany pierwszy gracz w calosci.
Teraz musze wymyslic sposob bym nie musial potwierdzac wyboru up/down
This commit is contained in:
parent
cfa61b69c4
commit
df3089dcbc
40
Pong.go
40
Pong.go
@ -17,17 +17,17 @@ var BallDirection [10][30]string
|
||||
var BallSpeed int
|
||||
var GameOver bool = false
|
||||
var LastPressedKey rune
|
||||
|
||||
func main() {
|
||||
SpawnEverything()
|
||||
}
|
||||
|
||||
func SpawnEverything() {
|
||||
CreateBoard()
|
||||
SpawnPlayers()
|
||||
SpawnBall()
|
||||
PrintBoard()
|
||||
Loop()
|
||||
|
||||
|
||||
}
|
||||
|
||||
func SpawnEverything() {
|
||||
}
|
||||
|
||||
func CreateBoard() {
|
||||
@ -49,25 +49,20 @@ func PrintBoard() {
|
||||
fmt.Print("\n")
|
||||
}
|
||||
}
|
||||
|
||||
func SpawnBall() {
|
||||
x = 4
|
||||
y = 14
|
||||
gameBoard[x][y] = "o"
|
||||
|
||||
}
|
||||
|
||||
func SpawnPlayers() {
|
||||
for i = 0; i < 10; i++ {
|
||||
Player1[i] = " "
|
||||
Player2[i] = " "
|
||||
}
|
||||
|
||||
for i = 3; i < 6; i++ {
|
||||
Player1[i] = "|"
|
||||
Player2[i] = "|"
|
||||
j = 0
|
||||
|
||||
gameBoard[i][0] = Player1[i]
|
||||
gameBoard[i][29] = Player2[i]
|
||||
}
|
||||
@ -79,24 +74,23 @@ func Loop() {
|
||||
fmt.Scanf("%c", &LastPressedKey)
|
||||
if LastPressedKey == 'w' {
|
||||
if P1index != 0 {
|
||||
P1index--
|
||||
gameBoard[P1index][0] = "|"
|
||||
gameBoard[P1index + 3][0] = " "
|
||||
PrintBoard()
|
||||
|
||||
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()
|
||||
}
|
||||
gameBoard[P1index][0] = " "
|
||||
P1index++
|
||||
gameBoard[P1index + 2][0] = "|"
|
||||
PrintBoard()
|
||||
} else {
|
||||
PrintBoard()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user