gamestate

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurrentState

type CurrentState int

CurrentState is an enum that represents the current state of the game.

const (
	// Running is the state when the game is running.
	Running CurrentState = iota

	// Paused is the state when the game is paused.
	Paused

	// NextWaveReady is the state when the next wave is ready.
	NextWaveReady
)

type GameState

type GameState struct {
	// LevelName is a name of the level.
	LevelName string

	// Map is a map of the game.
	Map *ingame.Map

	// TowersToBuy is a map of towers that can be bought.
	TowersToBuy map[string]*config.Tower

	// EnemyToCall is a map of enemies that can be called.
	EnemyToCall map[string]*config.Enemy

	// Ended is a flag that represents if the game is ended.
	Ended bool

	// Win is a flag that represents if the game is won.
	Win bool

	// State is a current state of the game.
	State CurrentState

	// UI is a UI of the game.
	UI *ebitenui.UI

	// CurrentWave is a number of the current wave.
	CurrentWave int

	// GameRule is a game rule of the game.
	GameRule ingame.GameRule

	// Time is a time of the game.
	Time general.Frames

	// PlayerMapState is a state of the player on the map.
	PlayerMapState ingame.PlayerMapState

	// Watcher is a watcher of the game.
	Watcher *replay.Watcher

	// PlayerState is a state of the player.
	PlayerState *ingame.PlayerState
	// contains filtered or unexported fields
}

GameState is a struct that represents the state of the game.

func New

func New(
	level *config.Level,
	maps map[string]*config.Map,
	en map[string]*config.Enemy,
	tw map[string]*config.Tower,
	ps *ingame.PlayerState,
	w general.Widgets,
) *GameState

New creates a new entity of GameState.

func (*GameState) Draw

func (s *GameState) Draw(screen *ebiten.Image)

Draw draws the game on the screen.

func (*GameState) End

func (s *GameState) End() bool

End returns true if the game is ended.

func (*GameState) Update

func (s *GameState) Update() error

Update updates the state of the game.

Jump to

Keyboard shortcuts

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