Documentation
¶
Index ¶
- func RemovePlayer(g *Game, socketID int)
- func SetPlayerInput(g *Game, socketID int, flags uint8)
- type Camera
- type Candidate
- type CircularCollisionPlugin
- type CollidableObject
- type Control
- type Faction
- type Game
- type GenericObject
- type GenericObjectCache
- type HealthComponent
- type Plane
- type Player
- type PolygonalCollisionPlugin
- type Ship
- type ShipAI
- type ShipCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RemovePlayer ¶
func SetPlayerInput ¶
Types ¶
type Camera ¶
type CircularCollisionPlugin ¶
type CircularCollisionPlugin struct {
GenericObject
AABB *util.AABB
}
func (*CircularCollisionPlugin) GetAABB ¶
func (ccp *CircularCollisionPlugin) GetAABB() (aabb *util.AABB)
func (*CircularCollisionPlugin) Insert ¶
func (ccp *CircularCollisionPlugin) Insert()
type CollidableObject ¶
type CollidableObject interface {
util.Identifiable
GetAABB() *util.AABB
Insert()
Collide()
}
type Faction ¶
type Faction struct {
ID uint64
Name string
Color color.RGBA
ShipsSpatialHash *util.SpatialHash[*Ship]
}
func NewFaction ¶
type Game ¶
type Game struct {
Factions map[uint64]*Faction
FactionsMu sync.RWMutex
Ships *util.SafeStorage[*Ship]
Planes *util.SafeStorage[*Plane]
ShipCache map[uint64]*ShipCache
ProjectileCache map[uint64]*GenericObjectCache
ShipCacheMu, ProjectileCacheMu sync.RWMutex
Players map[int]*Player
PlayersMu sync.RWMutex
// contains filtered or unexported fields
}
func (*Game) BeginUpdateLoop ¶
type GenericObject ¶
type GenericObject struct {
ID uint64
Game *Game
Position, Velocity *util.Vector2D
Size, Rotation, Friction, Density, Pushability float64
Faction *Faction
}
All game object should embed this either directly or through another embedded struct
func NewGameObject ¶
func NewGameObject(game *Game, position *util.Vector2D, f *Faction) (o *GenericObject)
func (*GenericObject) Collide ¶
func (o *GenericObject) Collide()
func (*GenericObject) GetAABB ¶
func (o *GenericObject) GetAABB() (aabb *util.AABB)
func (*GenericObject) GetID ¶
func (o *GenericObject) GetID() (id uint64)
func (*GenericObject) Insert ¶
func (o *GenericObject) Insert()
func (*GenericObject) PushWeight ¶
func (o *GenericObject) PushWeight() (weight float64)
func (*GenericObject) Update ¶
func (o *GenericObject) Update()
type GenericObjectCache ¶
type HealthComponent ¶
func NewHealth ¶
func NewHealth(health float64, canBeRepaired bool) (hc *HealthComponent)
func (*HealthComponent) Damage ¶
func (hc *HealthComponent) Damage(amount float64)
func (*HealthComponent) IsAlive ¶
func (hc *HealthComponent) IsAlive() (alive bool)
func (*HealthComponent) Ratio ¶
func (hc *HealthComponent) Ratio() (ratio float64)
type Plane ¶
type Plane struct {
CircularCollisionPlugin
}
type Player ¶
type Player struct {
Socket *web.Socket
Body *Ship
Camera *Camera
InputFlags uint8
LastFireTick int
InputMu sync.RWMutex
Faction *Faction
}
func (*Player) GetInputFlags ¶
func (*Player) SetInputFlags ¶
type PolygonalCollisionPlugin ¶
type PolygonalCollisionPlugin struct {
GenericObject
Polygon *util.Polygon
}
func (*PolygonalCollisionPlugin) GetAABB ¶
func (pcp *PolygonalCollisionPlugin) GetAABB() (aabb *util.AABB)
func (*PolygonalCollisionPlugin) Insert ¶
func (pcp *PolygonalCollisionPlugin) Insert()
type Ship ¶
type Ship struct {
PolygonalCollisionPlugin
Name string
Cfg *definitions.Ship
Health *HealthComponent
Control *Control
}
type ShipCache ¶
type ShipCache struct {
GenericObjectCache
Health float64
Shields [][2]float64 // [][hardpoint health ratio, shield health ratio]
Engines []float64 // []engine health ratio
Turrets [][2]float64 // [][hardpoint health ratio, turret facing (absolute)]
HealthChanged, ShieldsChanged, EnginesChanged, TurretsChanged bool
}
Click to show internal directories.
Click to hide internal directories.