pacman

package
v0.0.0-...-f4c9d17 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RUNE_INVINCIBLE = '🐶'
	RUNE_WEAKENING  = '🐕'
	RUNE_PLAYER     = '🐩'
	RUNE_WALL       = '⬛'
	RUNE_GHOST      = '🐈'
	RUNE_DEAD       = '👹'
	RUNE_FRUIT      = '●'
	RUNE_MEAT       = '🍖'
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Board

type Board struct {
	Width  int
	Height int
	Data   []rune
}

type Direction

type Direction int
const (
	DIR_NONE Direction = iota
	DIR_UP
	DIR_DOWN
	DIR_LEFT
	DIR_RIGHT
)

type Display

type Display interface {
	UpdateBoard(board *Board, score int)
}

type Engine

type Engine struct {
	Display    Display
	Board      Board
	FPS        int
	Score      int
	Invincible int
	Player     Sprite
	Ghosts     []Sprite
	Refresh    *time.Ticker
	Quit       chan bool
	Move       chan Direction
}

func NewEngine

func NewEngine(display Display, fps int) *Engine

func (*Engine) Start

func (e *Engine) Start()

func (*Engine) Stop

func (e *Engine) Stop()

type Game

type Game struct {
	*tview.Box

	Listener Listener
	App      *tview.Application
	Board    *Board
	Score    int
	Engine   *Engine
}

func NewGame

func NewGame(app *tview.Application, listener Listener) *Game

func (*Game) Draw

func (g *Game) Draw(screen tcell.Screen)

func (*Game) InputHandler

func (g *Game) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive)) bool

func (*Game) Play

func (g *Game) Play()

func (*Game) Quit

func (g *Game) Quit()

func (*Game) UpdateBoard

func (g *Game) UpdateBoard(board *Board, score int)

type Listener

type Listener interface {
	SnakeGameFinished()
}

type Sprite

type Sprite struct {
	X         int
	Y         int
	Char      rune
	Direction Direction
}

func (*Sprite) Hit

func (s *Sprite) Hit(other *Sprite) bool

Jump to

Keyboard shortcuts

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