snake

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Up = iota
	Left
	Right
	Down
)

Variables

This section is empty.

Functions

func StartGame

func StartGame()

Start the snake game.

Types

type Apple

type Apple Position

func (*Apple) Position added in v0.3.1

func (apple *Apple) Position() Position

type Board

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

type Game

type Game struct {
	Apple *Apple
	Board *Board
	Snake *Snake
	// contains filtered or unexported fields
}

func (*Game) SetMode added in v1.0.0

func (g *Game) SetMode(mode GameMode)

type GameMode added in v1.0.0

type GameMode int64
const (
	EasyMode GameMode = iota
	NormalMode
	HardMode
)

type Position added in v0.3.1

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

type Snake

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

func NewSnake added in v0.3.1

func NewSnake() *Snake

Create a new snake with default position and length.

func (*Snake) CanEat

func (s *Snake) CanEat(apple *Apple) bool

Check if the snake can eat the apple.

func (*Snake) Eat added in v0.3.1

func (s *Snake) Eat(apple *Apple)

The snake Eat the apple and add apple's position to snake body slice.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳