48 lines
832 B
Go
48 lines
832 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
func main() {
|
|
const board_y int = 7
|
|
const board_x int = 12
|
|
|
|
board := make_board(board_y, board_x)
|
|
|
|
// Pretend that the player did something in the middle
|
|
player_move_y := board_y / 2
|
|
player_move_x := board_x / 2
|
|
|
|
board[player_move_y][player_move_x] = "@ "
|
|
|
|
print_board(board)
|
|
|
|
}
|
|
|
|
func make_board(size_y, size_x int) [][]string {
|
|
//Make an array of empty strings
|
|
// Rows
|
|
board := make([][]string, size_y)
|
|
|
|
for y := 0; y < size_y; y++ {
|
|
//Make each array an array of empty strings
|
|
//cols
|
|
board[y] = make([]string, size_x)
|
|
// and populate em
|
|
for x := 0; x < size_x; x++ {
|
|
board[y][x] = "_ "
|
|
}
|
|
}
|
|
return board
|
|
}
|
|
|
|
func print_board(board [][]string) {
|
|
for y := 0; y < len(board); y++ {
|
|
for x := 0; x < len(board[y]); x++ {
|
|
fmt.Print(board[y][x])
|
|
}
|
|
fmt.Println()
|
|
}
|
|
}
|