Documentation
¶
Index ¶
- Variables
- func BridgemanCharacterModel() *characterModel
- func HeraldCharacterModel() *characterModel
- func SprenCharacterModel() *characterModel
- func SurgebinderCharacterModel() *characterModel
- type BaseAirborneState
- type BaseCharacter
- func (c BaseCharacter) Body() *physics.Body
- func (c BaseCharacter) Direction() physics.Direction
- func (c *BaseCharacter) Jump()
- func (c *BaseCharacter) KeepMovingLeft()
- func (c *BaseCharacter) KeepMovingRight()
- func (c *BaseCharacter) Land()
- func (c *BaseCharacter) OnAttacked(gtx GameContext)
- func (c *BaseCharacter) SetAnimation(a *graphics.SpriteAnimation)
- func (c *BaseCharacter) SetState(state State)
- func (c *BaseCharacter) Slow()
- func (c BaseCharacter) State() State
- func (c *BaseCharacter) Team() string
- func (c *BaseCharacter) Update(_ GameContext)
- func (c *BaseCharacter) WalkLeft()
- func (c *BaseCharacter) WalkRight()
- type BaseIdleState
- type BaseState
- func (s BaseState) Enter(_ Character)
- func (s BaseState) Exit(_ Character)
- func (s BaseState) HandleAirborne(_ Character)
- func (s BaseState) HandleCollision(_ Character, __ physics.CollisionEvent)
- func (s BaseState) HandleInput(_ GameContext, __ Character)
- func (s BaseState) Update(_ GameContext, __ Character)
- type BaseWalkingState
- type Bridgeman
- func (b *Bridgeman) DropoffSphere(gtx GameContext, sphere *Sphere, stockpile *SphereStockpile)
- func (b *Bridgeman) Jump()
- func (b *Bridgeman) Land()
- func (b *Bridgeman) OnAttacked(gtx GameContext)
- func (b *Bridgeman) PickupSphere(gtx GameContext, sphere *Sphere)
- func (b *Bridgeman) Slow()
- func (b *Bridgeman) Update(gtx GameContext)
- func (b *Bridgeman) WalkLeft()
- func (b *Bridgeman) WalkRight()
- type BridgemanDropoffSphereState
- type BridgemanPickupSphereState
- type BridgemanSphereState
- type BridgemanState
- type Character
- type CharacterSpawnTimer
- type CharacterSystem
- type CharacterType
- type Controller
- type Game
- func (g *Game) CharacterSystem() *CharacterSystem
- func (g *Game) Controller() Controller
- func (g *Game) LashingSystem() *LashingSystem
- func (g *Game) Map() *Map
- func (g *Game) ObjectSystem() *ObjectSystem
- func (g *Game) PhysicsContext() *physics.PhysicsContext
- func (g *Game) Run(ctx context.Context) error
- func (g *Game) SphereStockpiles() []*SphereStockpile
- type GameContext
- type GameOptions
- type GraphicsComponent
- type Herald
- type HeraldAttackingState
- type HeraldGroundedState
- type HeraldNotAttackingState
- type Lashable
- type Lasher
- type Lashing
- type LashingSystem
- type Map
- type MapDecoder
- type Object
- type ObjectSystem
- type PlayerSpawnLocation
- type Sounds
- type Sphere
- type SphereFactory
- type SphereGraphicsComponent
- type SpherePickupSubscriber
- type SphereSlot
- type SphereSlotLocation
- type SphereSpawn
- type SphereSpawnLocation
- type SphereStockpile
- type SphereStockpileArea
- type Spren
- type SprenAirborneState
- type SprenState
- type State
- func NewBridgemanAirborneState() State
- func NewBridgemanIdleState() State
- func NewBridgemanWalkingState() State
- func NewHeraldAirborneState() State
- func NewHeraldIdleState() State
- func NewHeraldWalkingState() State
- func NewSprenAirborneState() State
- func NewSprenIdleState() State
- func NewSprenWalkingState() State
- func NewSurgebinderAirborneState() State
- func NewSurgebinderIdleState() State
- func NewSurgebinderWalkingState() State
- type StateStack
- type Surgebinder
- func (s *Surgebinder) Jump()
- func (s *Surgebinder) Land()
- func (s *Surgebinder) OnAttacked(gtx GameContext)
- func (s *Surgebinder) SetStormlight(value int)
- func (s *Surgebinder) Slow()
- func (s *Surgebinder) Stormlight() int
- func (s *Surgebinder) Update(gtx GameContext)
- func (s *Surgebinder) WalkLeft()
- func (s *Surgebinder) WalkRight()
- type SurgebinderState
- type Updater
- type WindowCanvas
Constants ¶
This section is empty.
Variables ¶
var ( DefaultcharacterSounds = struct { Jump, Land assets.ID }{ Jump: assets.SoundAdventurerJump, Land: assets.SoundAdventurerLand, } )
Functions ¶
func BridgemanCharacterModel ¶
func BridgemanCharacterModel() *characterModel
func HeraldCharacterModel ¶
func HeraldCharacterModel() *characterModel
func SprenCharacterModel ¶
func SprenCharacterModel() *characterModel
func SurgebinderCharacterModel ¶
func SurgebinderCharacterModel() *characterModel
Types ¶
type BaseAirborneState ¶
type BaseAirborneState struct { BaseState Animation *graphics.SpriteAnimation MoveLeftButton pixelgl.Button MoveRightButton pixelgl.Button }
func (*BaseAirborneState) Enter ¶
func (s *BaseAirborneState) Enter(c Character)
func (*BaseAirborneState) HandleCollision ¶
func (s *BaseAirborneState) HandleCollision(c Character, event physics.CollisionEvent)
func (*BaseAirborneState) HandleInput ¶
func (s *BaseAirborneState) HandleInput(gtx GameContext, c Character)
type BaseCharacter ¶
type BaseCharacter struct { Graphics GraphicsComponent // contains filtered or unexported fields }
func (BaseCharacter) Body ¶
func (c BaseCharacter) Body() *physics.Body
func (BaseCharacter) Direction ¶
func (c BaseCharacter) Direction() physics.Direction
func (*BaseCharacter) Jump ¶
func (c *BaseCharacter) Jump()
NOTE: this pattern is actually error prone: concrete character types should have to implement Character methods directly so as to avoid the programmer forgetting to do so, which might lead to e.g. double-jumping because the concrete character does not have a Jump method to put them into the airborne state.
func (*BaseCharacter) KeepMovingLeft ¶
func (c *BaseCharacter) KeepMovingLeft()
func (*BaseCharacter) KeepMovingRight ¶
func (c *BaseCharacter) KeepMovingRight()
func (*BaseCharacter) Land ¶
func (c *BaseCharacter) Land()
func (*BaseCharacter) OnAttacked ¶
func (c *BaseCharacter) OnAttacked(gtx GameContext)
func (*BaseCharacter) SetAnimation ¶
func (c *BaseCharacter) SetAnimation(a *graphics.SpriteAnimation)
func (*BaseCharacter) SetState ¶
func (c *BaseCharacter) SetState(state State)
func (*BaseCharacter) Slow ¶
func (c *BaseCharacter) Slow()
func (BaseCharacter) State ¶
func (c BaseCharacter) State() State
func (*BaseCharacter) Team ¶
func (c *BaseCharacter) Team() string
func (*BaseCharacter) Update ¶
func (c *BaseCharacter) Update(_ GameContext)
func (*BaseCharacter) WalkLeft ¶
func (c *BaseCharacter) WalkLeft()
func (*BaseCharacter) WalkRight ¶
func (c *BaseCharacter) WalkRight()
type BaseIdleState ¶
type BaseIdleState struct { BaseState Animation *graphics.SpriteAnimation JumpButton pixelgl.Button MoveLeftButton pixelgl.Button MoveRightButton pixelgl.Button }
func (*BaseIdleState) Enter ¶
func (s *BaseIdleState) Enter(c Character)
func (*BaseIdleState) HandleInput ¶
func (s *BaseIdleState) HandleInput(gtx GameContext, c Character)
type BaseState ¶
type BaseState struct{}
BaseState implements all state methods so derived state classes don't have to.
func (BaseState) HandleAirborne ¶
func (BaseState) HandleCollision ¶
func (s BaseState) HandleCollision(_ Character, __ physics.CollisionEvent)
func (BaseState) HandleInput ¶
func (s BaseState) HandleInput(_ GameContext, __ Character)
func (BaseState) Update ¶
func (s BaseState) Update(_ GameContext, __ Character)
type BaseWalkingState ¶
type BaseWalkingState struct { BaseState Animation *graphics.SpriteAnimation JumpButton pixelgl.Button MoveLeftButton pixelgl.Button MoveRightButton pixelgl.Button }
func (*BaseWalkingState) Enter ¶
func (s *BaseWalkingState) Enter(c Character)
func (*BaseWalkingState) HandleInput ¶
func (s *BaseWalkingState) HandleInput(gtx GameContext, c Character)
type Bridgeman ¶
type Bridgeman struct { *BaseCharacter // contains filtered or unexported fields }
func NewBridgeman ¶
func NewBridgeman(_ context.Context, c *BaseCharacter) *Bridgeman
func (*Bridgeman) DropoffSphere ¶
func (b *Bridgeman) DropoffSphere(gtx GameContext, sphere *Sphere, stockpile *SphereStockpile)
func (*Bridgeman) OnAttacked ¶
func (b *Bridgeman) OnAttacked(gtx GameContext)
func (*Bridgeman) PickupSphere ¶
func (b *Bridgeman) PickupSphere(gtx GameContext, sphere *Sphere)
func (*Bridgeman) Update ¶
func (b *Bridgeman) Update(gtx GameContext)
Overrides BaseCharacter.Update.
type BridgemanDropoffSphereState ¶
type BridgemanDropoffSphereState struct {
// contains filtered or unexported fields
}
func (BridgemanDropoffSphereState) Update ¶
func (s BridgemanDropoffSphereState) Update(gtx GameContext, b *Bridgeman)
type BridgemanPickupSphereState ¶
type BridgemanPickupSphereState struct{}
func (BridgemanPickupSphereState) Update ¶
func (s BridgemanPickupSphereState) Update(gtx GameContext, b *Bridgeman)
type BridgemanSphereState ¶
type BridgemanSphereState interface {
Update(GameContext, *Bridgeman)
}
type BridgemanState ¶
type BridgemanState struct{ State }
func (*BridgemanState) HandleAirborne ¶
func (s *BridgemanState) HandleAirborne(c Character)
type Character ¶
type Character interface { Updater Body() *physics.Body SetAnimation(*graphics.SpriteAnimation) Team() string Jump() KeepMovingLeft() KeepMovingRight() Land() OnAttacked(GameContext) SetState(State) State() State Slow() WalkLeft() WalkRight() }
type CharacterSpawnTimer ¶
type CharacterSpawnTimer struct { C Character Now func() time.Time SpawnX float64 SpawnY float64 SpawnTime time.Time }
func (*CharacterSpawnTimer) Update ¶
func (t *CharacterSpawnTimer) Update(gtx GameContext) (done bool)
type CharacterSystem ¶
type CharacterSystem struct { Now func() time.Time RespawnDelay time.Duration // contains filtered or unexported fields }
func (*CharacterSystem) AddCharacter ¶
func (s *CharacterSystem) AddCharacter(c Character)
func (CharacterSystem) Characters ¶
func (s CharacterSystem) Characters() []Character
func (*CharacterSystem) RemoveCharacter ¶
func (s *CharacterSystem) RemoveCharacter(c Character)
func (*CharacterSystem) ScheduleSpawn ¶
func (s *CharacterSystem) ScheduleSpawn(gtx GameContext, c Character)
func (*CharacterSystem) Update ¶
func (s *CharacterSystem) Update(gtx GameContext)
type CharacterType ¶
type CharacterType = string
const ( SurgebinderCharacterType CharacterType = "surgebinder" BridgemanCharacterType CharacterType = "bridgeman" SprenCharacterType CharacterType = "spren" )
type Controller ¶
type Game ¶
type Game struct {
// contains filtered or unexported fields
}
func NewGame ¶
func NewGame(o GameOptions) *Game
func (*Game) CharacterSystem ¶
func (g *Game) CharacterSystem() *CharacterSystem
func (*Game) Controller ¶
func (g *Game) Controller() Controller
func (*Game) LashingSystem ¶
func (g *Game) LashingSystem() *LashingSystem
func (*Game) ObjectSystem ¶
func (g *Game) ObjectSystem() *ObjectSystem
func (*Game) PhysicsContext ¶
func (g *Game) PhysicsContext() *physics.PhysicsContext
func (*Game) SphereStockpiles ¶
func (g *Game) SphereStockpiles() []*SphereStockpile
type GameContext ¶
type GameContext interface { Controller() Controller PhysicsContext() *physics.PhysicsContext CharacterSystem() *CharacterSystem LashingSystem() *LashingSystem ObjectSystem() *ObjectSystem SphereStockpiles() []*SphereStockpile Map() *Map }
type GameOptions ¶
type GraphicsComponent ¶
type GraphicsComponent struct { DrawBoundingBox bool Canvas graphics.Canvas Animation *graphics.SpriteAnimation }
func (*GraphicsComponent) Update ¶
func (c *GraphicsComponent) Update(char *BaseCharacter)
type Herald ¶
type Herald struct { *BaseCharacter // contains filtered or unexported fields }
func (*Herald) OnAttacked ¶
func (h *Herald) OnAttacked(gtx GameContext)
func (*Herald) Update ¶
func (h *Herald) Update(gtx GameContext)
type HeraldAttackingState ¶
type HeraldAttackingState struct { BaseState Animation *graphics.SpriteAnimation }
func NewHeraldAttackingState ¶
func NewHeraldAttackingState() *HeraldAttackingState
func (*HeraldAttackingState) Enter ¶
func (s *HeraldAttackingState) Enter(c Character)
func (*HeraldAttackingState) HandleInput ¶
func (s *HeraldAttackingState) HandleInput(_ GameContext, __ Character)
func (*HeraldAttackingState) Update ¶
func (s *HeraldAttackingState) Update(gtx GameContext, c Character)
type HeraldGroundedState ¶
type HeraldGroundedState struct{ State }
func (*HeraldGroundedState) HandleAirborne ¶
func (s *HeraldGroundedState) HandleAirborne(c Character)
type HeraldNotAttackingState ¶
type HeraldNotAttackingState struct{ State }
func (*HeraldNotAttackingState) HandleInput ¶
func (s *HeraldNotAttackingState) HandleInput(gtx GameContext, c Character)
type Lashing ¶
type Lashing struct { // The character that activated the Lash ability. Lasher Lasher // The target of this lashing. // // If null, a target will be selected automatically. Target Lashable // The direction to lash the target. Direction physics.Direction }
Lashing forcibly changes the direction of a character's gravity.
type LashingSystem ¶
type LashingSystem struct { StormlightCost int // contains filtered or unexported fields }
func (*LashingSystem) Activate ¶
func (s *LashingSystem) Activate(gtx GameContext, lashing Lashing)
func (*LashingSystem) Update ¶
func (s *LashingSystem) Update(_ GameContext)
type Map ¶
type Map struct { // The locations where surgespheres spawn on this map. SphereSpawnLocations []*SphereSpawnLocation // The locations where Surgespheres may be stored. // // Each team on this map should have a single SphereStockpileArea in this // list. SphereStockpileAreas []*SphereStockpileArea // The set of player spawn locations. PlayerSpawnLocations []*PlayerSpawnLocation // The rectangles that form the collision locations with map terrain. CollisionBoxes []*physics.Rect // A sprite to render as the background image for this map. BackgroundSprite *pixel.Sprite WidthInPixels int HeightInPixels int }
Map represents a Surge game world.
func (*Map) AddPlayerSpawnLocation ¶
func (m *Map) AddPlayerSpawnLocation(l *PlayerSpawnLocation)
func (*Map) AddSphereSlotLocation ¶
func (m *Map) AddSphereSlotLocation(s *SphereSlotLocation)
func (*Map) AddSphereSpawnLocation ¶
func (m *Map) AddSphereSpawnLocation(s *SphereSpawnLocation)
func (*Map) AddSphereStockpileArea ¶
func (m *Map) AddSphereStockpileArea(a *SphereStockpileArea)
type MapDecoder ¶
type ObjectSystem ¶
type ObjectSystem struct {
// contains filtered or unexported fields
}
func (*ObjectSystem) AddObject ¶
func (s *ObjectSystem) AddObject(object Object)
func (*ObjectSystem) Objects ¶
func (s *ObjectSystem) Objects() []Object
func (*ObjectSystem) RemoveObject ¶
func (s *ObjectSystem) RemoveObject(object Object)
func (*ObjectSystem) Update ¶
func (s *ObjectSystem) Update(gtx GameContext)
type PlayerSpawnLocation ¶
type PlayerSpawnLocation struct { CharacterType CharacterType Team string PlayerID string X, Y float64 }
type Sphere ¶
type Sphere struct { Graphics SphereGraphicsComponent Body *physics.Body IsFrozen bool // contains filtered or unexported fields }
func (*Sphere) AddPickupSubscriber ¶
func (c *Sphere) AddPickupSubscriber(subscriber SpherePickupSubscriber)
AddPickupSubscriber registers subscriber to run the first time this sphere is picked up.
func (*Sphere) HandlePickup ¶
func (c *Sphere) HandlePickup(gtx GameContext)
func (*Sphere) Update ¶
func (c *Sphere) Update(gtx GameContext)
type SphereFactory ¶
func (SphereFactory) Create ¶
func (f SphereFactory) Create(x, y float64) *Sphere
type SphereGraphicsComponent ¶
type SphereGraphicsComponent struct { Animation *graphics.SpriteAnimation Canvas graphics.Canvas }
func (*SphereGraphicsComponent) Update ¶
func (c *SphereGraphicsComponent) Update(sphere *Sphere)
type SpherePickupSubscriber ¶
type SpherePickupSubscriber func()
type SphereSlot ¶
type SphereSlot struct {
X, Y float64
// contains filtered or unexported fields
}
func (*SphereSlot) Insert ¶
func (s *SphereSlot) Insert(gtx GameContext, sphere *Sphere)
func (SphereSlot) IsOpen ¶
func (s SphereSlot) IsOpen() bool
type SphereSlotLocation ¶
type SphereSpawn ¶
type SphereSpawn struct {
X, Y float64
Now func() time.Time
SphereFactory *SphereFactory
SpawnDelay time.Duration
// contains filtered or unexported fields
}
SphereSpawn is a location on the map where spheres repeatedly spawn.
func (*SphereSpawn) ScheduleSpawn ¶
func (s *SphereSpawn) ScheduleSpawn()
func (*SphereSpawn) Update ¶
func (s *SphereSpawn) Update(gtx GameContext)
type SphereSpawnLocation ¶
type SphereSpawnLocation struct {
X, Y float64
}
type SphereStockpile ¶
type SphereStockpile struct { Team string // contains filtered or unexported fields }
SphereStockpile is a where a team's spheres are stored.
func NewSphereStockpile ¶
func NewSphereStockpile(team string, bounds *physics.Rect, slots []*SphereSlot) *SphereStockpile
func (*SphereStockpile) AddSphere ¶
func (s *SphereStockpile) AddSphere(gtx GameContext, sphere *Sphere) bool
func (*SphereStockpile) Bounds ¶
func (s *SphereStockpile) Bounds() *physics.Rect
type SphereStockpileArea ¶
type SphereStockpileArea struct { Team string X, Y, Width, Height float64 Slots []*SphereSlotLocation }
func (*SphereStockpileArea) Bounds ¶
func (s *SphereStockpileArea) Bounds() *physics.Rect
type Spren ¶
type Spren struct{ *BaseCharacter }
func (*Spren) OnAttacked ¶
func (s *Spren) OnAttacked(gtx GameContext)
func (*Spren) Update ¶
func (s *Spren) Update(gtx GameContext)
type SprenAirborneState ¶
type SprenAirborneState struct{ *BaseAirborneState }
func (*SprenAirborneState) HandleInput ¶
func (s *SprenAirborneState) HandleInput(gtx GameContext, c Character)
type SprenState ¶
type SprenState struct{ State }
func (*SprenState) HandleAirborne ¶
func (s *SprenState) HandleAirborne(c Character)
type State ¶
type State interface { Enter(Character) Exit(Character) HandleAirborne(Character) HandleInput(GameContext, Character) HandleCollision(Character, physics.CollisionEvent) Update(GameContext, Character) }
func NewBridgemanAirborneState ¶
func NewBridgemanAirborneState() State
func NewBridgemanIdleState ¶
func NewBridgemanIdleState() State
func NewBridgemanWalkingState ¶
func NewBridgemanWalkingState() State
func NewHeraldAirborneState ¶
func NewHeraldAirborneState() State
func NewHeraldIdleState ¶
func NewHeraldIdleState() State
func NewHeraldWalkingState ¶
func NewHeraldWalkingState() State
func NewSprenAirborneState ¶
func NewSprenAirborneState() State
func NewSprenIdleState ¶
func NewSprenIdleState() State
func NewSprenWalkingState ¶
func NewSprenWalkingState() State
func NewSurgebinderAirborneState ¶
func NewSurgebinderAirborneState() State
func NewSurgebinderIdleState ¶
func NewSurgebinderIdleState() State
func NewSurgebinderWalkingState ¶
func NewSurgebinderWalkingState() State
type StateStack ¶
type StateStack struct {
// contains filtered or unexported fields
}
func (StateStack) At ¶
func (s StateStack) At(i int) State
func (StateStack) Dump ¶
func (s StateStack) Dump(format func(State) string)
func (StateStack) IsEmpty ¶
func (s StateStack) IsEmpty() bool
func (*StateStack) Pop ¶
func (s *StateStack) Pop() (State, bool)
func (*StateStack) Push ¶
func (s *StateStack) Push(state State)
func (StateStack) Size ¶
func (s StateStack) Size() int
func (StateStack) Top ¶
func (s StateStack) Top() State
type Surgebinder ¶
type Surgebinder struct { *BaseCharacter // contains filtered or unexported fields }
Surgebinder is a BaseCharacter that can use stormlight to affect themselves and other players.
The surgebinder, can 'lash' themselves in any cardinal direction, as well as other players. They have finite amount of stormlight, and convert back into Bridgemen when their stormlight runs out.
func NewSurgebinder ¶
func NewSurgebinder(ctx context.Context, c *BaseCharacter) *Surgebinder
func (*Surgebinder) Jump ¶
func (s *Surgebinder) Jump()
func (*Surgebinder) Land ¶
func (s *Surgebinder) Land()
func (*Surgebinder) OnAttacked ¶
func (s *Surgebinder) OnAttacked(gtx GameContext)
func (*Surgebinder) SetStormlight ¶
func (s *Surgebinder) SetStormlight(value int)
func (*Surgebinder) Slow ¶
func (s *Surgebinder) Slow()
func (*Surgebinder) Stormlight ¶
func (s *Surgebinder) Stormlight() int
func (*Surgebinder) Update ¶
func (s *Surgebinder) Update(gtx GameContext)
Overrides BaseCharacter.Updater
func (*Surgebinder) WalkLeft ¶
func (s *Surgebinder) WalkLeft()
func (*Surgebinder) WalkRight ¶
func (s *Surgebinder) WalkRight()
type SurgebinderState ¶
type SurgebinderState struct{ State }
SurgebinderState allows the surgebinder to lash objects and other players. They may do this while in any state.
func (*SurgebinderState) HandleInput ¶
func (s *SurgebinderState) HandleInput(gtx GameContext, c Character)
type Updater ¶
type Updater interface {
Update(GameContext)
}
type WindowCanvas ¶
func (WindowCanvas) Center ¶
func (w WindowCanvas) Center() pixel.Vec
func (WindowCanvas) DrawRect ¶
func (w WindowCanvas) DrawRect(rect *physics.Rect)
func (WindowCanvas) DrawSprite ¶
func (w WindowCanvas) DrawSprite(sprite *pixel.Sprite, pos pixel.Matrix)
func (WindowCanvas) DrawVertex ¶
func (w WindowCanvas) DrawVertex(vec pixel.Vec, rgb pixel.RGBA)