Documentation ¶
Index ¶
- type Component
- type ComponentHandler
- type Entity
- func (e *Entity) Add(comp Component) *Entity
- func (e Entity) Get(comp string) (Component, bool)
- func (e Entity) H() int32
- func (e Entity) Has(comp string) bool
- func (e Entity) ID() uint64
- func (e *Entity) Rect() sdl.Rect
- func (e *Entity) Remove(comp string)
- func (e *Entity) SetH(n int32)
- func (e *Entity) SetW(n int32)
- func (e *Entity) SetX(n float64)
- func (e *Entity) SetY(n float64)
- func (e *Entity) SetZ(n int32)
- func (e Entity) W() int32
- func (e Entity) X() float64
- func (e Entity) Y() float64
- func (e Entity) Z() int32
- type EntityManager
- type GameInterface
- type Identifier
- type Message
- type Priority
- type System
- type SystemManager
- func (mngr *SystemManager) AddSystem(s System, t SystemType)
- func (mngr *SystemManager) AllSystems() []System
- func (mngr *SystemManager) BeforeUpdate(dt float64)
- func (mngr SystemManager) GetEntityManager() *EntityManager
- func (mngr *SystemManager) Render(lag float64)
- func (mngr *SystemManager) SendMessage(msg Message, data interface{}) (interface{}, error)
- func (mngr *SystemManager) SetEntityManager(em EntityManager)
- func (mngr *SystemManager) Systems(t SystemType) []System
- func (mngr *SystemManager) Update(dt float64)
- type SystemType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component interface { }
Component specifies the interface that every component should follow.
type ComponentHandler ¶
type ComponentHandler interface { Add(comp Component) Remove(comp Component) Get(comp Component) (Component, bool) Has(comp Component) bool }
ComponentHandler specifies what objects can handle a list of components.
type Entity ¶
type Entity struct {
// contains filtered or unexported fields
}
Entity defines the entity in the entity component system.
type EntityManager ¶
type EntityManager interface { Add(entity Entity, systemIDs ...string) Delete(id uint64, systemIDs ...string) Get(id uint64) Entity HandleMessage(msg Message, data interface{}) interface{} }
EntityManager defines the interface for an entitymanager.
type GameInterface ¶
type GameInterface interface { Update(dt float64) Render(lag float64) IsRunning() bool SetRunning(state bool) ToggleFullscreen() HandleMessage(msg Message, data interface{}) interface{} }
GameInterface defines the interface that every game should follow. Mostly used to decouple stuff so I can cyclic import :)
type Identifier ¶
type Identifier interface {
ID() uint64
}
Identifier specifies something that can be uniquely identified.
type Priority ¶
type Priority interface {
Priority() uint
}
Priority implies that some things are more important than others.
type System ¶
type System interface { Init(mngr *SystemManager) Update(dt float64) HandleMessage(msg Message, data interface{}) interface{} }
System specifies a system.
type SystemManager ¶
type SystemManager struct {
// contains filtered or unexported fields
}
SystemManager manages all the systems.
func NewSystemManager ¶
func NewSystemManager(game GameInterface) *SystemManager
NewSystemManager makes a new system manager.
func (*SystemManager) AddSystem ¶
func (mngr *SystemManager) AddSystem(s System, t SystemType)
AddSystem adds a system to the manager and sorts the list based on priority.
func (*SystemManager) AllSystems ¶
func (mngr *SystemManager) AllSystems() []System
AllSystems returns ALL the systems that this manager manages.
func (*SystemManager) BeforeUpdate ¶
func (mngr *SystemManager) BeforeUpdate(dt float64)
BeforeUpdate goes through the sorted list and updates all the systems.
func (SystemManager) GetEntityManager ¶
func (mngr SystemManager) GetEntityManager() *EntityManager
GetEntityManager returns the entitymanager.
func (*SystemManager) Render ¶
func (mngr *SystemManager) Render(lag float64)
Render goes through the sorted list and renders all the systems.
func (*SystemManager) SendMessage ¶
func (mngr *SystemManager) SendMessage( msg Message, data interface{}) (interface{}, error)
SendMessage sends a message to all systems, entityManager and Game.
func (*SystemManager) SetEntityManager ¶
func (mngr *SystemManager) SetEntityManager(em EntityManager)
SetEntityManager sets the entitymanager.
func (*SystemManager) Systems ¶
func (mngr *SystemManager) Systems(t SystemType) []System
Systems returns the systems that this manager manages.
func (*SystemManager) Update ¶
func (mngr *SystemManager) Update(dt float64)
Update goes through the sorted list and updates all the systems.
type SystemType ¶
type SystemType int
SystemType defines the type used for the SystemType enum
const ( STypeBeforeUpdate SystemType = iota STypeUpdate STypeRender STypeCount )
The SystemType enum