Documentation ¶
Index ¶
Constants ¶
View Source
const ( // NoWinner if the game continues NoWinner = iota // Draw if reached end game and the game is draw Draw // P1Wins if player 1 wins P1Wins // P2Wins if player 2 wins P2Wins )
View Source
const ( // EmptyCell represents an empty cell EmptyCell = iota // P1Head cell that contains the player 1 position P1Head // P2Head cell that contains the player 2 position P2Head // P1Tail cell - tail of player 1 P1Tail // P2Tail cell - tail of player 2 P2Tail // Crash cell - when p1 or p2 hits the board edge or another player Crash )
View Source
const ( // Up Up = iota // Left Left // Down Down // Right Right )
Direction representation
View Source
const BoardHeight = 16
BoardHeight in cells
View Source
const BoardWidth = 16
BoardWidth in cells
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Board ¶
Board rerpesents a game board: - P1, P2 - reference to players - Grid - a two dimensional array, containing the board state
type Cell ¶
type Cell byte
Cell represents a cell of the board grid The enum above contains the possibble values
type Grid ¶
type Grid [BoardWidth][BoardHeight]Cell
Grid is a two-dimensional array of bytes, representing the Grid state The lower left corner has coordinates 0, 0
type Player ¶
Player represents a player in the game
func (*Player) SetDirection ¶
SetDirection checks if the change in direction is a valid one and updates the player if so
Click to show internal directories.
Click to hide internal directories.