2018-11-13 16:10:46 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
var gameBoard [10][30]string
|
|
|
|
var x, y int
|
|
|
|
var i, j int
|
|
|
|
var Player1 [10]string
|
|
|
|
var Player2 [10]string
|
|
|
|
var Ball [10][30]string
|
|
|
|
var BallDirection [10][30]string
|
|
|
|
var BallSpeed int
|
2018-11-15 18:03:37 +01:00
|
|
|
var GameOver bool = false
|
|
|
|
var LastPressedKey string
|
2018-11-13 16:10:46 +01:00
|
|
|
func main() {
|
|
|
|
CreateBoard()
|
|
|
|
SpawnPlayers()
|
|
|
|
SpawnBall()
|
|
|
|
PrintBoard()
|
2018-11-15 18:03:37 +01:00
|
|
|
Loop()
|
|
|
|
|
2018-11-13 16:10:46 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func SpawnEverything() {
|
|
|
|
}
|
|
|
|
|
|
|
|
func CreateBoard() {
|
|
|
|
for i = 0; i < 10; i++ {
|
|
|
|
for j = 0; j < 30; j++ {
|
|
|
|
gameBoard[i][j] = " "
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func PrintBoard() {
|
|
|
|
for i = 0; i < 10; i++ {
|
|
|
|
for j = 0; j < 30; j++ {
|
|
|
|
fmt.Printf("%s", gameBoard[i][j])
|
|
|
|
}
|
|
|
|
fmt.Printf("\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]
|
|
|
|
}
|
|
|
|
}
|
2018-11-14 17:18:33 +01:00
|
|
|
func Loop() {
|
2018-11-15 18:03:37 +01:00
|
|
|
i = 5
|
|
|
|
for GameOver == false {
|
|
|
|
fmt.Scanf("%s", &LastPressedKey)
|
|
|
|
if LastPressedKey == "w" {
|
|
|
|
gameBoard[2][0] = "|"
|
|
|
|
gameBoard[5][0] = " "
|
|
|
|
i=i-1
|
|
|
|
PrintBoard()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PrintBoard()
|
2018-11-14 17:18:33 +01:00
|
|
|
}
|