Documentation ¶
Overview ¶
Package core contains lower level component systems.
Index ¶
- func ApplyOrigin(length, origin float64) float64
- func Clamp(x, min, max float64) float64
- func Intmax(a, b int) int
- func Lerpc(a, b color.RGBA, t float64) color.RGBA
- func Lerpf(a, b, t float64) float64
- func Nonzeroval(vals ...float64) float64
- func Scaleb(b uint8, scale float64) uint8
- func Scalef(f, scale float64) float64
- type Context
- type DrawCtx
- type DrawManager
- type DrawMask
- type DrawTarget
- type DrawTargetID
- type Engine
- type EntitySet
- type EntitySortedList
- func (sl *EntitySortedList) AddOrUpdate(key ecs.Entity, value SLVal) bool
- func (sl *EntitySortedList) Delete(key ecs.Entity) bool
- func (sl *EntitySortedList) Each(fn func(key ecs.Entity, value SLVal) bool)
- func (sl *EntitySortedList) FirstValue() SLVal
- func (sl *EntitySortedList) Get(key ecs.Entity) (SLVal, bool)
- func (sl *EntitySortedList) LastValue() SLVal
- func (sl *EntitySortedList) Reset()
- type Event
- type EventFn
- type EventID
- type EventManager
- type GameWorld
- type Module
- type Observer
- type SLVal
- type SetBase
- type System
- type UpdateCtx
- type World
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyOrigin ¶ added in v0.7.2
func Clamp ¶
Clamp returns x clamped to the interval [min, max].
If x is less than min, min is returned. If x is more than max, max is returned. Otherwise, x is returned.
func Nonzeroval ¶ added in v0.7.2
Nonzeroval will return the first non zero value. It will return 0 if all input values are 0
Types ¶
type DrawCtx ¶ added in v0.5.0
type DrawCtx interface { Context Renderer() DrawManager }
DrawCtx is the context passed to every system update function.
func NewDrawCtx ¶ added in v0.5.0
func NewDrawCtx(e Engine, frame int64, dt, tps float64, m DrawManager) DrawCtx
type DrawManager ¶ added in v0.4.0
type DrawManager interface { DrawImage(image *ebiten.Image, opt *ebiten.DrawImageOptions, drawmask DrawMask) Screen() *ebiten.Image DrawTarget(id DrawTargetID) DrawTarget }
type DrawMask ¶ added in v0.7.2
type DrawMask uint64
DrawMask is a flag to choose the draw target(s) of a drawable component
var ( // DrawMaskDefault can be changed to make all new drawable components // start with a different value. // // The initial value of DrawMaskDefault is DrawMaskAll DrawMaskDefault DrawMask = DrawMaskAll )
type DrawTarget ¶ added in v0.7.2
type DrawTargetID ¶ added in v0.7.2
type DrawTargetID uint64
func (DrawTargetID) String ¶ added in v0.7.2
func (d DrawTargetID) String() string
type Engine ¶
type Engine interface { AddModule(module Module, priority int) NewWorld(priority int) World NewWorldWithDefaults(priority int) World RemoveWorld(w World) Run() error Ready() <-chan struct{} UpdateFrame() int64 DrawFrame() int64 Width() int Height() int SizeVec() geom.Vec AddEventListener(eventName string, fn EventFn) EventID RemoveEventListener(id EventID) bool DispatchEvent(eventName string, data interface{}) SetDebugTPS(v bool) SetDebugFPS(v bool) SetScreenScale(scale float64) }
type EntitySet ¶
type EntitySet interface { Add(elements ...ecs.Entity) Remove(elements ...ecs.Entity) Contains(elements ...ecs.Entity) bool Values() []ecs.Entity SetBase }
func NewEntitySet ¶
NewEntitySet instantiates a new empty set and adds the entities (if present)
type EntitySortedList ¶
type EntitySortedList struct {
// contains filtered or unexported fields
}
func NewEntitySortedList ¶
func NewEntitySortedList(mincap int) *EntitySortedList
func (*EntitySortedList) AddOrUpdate ¶
func (sl *EntitySortedList) AddOrUpdate(key ecs.Entity, value SLVal) bool
func (*EntitySortedList) Delete ¶
func (sl *EntitySortedList) Delete(key ecs.Entity) bool
func (*EntitySortedList) Each ¶
func (sl *EntitySortedList) Each(fn func(key ecs.Entity, value SLVal) bool)
Each iterates on all entries, sorted.
Do not delete or add entries while looping (it is read locked while looping).
func (*EntitySortedList) FirstValue ¶
func (sl *EntitySortedList) FirstValue() SLVal
func (*EntitySortedList) Get ¶
func (sl *EntitySortedList) Get(key ecs.Entity) (SLVal, bool)
func (*EntitySortedList) LastValue ¶
func (sl *EntitySortedList) LastValue() SLVal
type EventManager ¶
type EventManager struct {
// contains filtered or unexported fields
}
func (*EventManager) Deregister ¶
func (m *EventManager) Deregister(id EventID) bool
func (*EventManager) Dispatch ¶
func (m *EventManager) Dispatch(eventName string, engine Engine, data interface{})
type GameWorld ¶ added in v0.5.0
type GameWorld struct { *ecs.World // contains filtered or unexported fields }
func (*GameWorld) SetEnabled ¶ added in v0.6.1
SetEnabled is very useful to prevent weird behavior if you're using a goroutine to create entities (and components) inside a scene loader.
type Module ¶ added in v0.7.2
type Module interface { BeforeUpdate(ctx UpdateCtx) AfterUpdate(ctx UpdateCtx) BeforeDraw(ctx DrawCtx) AfterDraw(ctx DrawCtx) }
Module defines a Primen Engine module