game

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Circular    BulletType = "circular"    // Default (●)
	Directional            = "directional" // Bi-directional <●>
	Vector                 = "vector"      // Vector ●>
)

Defines the different types of rendered bullets

View Source
const (
	Fixed  = "fixed"  // Fixed angle
	Radial = "radial" // Radial angle from spawner
	Random = "random" // Random angle
)
View Source
const ACTIVATE_COOLDOWN = 5

Default cooldown for interactive activation + degradation

View Source
const DEGRADE_COOLDOWN = ACTIVATE_COOLDOWN * 10

Variables

View Source
var (
	ErrMissingMap  = errors.New("missing map")
	ErrNoActiveMap = errors.New("no active map")
)

Functions

func CheckActiveCondition

func CheckActiveCondition(check *[]string, interactives []*Interactive) bool

Check that all interactives in args are active

func CheckConditions

func CheckConditions(conditions []*resources.ConditionDef, interactives []*Interactive, enemies []*Enemy) bool

Check all provided conditions are true If no conditions, return false

func CheckKilledEnemiesCondition

func CheckKilledEnemiesCondition(check *[]string, enemies []*Enemy) bool

Check that all enemies in args are dead If no args, check all enemies are dead

Types

type Action

type Action interface {
}

type ActionDeflect

type ActionDeflect struct {
	X, Y      float64
	Direction float64
}

type ActionFindNearestActor

type ActionFindNearestActor struct {
	Actor Actor
}

type ActionMove

type ActionMove struct {
	X, Y float64
}

type ActionReverse

type ActionReverse struct {
	X, Y float64
}

type ActionShield

type ActionShield struct {
}

type ActionSpawnBullets

type ActionSpawnBullets struct {
	Bullets []*Bullet
}

type ActionSpawnEnemy

type ActionSpawnEnemy struct {
	Name string
	ID   string
	X, Y float64
}

type ActionSpawnParticle

type ActionSpawnParticle struct {
	Img   string
	X, Y  float64
	Angle float64
	Speed float64
	Life  int
}

type Actor

type Actor interface {
	Save()
	Restore()
	Dead() bool
	Destroyed() bool
	Player() Player
	SetPlayer(p Player)
	SetImpulses(impulses ImpulseSet)
	Update() []Action
	Draw(ctx states.DrawContext)
	Shape() Shape
	Bounds() (x, y, w, h float64)
	SetXY(x, y float64)
	SetSize(r float64)
}

type ActorActions

type ActorActions struct {
	Actor   Actor
	Actions []Action
}

type Bullet

type Bullet struct {
	Shape CircleShape

	TargetActor     Actor       // Target actor to head towards
	Speed           float64     // How fastum the bullet goes
	Angle           float64     // What angle the bullet has
	Acceleration    float64     // How fast the bullet accelerates
	AccelAccel      float64     // How fast the bullet accelerates its acceleration
	MinSpeed        float64     // Minimum speed of the bullet
	MaxSpeed        float64     // Maximum speed of the bullet
	AngularVelocity float64     // How fast the bullet rotates
	Color           color.Color // Color of the bullet

	Lifetime  int
	Deathtime int // Maximum lifetime of the bullet
	Destroyed bool
	Damage    int
	// contains filtered or unexported fields
}

func BulletFromExisting

func BulletFromExisting(b *Bullet, angle float64) *Bullet

Copy a bullet

func CreateBullet

func CreateBullet(
	bulletType BulletType,
	clr color.Color,
	radius, speed, angle, acceleration, accelAccel, minSpeed, maxSpeed, angularVelocity float64,
	aimTime, aimDelay int,
) *Bullet

TODO: do this differently, hard to read and write arguments

func CreateBulletFromDef

func CreateBulletFromDef(override, alias *resources.Bullet) *Bullet

func (*Bullet) Deflect

func (b *Bullet) Deflect(angle float64)

func (*Bullet) Draw

func (b *Bullet) Draw(ctx states.DrawContext)

Draw the bullet

func (*Bullet) Reverse

func (b *Bullet) Reverse()

func (*Bullet) SetXY

func (b *Bullet) SetXY(x, y float64)

func (*Bullet) Update

func (b *Bullet) Update() (actions []Action)

Update the bullet's position and speed

type BulletActions

type BulletActions struct {
	Bullet  *Bullet
	Actions []Action
}

type BulletGroup

type BulletGroup struct {
	X float64
	Y float64
	// contains filtered or unexported fields
}

func CreateBulletGroupFromDef

func CreateBulletGroupFromDef(override, alias *resources.BulletGroup) *BulletGroup

func (*BulletGroup) SetXY

func (bg *BulletGroup) SetXY(x, y float64)

func (*BulletGroup) Update

func (bg *BulletGroup) Update() (actions []Action)

type BulletType

type BulletType string

type Cell

type Cell struct {
	Sprite *resources.Sprite
	Shape  RectangleShape
	// contains filtered or unexported fields
}

type CellCollision

type CellCollision struct {
	Cell Cell
}

type CircleShape

type CircleShape struct {
	X, Y   float64
	Radius float64
}

func (*CircleShape) Bounds

func (c *CircleShape) Bounds() (x, y, width, height float64)

func (*CircleShape) Clone

func (c *CircleShape) Clone() Shape

func (*CircleShape) Collides

func (c *CircleShape) Collides(s Shape) bool

type Companion

type Companion struct {

	//
	Arrow  *resources.Sprite
	Sprite *resources.Sprite
	Hat    *resources.Sprite

	Hand              Hand
	Energy            int
	MaxEnergy         int
	EnergyRestoreRate int

	TicksSinceLastInteraction int
	// contains filtered or unexported fields
}

func (*Companion) Bounds

func (p *Companion) Bounds() (x, y, w, h float64)

func (*Companion) Dead

func (p *Companion) Dead() bool

func (*Companion) Destroyed

func (p *Companion) Destroyed() bool

func (*Companion) Draw

func (p *Companion) Draw(ctx states.DrawContext)

func (*Companion) DrawHand

func (p *Companion) DrawHand(ctx states.DrawContext)

func (*Companion) DrawHat

func (p *Companion) DrawHat(screen *ebiten.Image, x, y float64)

DrawHat draws the player's dumb hat.

func (*Companion) HasEnergyFor

func (p *Companion) HasEnergyFor(imp Impulse) bool

func (*Companion) Player

func (p *Companion) Player() Player

func (*Companion) Restore

func (p *Companion) Restore()

func (*Companion) Save

func (p *Companion) Save()

func (*Companion) SetImpulses

func (p *Companion) SetImpulses(impulses ImpulseSet)

func (*Companion) SetPlayer

func (p *Companion) SetPlayer(player Player)

func (*Companion) SetSize

func (p *Companion) SetSize(r float64)

func (*Companion) SetXY

func (p *Companion) SetXY(x, y float64)

func (*Companion) Shape

func (p *Companion) Shape() Shape

func (*Companion) Snarf

func (p *Companion) Snarf()

func (*Companion) Update

func (p *Companion) Update() (actions []Action)

type Enemy

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

func CreateEnemy

func CreateEnemy(ctx states.Context, id, enemyName string) *Enemy

func (*Enemy) Bounds

func (e *Enemy) Bounds() (x, y, w, h float64)

func (*Enemy) Damage

func (e *Enemy) Damage(amount int) bool

func (*Enemy) Dead

func (e *Enemy) Dead() bool

func (*Enemy) Destroyed

func (e *Enemy) Destroyed() bool

func (*Enemy) Draw

func (e *Enemy) Draw(ctx states.DrawContext)

func (*Enemy) ID

func (e *Enemy) ID() string

func (*Enemy) IsAlive

func (e *Enemy) IsAlive() bool

func (*Enemy) Player

func (e *Enemy) Player() Player

func (*Enemy) Restore

func (e *Enemy) Restore()

func (*Enemy) Save

func (e *Enemy) Save()

func (*Enemy) SetImpulses

func (e *Enemy) SetImpulses(impulses ImpulseSet)

func (*Enemy) SetPlayer

func (e *Enemy) SetPlayer(p Player)

func (*Enemy) SetSize

func (e *Enemy) SetSize(r float64)

func (*Enemy) SetTarget

func (e *Enemy) SetTarget(a Actor)

func (*Enemy) SetXY

func (e *Enemy) SetXY(x, y float64)

func (*Enemy) Shape

func (e *Enemy) Shape() Shape

func (*Enemy) Update

func (e *Enemy) Update() (a []Action)

type EnemyState

type EnemyState int
const (
	EnemyStateHunt EnemyState = iota
	EnemyStateWander
	EnemyStateChase
	EnemyStateFriendly
)

type GroupAngle

type GroupAngle string

type Hand

type Hand struct {
	Shape       CircleShape
	Sprite      *resources.Sprite
	HoverSprite *resources.Sprite
}

func (*Hand) SetXY

func (h *Hand) SetXY(x, y float64)

type HintGroup

type HintGroup struct {
	Items   []string
	OffsetY float64
	Prefix  string
}

type Hints

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

func (*Hints) ActivateGroup

func (h *Hints) ActivateGroup(group string)

func (*Hints) AddHintGroup

func (h *Hints) AddHintGroup(group string, hintGroup HintGroup)

func (*Hints) DeactivateGroups

func (h *Hints) DeactivateGroups()

func (*Hints) Draw

func (h *Hints) Draw(ctx states.DrawContext)

func (*Hints) Update

func (h *Hints) Update(ctx states.Context) error

type Impulse

type Impulse interface {
	Cost() int
	Ident() uint8
	ToBytes() []byte
	FromBytes([]byte) (net.Message, int)
}

type ImpulseDeflect

type ImpulseDeflect struct {
	X, Y float64 // X and Y are the current cursor coordinates.
}

func (ImpulseDeflect) Cost

func (i ImpulseDeflect) Cost() int

func (ImpulseDeflect) FromBytes

func (i ImpulseDeflect) FromBytes(b []byte) (net.Message, int)

func (ImpulseDeflect) Ident

func (i ImpulseDeflect) Ident() uint8

func (ImpulseDeflect) ToBytes

func (i ImpulseDeflect) ToBytes() (b []byte)

type ImpulseMove

type ImpulseMove struct {
	Direction float64
}

func (ImpulseMove) FromBytes

func (i ImpulseMove) FromBytes(b []byte) (net.Message, int)

func (ImpulseMove) Ident

func (i ImpulseMove) Ident() uint8

func (ImpulseMove) ToBytes

func (i ImpulseMove) ToBytes() (b []byte)

type ImpulseReverse

type ImpulseReverse struct {
	X, Y float64 // X and Y are the current cursor coordinates.
}

func (ImpulseReverse) Cost

func (i ImpulseReverse) Cost() int

func (ImpulseReverse) FromBytes

func (i ImpulseReverse) FromBytes(b []byte) (net.Message, int)

func (ImpulseReverse) Ident

func (i ImpulseReverse) Ident() uint8

func (ImpulseReverse) ToBytes

func (i ImpulseReverse) ToBytes() (b []byte)

type ImpulseSet

type ImpulseSet struct {
	Move        *ImpulseMove
	Interaction Impulse
}

func (ImpulseSet) FromBytes

func (i ImpulseSet) FromBytes(b []byte) (net.Message, int)

func (ImpulseSet) Ident

func (i ImpulseSet) Ident() uint8

func (ImpulseSet) ToBytes

func (i ImpulseSet) ToBytes() (b []byte)

type ImpulseShield

type ImpulseShield struct {
}

func (ImpulseShield) Cost

func (i ImpulseShield) Cost() int

func (ImpulseShield) FromBytes

func (i ImpulseShield) FromBytes(b []byte) (net.Message, int)

func (ImpulseShield) Ident

func (i ImpulseShield) Ident() uint8

func (ImpulseShield) ToBytes

func (i ImpulseShield) ToBytes() (b []byte)

type ImpulseShoot

type ImpulseShoot struct {
	X, Y float64 // X and Y are the current cursor coordinates.
}

func (ImpulseShoot) Cost

func (i ImpulseShoot) Cost() int

func (ImpulseShoot) FromBytes

func (i ImpulseShoot) FromBytes(b []byte) (net.Message, int)

func (ImpulseShoot) Ident

func (i ImpulseShoot) Ident() uint8

func (ImpulseShoot) ToBytes

func (i ImpulseShoot) ToBytes() (b []byte)

type Interactive

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

func CreateInteractive

func CreateInteractive(ctx states.Context, actorDef resources.ActorSpawn) *Interactive

func (*Interactive) Active

func (i *Interactive) Active() bool

func (*Interactive) AddLinkedInteractive

func (i *Interactive) AddLinkedInteractive(interactives *Interactive)

func (*Interactive) Bounds

func (i *Interactive) Bounds() (x, y, w, h float64)

func (*Interactive) Conditions

func (i *Interactive) Conditions() []*resources.ConditionDef

func (*Interactive) Dead

func (i *Interactive) Dead() bool

func (*Interactive) DecreaseActivation

func (i *Interactive) DecreaseActivation(parentIds []string)

Takes parent ID to prevent infinite loops

func (*Interactive) Destroyed

func (i *Interactive) Destroyed() bool

func (*Interactive) Draw

func (i *Interactive) Draw(ctx states.DrawContext)

If the interactive object is active, draw the active sprite otherwise draw the inactive sprite

func (*Interactive) Hit

func (i *Interactive) Hit()

func (*Interactive) ID

func (i *Interactive) ID() string

func (*Interactive) IncreaseActivation

func (i *Interactive) IncreaseActivation(parentIds []string)

Takes parent ID to prevent infinite loops

func (*Interactive) Player

func (i *Interactive) Player() Player

func (*Interactive) Restore

func (i *Interactive) Restore()

func (*Interactive) Reverse

func (i *Interactive) Reverse()

Reverse the interactive object

func (*Interactive) Reverseable

func (i *Interactive) Reverseable() bool

func (*Interactive) Save

func (i *Interactive) Save()

func (*Interactive) SetImpulses

func (i *Interactive) SetImpulses(impulses ImpulseSet)

func (*Interactive) SetPlayer

func (i *Interactive) SetPlayer(p Player)

func (*Interactive) SetSize

func (i *Interactive) SetSize(r float64)

func (*Interactive) SetXY

func (i *Interactive) SetXY(x, y float64)

func (*Interactive) Shape

func (i *Interactive) Shape() Shape

func (*Interactive) Shootable

func (i *Interactive) Shootable() bool

func (*Interactive) Touchable

func (i *Interactive) Touchable() bool

func (*Interactive) Update

func (i *Interactive) Update() []Action

type LocalPlayer

type LocalPlayer struct {
	GamepadID  int    // Target gamepad for this player to use.
	GamepadMap string // Target mapping to use.
	// contains filtered or unexported fields
}

LocalPlayer is a player on the local computer.

func NewLocalPlayer

func NewLocalPlayer() *LocalPlayer

func (*LocalPlayer) Actor

func (p *LocalPlayer) Actor() Actor

func (*LocalPlayer) ClearImpulses

func (p *LocalPlayer) ClearImpulses()

func (*LocalPlayer) Hat

func (p *LocalPlayer) Hat() string

func (*LocalPlayer) Impulses

func (p *LocalPlayer) Impulses() ImpulseSet

Impulses is a list of impulses that the player currently desires their actor to process.

func (*LocalPlayer) QueueImpulses

func (p *LocalPlayer) QueueImpulses(impulses ImpulseSet)

func (*LocalPlayer) Ready

func (p *LocalPlayer) Ready(nextTick int) bool

func (*LocalPlayer) SetActor

func (p *LocalPlayer) SetActor(actor Actor)

func (*LocalPlayer) SetHat

func (p *LocalPlayer) SetHat(hat string)

func (*LocalPlayer) Thoughts

func (p *LocalPlayer) Thoughts() Thoughts

func (*LocalPlayer) Tick

func (p *LocalPlayer) Tick()

Tick is called on actual world tick.

func (*LocalPlayer) Update

func (p *LocalPlayer) Update()

type Map

type Map struct {
	Cells [][][]Cell
	// contains filtered or unexported fields
}

func (*Map) Collides

func (m *Map) Collides(s Shape) *CellCollision

func (*Map) DoesLineCollide

func (m *Map) DoesLineCollide(fx1, fy1, fx2, fy2 float64, z int) bool

func (*Map) Draw

func (m *Map) Draw(ctx states.DrawContext)

func (*Map) FindCellById

func (m *Map) FindCellById(id string) *Cell

func (*Map) GetCell

func (m *Map) GetCell(x, y, z int) *Cell

func (*Map) OutOfBounds

func (m *Map) OutOfBounds(s Shape) bool

type Overlay

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

func (*Overlay) Draw

func (o *Overlay) Draw(ctx states.DrawContext)

func (*Overlay) Init

func (o *Overlay) Init(ctx states.Context) error

func (*Overlay) Sync

func (o *Overlay) Sync(ctx states.Context)

func (*Overlay) Update

func (o *Overlay) Update(ctx states.Context) error

type PC

type PC struct {

	//
	Arrow       *resources.Sprite
	Sprite      *resources.Sprite
	DeathSprite *resources.Sprite
	Phylactery  *resources.Sprite
	Hat         *resources.Sprite
	Life        *resources.Sprite

	Hand                      Hand
	Lives                     int
	InvulnerableTicks         int // Ticks the player should be invulnerable for
	TicksSinceLastInteraction int
	Energy                    int
	MaxEnergy                 int
	EnergyRestoreRate         int
	HasDeflect                bool
	HasShield                 bool
	// contains filtered or unexported fields
}

func (*PC) Bounds

func (p *PC) Bounds() (x, y, w, h float64)

func (*PC) Dead

func (p *PC) Dead() bool

func (*PC) Destroyed

func (p *PC) Destroyed() bool

func (*PC) Draw

func (p *PC) Draw(ctx states.DrawContext)

func (*PC) DrawHand

func (p *PC) DrawHand(ctx states.DrawContext)

func (*PC) DrawHat

func (p *PC) DrawHat(screen *ebiten.Image, x, y float64)

DrawHat draws the player's dumb hat.

func (*PC) HasEnergyFor

func (p *PC) HasEnergyFor(imp Impulse) bool

func (*PC) Hurtie

func (p *PC) Hurtie()

func (*PC) PlayAudio

func (p *PC) PlayAudio(deflecting, reversing, shielding bool)

func (*PC) Player

func (p *PC) Player() Player

func (*PC) Restore

func (p *PC) Restore()

func (*PC) Save

func (p *PC) Save()

func (*PC) SetImpulses

func (p *PC) SetImpulses(impulses ImpulseSet)

func (*PC) SetPlayer

func (p *PC) SetPlayer(player Player)

func (*PC) SetSize

func (p *PC) SetSize(r float64)

func (*PC) SetXY

func (p *PC) SetXY(x, y float64)

func (*PC) Shape

func (p *PC) Shape() Shape

func (*PC) Update

func (p *PC) Update() (actions []Action)

type Particle

type Particle struct {
	Sprite *resources.Sprite
	X, Y   float64
	VX, VY float64
	Age    int
	Life   int
}

func (*Particle) Dead

func (p *Particle) Dead() bool

func (*Particle) Draw

func (p *Particle) Draw(ctx states.DrawContext)

func (*Particle) Update

func (p *Particle) Update()

type Player

type Player interface {
	// ???
	Ready(nextTick int) bool
	SetActor(actor Actor)
	Actor() Actor
	Update()
	Tick()
	Impulses() ImpulseSet
	ClearImpulses()
	QueueImpulses(impulses ImpulseSet)
	//
	Thoughts() Thoughts
	//
	SetHat(string)
	Hat() string
}

Player represents either a local or remote player.

type QuitThought

type QuitThought struct{}

func (QuitThought) FromBytes

func (t QuitThought) FromBytes(b []byte) (net.Message, int)

func (QuitThought) Ident

func (t QuitThought) Ident() uint8

func (QuitThought) ToBytes

func (t QuitThought) ToBytes() (b []byte)

type RectangleShape

type RectangleShape struct {
	X, Y, Width, Height float64
}

func (*RectangleShape) Bounds

func (r *RectangleShape) Bounds() (x, y, width, height float64)

func (*RectangleShape) Clone

func (r *RectangleShape) Clone() Shape

func (*RectangleShape) Collides

func (r *RectangleShape) Collides(s Shape) bool

type RemotePlayer

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

RemotePlayer is a networked player.

func NewRemotePlayer

func NewRemotePlayer(peer *net.Peer) *RemotePlayer

func (*RemotePlayer) Actor

func (p *RemotePlayer) Actor() Actor

func (*RemotePlayer) ClearImpulses

func (p *RemotePlayer) ClearImpulses()

func (*RemotePlayer) Hat

func (p *RemotePlayer) Hat() string

func (*RemotePlayer) Impulses

func (p *RemotePlayer) Impulses() ImpulseSet

func (*RemotePlayer) Peer

func (p *RemotePlayer) Peer() *net.Peer

func (*RemotePlayer) QueueImpulses

func (p *RemotePlayer) QueueImpulses(impulses ImpulseSet)

func (*RemotePlayer) Ready

func (p *RemotePlayer) Ready(nextTick int) bool

func (*RemotePlayer) SetActor

func (p *RemotePlayer) SetActor(actor Actor)

func (*RemotePlayer) SetHat

func (p *RemotePlayer) SetHat(hat string)

func (*RemotePlayer) Thoughts

func (p *RemotePlayer) Thoughts() Thoughts

func (*RemotePlayer) Tick

func (p *RemotePlayer) Tick()

func (*RemotePlayer) Update

func (p *RemotePlayer) Update()

type ResetThought

type ResetThought struct{}

func (ResetThought) FromBytes

func (t ResetThought) FromBytes(b []byte) (net.Message, int)

func (ResetThought) Ident

func (t ResetThought) Ident() uint8

func (ResetThought) ToBytes

func (t ResetThought) ToBytes() (b []byte)

type Shape

type Shape interface {
	Clone() Shape
	Bounds() (x, y, width, height float64)
	Collides(s Shape) bool
}

type Snaggable

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

func CreateSnaggable

func CreateSnaggable(ctx states.Context, id, spriteName string) *Snaggable

func (*Snaggable) Bounds

func (s *Snaggable) Bounds() (x, y, w, h float64)

func (*Snaggable) Dead

func (s *Snaggable) Dead() bool

func (*Snaggable) Destroyed

func (s *Snaggable) Destroyed() bool

func (*Snaggable) Draw

func (s *Snaggable) Draw(ctx states.DrawContext)

func (*Snaggable) Player

func (s *Snaggable) Player() Player

func (*Snaggable) Restore

func (s *Snaggable) Restore()

func (*Snaggable) Save

func (s *Snaggable) Save()

func (*Snaggable) SetImpulses

func (s *Snaggable) SetImpulses(impulses ImpulseSet)

func (*Snaggable) SetPlayer

func (s *Snaggable) SetPlayer(p Player)

func (*Snaggable) SetSize

func (s *Snaggable) SetSize(r float64)

func (*Snaggable) SetXY

func (s *Snaggable) SetXY(x, y float64)

func (*Snaggable) Shape

func (s *Snaggable) Shape() Shape

func (*Snaggable) Update

func (s *Snaggable) Update() (actions []Action)

type Spawner

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

This can probably be attached to an actor instead being its own actor

func CreateSpawner

func CreateSpawner(ctx states.Context, bulletGroupDefs []*resources.BulletGroup) *Spawner

func (*Spawner) Bounds

func (s *Spawner) Bounds() (x, y, w, h float64)

func (*Spawner) Dead

func (s *Spawner) Dead() bool

func (*Spawner) Destroyed

func (s *Spawner) Destroyed() bool

func (*Spawner) Draw

func (s *Spawner) Draw(states.DrawContext)

func (*Spawner) Player

func (s *Spawner) Player() Player

func (*Spawner) Restore

func (s *Spawner) Restore()

func (*Spawner) Save

func (s *Spawner) Save()

func (*Spawner) SetImpulses

func (s *Spawner) SetImpulses(impulses ImpulseSet)

func (*Spawner) SetPlayer

func (s *Spawner) SetPlayer(p Player)

func (*Spawner) SetSize

func (s *Spawner) SetSize(r float64)

func (*Spawner) SetXY

func (s *Spawner) SetXY(x, y float64)

func (*Spawner) Shape

func (s *Spawner) Shape() Shape

func (*Spawner) Update

func (s *Spawner) Update() (actions []Action)

type Thought

type Thought interface {
	Ident() uint8
	ToBytes() []byte
	FromBytes(b []byte) (net.Message, int)
}

Thoughts are a poorly named notion that sits above Impulses. These can effectively be viewed as player desires/commands and are sent across the wire between clients.

type Thoughts

type Thoughts struct {
	Thoughts []Thought
}

func (Thoughts) FromBytes

func (t Thoughts) FromBytes(b []byte) (net.Message, int)

func (Thoughts) Ident

func (t Thoughts) Ident() uint8

func (Thoughts) ToBytes

func (t Thoughts) ToBytes() (b []byte)

type TickState

type TickState struct {
	Thoughts Thoughts
	Impulses ImpulseSet
}

func (TickState) FromBytes

func (t TickState) FromBytes(b []byte) (net.Message, int)

func (TickState) Ident

func (t TickState) Ident() uint8

func (TickState) ToBytes

func (t TickState) ToBytes() (b []byte)

type World

type World struct {
	Players []Player // Exposed so singleplayer/multiplayer can set it.

	StartingMap string
	ShowHints   bool

	Net  net.ServerClient
	Seed int64

	Difficulty *states.Difficulty
	// contains filtered or unexported fields
}

func (*World) ArePlayersDead

func (s *World) ArePlayersDead() bool

func (*World) CurrentState

func (s *World) CurrentState() WorldState

func (*World) DoPlayersShareThought

func (s *World) DoPlayersShareThought(thought Thought) bool

func (*World) Draw

func (s *World) Draw(ctx states.DrawContext)

func (*World) Enter

func (s *World) Enter(ctx states.Context, v interface{}) error

func (*World) Finalize

func (s *World) Finalize(ctx states.Context) error

func (*World) FindNearestActor

func (s *World) FindNearestActor(from Shape, a Actor) Actor

func (*World) HandleTrash

func (s *World) HandleTrash()

func (*World) Init

func (s *World) Init(ctx states.Context) error

func (*World) IntersectingActors

func (s *World) IntersectingActors(sh Shape) []Actor

func (*World) IntersectingBullets

func (s *World) IntersectingBullets(sh Shape) []*Bullet

func (*World) NewCompanion

func (s *World) NewCompanion(ctx states.Context) *Companion

func (*World) NewPC

func (s *World) NewPC(ctx states.Context) *PC

func (*World) PlayerFromPeer

func (s *World) PlayerFromPeer(peer *net.Peer) *RemotePlayer

func (*World) PopState

func (s *World) PopState(ctx states.Context)

func (*World) PushState

func (s *World) PushState(state WorldState, ctx states.Context)

func (*World) ResetActiveMap

func (s *World) ResetActiveMap(ctx states.Context) error

func (*World) SpawnParticle

func (w *World) SpawnParticle(ctx states.Context, img string, x, y float64, angle float64, speed float64, life int)

func (*World) TravelToMap

func (s *World) TravelToMap(ctx states.Context, mapName string) error

func (*World) Update

func (s *World) Update(ctx states.Context) error

type WorldState

type WorldState interface {
	Enter(w *World, ctx states.Context)
	Leave(w *World, ctx states.Context)
	Tick(w *World, ctx states.Context)
	Draw(w *World, ctx states.DrawContext)
}

type WorldStateBegin

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

func (*WorldStateBegin) Draw

func (w *WorldStateBegin) Draw(s *World, ctx states.DrawContext)

func (*WorldStateBegin) Enter

func (w *WorldStateBegin) Enter(s *World, ctx states.Context)

func (*WorldStateBegin) Leave

func (w *WorldStateBegin) Leave(s *World, ctx states.Context)

func (*WorldStateBegin) Tick

func (w *WorldStateBegin) Tick(s *World, ctx states.Context)

type WorldStateDead

type WorldStateDead struct {
}

func (*WorldStateDead) Draw

func (w *WorldStateDead) Draw(s *World, ctx states.DrawContext)

func (*WorldStateDead) Enter

func (w *WorldStateDead) Enter(s *World, ctx states.Context)

func (*WorldStateDead) Leave

func (w *WorldStateDead) Leave(s *World, ctx states.Context)

func (*WorldStateDead) Tick

func (w *WorldStateDead) Tick(s *World, ctx states.Context)

type WorldStateEnd

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

func (*WorldStateEnd) Draw

func (w *WorldStateEnd) Draw(s *World, ctx states.DrawContext)

func (*WorldStateEnd) Enter

func (w *WorldStateEnd) Enter(s *World, ctx states.Context)

func (*WorldStateEnd) Leave

func (w *WorldStateEnd) Leave(s *World, ctx states.Context)

func (*WorldStateEnd) Tick

func (w *WorldStateEnd) Tick(s *World, ctx states.Context)

type WorldStateLive

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

func (*WorldStateLive) Draw

func (w *WorldStateLive) Draw(s *World, ctx states.DrawContext)

func (*WorldStateLive) Enter

func (w *WorldStateLive) Enter(s *World, ctx states.Context)

func (*WorldStateLive) Leave

func (w *WorldStateLive) Leave(s *World, ctx states.Context)

func (*WorldStateLive) Tick

func (w *WorldStateLive) Tick(s *World, ctx states.Context)

Jump to

Keyboard shortcuts

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