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 boardY int = 7
|
||||||
const boardX int = 12
|
const boardX int = 12
|
||||||
|
|
||||||
board := makeBoard(boardY, boardX)
|
board := makeBoard(boardY, boardX, "_")
|
||||||
|
|
||||||
// Pretend that the player did something in the middle
|
// Pretend that the player did something in the middle
|
||||||
playerMoveY := boardY / 2
|
playerMoveY := boardY / 2
|
||||||
playerMoveX := boardX / 2
|
playerMoveX := boardX / 2
|
||||||
|
|
||||||
board[playerMoveY][playerMoveX] = "@ "
|
board[playerMoveY][playerMoveX] = "@"
|
||||||
|
|
||||||
printBoard(board)
|
printBoard(board)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeBoard(sizeY, sizeX int) [][]string {
|
func makeBoard(sizeY, sizeX int, symbol string) [][]string {
|
||||||
//Make an array of empty strings
|
//Make an array of empty strings
|
||||||
// Rows
|
// Rows
|
||||||
board := make([][]string, sizeY)
|
board := make([][]string, sizeY)
|
||||||
@ -31,7 +31,7 @@ func makeBoard(sizeY, sizeX int) [][]string {
|
|||||||
board[y] = make([]string, sizeX)
|
board[y] = make([]string, sizeX)
|
||||||
// and populate em
|
// and populate em
|
||||||
for x := 0; x < sizeX; x++ {
|
for x := 0; x < sizeX; x++ {
|
||||||
board[y][x] = "_ "
|
board[y][x] = symbol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return board
|
return board
|
||||||
|
Loading…
x
Reference in New Issue
Block a user