game

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Game

type Game struct {
	ScreenWidth  float64
	ScreenHeight float64
	// contains filtered or unexported fields
}

func New

func New(log *logrus.Logger, nAsteroids int, debug bool) *Game

func (*Game) AddAsteroid

func (g *Game) AddAsteroid(asteroidImage *ebiten.Image)

AddAsteroid insert a new asteroid in the game.

func (*Game) Draw

func (g *Game) Draw(screen *ebiten.Image)

Draw draws the game screen. Draw is called every frame (typically 1/60[s] for 60Hz display).

func (*Game) DrawAgents

func (g *Game) DrawAgents(screen *ebiten.Image)

DrawAgents loops over all game agents to update them

func (*Game) Layout

func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)

Layout takes the outside size (e.g., the window size) and returns the (logical) screen size. If you don't have to adjust the screen size with the outside size, just return a fixed size.

func (*Game) LoadImage

func (g *Game) LoadImage(file string) (*ebiten.Image, error)

LoadImage loads a picture into an ebiten image.

func (*Game) Register

func (g *Game) Register(agent physics.Physic)

Register adds a new agent (player or ai) to the game.

func (*Game) RestartGame

func (g *Game) RestartGame()

RestartGame cleans current game and a start a new game.

func (*Game) Score

func (g *Game) Score() int

func (*Game) StartGame

func (g *Game) StartGame()

StartGame initializes a new game.

func (*Game) String

func (g *Game) String() string

func (*Game) Unregister

func (g *Game) Unregister(id, agentType string)

Unregister deletes an agent (player or ai) from the game.

func (*Game) Update

func (g *Game) Update() error

Update proceeds the game state. Update is called every tick (1/60 [s] by default).

func (*Game) UpdateAgents

func (g *Game) UpdateAgents()

UpdateAgents loops over all game agents to update them

Jump to

Keyboard shortcuts

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