game

package
v0.0.0-...-b6b0c08 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Wall         = int('#')
	Snake        = int('x')
	Tail         = int('o')
	Food         = int('*')
	Floor        = int(' ')
	MaxWidth     = 0
	MaxHeight    = 0
	CurrentFoodX = -1
	CurrentFoodY = -1

	Speed = 80
)

Functions

func InitFood

func InitFood(board [][]int) [][]int

Initialize a new food randomly.

func Render

func Render(game *Game)

Refresh the screen.

Types

type Game

type Game struct {
	Level    int
	Board    [][]int
	DataBase *levels
	Property GameProperty
}

func NewGame

func NewGame(level int) *Game

Initialize the game.

func (*Game) Move

func (game *Game) Move(dir Keys)

Manage moves.

func (*Game) Next

func (game *Game) Next() *Game

Going to the next level.

func (*Game) SetSpeed

func (game *Game) SetSpeed(i int)

Manage the snake's speed.

type GameProperty

type GameProperty struct {
	HeadX int
	HeadY int
	Score int
	Lost  int
	// contains filtered or unexported fields
}

type Keys

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

type Shift

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

Jump to

Keyboard shortcuts

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