Dodany pierwszy gracz w calosci.

Teraz musze wymyslic sposob bym nie musial potwierdzac wyboru up/down
This commit is contained in:
knmarcin 2018-11-17 09:25:33 +01:00
parent cfa61b69c4
commit df3089dcbc
2 changed files with 17 additions and 23 deletions

BIN
Pong

Binary file not shown.

40
Pong.go
View File

@ -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()
}
}
}
}