Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CenterAlignString ¶ added in v0.3.2
CenterAlignString will align the input string in the middle, based on the supplied width
func ListenEvents ¶ added in v0.3.2
ListenEvents will start listening for keyboard and resize events, then emit them on the supplied channels
Types ¶
type Direction ¶
Direction in -1/+1 X and Y coordinates
func GetInputDirection ¶
func GetInputDirection(key termbox.Key) Direction
GetInputDirection will convert a keyboard key to a Direction
type Game ¶
type Game struct {
// contains filtered or unexported fields
}
Game of sneaky snakey goodness
func (*Game) IncrementScore ¶
func (game *Game) IncrementScore()
IncrementScore will increase the score of the current game
type Level ¶
type Level struct {
// contains filtered or unexported fields
}
Level of awesomeness?
func NewLevel ¶
NewLevel creates a new level of a certain size, also spawning in the snake and an apple
func (*Level) EatApple ¶
func (level *Level) EatApple()
EatApple will destroy the current apple, increment the snake size and score, finally spawning a new apple
func (*Level) GetRandomPosition ¶
GetRandomPosition will return a randomize Position, constrained to the size of the current level
func (*Level) IsWall ¶ added in v0.3.2
IsWall will return true if the supplied position is a wall or a corner
type Position ¶
Position in X and Y coordinates
type Score ¶ added in v0.3.2
type Score struct {
// contains filtered or unexported fields
}
Score information for the game
func NewScore ¶ added in v0.3.2
func NewScore() *Score
NewScore creates and returns a new Score object
func (*Score) GetHighscore ¶ added in v0.3.2
GetHighscore returns the best score
func (*Score) IncrementScore ¶ added in v0.3.2
func (score *Score) IncrementScore()
IncrementScore updates the current and best score
type Snake ¶
type Snake struct {
// contains filtered or unexported fields
}
Snake wants an Apple
func (*Snake) CheckHitbox ¶
CheckHitbox will see if the supplied position is within the snake's calculated "body" (including head)
func (*Snake) IncrementSize ¶
func (snake *Snake) IncrementSize()
IncrementSize will increase the size (length) of the snake
func (*Snake) Move ¶
func (snake *Snake) Move()
Move the snake one coordinate along its current direction
func (*Snake) UpdateDirection ¶
UpdateDirection will set the snake direction, so long as it's not the opposite direction