agents

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asteroid

type Asteroid struct {
	physics.PhysicBody
	// contains filtered or unexported fields
}

Asteroid is a PhysicalBody agent It represents a bullet shot by a starship agent.

func NewAsteroid

func NewAsteroid(
	log *logrus.Logger,
	x, y,
	screenWidth, screenHeight float64,
	cbr physics.AgentRegister,
	cbu physics.AgentUnregister,
	asteroidImage *ebiten.Image,
	rubbleImages []*ebiten.Image,
	debug bool) *Asteroid

NewAsteroid creates a new Asteroid (PhysicalBody agent)

func (*Asteroid) Draw

func (a *Asteroid) Draw(screen *ebiten.Image)

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

func (*Asteroid) Explode

func (a *Asteroid) Explode()

Explode proceeds the asteroid explosion and termination. For the first explosion, it splits into smaller asteroids (e.g. rubble). For the second explosion, each rubble disapear from game.

func (*Asteroid) Update

func (a *Asteroid) Update()

Update proceeds the game state. Update is called every tick (1/60 [s] by default). Update maintains a TTL counter to limit live of bullets.

type Bullet

type Bullet struct {
	physics.PhysicBody
	// contains filtered or unexported fields
}

Bullet is a PhysicalBody agent It represents a bullet shot by a starship agent.

func NewBullet

func NewBullet(log *logrus.Logger,
	x, y float64,
	orientation float64,
	screenWidth, screenHeight float64,
	cb physics.AgentUnregister,
	bulletImage *ebiten.Image) *Bullet

NewBullet creates a new Bullet (PhysicalBody agent)

func (*Bullet) Draw

func (b *Bullet) Draw(screen *ebiten.Image)

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

func (*Bullet) SelfDestroy

func (b *Bullet) SelfDestroy()

SelfDestroy removes the agent from the game

func (*Bullet) Update

func (b *Bullet) Update()

Update proceeds the game state. Update is called every tick (1/60 [s] by default). Update maintains a TTL counter to limit live of bullets.

type Rubble

type Rubble struct {
	physics.PhysicBody
}

Rubble is a PhysicalBody agent It represents a bullet shot by a starship agent.

func NewRubble

func NewRubble(log *logrus.Logger,
	x, y,
	screenWidth, screenHeight float64,
	cbu physics.AgentUnregister,
	rubbleImage *ebiten.Image,
	debug bool) *Rubble

NewRubble creates a new Rubble (PhysicalBody agent)

func (*Rubble) Draw

func (r *Rubble) Draw(screen *ebiten.Image)

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

func (*Rubble) Explode

func (r *Rubble) Explode()

Explode proceeds the rubble termination.

func (*Rubble) Update

func (r *Rubble) Update()

Update proceeds the game state. Update is called every tick (1/60 [s] by default). Update maintains a TTL counter to limit live of bullets.

type Starship

type Starship struct {
	physics.PhysicBody
	// contains filtered or unexported fields
}

Starship is a PhysicalBody agent. It represents a playable star ship.

func NewStarship

func NewStarship(
	log *logrus.Logger,
	x, y,
	screenWidth, screenHeight float64,
	cbr physics.AgentRegister,
	cbu physics.AgentUnregister,
	starshipImage *ebiten.Image,
	bulletImage *ebiten.Image,
	debug bool) *Starship

NewStarship creates a new Starship (PhysicalBody agent)

func (*Starship) Draw

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

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

func (*Starship) SelfDestroy

func (s *Starship) SelfDestroy()

SelfDestroy removes the agent from the game

func (*Starship) Shot

func (s *Starship) Shot()

Shot adds a new bullet to the game.

func (*Starship) Update

func (s *Starship) Update()

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

Jump to

Keyboard shortcuts

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