48 lines
808 B
Go
48 lines
808 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
func main() {
|
|
const boardY int = 7
|
|
const boardX int = 12
|
|
|
|
board := makeBoard(boardY, boardX)
|
|
|
|
// Pretend that the player did something in the middle
|
|
playerMoveY := boardY / 2
|
|
playerMoveX := boardX / 2
|
|
|
|
board[playerMoveY][playerMoveX] = "@ "
|
|
|
|
printBoard(board)
|
|
|
|
}
|
|
|
|
func makeBoard(sizeY, sizeX int) [][]string {
|
|
//Make an array of empty strings
|
|
// Rows
|
|
board := make([][]string, sizeY)
|
|
|
|
for y := 0; y < sizeY; y++ {
|
|
//Make each array an array of empty strings
|
|
//cols
|
|
board[y] = make([]string, sizeX)
|
|
// and populate em
|
|
for x := 0; x < sizeX; x++ {
|
|
board[y][x] = "_ "
|
|
}
|
|
}
|
|
return board
|
|
}
|
|
|
|
func printBoard(board [][]string) {
|
|
for y := 0; y < len(board); y++ {
|
|
for x := 0; x < len(board[y]); x++ {
|
|
fmt.Print(board[y][x])
|
|
}
|
|
fmt.Println()
|
|
}
|
|
}
|