spacegame

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewULID added in v1.1.0

func NewULID() string

NewULID encapsulate the way to generate new ULIDs

Types

type Action

type Action int
const (
	NoneAction Action = iota
	ShootAction
)

type Direction

type Direction int
const (
	Idle Direction = iota
	LeftDirection
	RightDirection
)

type Laser added in v1.1.0

type Laser struct {
	// contains filtered or unexported fields
}

func NewBaseLaser added in v1.1.0

func NewBaseLaser(path, sfxPath string, vel float64, world *World) (*Laser, error)

NewBaseLaser initializes a new base laser with all common properties

func (Laser) Draw added in v1.1.0

func (l Laser) Draw(t pixel.Target)

Draw draws laser if it is visible

func (*Laser) NewLaser added in v1.1.0

func (l *Laser) NewLaser(pos pixel.Vec) *Laser

NewLaser initializes a new laser with common properties and all specific properties

func (Laser) Shoot added in v1.2.0

func (l Laser) Shoot()

Shoot loads shoot sound and plays it

func (*Laser) Update added in v1.1.0

func (l *Laser) Update()

Update updates laser position and visibility

type Player

type Player struct {
	// contains filtered or unexported fields
}

func NewPlayer

func NewPlayer(path string, life int, world *World) (*Player, error)

NewPlayer initializes a new player with all its properties

func (Player) Draw

func (p Player) Draw(t pixel.Target)

Draw draws player in its position and its lasers

func (Player) Frame added in v1.2.0

func (p Player) Frame() pixel.Rect

func (*Player) Update

func (p *Player) Update(direction Direction, action Action, dt float64)

Update updates player state and its lasers

type SFX added in v1.2.0

type SFX struct {
	// contains filtered or unexported fields
}

type World

type World struct {
	// contains filtered or unexported fields
}

func NewWorld

func NewWorld(w, h float64) *World

NewWorld initializes a new world with its properties

func (*World) AddBackground

func (w *World) AddBackground(path string) error

AddBackground adds background image to the world

func (World) Bounds

func (w World) Bounds() pixel.Rect

Bounds returns world's bounds

func (World) Draw

func (w World) Draw(t pixel.Target)

Draw draws the world

Jump to

Keyboard shortcuts

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