game

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AffectedByGravityKey = CompKey(iota)
	BoundLocationKey     = CompKey(iota)
	CanExplodeKey        = CompKey(iota)
	FrameEndDeleteKey    = CompKey(iota)
	KeepInCameraKey      = CompKey(iota)
	LookupKey            = CompKey(iota)
	MissileDetailsKey    = CompKey(iota)
	MomentumKey          = CompKey(iota)
	NetworkIdKey         = CompKey(iota)
	NetworkReceiveKey    = CompKey(iota)
	NetworkTransmitKey   = CompKey(iota)
	ParticleSunDeleteKey = CompKey(iota)
	PointRenderKey       = CompKey(iota)
	PosKey               = CompKey(iota)
	RotKey               = CompKey(iota)
	ShipControlKey       = CompKey(iota)
	SpinKey              = CompKey(iota)
	SpriteKey            = CompKey(iota)
	TimedDestroyKey      = CompKey(iota)
	TimedExplodeKey      = CompKey(iota)
)
View Source
const (
	SpriteUnset = Sprite(iota)
	SpriteShip
	SpriteEnemyShip
	SpriteMissile
	SpriteStar
	SpriteStarBit
	SpriteExplosionFlash
)
View Source
const ExplosionRadius = 2

Variables

This section is empty.

Functions

This section is empty.

Types

type Comp

type Comp interface {
	Swap(j1, j2 int)
	Extend(i int)
	RemoveLast()
}

type CompKey

type CompKey uint16

type Entities

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

func (*Entities) NewIter

func (e *Entities) NewIter() *Iter

type EntityBag

type EntityBag struct {
	Lookup         *comp_Lookup
	MissileDetails *comp_MissileDetails
	Momentum       *comp_Vec2
	NetworkId      *comp_uint64
	Pos            *comp_Vec2
	Rot            *comp_float32
	ShipControl    *comp_ShipControl
	Spin           *comp_float32
	Sprite         *comp_Sprite
	TimedDestroy   *comp_float32
	TimedExplode   *comp_float32
	// contains filtered or unexported fields
}

func (*EntityBag) Add

func (e *EntityBag) Add(i int) int

func (*EntityBag) Remove

func (e *EntityBag) Remove(i int)

type ExplosionDetails

type ExplosionDetails struct {
	Initialized    bool
	MoreExplosions bool
}

type Game

type Game struct {
	E *Entities

	NextNetworkId uint64

	ControlledShip *Lookup

	NetworkIds map[uint64]*Lookup
	// contains filtered or unexported fields
}

func NewGame

func NewGame() *Game

func (*Game) NextNid

func (g *Game) NextNid() uint64

func (*Game) Step

func (g *Game) Step(input *Input)

type Input

type Input struct {
	Up    Keystate
	Down  Keystate
	Left  Keystate
	Right Keystate
	Fire  Keystate
	Dt    float32
	// Whether entities which only exist for render should be created.
	IsRendered bool
	// Whether code which runs only if the input is going to control
	// a player ship should run.
	IsPlayer    bool
	IsConnected bool
	// Whether the this instance is the host, if not it is a client.
	IsHost   bool
	Cid      int64
	Memos    []*pb.Memo
	MemosOut []*pb.Memo
}

func NewInput

func NewInput() *Input

func (*Input) BroadcastAll

func (i *Input) BroadcastAll(actual proto.Message)

func (*Input) BroadcastOthers

func (i *Input) BroadcastOthers(actual proto.Message)

func (*Input) FrameEndReset

func (inp *Input) FrameEndReset()

func (*Input) SendMemo

func (i *Input) SendMemo(partial *pb.Memo, actual proto.Message)

func (*Input) SendTo

func (i *Input) SendTo(to int64, actual proto.Message)

type Iter

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

func (*Iter) Get

func (iter *Iter) Get(indices *Lookup)

func (*Iter) Lookup

func (iter *Iter) Lookup() *Lookup

func (*Iter) MissileDetails

func (iter *Iter) MissileDetails() *MissileDetails

func (*Iter) Momentum

func (iter *Iter) Momentum() *Vec2

func (*Iter) NetworkId

func (iter *Iter) NetworkId() *uint64

func (*Iter) New

func (iter *Iter) New()

func (*Iter) Next

func (iter *Iter) Next() bool

func (*Iter) Pos

func (iter *Iter) Pos() *Vec2

func (*Iter) Remove

func (iter *Iter) Remove()

func (*Iter) Require

func (iter *Iter) Require(k CompKey)

func (*Iter) Rot

func (iter *Iter) Rot() *float32

func (*Iter) ShipControl

func (iter *Iter) ShipControl() *ShipControl

func (*Iter) Spin

func (iter *Iter) Spin() *float32

func (*Iter) Sprite

func (iter *Iter) Sprite() *Sprite

func (*Iter) TimedDestroy

func (iter *Iter) TimedDestroy() *float32

func (*Iter) TimedExplode

func (iter *Iter) TimedExplode() *float32

type Keystate

type Keystate struct {
	Press   bool
	Hold    bool
	Release bool
}

func (*Keystate) Down

func (k *Keystate) Down()

func (*Keystate) FrameEndReset

func (k *Keystate) FrameEndReset()

func (*Keystate) Up

func (k *Keystate) Up()

type Lookup

type Lookup [2]int

func (*Lookup) Alive

func (l *Lookup) Alive() bool

type MissileDetails

type MissileDetails struct {
	Owner *Lookup
}

type PlayerConnectedEvent

type PlayerConnectedEvent struct {
}

TODO: Use?

type ShipControl

type ShipControl struct {
	Up           bool
	Down         bool
	Left         bool
	Right        bool
	Fire         bool
	FireCoolDown float32
}

type Sprite

type Sprite uint16

type Vec2

type Vec2 [2]float32

func Vec2FromProto

func Vec2FromProto(p *pb.Vec2) Vec2

func Vec2FromRadians

func Vec2FromRadians(rad float32) Vec2

func (Vec2) Add

func (v Vec2) Add(o Vec2) Vec2

func (*Vec2) AddEqual

func (v *Vec2) AddEqual(o Vec2)

func (Vec2) Dot

func (v Vec2) Dot(o Vec2) float32

func (*Vec2) Length

func (v *Vec2) Length() float32

func (Vec2) Normalize

func (v Vec2) Normalize() Vec2

func (Vec2) Scale

func (v Vec2) Scale(s float32) Vec2

func (Vec2) Sub

func (v Vec2) Sub(o Vec2) Vec2

func (*Vec2) ToProto

func (v *Vec2) ToProto() *pb.Vec2

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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