Documentation ¶
Index ¶
- Variables
- type Direction
- type Type
- func (s *Type) CheckIfSnakeHasEaten(gameCFG *game.Config, berry pixel.Vec) bool
- func (s *Type) CheckSnakeOK(gameCFG *game.Config) bool
- func (s *Type) GetHeadPos() pixel.Vec
- func (s *Type) GetPositionPoints() []pixel.Vec
- func (s *Type) GetSpeed() float64
- func (s *Type) GetTailPos() pixel.Vec
- func (s *Type) GetTicker() <-chan time.Time
- func (s *Type) IncreaseSpeed()
- func (s *Type) StartOfGame(dir Direction)
- func (s *Type) Update(eaten bool, dir Direction)
Constants ¶
This section is empty.
Variables ¶
var ( // UP is the Direction defining travel towards the top of the game area. UP = Direction{pixel.V(0, 1)} // DOWN is the Direction defining travel towards the bottom of the game area. DOWN = Direction{pixel.V(0, -1)} // LEFT is the Direction defining travel towards the left of the game area. LEFT = Direction{pixel.V(-1, 0)} // RIGHT is the Direction defining travel towards the right of the game area. RIGHT = Direction{pixel.V(1, 0)} // NOCHANGE is a blank Direction, it can be used to not alter the current heading. NOCHANGE = Direction{pixel.V(0, 0)} )
Functions ¶
This section is empty.
Types ¶
type Direction ¶
type Direction struct {
// contains filtered or unexported fields
}
Direction is used to define the direction the snake is heading
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type is a struct which represents a snake in the game
func (*Type) CheckIfSnakeHasEaten ¶
CheckIfSnakeHasEaten is used to check the snake has easten the berry
func (*Type) CheckSnakeOK ¶
CheckSnakeOK is used to check the snake hasn't exicted the game area and has not hit itself
func (*Type) GetHeadPos ¶
GetHeadPos returns the position of the head of the snake in the game area coordinate plane
func (*Type) GetPositionPoints ¶
GetPositionPoints returns the list of the snakes previous turn positions in the game area coordinate plane
func (*Type) GetTailPos ¶
GetTailPos returns the position of the tail of the snake in the game area coordinate plane
func (*Type) IncreaseSpeed ¶
func (s *Type) IncreaseSpeed()
IncreaseSpeed increase the speed of the snake
func (*Type) StartOfGame ¶
StartOfGame is used to allow the starting of the game with the arrow keys to choose the initial direction of the snake.