snake

package
v0.0.0-...-4f8f181 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AssetBody *ebiten.Image
View Source
var AssetCherry *ebiten.Image
View Source
var AssetHead *ebiten.Image
View Source
var AssetTail *ebiten.Image
View Source
var ErrUnauthorizedMove = errors.New("unauthorized move")

Functions

func LoadFont

func LoadFont(filename string) *opentype.Font

func LoadImage

func LoadImage(filename string) *ebiten.Image

Types

type Board

type Board struct {
	// contains filtered or unexported fields
}

Board The board is a simple rectangle in which the snake will evolve

func NewBoard

func NewBoard(X1, Y1, X2, Y2 float64) *Board

func (*Board) Draw

func (b *Board) Draw(screen *ebiten.Image)

func (*Board) Height

func (b *Board) Height() int

func (*Board) Width

func (b *Board) Width() int

func (*Board) X

func (b *Board) X() float64

func (*Board) Y

func (b *Board) Y() float64

type Cherry

type Cherry struct {
	X, Y int // X & Y position in the grid
	// contains filtered or unexported fields
}

func NewCherry

func NewCherry(X, Y int, board *Board) *Cherry

func (*Cherry) Draw

func (c *Cherry) Draw(screen *ebiten.Image)

type Direction

type Direction int
const (
	Up Direction = iota
	Down
	Left
	Right
)

type GameOver

type GameOver struct {
	// contains filtered or unexported fields
}

func NewGameOver

func NewGameOver(layoutWidth, layoutHeight int) *GameOver

func (*GameOver) Draw

func (g *GameOver) Draw(screen *ebiten.Image, score int)

func (*GameOver) UpdateKeys

func (g *GameOver) UpdateKeys(keys []ebiten.Key) (retry bool)
type Menu struct {
	// contains filtered or unexported fields
}

func NewMenu

func NewMenu(layoutWidth, layoutHeight int) *Menu
func (m *Menu) Draw(screen *ebiten.Image)
func (m *Menu) UpdateKeys(keys []ebiten.Key) (startGame bool)

type Part

type Part struct {
	X, Y int // X & Y position in the grid
	// contains filtered or unexported fields
}

func NewPart

func NewPart(X, Y int, board *Board) *Part

func (*Part) Draw

func (p *Part) Draw(screen *ebiten.Image, direction Direction, partType PartType)

type PartType

type PartType int
const (
	Head PartType = iota
	Body
	Tail
)

type Snake

type Snake struct {
	// contains filtered or unexported fields
}

func NewSnake

func NewSnake(layoutWidth, layoutHeight int) *Snake

func (*Snake) ApplyDirection

func (s *Snake) ApplyDirection(keys []ebiten.Key)

func (*Snake) Draw

func (s *Snake) Draw(screen *ebiten.Image)

func (*Snake) Score

func (s *Snake) Score() int

func (*Snake) UpdateKeys

func (s *Snake) UpdateKeys(keys []ebiten.Key) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL