snake

package
v0.0.0-...-e79ed84 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScreenWidth  = 600
	ScreenHeight = 600
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Board

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

func NewBoard

func NewBoard(rows int, cols int) *Board

func (*Board) Update

func (b *Board) Update(input *Input) error

type Direction

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

type Game

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

func NewGame

func NewGame() *Game

func (*Game) Draw

func (g *Game) Draw(screen *ebiten.Image)

func (*Game) Layout

func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)

func (*Game) Update

func (g *Game) Update() error

type Input

type Input struct{}

func NewInput

func NewInput() *Input

func (*Input) GetDirection

func (i *Input) GetDirection() (Direction, bool)

type Position

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

type Snake

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

func NewSnake

func NewSnake(body []Position, facing Direction) *Snake

func (*Snake) Grow

func (s *Snake) Grow()

func (*Snake) HasPosition

func (s *Snake) HasPosition(p *Position) bool

func (*Snake) Head

func (s *Snake) Head() Position

func (*Snake) HitsSelf

func (s *Snake) HitsSelf() bool

func (*Snake) Move

func (s *Snake) Move()

func (*Snake) Turn

func (s *Snake) Turn(d Direction)

Jump to

Keyboard shortcuts

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