Documentation ¶
Index ¶
Constants ¶
const ( // FontUbuntu filename of ubuntu font in the resources FontUbuntu string = "ubuntu.ttf" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Apple ¶
type Apple struct {
// contains filtered or unexported fields
}
Apple is the game object
type DeadScreen ¶
type DeadScreen struct { Score *Score Font ttf.Font Screen GameScreen // contains filtered or unexported fields }
DeadScreen object of game which can be painted
func (*DeadScreen) HandleEvent ¶
func (ds *DeadScreen) HandleEvent(event sdl.Event)
HandleEvent handle event from the input devices and manages the state
func (DeadScreen) Paint ¶
func (ds DeadScreen) Paint(d grafio.Drawer) error
Paint paints text and Score to renderer
func (*DeadScreen) Update ¶
func (ds *DeadScreen) Update() GameState
Update update dead screen and gives game state
type GameScreen ¶
type GameScreen struct {
W, H int32
}
GameScreen have struct of width and height of screen
type GameState ¶
type GameState int
GameState game current action
const ( // SnakeRunning state when the Snake is running/moving and it's not the end yet SnakeRunning GameState = iota // DeadSnake state when Snake touches something and dies and need to show dead screen DeadSnake // MenuScreen state when There's menu shown for setting and entering into game MenuScreen )
type Handleable ¶
Handleable it can handle input from sdl events
type Snake ¶
type Snake struct {
// contains filtered or unexported fields
}
Snake game object
func NewSnake ¶
func NewSnake(a *Apple, s *Score, scr GameScreen) *Snake
NewSnake create Snake struct with default and given values
func (*Snake) HandleEvent ¶
HandleEvent handles the movement of snake
type Updateable ¶
type Updateable interface {
Update() GameState
}
Updateable object data can or should be updated every each frame with certain information in function
type WelcomeText ¶
type WelcomeText struct { Screen GameScreen Snake *Snake // contains filtered or unexported fields }
WelcomeText object of showing welcome text
func (*WelcomeText) HandleEvent ¶
func (wt *WelcomeText) HandleEvent(event sdl.Event)
HandleEvent handles events from input devices
func (WelcomeText) Paint ¶
func (wt WelcomeText) Paint(d grafio.Drawer) error
Paint paints text and Score to renderer
func (*WelcomeText) Update ¶
func (wt *WelcomeText) Update() GameState
Update updates snake and chooses game state to return