go:make_board: Changed makeBoard to accept a symbol to place in the array
This commit is contained in:
parent
c297adac81
commit
93e5494f70
@ -8,19 +8,19 @@ func main() {
|
||||
const boardY int = 7
|
||||
const boardX int = 12
|
||||
|
||||
board := makeBoard(boardY, boardX)
|
||||
board := makeBoard(boardY, boardX, "_")
|
||||
|
||||
// Pretend that the player did something in the middle
|
||||
playerMoveY := boardY / 2
|
||||
playerMoveX := boardX / 2
|
||||
|
||||
board[playerMoveY][playerMoveX] = "@ "
|
||||
board[playerMoveY][playerMoveX] = "@"
|
||||
|
||||
printBoard(board)
|
||||
|
||||
}
|
||||
|
||||
func makeBoard(sizeY, sizeX int) [][]string {
|
||||
func makeBoard(sizeY, sizeX int, symbol string) [][]string {
|
||||
//Make an array of empty strings
|
||||
// Rows
|
||||
board := make([][]string, sizeY)
|
||||
@ -31,7 +31,7 @@ func makeBoard(sizeY, sizeX int) [][]string {
|
||||
board[y] = make([]string, sizeX)
|
||||
// and populate em
|
||||
for x := 0; x < sizeX; x++ {
|
||||
board[y][x] = "_ "
|
||||
board[y][x] = symbol
|
||||
}
|
||||
}
|
||||
return board
|
||||
|
Loading…
x
Reference in New Issue
Block a user