game

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

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Title        = "Timber Cutter"
	ScreenWidth  = 640
	ScreenHeight = 480
)

Variables

View Source
var (
	GreenColor = color.RGBA{
		R: 0,
		G: 0xFF,
		B: 0,
		A: 0xFF,
	}
	RedColor = color.RGBA{
		R: 0xFF,
		G: 0,
		B: 0,
		A: 0xFF,
	}
)
View Source
var (
	ErrTerminated = errors.New("terminated")
)

Functions

This section is empty.

Types

type Game

type Game struct {
	State *GameState
	Scene GameScene
}

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) Pause

func (g *Game) Pause()

func (*Game) Play

func (g *Game) Play()

func (*Game) ResetGame

func (g *Game) ResetGame()

func (*Game) Update

func (g *Game) Update() (err error)

type GameScene

type GameScene struct {
	Current Scene
}

func (*GameScene) Draw

func (gs *GameScene) Draw(game *Game, screen *ebiten.Image)

type GameState

type GameState struct {
	PlayerPos Position
	Tree      []Position
}

func NewGameState

func NewGameState() *GameState

func (*GameState) UpdateTree

func (g *GameState) UpdateTree()

type Position

type Position int
const (
	PosLeft  Position = -1
	PosNone  Position = 0 // Empty
	PosRight Position = 1
)

func GenerateInitialTree

func GenerateInitialTree() []Position

func GenerateSection

func GenerateSection(prevPos Position) Position

type Scene

type Scene int
const (
	NewGameScene Scene = iota
	PlayingScene
	PauseScene
	GameOverScene
)

Jump to

Keyboard shortcuts

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