go:make_board: Converted snake case to camel case

This commit is contained in:
Logen Kain 2017-10-03 00:48:20 -07:00
parent 778b6dd7ab
commit c297adac81

View File

@ -5,39 +5,39 @@ import (
) )
func main() { func main() {
const board_y int = 7 const boardY int = 7
const board_x int = 12 const boardX int = 12
board := make_board(board_y, board_x) board := makeBoard(boardY, boardX)
// Pretend that the player did something in the middle // Pretend that the player did something in the middle
player_move_y := board_y / 2 playerMoveY := boardY / 2
player_move_x := board_x / 2 playerMoveX := boardX / 2
board[player_move_y][player_move_x] = "@ " board[playerMoveY][playerMoveX] = "@ "
print_board(board) printBoard(board)
} }
func make_board(size_y, size_x int) [][]string { func makeBoard(sizeY, sizeX int) [][]string {
//Make an array of empty strings //Make an array of empty strings
// Rows // Rows
board := make([][]string, size_y) board := make([][]string, sizeY)
for y := 0; y < size_y; y++ { for y := 0; y < sizeY; y++ {
//Make each array an array of empty strings //Make each array an array of empty strings
//cols //cols
board[y] = make([]string, size_x) board[y] = make([]string, sizeX)
// and populate em // and populate em
for x := 0; x < size_x; x++ { for x := 0; x < sizeX; x++ {
board[y][x] = "_ " board[y][x] = "_ "
} }
} }
return board return board
} }
func print_board(board [][]string) { func printBoard(board [][]string) {
for y := 0; y < len(board); y++ { for y := 0; y < len(board); y++ {
for x := 0; x < len(board[y]); x++ { for x := 0; x < len(board[y]); x++ {
fmt.Print(board[y][x]) fmt.Print(board[y][x])