core

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package core contains lower level component systems.

Index

Constants

View Source
const (
	// ZIndexTop is to set the ZIndex at the top
	ZIndexTop = int64(math.MinInt64)
	// ZIndexBottom is to set the ZIndex at the bottom
	ZIndexBottom = int64(math.MinInt64 + 1)
)

Variables

View Source
var (
	// DebugDraw enables to see debug lines and stats
	DebugDraw = false
)

Functions

func Clamp

func Clamp(x, min, max float64) float64

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 SetDrawLayerComponentData added in v0.5.0

func SetDrawLayerComponentData(w ecs.BaseWorld, e ecs.Entity, data DrawLayer)

SetDrawLayerComponentData updates/adds a DrawLayer to Entity e

func SetDrawableComponentData added in v0.5.0

func SetDrawableComponentData(w ecs.BaseWorld, e ecs.Entity, data Drawable)

SetDrawableComponentData updates/adds a Drawable to Entity e

func SetFunctionComponentData added in v0.5.0

func SetFunctionComponentData(w ecs.BaseWorld, e ecs.Entity, data Function)

SetFunctionComponentData updates/adds a Function to Entity e

func SetLabelComponentData added in v0.5.0

func SetLabelComponentData(w ecs.BaseWorld, e ecs.Entity, data Label)

SetLabelComponentData updates/adds a Label to Entity e

func SetSpriteAnimationComponentData added in v0.5.0

func SetSpriteAnimationComponentData(w ecs.BaseWorld, e ecs.Entity, data SpriteAnimation)

SetSpriteAnimationComponentData updates/adds a SpriteAnimation to Entity e

func SetSpriteComponentData added in v0.5.0

func SetSpriteComponentData(w ecs.BaseWorld, e ecs.Entity, data Sprite)

SetSpriteComponentData updates/adds a Sprite to Entity e

func SetTileSetComponentData added in v0.5.0

func SetTileSetComponentData(w ecs.BaseWorld, e ecs.Entity, data TileSet)

SetTileSetComponentData updates/adds a TileSet to Entity e

func SetTransformComponentData added in v0.5.0

func SetTransformComponentData(w ecs.BaseWorld, e ecs.Entity, data Transform)

SetTransformComponentData updates/adds a Transform to Entity e

Types

type AnimClipMode

type AnimClipMode byte

AnimClipMode determines how time is treated outside of the keyframed range of an animation clip.

const (
	// AnimOnce - When time reaches the end of the animation clip, the clip will automatically
	// stop playing and time will be reset to beginning of the clip.
	AnimOnce AnimClipMode = 0
	// AnimLoop - When time reaches the end of the animation clip, time will continue at the beginning.
	AnimLoop AnimClipMode = 1
	// AnimPingPong - When time reaches the end of the animation clip, time will ping pong back between beginning
	// and end.
	AnimPingPong AnimClipMode = 2
	// AnimClampForever - Plays back the animation. When it reaches the end, it will keep playing the last frame
	// and never stop playing.
	//
	// When playing backwards it will reach the first frame and will keep playing that. This is useful for code
	// that uses the Playing bool to avoid activating said trigger.
	AnimClampForever AnimClipMode = 3
)

type Animation added in v0.3.0

type Animation interface {
	Each(fn func(i int, clip AnimationClip) bool)
	GetClip(index int) AnimationClip
	GetClipEvents(index int) []*AnimationEvent
	GetClipImage(clipindex, frame int) *ebiten.Image
	GetClipRect(clipindex, frame int) image.Rectangle
	GetClipOffset(clipindex, frame int) (x, y float64)
	Count() int
}

Animation is a shared container of clips (reusable)

type AnimationClip added in v0.3.0

type AnimationClip interface {
	GetName() string
	GetFPS() float64
	GetImage(frame int) *ebiten.Image
	GetFrameCount() int
	GetMode() AnimClipMode
	GetEndedEvent() *AnimationEvent
	GetEvents() []*AnimationEvent
	GetRect(frame int) image.Rectangle
	GetOffset(frame int) (x, y float64)
}

AnimationClip is the data os an animation clip (reusable)

type AnimationEvent added in v0.3.0

type AnimationEvent struct {
	Name  string
	Value string
}

AnimationEvent holds a name and value to pass to listeners when the event is triggered

type AnimationEventFn

type AnimationEventFn func(name, value string)

AnimationEventFn is a valid AnimationEvent function

type AnimationEventID

type AnimationEventID int64

AnimationEventID is the id oa an animation listener instance

type AnimationEventListeners

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

AnimationEventListeners groups AnimationEvent listeners

func (*AnimationEventListeners) Add

Add a new listener

func (*AnimationEventListeners) AddCatchAll

AddCatchAll adds a wildcard listener

func (*AnimationEventListeners) Clear

func (ae *AnimationEventListeners) Clear()

Clear removes all event listeners

func (*AnimationEventListeners) Dispatch

func (ae *AnimationEventListeners) Dispatch(name, value string)

Dispatch triggers all compatible listeners with the event

func (*AnimationEventListeners) Remove

Remove a listener by ID

type ColorMatrix added in v0.4.0

type ColorMatrix interface {
	Reset() ColorMatrix
	M() *ebiten.ColorM
	MV() ebiten.ColorM
	RotateHue(theta float64) ColorMatrix
	ChangeHSV(hueTheta float64, saturationScale float64, valueScale float64) ColorMatrix
	Apply(clr color.Color) ColorMatrix
}

func ColorM added in v0.4.0

func ColorM() ColorMatrix

func ColorM2 added in v0.4.0

func ColorM2(m ebiten.ColorM) ColorMatrix

func ColorTint added in v0.4.0

func ColorTint(c color.Color) ColorMatrix

type Context

type Context interface {
	Frame() int64
	DT() float64
	TPS() float64
	Engine() Engine
}

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, screen *ebiten.Image) DrawCtx

type DrawFn added in v0.3.0

type DrawFn func(ctx DrawCtx, e ecs.Entity)

type DrawLayer

type DrawLayer struct {
	Layer  LayerIndex
	ZIndex int64
	// contains filtered or unexported fields
}

func GetDrawLayerComponentData added in v0.5.0

func GetDrawLayerComponentData(w ecs.BaseWorld, e ecs.Entity) *DrawLayer

GetDrawLayerComponentData gets the *DrawLayer of Entity e

type DrawLayerComponent added in v0.5.0

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

DrawLayerComponent implements ecs.BaseComponent

func GetDrawLayerComponent added in v0.5.0

func GetDrawLayerComponent(w ecs.BaseWorld) *DrawLayerComponent

GetDrawLayerComponent returns the instance of the component in a World

func (*DrawLayerComponent) Data added in v0.5.0

func (c *DrawLayerComponent) Data(e ecs.Entity) *DrawLayer

func (*DrawLayerComponent) Flag added in v0.5.0

func (c *DrawLayerComponent) Flag() ecs.Flag

Flag returns the

func (DrawLayerComponent) Name added in v0.5.0

func (DrawLayerComponent) Name() string

Name implements ecs.BaseComponent

func (*DrawLayerComponent) Remove added in v0.5.0

func (c *DrawLayerComponent) Remove(e ecs.Entity)

Remove a DrawLayer data from entity e

Warning: DO NOT call remove inside the system entities loop

func (*DrawLayerComponent) Setup added in v0.5.0

func (c *DrawLayerComponent) Setup(w ecs.BaseWorld, f ecs.Flag, key [4]byte)

Setup is called by ecs.BaseWorld

Do not call this directly

func (DrawLayerComponent) UUID added in v0.5.0

func (DrawLayerComponent) UUID() string

UUID implements ecs.BaseComponent

func (*DrawLayerComponent) Upsert added in v0.5.0

func (c *DrawLayerComponent) Upsert(e ecs.Entity, data interface{})

Upsert creates or updates a component data of an entity. Not recommended to be used directly. Use SetDrawLayerComponentData to change component data outside of a system loop.

type DrawLayerDrawableSystem added in v0.5.0

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

DrawLayerDrawableSystem implements ecs.BaseSystem

func GetDrawLayerDrawableSystem added in v0.5.0

func GetDrawLayerDrawableSystem(w ecs.BaseWorld) *DrawLayerDrawableSystem

GetDrawLayerDrawableSystem returns the instance of the system in a World

func (*DrawLayerDrawableSystem) ComponentAdded added in v0.5.0

func (s *DrawLayerDrawableSystem) ComponentAdded(e ecs.Entity, eflag ecs.Flag)

func (*DrawLayerDrawableSystem) ComponentRemoved added in v0.5.0

func (s *DrawLayerDrawableSystem) ComponentRemoved(e ecs.Entity, eflag ecs.Flag)

func (*DrawLayerDrawableSystem) ComponentResized added in v0.5.0

func (s *DrawLayerDrawableSystem) ComponentResized(cflag ecs.Flag)

func (*DrawLayerDrawableSystem) ComponentWillResize added in v0.5.0

func (s *DrawLayerDrawableSystem) ComponentWillResize(cflag ecs.Flag)

func (*DrawLayerDrawableSystem) Disable added in v0.5.0

func (s *DrawLayerDrawableSystem) Disable()

Disable system

func (*DrawLayerDrawableSystem) Draw added in v0.5.0

func (s *DrawLayerDrawableSystem) Draw(ctx DrawCtx)

Draw draws a drawable by its layer and zindex order

func (*DrawLayerDrawableSystem) DrawPriority added in v0.5.0

func (s *DrawLayerDrawableSystem) DrawPriority(ctx DrawCtx)

DrawPriority is noop as of now

func (*DrawLayerDrawableSystem) Enable added in v0.5.0

func (s *DrawLayerDrawableSystem) Enable()

Enable system

func (*DrawLayerDrawableSystem) Enabled added in v0.5.0

func (s *DrawLayerDrawableSystem) Enabled() bool

Enabled checks if enabled

func (DrawLayerDrawableSystem) Name added in v0.5.0

func (*DrawLayerDrawableSystem) Priority added in v0.5.0

func (*DrawLayerDrawableSystem) Priority() int64

func (*DrawLayerDrawableSystem) Setup added in v0.5.0

func (s *DrawLayerDrawableSystem) Setup(w ecs.BaseWorld)

func (DrawLayerDrawableSystem) UUID added in v0.5.0

UUID implements ecs.BaseSystem

func (*DrawLayerDrawableSystem) Update added in v0.5.0

func (s *DrawLayerDrawableSystem) Update(ctx UpdateCtx)

Update is noop as of now

func (*DrawLayerDrawableSystem) UpdatePriority added in v0.5.0

func (s *DrawLayerDrawableSystem) UpdatePriority(ctx UpdateCtx)

UpdatePriority updates layer changes

func (*DrawLayerDrawableSystem) V added in v0.5.0

func (s *DrawLayerDrawableSystem) V() *viewDrawLayerDrawableSystem

type DrawManager added in v0.4.0

type DrawManager interface {
	DrawImageXY(image *ebiten.Image, x, y float64)
	DrawImage(image *ebiten.Image, m GeoMatrix)
	DrawImageC(image *ebiten.Image, m GeoMatrix, c ColorMatrix)
	DrawImageComp(image *ebiten.Image, m GeoMatrix, mode ebiten.CompositeMode)
	DrawImageCComp(image *ebiten.Image, m GeoMatrix, c ColorMatrix, mode ebiten.CompositeMode)
	DrawImageRaw(image *ebiten.Image, opt *ebiten.DrawImageOptions)
	Screen() *ebiten.Image
}

type Drawable

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

Drawable is the component that controls drawing to the ebiten screen

func GetDrawableComponentData added in v0.5.0

func GetDrawableComponentData(w ecs.BaseWorld, e ecs.Entity) *Drawable

GetDrawableComponentData gets the *Drawable of Entity e

func (*Drawable) Draw

func (d *Drawable) Draw(ctx DrawCtx)

Draw uses drawer or defaultDraw

func (*Drawable) G added in v0.5.0

func (d *Drawable) G(sx, sy, r, x, y float64) ebiten.GeoM

G returns the concatm (if set by a *Transform) or a pre calculated matrix using sx, sy (scale) r (radians) x, y position

func (*Drawable) SetConcatM added in v0.5.0

func (d *Drawable) SetConcatM(m ebiten.GeoM)

type DrawableComponent added in v0.5.0

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

DrawableComponent implements ecs.BaseComponent

func GetDrawableComponent added in v0.5.0

func GetDrawableComponent(w ecs.BaseWorld) *DrawableComponent

GetDrawableComponent returns the instance of the component in a World

func (*DrawableComponent) Data added in v0.5.0

func (c *DrawableComponent) Data(e ecs.Entity) *Drawable

func (*DrawableComponent) Flag added in v0.5.0

func (c *DrawableComponent) Flag() ecs.Flag

Flag returns the

func (DrawableComponent) Name added in v0.5.0

func (DrawableComponent) Name() string

Name implements ecs.BaseComponent

func (*DrawableComponent) Remove added in v0.5.0

func (c *DrawableComponent) Remove(e ecs.Entity)

Remove a Drawable data from entity e

Warning: DO NOT call remove inside the system entities loop

func (*DrawableComponent) Setup added in v0.5.0

func (c *DrawableComponent) Setup(w ecs.BaseWorld, f ecs.Flag, key [4]byte)

Setup is called by ecs.BaseWorld

Do not call this directly

func (DrawableComponent) UUID added in v0.5.0

func (DrawableComponent) UUID() string

UUID implements ecs.BaseComponent

func (*DrawableComponent) Upsert added in v0.5.0

func (c *DrawableComponent) Upsert(e ecs.Entity, data interface{})

Upsert creates or updates a component data of an entity. Not recommended to be used directly. Use SetDrawableComponentData to change component data outside of a system loop.

type DrawableLabelSystem added in v0.5.0

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

DrawableLabelSystem implements ecs.BaseSystem

func GetDrawableLabelSystem added in v0.5.0

func GetDrawableLabelSystem(w ecs.BaseWorld) *DrawableLabelSystem

GetDrawableLabelSystem returns the instance of the system in a World

func (*DrawableLabelSystem) ComponentAdded added in v0.5.0

func (s *DrawableLabelSystem) ComponentAdded(e ecs.Entity, eflag ecs.Flag)

func (*DrawableLabelSystem) ComponentRemoved added in v0.5.0

func (s *DrawableLabelSystem) ComponentRemoved(e ecs.Entity, eflag ecs.Flag)

func (*DrawableLabelSystem) ComponentResized added in v0.5.0

func (s *DrawableLabelSystem) ComponentResized(cflag ecs.Flag)

func (*DrawableLabelSystem) ComponentWillResize added in v0.5.0

func (s *DrawableLabelSystem) ComponentWillResize(cflag ecs.Flag)

func (*DrawableLabelSystem) Disable added in v0.5.0

func (s *DrawableLabelSystem) Disable()

Disable system

func (*DrawableLabelSystem) Draw added in v0.5.0

func (s *DrawableLabelSystem) Draw(ctx DrawCtx)

Draw noop (drawing is controlled by *Drawable)

func (*DrawableLabelSystem) DrawPriority added in v0.5.0

func (s *DrawableLabelSystem) DrawPriority(ctx DrawCtx)

DrawPriority noop

func (*DrawableLabelSystem) Enable added in v0.5.0

func (s *DrawableLabelSystem) Enable()

Enable system

func (*DrawableLabelSystem) Enabled added in v0.5.0

func (s *DrawableLabelSystem) Enabled() bool

Enabled checks if enabled

func (DrawableLabelSystem) Name added in v0.5.0

func (DrawableLabelSystem) Name() string

func (*DrawableLabelSystem) Priority added in v0.5.0

func (*DrawableLabelSystem) Priority() int64

func (*DrawableLabelSystem) Setup added in v0.5.0

func (s *DrawableLabelSystem) Setup(w ecs.BaseWorld)

func (DrawableLabelSystem) UUID added in v0.5.0

func (DrawableLabelSystem) UUID() string

UUID implements ecs.BaseSystem

func (*DrawableLabelSystem) Update added in v0.5.0

func (s *DrawableLabelSystem) Update(ctx UpdateCtx)

Update computes labes if dirty

func (*DrawableLabelSystem) UpdatePriority added in v0.5.0

func (s *DrawableLabelSystem) UpdatePriority(ctx UpdateCtx)

UpdatePriority noop

func (*DrawableLabelSystem) V added in v0.5.0

func (s *DrawableLabelSystem) V() *viewDrawableLabelSystem

type DrawableObj added in v0.5.0

type DrawableObj interface {
	Draw(ctx DrawCtx, o *Drawable)
}

DrawableObj is the interface of a custom drawable component to use inetead of Drawable.Draw()

type DrawableSpriteSystem added in v0.5.0

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

DrawableSpriteSystem implements ecs.BaseSystem

func GetDrawableSpriteSystem added in v0.5.0

func GetDrawableSpriteSystem(w ecs.BaseWorld) *DrawableSpriteSystem

GetDrawableSpriteSystem returns the instance of the system in a World

func (*DrawableSpriteSystem) ComponentAdded added in v0.5.0

func (s *DrawableSpriteSystem) ComponentAdded(e ecs.Entity, eflag ecs.Flag)

func (*DrawableSpriteSystem) ComponentRemoved added in v0.5.0

func (s *DrawableSpriteSystem) ComponentRemoved(e ecs.Entity, eflag ecs.Flag)

func (*DrawableSpriteSystem) ComponentResized added in v0.5.0

func (s *DrawableSpriteSystem) ComponentResized(cflag ecs.Flag)

func (*DrawableSpriteSystem) ComponentWillResize added in v0.5.0

func (s *DrawableSpriteSystem) ComponentWillResize(cflag ecs.Flag)

func (*DrawableSpriteSystem) Disable added in v0.5.0

func (s *DrawableSpriteSystem) Disable()

Disable system

func (*DrawableSpriteSystem) Draw added in v0.5.0

func (s *DrawableSpriteSystem) Draw(ctx DrawCtx)

Draw noop - drawing is controlled by *Drawable

func (*DrawableSpriteSystem) DrawPriority added in v0.5.0

func (s *DrawableSpriteSystem) DrawPriority(ctx DrawCtx)

DrawPriority noop

func (*DrawableSpriteSystem) Enable added in v0.5.0

func (s *DrawableSpriteSystem) Enable()

Enable system

func (*DrawableSpriteSystem) Enabled added in v0.5.0

func (s *DrawableSpriteSystem) Enabled() bool

Enabled checks if enabled

func (DrawableSpriteSystem) Name added in v0.5.0

func (*DrawableSpriteSystem) Priority added in v0.5.0

func (*DrawableSpriteSystem) Priority() int64

func (*DrawableSpriteSystem) Setup added in v0.5.0

func (s *DrawableSpriteSystem) Setup(w ecs.BaseWorld)

func (DrawableSpriteSystem) UUID added in v0.5.0

UUID implements ecs.BaseSystem

func (*DrawableSpriteSystem) Update added in v0.5.0

func (s *DrawableSpriteSystem) Update(ctx UpdateCtx)

Update noop

func (*DrawableSpriteSystem) UpdatePriority added in v0.5.0

func (s *DrawableSpriteSystem) UpdatePriority(ctx UpdateCtx)

UpdatePriority noop

func (*DrawableSpriteSystem) V added in v0.5.0

func (s *DrawableSpriteSystem) V() *viewDrawableSpriteSystem

type DrawableTileSetSystem added in v0.5.0

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

DrawableTileSetSystem implements ecs.BaseSystem

func GetDrawableTileSetSystem added in v0.5.0

func GetDrawableTileSetSystem(w ecs.BaseWorld) *DrawableTileSetSystem

GetDrawableTileSetSystem returns the instance of the system in a World

func (*DrawableTileSetSystem) ComponentAdded added in v0.5.0

func (s *DrawableTileSetSystem) ComponentAdded(e ecs.Entity, eflag ecs.Flag)

func (*DrawableTileSetSystem) ComponentRemoved added in v0.5.0

func (s *DrawableTileSetSystem) ComponentRemoved(e ecs.Entity, eflag ecs.Flag)

func (*DrawableTileSetSystem) ComponentResized added in v0.5.0

func (s *DrawableTileSetSystem) ComponentResized(cflag ecs.Flag)

func (*DrawableTileSetSystem) ComponentWillResize added in v0.5.0

func (s *DrawableTileSetSystem) ComponentWillResize(cflag ecs.Flag)

func (*DrawableTileSetSystem) Disable added in v0.5.0

func (s *DrawableTileSetSystem) Disable()

Disable system

func (*DrawableTileSetSystem) Draw added in v0.5.0

func (s *DrawableTileSetSystem) Draw(ctx DrawCtx)

Draw noop (controlled by *Drawable)

func (*DrawableTileSetSystem) DrawPriority added in v0.5.0

func (s *DrawableTileSetSystem) DrawPriority(ctx DrawCtx)

DrawPriority noop

func (*DrawableTileSetSystem) Enable added in v0.5.0

func (s *DrawableTileSetSystem) Enable()

Enable system

func (*DrawableTileSetSystem) Enabled added in v0.5.0

func (s *DrawableTileSetSystem) Enabled() bool

Enabled checks if enabled

func (DrawableTileSetSystem) Name added in v0.5.0

func (*DrawableTileSetSystem) Priority added in v0.5.0

func (*DrawableTileSetSystem) Priority() int64

func (*DrawableTileSetSystem) Setup added in v0.5.0

func (s *DrawableTileSetSystem) Setup(w ecs.BaseWorld)

func (DrawableTileSetSystem) UUID added in v0.5.0

UUID implements ecs.BaseSystem

func (*DrawableTileSetSystem) Update added in v0.5.0

func (s *DrawableTileSetSystem) Update(ctx UpdateCtx)

Update noop TODO: remove logic

func (*DrawableTileSetSystem) UpdatePriority added in v0.5.0

func (s *DrawableTileSetSystem) UpdatePriority(ctx UpdateCtx)

UpdatePriority noop

func (*DrawableTileSetSystem) V added in v0.5.0

func (s *DrawableTileSetSystem) V() *viewDrawableTileSetSystem

type DrawableTransformSystem added in v0.5.0

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

DrawableTransformSystem implements ecs.BaseSystem

func GetDrawableTransformSystem added in v0.5.0

func GetDrawableTransformSystem(w ecs.BaseWorld) *DrawableTransformSystem

GetDrawableTransformSystem returns the instance of the system in a World

func (*DrawableTransformSystem) ComponentAdded added in v0.5.0

func (s *DrawableTransformSystem) ComponentAdded(e ecs.Entity, eflag ecs.Flag)

func (*DrawableTransformSystem) ComponentRemoved added in v0.5.0

func (s *DrawableTransformSystem) ComponentRemoved(e ecs.Entity, eflag ecs.Flag)

func (*DrawableTransformSystem) ComponentResized added in v0.5.0

func (s *DrawableTransformSystem) ComponentResized(cflag ecs.Flag)

func (*DrawableTransformSystem) ComponentWillResize added in v0.5.0

func (s *DrawableTransformSystem) ComponentWillResize(cflag ecs.Flag)

func (*DrawableTransformSystem) Disable added in v0.5.0

func (s *DrawableTransformSystem) Disable()

Disable system

func (*DrawableTransformSystem) Draw added in v0.5.0

func (s *DrawableTransformSystem) Draw(ctx DrawCtx)

Draw noop

func (*DrawableTransformSystem) DrawPriority added in v0.5.0

func (s *DrawableTransformSystem) DrawPriority(ctx DrawCtx)

DrawPriority noop

func (*DrawableTransformSystem) Enable added in v0.5.0

func (s *DrawableTransformSystem) Enable()

Enable system

func (*DrawableTransformSystem) Enabled added in v0.5.0

func (s *DrawableTransformSystem) Enabled() bool

Enabled checks if enabled

func (DrawableTransformSystem) Name added in v0.5.0

func (*DrawableTransformSystem) Priority added in v0.5.0

func (*DrawableTransformSystem) Priority() int64

func (*DrawableTransformSystem) Setup added in v0.5.0

func (s *DrawableTransformSystem) Setup(w ecs.BaseWorld)

func (DrawableTransformSystem) UUID added in v0.5.0

UUID implements ecs.BaseSystem

func (*DrawableTransformSystem) Update added in v0.5.0

func (s *DrawableTransformSystem) Update(ctx UpdateCtx)

Update sets the drawable transform

func (*DrawableTransformSystem) UpdatePriority added in v0.5.0

func (s *DrawableTransformSystem) UpdatePriority(ctx UpdateCtx)

UpdatePriority noop

func (*DrawableTransformSystem) V added in v0.5.0

func (s *DrawableTransformSystem) V() *viewDrawableTransformSystem

type Engine

type Engine interface {
	NewWorld(priority int) World
	NewWorldWithDefaults(priority int) World
	RemoveWorld(w World)
	Run() error
	Ready() <-chan struct{}
	UpdateFrame() int64
	DrawFrame() int64
	Width() int
	Height() int
	AddEventListener(eventName string, fn EventFn) EventID
	RemoveEventListener(id EventID) bool
	DispatchEvent(eventName string, data interface{})
	SetDebugTPS(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

func NewEntitySet(values ...ecs.Entity) EntitySet

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

func (*EntitySortedList) Reset

func (sl *EntitySortedList) Reset()

Reset clears the list.

type Event

type Event struct {
	Engine Engine
	Data   interface{}
}

type EventFn

type EventFn func(eventName string, e Event)

type EventID

type EventID int64

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{})

func (*EventManager) Register

func (m *EventManager) Register(eventName string, fn EventFn) EventID

type Function added in v0.5.0

type Function struct {
	DrawPriority   DrawFn
	Draw           DrawFn
	UpdatePriority UpdateFn
	Update         UpdateFn
}

func GetFunctionComponentData added in v0.5.0

func GetFunctionComponentData(w ecs.BaseWorld, e ecs.Entity) *Function

GetFunctionComponentData gets the *Function of Entity e

type FunctionComponent added in v0.5.0

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

FunctionComponent implements ecs.BaseComponent

func GetFunctionComponent added in v0.5.0

func GetFunctionComponent(w ecs.BaseWorld) *FunctionComponent

GetFunctionComponent returns the instance of the component in a World

func (*FunctionComponent) Data added in v0.5.0

func (c *FunctionComponent) Data(e ecs.Entity) *Function

func (*FunctionComponent) Flag added in v0.5.0

func (c *FunctionComponent) Flag() ecs.Flag

Flag returns the

func (FunctionComponent) Name added in v0.5.0

func (FunctionComponent) Name() string

Name implements ecs.BaseComponent

func (*FunctionComponent) Remove added in v0.5.0

func (c *FunctionComponent) Remove(e ecs.Entity)

Remove a Function data from entity e

Warning: DO NOT call remove inside the system entities loop

func (*FunctionComponent) Setup added in v0.5.0

func (c *FunctionComponent) Setup(w ecs.BaseWorld, f ecs.Flag, key [4]byte)

Setup is called by ecs.BaseWorld

Do not call this directly

func (FunctionComponent) UUID added in v0.5.0

func (FunctionComponent) UUID() string

UUID implements ecs.BaseComponent

func (*FunctionComponent) Upsert added in v0.5.0

func (c *FunctionComponent) Upsert(e ecs.Entity, data interface{})

Upsert creates or updates a component data of an entity. Not recommended to be used directly. Use SetFunctionComponentData to change component data outside of a system loop.

type FunctionSystem added in v0.5.0

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

FunctionSystem implements ecs.BaseSystem

func GetFunctionSystem added in v0.5.0

func GetFunctionSystem(w ecs.BaseWorld) *FunctionSystem

GetFunctionSystem returns the instance of the system in a World

func (*FunctionSystem) ComponentAdded added in v0.5.0

func (s *FunctionSystem) ComponentAdded(e ecs.Entity, eflag ecs.Flag)

func (*FunctionSystem) ComponentRemoved added in v0.5.0

func (s *FunctionSystem) ComponentRemoved(e ecs.Entity, eflag ecs.Flag)

func (*FunctionSystem) ComponentResized added in v0.5.0

func (s *FunctionSystem) ComponentResized(cflag ecs.Flag)

func (*FunctionSystem) ComponentWillResize added in v0.5.0

func (s *FunctionSystem) ComponentWillResize(cflag ecs.Flag)

func (*FunctionSystem) Disable added in v0.5.0

func (s *FunctionSystem) Disable()

Disable system

func (*FunctionSystem) Draw added in v0.5.0

func (s *FunctionSystem) Draw(ctx DrawCtx)

func (*FunctionSystem) DrawPriority added in v0.5.0

func (s *FunctionSystem) DrawPriority(ctx DrawCtx)

func (*FunctionSystem) Enable added in v0.5.0

func (s *FunctionSystem) Enable()

Enable system

func (*FunctionSystem) Enabled added in v0.5.0

func (s *FunctionSystem) Enabled() bool

Enabled checks if enabled

func (FunctionSystem) Name added in v0.5.0

func (FunctionSystem) Name() string

func (*FunctionSystem) Priority added in v0.5.0

func (*FunctionSystem) Priority() int64

func (*FunctionSystem) Setup added in v0.5.0

func (s *FunctionSystem) Setup(w ecs.BaseWorld)

func (FunctionSystem) UUID added in v0.5.0

func (FunctionSystem) UUID() string

UUID implements ecs.BaseSystem

func (*FunctionSystem) Update added in v0.5.0

func (s *FunctionSystem) Update(ctx UpdateCtx)

func (*FunctionSystem) UpdatePriority added in v0.5.0

func (s *FunctionSystem) UpdatePriority(ctx UpdateCtx)

func (*FunctionSystem) V added in v0.5.0

func (s *FunctionSystem) V() *viewFunctionSystem

type GameWorld added in v0.5.0

type GameWorld struct {
	*ecs.World
	// contains filtered or unexported fields
}

func NewWorld

func NewWorld(e Engine) *GameWorld

func (*GameWorld) Engine added in v0.5.0

func (w *GameWorld) Engine() Engine

type GeoMatrix added in v0.4.0

type GeoMatrix interface {
	Translate(tx, ty float64) GeoMatrix
	Scale(sx, sy float64) GeoMatrix
	Rotate(theta float64) GeoMatrix
	Concat(m ebiten.GeoM) GeoMatrix
	M() *ebiten.GeoM
	MV() ebiten.GeoM
	Reset() GeoMatrix
}

func GeoM added in v0.4.0

func GeoM() GeoMatrix

func GeoM2 added in v0.4.0

func GeoM2(m ebiten.GeoM) GeoMatrix

type Label added in v0.3.0

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

func GetLabelComponentData added in v0.5.0

func GetLabelComponentData(w ecs.BaseWorld, e ecs.Entity) *Label

GetLabelComponentData gets the *Label of Entity e

func NewLabel added in v0.5.0

func NewLabel() Label

func (*Label) ComputedSize added in v0.3.0

func (l *Label) ComputedSize() image.Point

ComputedSize returns the width and height of the printable area of the label

func (*Label) Draw added in v0.3.0

func (l *Label) Draw(ctx DrawCtx, d *Drawable)

func (*Label) FontFaceHeight added in v0.3.0

func (l *Label) FontFaceHeight() int

FontFaceHeight returns the font height

func (*Label) ResetTextOffset added in v0.3.0

func (l *Label) ResetTextOffset()

ResetTextOffset sets the text offset to default (0, l.FontFaceHeight())

func (*Label) SetColor added in v0.5.0

func (l *Label) SetColor(c color.Color) *Label

func (*Label) SetFaceOffset added in v0.5.0

func (l *Label) SetFaceOffset(x, y int) *Label

func (*Label) SetFaceOffsetModeAuto added in v0.5.0

func (l *Label) SetFaceOffsetModeAuto(auto bool) *Label

func (*Label) SetFilter added in v0.5.0

func (l *Label) SetFilter(f ebiten.Filter)

func (*Label) SetOrigin added in v0.5.0

func (l *Label) SetOrigin(ox, oy float64) *Label

func (*Label) SetText added in v0.5.0

func (l *Label) SetText(t string) *Label

type LabelComponent added in v0.5.0

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

LabelComponent implements ecs.BaseComponent

func GetLabelComponent added in v0.5.0

func GetLabelComponent(w ecs.BaseWorld) *LabelComponent

GetLabelComponent returns the instance of the component in a World

func (*LabelComponent) Data added in v0.5.0

func (c *LabelComponent) Data(e ecs.Entity) *Label

func (*LabelComponent) Flag added in v0.5.0

func (c *LabelComponent) Flag() ecs.Flag

Flag returns the

func (LabelComponent) Name added in v0.5.0

func (LabelComponent) Name() string

Name implements ecs.BaseComponent

func (*LabelComponent) Remove added in v0.5.0

func (c *LabelComponent) Remove(e ecs.Entity)

Remove a Label data from entity e

Warning: DO NOT call remove inside the system entities loop

func (*LabelComponent) Setup added in v0.5.0

func (c *LabelComponent) Setup(w ecs.BaseWorld, f ecs.Flag, key [4]byte)

Setup is called by ecs.BaseWorld

Do not call this directly

func (LabelComponent) UUID added in v0.5.0

func (LabelComponent) UUID() string

UUID implements ecs.BaseComponent

func (*LabelComponent) Upsert added in v0.5.0

func (c *LabelComponent) Upsert(e ecs.Entity, data interface{})

Upsert creates or updates a component data of an entity. Not recommended to be used directly. Use SetLabelComponentData to change component data outside of a system loop.

type LayerIndex

type LayerIndex int64

LayerIndex is the layer index

type LayerTuple

type LayerTuple struct {
	Index LayerIndex
	Items *EntitySortedList
}

LayerTuple is returned when fetching all layers

type Observer

type Observer interface {
	EventName() string
	OnEvent(e Event)
}

type PcAnimClip added in v0.3.0

type PcAnimClip struct {
	// The name of an animation is not allowed to be changed during runtime
	// but since this is part of a component (and components shouldn't have logic),
	// it is a public member.
	Name       string
	Frames     []PcFrame
	Events     []*AnimationEvent //TODO: link
	Fps        float64
	ClipMode   AnimClipMode
	EndedEvent *AnimationEvent //TODO: link
}

PcAnimClip is a pre-computed animation clip.

func (PcAnimClip) GetEndedEvent added in v0.3.0

func (c PcAnimClip) GetEndedEvent() *AnimationEvent

func (PcAnimClip) GetEvents added in v0.3.0

func (c PcAnimClip) GetEvents() []*AnimationEvent

func (PcAnimClip) GetFPS added in v0.3.0

func (c PcAnimClip) GetFPS() float64

func (PcAnimClip) GetFrameCount added in v0.3.0

func (c PcAnimClip) GetFrameCount() int

func (PcAnimClip) GetImage added in v0.3.0

func (c PcAnimClip) GetImage(frame int) *ebiten.Image

func (PcAnimClip) GetMode added in v0.3.0

func (c PcAnimClip) GetMode() AnimClipMode

func (PcAnimClip) GetName added in v0.3.0

func (c PcAnimClip) GetName() string

GetName returns the animation clip name

func (PcAnimClip) GetOffset added in v0.3.0

func (c PcAnimClip) GetOffset(frame int) (x, y float64)

GetOffset returns the pixel offset (from the origin) of the current frame

func (PcAnimClip) GetRect added in v0.3.0

func (c PcAnimClip) GetRect(frame int) image.Rectangle

GetRect returns the drawable bounds

type PcFrame added in v0.3.0

type PcFrame struct {
	Image   *ebiten.Image
	Rect    image.Rectangle
	OffsetX float64
	OffsetY float64
}

type PrecomputedAnimation added in v0.3.0

type PrecomputedAnimation struct {
	Clips []PcAnimClip
}

PrecomputedAnimation is an animation of a one or more image sources It is the default data structure of an Atlas

func (*PrecomputedAnimation) Count added in v0.3.0

func (a *PrecomputedAnimation) Count() int

Count returns the total count of cnimation clips

func (*PrecomputedAnimation) Each added in v0.3.0

func (a *PrecomputedAnimation) Each(fn func(i int, clip AnimationClip) bool)

Each iterates through all animation clips

func (*PrecomputedAnimation) GetClip added in v0.3.0

func (a *PrecomputedAnimation) GetClip(index int) AnimationClip

GetClip returns an animation clip by index

func (*PrecomputedAnimation) GetClipEvents added in v0.3.0

func (a *PrecomputedAnimation) GetClipEvents(index int) []*AnimationEvent

GetClipEvents returns all animation clip events by the clip index

func (*PrecomputedAnimation) GetClipImage added in v0.3.0

func (a *PrecomputedAnimation) GetClipImage(clipi, frame int) *ebiten.Image

GetClipImage returns the clip image

func (*PrecomputedAnimation) GetClipOffset added in v0.3.0

func (a *PrecomputedAnimation) GetClipOffset(clipi, frame int) (x, y float64)

GetClipOffset returns the clip offset

func (*PrecomputedAnimation) GetClipRect added in v0.3.0

func (a *PrecomputedAnimation) GetClipRect(clipi, frame int) image.Rectangle

GetClipRect returns the clip Rectangle (bounds)

type SLVal

type SLVal interface {
	Less(v interface{}) bool
	Destroy()
}

type SetBase

type SetBase interface {
	Empty() bool
	Size() int
	Clear()
}

type SoloDrawableSystem added in v0.5.0

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

SoloDrawableSystem implements ecs.BaseSystem

func GetSoloDrawableSystem added in v0.5.0

func GetSoloDrawableSystem(w ecs.BaseWorld) *SoloDrawableSystem

GetSoloDrawableSystem returns the instance of the system in a World

func (*SoloDrawableSystem) ComponentAdded added in v0.5.0

func (s *SoloDrawableSystem) ComponentAdded(e ecs.Entity, eflag ecs.Flag)

func (*SoloDrawableSystem) ComponentRemoved added in v0.5.0

func (s *SoloDrawableSystem) ComponentRemoved(e ecs.Entity, eflag ecs.Flag)

func (*SoloDrawableSystem) ComponentResized added in v0.5.0

func (s *SoloDrawableSystem) ComponentResized(cflag ecs.Flag)

func (*SoloDrawableSystem) ComponentWillResize added in v0.5.0

func (s *SoloDrawableSystem) ComponentWillResize(cflag ecs.Flag)

func (*SoloDrawableSystem) Disable added in v0.5.0

func (s *SoloDrawableSystem) Disable()

Disable system

func (*SoloDrawableSystem) Draw added in v0.5.0

func (s *SoloDrawableSystem) Draw(ctx DrawCtx)

Draw all solo drawables ordered by entity ID

func (*SoloDrawableSystem) DrawPriority added in v0.5.0

func (s *SoloDrawableSystem) DrawPriority(ctx DrawCtx)

DrawPriority is noop as of now

func (*SoloDrawableSystem) Enable added in v0.5.0

func (s *SoloDrawableSystem) Enable()

Enable system

func (*SoloDrawableSystem) Enabled added in v0.5.0

func (s *SoloDrawableSystem) Enabled() bool

Enabled checks if enabled

func (SoloDrawableSystem) Name added in v0.5.0

func (SoloDrawableSystem) Name() string

func (*SoloDrawableSystem) Priority added in v0.5.0

func (*SoloDrawableSystem) Priority() int64

func (*SoloDrawableSystem) Setup added in v0.5.0

func (s *SoloDrawableSystem) Setup(w ecs.BaseWorld)

func (SoloDrawableSystem) UUID added in v0.5.0

func (SoloDrawableSystem) UUID() string

UUID implements ecs.BaseSystem

func (*SoloDrawableSystem) Update added in v0.5.0

func (s *SoloDrawableSystem) Update(ctx UpdateCtx)

Update is noop as of now

func (*SoloDrawableSystem) UpdatePriority added in v0.5.0

func (s *SoloDrawableSystem) UpdatePriority(ctx UpdateCtx)

UpdatePriority sets v.Drawable.concatset to false on all Drawables

func (*SoloDrawableSystem) V added in v0.5.0

func (s *SoloDrawableSystem) V() *viewSoloDrawableSystem

type Sprite

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

Sprite is the data of a sprite component.

func GetSpriteComponentData added in v0.5.0

func GetSpriteComponentData(w ecs.BaseWorld, e ecs.Entity) *Sprite

GetSpriteComponentData gets the *Sprite of Entity e

func NewSprite added in v0.5.0

func NewSprite(x, y float64, quad *ebiten.Image) Sprite

NewSprite creates a new sprite (component data)

func (*Sprite) Angle

func (s *Sprite) Angle() float64

Angle gets the local angle (radians). It is overrided by the transform component.

func (*Sprite) Draw

func (s *Sprite) Draw(ctx DrawCtx, d *Drawable)

func (*Sprite) Image

func (s *Sprite) Image() *ebiten.Image

func (*Sprite) Origin added in v0.5.0

func (s *Sprite) Origin() (ox, oy float64)

func (*Sprite) ResetColorMatrix added in v0.5.0

func (s *Sprite) ResetColorMatrix()

func (*Sprite) RotateHue added in v0.5.0

func (s *Sprite) RotateHue(theta float64)

func (*Sprite) ScaleX

func (s *Sprite) ScaleX() float64

func (*Sprite) ScaleY

func (s *Sprite) ScaleY() float64

func (*Sprite) SetAngle added in v0.5.0

func (s *Sprite) SetAngle(r float64) *Sprite

func (*Sprite) SetCompositeMode added in v0.4.0

func (s *Sprite) SetCompositeMode(mode ebiten.CompositeMode)

func (*Sprite) SetEnabled added in v0.5.0

func (s *Sprite) SetEnabled(enabled bool) *Sprite

func (*Sprite) SetImage

func (s *Sprite) SetImage(img *ebiten.Image) *Sprite

func (*Sprite) SetOffset added in v0.3.0

func (s *Sprite) SetOffset(x, y float64) *Sprite

func (*Sprite) SetOrigin added in v0.5.0

func (s *Sprite) SetOrigin(ox, oy float64) *Sprite

func (*Sprite) SetScaleX added in v0.5.0

func (s *Sprite) SetScaleX(sx float64) *Sprite

func (*Sprite) SetScaleY added in v0.5.0

func (s *Sprite) SetScaleY(sy float64) *Sprite

func (*Sprite) SetX added in v0.5.0

func (s *Sprite) SetX(x float64) *Sprite

func (*Sprite) SetY added in v0.5.0

func (s *Sprite) SetY(y float64) *Sprite

func (*Sprite) X

func (s *Sprite) X() float64

X gets the local x position. Overrided by the transform

func (*Sprite) Y

func (s *Sprite) Y() float64

Y gets the local y position. Overrided by the transform

type SpriteAnimation

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

SpriteAnimation holds the data of a sprite animation (and clips)

func GetSpriteAnimationComponentData added in v0.5.0

func GetSpriteAnimationComponentData(w ecs.BaseWorld, e ecs.Entity) *SpriteAnimation

GetSpriteAnimationComponentData gets the *SpriteAnimation of Entity e

func NewSpriteAnimation added in v0.5.0

func NewSpriteAnimation(fps float64, anim Animation) SpriteAnimation

func (*SpriteAnimation) AddEventListener added in v0.5.0

func (a *SpriteAnimation) AddEventListener(name string, fn AnimationEventFn) AnimationEventID

func (*SpriteAnimation) AddEventListenerW added in v0.5.0

func (a *SpriteAnimation) AddEventListenerW(fn AnimationEventFn) AnimationEventID

func (*SpriteAnimation) AnimEvent

func (a *SpriteAnimation) AnimEvent(name, value string)

AnimEvent dispatches an animation event to listeners

func (*SpriteAnimation) Animation added in v0.5.0

func (a *SpriteAnimation) Animation() Animation

func (*SpriteAnimation) PlayClip

func (a *SpriteAnimation) PlayClip(name string) bool

PlayClip sets the animation to play a clip by name

func (*SpriteAnimation) PlayClipFrame added in v0.5.0

func (a *SpriteAnimation) PlayClipFrame(name string, frame int) bool

PlayClip sets the animation to play a clip by name and at a specific frame

func (*SpriteAnimation) PlayClipIndex added in v0.3.0

func (a *SpriteAnimation) PlayClipIndex(i int) bool

PlayClipIndex plays a clip at index i

func (*SpriteAnimation) PlayClipIndexFrame added in v0.5.0

func (a *SpriteAnimation) PlayClipIndexFrame(i, frame int) bool

PlayClipIndexFrame plays a clip at index i

func (*SpriteAnimation) Playing

func (a *SpriteAnimation) Playing() bool

func (*SpriteAnimation) RemoveEventListener added in v0.5.0

func (a *SpriteAnimation) RemoveEventListener(id AnimationEventID) bool

func (*SpriteAnimation) Reversed added in v0.5.0

func (a *SpriteAnimation) Reversed() bool

func (*SpriteAnimation) SetAnimation added in v0.5.0

func (a *SpriteAnimation) SetAnimation(anim Animation)

SetAnimation parses the clip map and animations

func (*SpriteAnimation) SetReversed added in v0.5.0

func (a *SpriteAnimation) SetReversed(reversed bool)

SetReversed sets "reversed". It does nothing if it's not playing.

type SpriteAnimationComponent added in v0.5.0

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

SpriteAnimationComponent implements ecs.BaseComponent

func GetSpriteAnimationComponent added in v0.5.0

func GetSpriteAnimationComponent(w ecs.BaseWorld) *SpriteAnimationComponent

GetSpriteAnimationComponent returns the instance of the component in a World

func (*SpriteAnimationComponent) Data added in v0.5.0

func (c *SpriteAnimationComponent) Data(e ecs.Entity) *SpriteAnimation

func (*SpriteAnimationComponent) Flag added in v0.5.0

func (c *SpriteAnimationComponent) Flag() ecs.Flag

Flag returns the

func (SpriteAnimationComponent) Name added in v0.5.0

Name implements ecs.BaseComponent

func (*SpriteAnimationComponent) Remove added in v0.5.0

func (c *SpriteAnimationComponent) Remove(e ecs.Entity)

Remove a SpriteAnimation data from entity e

Warning: DO NOT call remove inside the system entities loop

func (*SpriteAnimationComponent) Setup added in v0.5.0

func (c *SpriteAnimationComponent) Setup(w ecs.BaseWorld, f ecs.Flag, key [4]byte)

Setup is called by ecs.BaseWorld

Do not call this directly

func (SpriteAnimationComponent) UUID added in v0.5.0

UUID implements ecs.BaseComponent

func (*SpriteAnimationComponent) Upsert added in v0.5.0

func (c *SpriteAnimationComponent) Upsert(e ecs.Entity, data interface{})

Upsert creates or updates a component data of an entity. Not recommended to be used directly. Use SetSpriteAnimationComponentData to change component data outside of a system loop.

type SpriteAnimationSystem added in v0.5.0

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

SpriteAnimationSystem implements ecs.BaseSystem

func GetSpriteAnimationSystem added in v0.5.0

func GetSpriteAnimationSystem(w ecs.BaseWorld) *SpriteAnimationSystem

GetSpriteAnimationSystem returns the instance of the system in a World

func (*SpriteAnimationSystem) ComponentAdded added in v0.5.0

func (s *SpriteAnimationSystem) ComponentAdded(e ecs.Entity, eflag ecs.Flag)

func (*SpriteAnimationSystem) ComponentRemoved added in v0.5.0

func (s *SpriteAnimationSystem) ComponentRemoved(e ecs.Entity, eflag ecs.Flag)

func (*SpriteAnimationSystem) ComponentResized added in v0.5.0

func (s *SpriteAnimationSystem) ComponentResized(cflag ecs.Flag)

func (*SpriteAnimationSystem) ComponentWillResize added in v0.5.0

func (s *SpriteAnimationSystem) ComponentWillResize(cflag ecs.Flag)

func (*SpriteAnimationSystem) Disable added in v0.5.0

func (s *SpriteAnimationSystem) Disable()

Disable system

func (*SpriteAnimationSystem) Draw added in v0.5.0

func (s *SpriteAnimationSystem) Draw(ctx DrawCtx)

Draw noop

func (*SpriteAnimationSystem) DrawPriority added in v0.5.0

func (s *SpriteAnimationSystem) DrawPriority(ctx DrawCtx)

DrawPriority noop

func (*SpriteAnimationSystem) Enable added in v0.5.0

func (s *SpriteAnimationSystem) Enable()

Enable system

func (*SpriteAnimationSystem) Enabled added in v0.5.0

func (s *SpriteAnimationSystem) Enabled() bool

Enabled checks if enabled

func (SpriteAnimationSystem) Name added in v0.5.0

func (*SpriteAnimationSystem) Priority added in v0.5.0

func (*SpriteAnimationSystem) Priority() int64

func (*SpriteAnimationSystem) Setup added in v0.5.0

func (s *SpriteAnimationSystem) Setup(w ecs.BaseWorld)

func (SpriteAnimationSystem) UUID added in v0.5.0

UUID implements ecs.BaseSystem

func (*SpriteAnimationSystem) Update added in v0.5.0

func (s *SpriteAnimationSystem) Update(ctx UpdateCtx)

Update plays the animations

func (*SpriteAnimationSystem) UpdatePriority added in v0.5.0

func (s *SpriteAnimationSystem) UpdatePriority(ctx UpdateCtx)

UpdatePriority noop

func (*SpriteAnimationSystem) V added in v0.5.0

func (s *SpriteAnimationSystem) V() *viewSpriteAnimationSystem

type SpriteComponent added in v0.5.0

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

SpriteComponent implements ecs.BaseComponent

func GetSpriteComponent added in v0.5.0

func GetSpriteComponent(w ecs.BaseWorld) *SpriteComponent

GetSpriteComponent returns the instance of the component in a World

func (*SpriteComponent) Data added in v0.5.0

func (c *SpriteComponent) Data(e ecs.Entity) *Sprite

func (*SpriteComponent) Flag added in v0.5.0

func (c *SpriteComponent) Flag() ecs.Flag

Flag returns the

func (SpriteComponent) Name added in v0.5.0

func (SpriteComponent) Name() string

Name implements ecs.BaseComponent

func (*SpriteComponent) Remove added in v0.5.0

func (c *SpriteComponent) Remove(e ecs.Entity)

Remove a Sprite data from entity e

Warning: DO NOT call remove inside the system entities loop

func (*SpriteComponent) Setup added in v0.5.0

func (c *SpriteComponent) Setup(w ecs.BaseWorld, f ecs.Flag, key [4]byte)

Setup is called by ecs.BaseWorld

Do not call this directly

func (SpriteComponent) UUID added in v0.5.0

func (SpriteComponent) UUID() string

UUID implements ecs.BaseComponent

func (*SpriteComponent) Upsert added in v0.5.0

func (c *SpriteComponent) Upsert(e ecs.Entity, data interface{})

Upsert creates or updates a component data of an entity. Not recommended to be used directly. Use SetSpriteComponentData to change component data outside of a system loop.

type System added in v0.5.0

type System interface {
	DrawPriority(ctx DrawCtx)
	Draw(ctx DrawCtx)
	UpdatePriority(ctx UpdateCtx)
	Update(ctx UpdateCtx)
}

type TileSet added in v0.4.0

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

TileSet is a drawable that efficiently draws tiles in a 2d array

func GetTileSetComponentData added in v0.5.0

func GetTileSetComponentData(w ecs.BaseWorld, e ecs.Entity) *TileSet

GetTileSetComponentData gets the *TileSet of Entity e

func NewTileSet added in v0.5.0

func NewTileSet(db []*ebiten.Image, rows, cols int, cellwidthpx, cellheightpx float64, cells []int) TileSet

func (*TileSet) Angle added in v0.4.0

func (s *TileSet) Angle() float64

Angle gets the local angle (radians). It is overrided by the transform component.

func (*TileSet) Draw added in v0.4.0

func (t *TileSet) Draw(ctx DrawCtx, d *Drawable)

func (*TileSet) Origin added in v0.5.0

func (s *TileSet) Origin() (ox, oy float64)

func (*TileSet) ScaleX added in v0.4.0

func (s *TileSet) ScaleX() float64

func (*TileSet) ScaleY added in v0.4.0

func (s *TileSet) ScaleY() float64

func (*TileSet) SetAngle added in v0.5.0

func (s *TileSet) SetAngle(r float64) *TileSet

func (*TileSet) SetCells added in v0.5.0

func (s *TileSet) SetCells(cells []int) *TileSet

func (*TileSet) SetColsRows added in v0.5.0

func (s *TileSet) SetColsRows(cols, rows int) *TileSet

func (*TileSet) SetDB added in v0.5.0

func (s *TileSet) SetDB(db []*ebiten.Image) *TileSet

func (*TileSet) SetEnabled added in v0.5.0

func (s *TileSet) SetEnabled(enabled bool) *TileSet

func (*TileSet) SetOffset added in v0.4.0

func (s *TileSet) SetOffset(x, y float64) *TileSet

func (*TileSet) SetOrigin added in v0.5.0

func (s *TileSet) SetOrigin(ox, oy float64) *TileSet

func (*TileSet) SetScaleX added in v0.5.0

func (s *TileSet) SetScaleX(sx float64) *TileSet

func (*TileSet) SetScaleY added in v0.5.0

func (s *TileSet) SetScaleY(sy float64) *TileSet

func (*TileSet) SetX added in v0.5.0

func (s *TileSet) SetX(x float64) *TileSet

func (*TileSet) SetY added in v0.5.0

func (s *TileSet) SetY(y float64) *TileSet

func (*TileSet) X added in v0.4.0

func (s *TileSet) X() float64

X gets the local x position. Overrided by the transform

func (*TileSet) Y added in v0.4.0

func (s *TileSet) Y() float64

Y gets the local y position. Overrided by the transform

type TileSetComponent added in v0.5.0

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

TileSetComponent implements ecs.BaseComponent

func GetTileSetComponent added in v0.5.0

func GetTileSetComponent(w ecs.BaseWorld) *TileSetComponent

GetTileSetComponent returns the instance of the component in a World

func (*TileSetComponent) Data added in v0.5.0

func (c *TileSetComponent) Data(e ecs.Entity) *TileSet

func (*TileSetComponent) Flag added in v0.5.0

func (c *TileSetComponent) Flag() ecs.Flag

Flag returns the

func (TileSetComponent) Name added in v0.5.0

func (TileSetComponent) Name() string

Name implements ecs.BaseComponent

func (*TileSetComponent) Remove added in v0.5.0

func (c *TileSetComponent) Remove(e ecs.Entity)

Remove a TileSet data from entity e

Warning: DO NOT call remove inside the system entities loop

func (*TileSetComponent) Setup added in v0.5.0

func (c *TileSetComponent) Setup(w ecs.BaseWorld, f ecs.Flag, key [4]byte)

Setup is called by ecs.BaseWorld

Do not call this directly

func (TileSetComponent) UUID added in v0.5.0

func (TileSetComponent) UUID() string

UUID implements ecs.BaseComponent

func (*TileSetComponent) Upsert added in v0.5.0

func (c *TileSetComponent) Upsert(e ecs.Entity, data interface{})

Upsert creates or updates a component data of an entity. Not recommended to be used directly. Use SetTileSetComponentData to change component data outside of a system loop.

type TiledAnimation added in v0.3.0

type TiledAnimation struct {
	Clips []TiledAnimationClip
}

TiledAnimation is an animation of a single image source and many Rectangles that represent views (subimages)

func (*TiledAnimation) Count added in v0.3.0

func (a *TiledAnimation) Count() int

Count returns the total count of cnimation clips

func (*TiledAnimation) Each added in v0.3.0

func (a *TiledAnimation) Each(fn func(i int, clip AnimationClip) bool)

Each iterates through all animation clips

func (*TiledAnimation) GetClip added in v0.3.0

func (a *TiledAnimation) GetClip(index int) AnimationClip

GetClip returns an animation clip by index

func (*TiledAnimation) GetClipEvents added in v0.3.0

func (a *TiledAnimation) GetClipEvents(index int) []*AnimationEvent

GetClipEvents returns all animation clip events by the clip index

func (*TiledAnimation) GetClipImage added in v0.3.0

func (a *TiledAnimation) GetClipImage(clipi, frame int) *ebiten.Image

GetClipImage returns the clip image

func (*TiledAnimation) GetClipOffset added in v0.3.0

func (a *TiledAnimation) GetClipOffset(clipi, frame int) (x, y float64)

GetClipOffset returns the clip offset

func (*TiledAnimation) GetClipRect added in v0.3.0

func (a *TiledAnimation) GetClipRect(clipi, frame int) image.Rectangle

GetClipRect returns the clip Rectangle (bounds)

type TiledAnimationClip added in v0.3.0

type TiledAnimationClip struct {
	// The name of an animation is not allowed to be changed during runtime
	// but since this is part of a component (and components shouldn't have logic),
	// it is a public member.
	Name       string
	Image      *ebiten.Image
	Frames     []image.Rectangle
	Events     []*AnimationEvent //TODO: link
	Fps        float64
	ClipMode   AnimClipMode
	EndedEvent *AnimationEvent //TODO: link
}

TiledAnimationClip is an animation clip, like a character walk cycle.

func (TiledAnimationClip) GetEndedEvent added in v0.3.0

func (c TiledAnimationClip) GetEndedEvent() *AnimationEvent

func (TiledAnimationClip) GetEvents added in v0.3.0

func (c TiledAnimationClip) GetEvents() []*AnimationEvent

func (TiledAnimationClip) GetFPS added in v0.3.0

func (c TiledAnimationClip) GetFPS() float64

func (TiledAnimationClip) GetFrameCount added in v0.3.0

func (c TiledAnimationClip) GetFrameCount() int

func (TiledAnimationClip) GetImage added in v0.3.0

func (c TiledAnimationClip) GetImage(frame int) *ebiten.Image

func (TiledAnimationClip) GetMode added in v0.3.0

func (c TiledAnimationClip) GetMode() AnimClipMode

func (TiledAnimationClip) GetName added in v0.3.0

func (c TiledAnimationClip) GetName() string

GetName returns the animation clip name

func (TiledAnimationClip) GetOffset added in v0.3.0

func (c TiledAnimationClip) GetOffset(frame int) (x, y float64)

GetOffset is anoop for TiledAnimationClip

func (TiledAnimationClip) GetRect added in v0.3.0

func (c TiledAnimationClip) GetRect(frame int) image.Rectangle

GetRect returns the drawable bounds

type Transform

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

Transform is a hierarchy based matrix

func GetTransformComponentData added in v0.5.0

func GetTransformComponentData(w ecs.BaseWorld, e ecs.Entity) *Transform

GetTransformComponentData gets the *Transform of Entity e

func NewTransform

func NewTransform(x, y float64) Transform

func (*Transform) Angle

func (t *Transform) Angle() float64

Angle gets the angle (in radians)

func (*Transform) Parent

func (t *Transform) Parent() ecs.Entity

func (*Transform) ParentTransform added in v0.5.0

func (t *Transform) ParentTransform() *Transform

func (*Transform) Scale added in v0.5.0

func (t *Transform) Scale() (sx, sy float64)

func (*Transform) ScaleX

func (t *Transform) ScaleX() float64

func (*Transform) ScaleY

func (t *Transform) ScaleY() float64

func (*Transform) SetAngle added in v0.5.0

func (t *Transform) SetAngle(r float64) *Transform

SetAngle sets the angle (in radians)

func (*Transform) SetParent added in v0.5.0

func (t *Transform) SetParent(e ecs.Entity) bool

func (*Transform) SetScale added in v0.5.0

func (t *Transform) SetScale(sx, sy float64) *Transform

func (*Transform) SetScaleX added in v0.5.0

func (t *Transform) SetScaleX(sx float64) *Transform

func (*Transform) SetScaleY added in v0.5.0

func (t *Transform) SetScaleY(sy float64) *Transform

func (*Transform) SetX added in v0.5.0

func (t *Transform) SetX(x float64) *Transform

func (*Transform) SetY added in v0.5.0

func (t *Transform) SetY(y float64) *Transform

func (*Transform) X

func (t *Transform) X() float64

func (*Transform) Y

func (t *Transform) Y() float64

type TransformComponent added in v0.5.0

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

TransformComponent implements ecs.BaseComponent

func GetTransformComponent added in v0.5.0

func GetTransformComponent(w ecs.BaseWorld) *TransformComponent

GetTransformComponent returns the instance of the component in a World

func (*TransformComponent) Data added in v0.5.0

func (c *TransformComponent) Data(e ecs.Entity) *Transform

func (*TransformComponent) Flag added in v0.5.0

func (c *TransformComponent) Flag() ecs.Flag

Flag returns the

func (TransformComponent) Name added in v0.5.0

func (TransformComponent) Name() string

Name implements ecs.BaseComponent

func (*TransformComponent) Remove added in v0.5.0

func (c *TransformComponent) Remove(e ecs.Entity)

Remove a Transform data from entity e

Warning: DO NOT call remove inside the system entities loop

func (*TransformComponent) Setup added in v0.5.0

func (c *TransformComponent) Setup(w ecs.BaseWorld, f ecs.Flag, key [4]byte)

Setup is called by ecs.BaseWorld

Do not call this directly

func (TransformComponent) UUID added in v0.5.0

func (TransformComponent) UUID() string

UUID implements ecs.BaseComponent

func (*TransformComponent) Upsert added in v0.5.0

func (c *TransformComponent) Upsert(e ecs.Entity, data interface{})

Upsert creates or updates a component data of an entity. Not recommended to be used directly. Use SetTransformComponentData to change component data outside of a system loop.

type TransformSystem added in v0.5.0

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

TransformSystem implements ecs.BaseSystem

func GetTransformSystem added in v0.5.0

func GetTransformSystem(w ecs.BaseWorld) *TransformSystem

GetTransformSystem returns the instance of the system in a World

func (*TransformSystem) ComponentAdded added in v0.5.0

func (s *TransformSystem) ComponentAdded(e ecs.Entity, eflag ecs.Flag)

func (*TransformSystem) ComponentRemoved added in v0.5.0

func (s *TransformSystem) ComponentRemoved(e ecs.Entity, eflag ecs.Flag)

func (*TransformSystem) ComponentResized added in v0.5.0

func (s *TransformSystem) ComponentResized(cflag ecs.Flag)

func (*TransformSystem) ComponentWillResize added in v0.5.0

func (s *TransformSystem) ComponentWillResize(cflag ecs.Flag)

func (*TransformSystem) Disable added in v0.5.0

func (s *TransformSystem) Disable()

Disable system

func (*TransformSystem) Draw added in v0.5.0

func (s *TransformSystem) Draw(ctx DrawCtx)

Draw noop

func (*TransformSystem) DrawPriority added in v0.5.0

func (s *TransformSystem) DrawPriority(ctx DrawCtx)

DrawPriority noop

func (*TransformSystem) Enable added in v0.5.0

func (s *TransformSystem) Enable()

Enable system

func (*TransformSystem) Enabled added in v0.5.0

func (s *TransformSystem) Enabled() bool

Enabled checks if enabled

func (TransformSystem) Name added in v0.5.0

func (TransformSystem) Name() string

func (*TransformSystem) Priority added in v0.5.0

func (*TransformSystem) Priority() int64

func (*TransformSystem) Setup added in v0.5.0

func (s *TransformSystem) Setup(w ecs.BaseWorld)

func (TransformSystem) UUID added in v0.5.0

func (TransformSystem) UUID() string

UUID implements ecs.BaseSystem

func (*TransformSystem) Update added in v0.5.0

func (s *TransformSystem) Update(ctx UpdateCtx)

Update calculates all transform matrices

func (*TransformSystem) UpdatePriority added in v0.5.0

func (s *TransformSystem) UpdatePriority(ctx UpdateCtx)

UpdatePriority noop

func (*TransformSystem) V added in v0.5.0

func (s *TransformSystem) V() *viewTransformSystem

type UpdateCtx added in v0.5.0

type UpdateCtx interface {
	Context
}

UpdateCtx is the context passed to every system update function.

func NewUpdateCtx added in v0.5.0

func NewUpdateCtx(e Engine, frame int64, dt, tps float64) UpdateCtx

type UpdateFn

type UpdateFn func(ctx UpdateCtx, e ecs.Entity)

type VIDrawLayerDrawableSystem added in v0.5.0

type VIDrawLayerDrawableSystem struct {
	Entity ecs.Entity

	Drawable *Drawable

	DrawLayer *DrawLayer
}

type VIDrawableLabelSystem added in v0.5.0

type VIDrawableLabelSystem struct {
	Entity ecs.Entity

	Drawable *Drawable

	Label *Label
}

type VIDrawableSpriteSystem added in v0.5.0

type VIDrawableSpriteSystem struct {
	Entity ecs.Entity

	Drawable *Drawable

	Sprite *Sprite
}

type VIDrawableTileSetSystem added in v0.5.0

type VIDrawableTileSetSystem struct {
	Entity ecs.Entity

	Drawable *Drawable

	TileSet *TileSet
}

type VIDrawableTransformSystem added in v0.5.0

type VIDrawableTransformSystem struct {
	Entity ecs.Entity

	Transform *Transform

	Drawable *Drawable
}

type VIFunctionSystem added in v0.5.0

type VIFunctionSystem struct {
	Entity ecs.Entity

	Function *Function
}

type VISoloDrawableSystem added in v0.5.0

type VISoloDrawableSystem struct {
	Entity ecs.Entity

	Drawable *Drawable
}

type VISpriteAnimationSystem added in v0.5.0

type VISpriteAnimationSystem struct {
	Entity ecs.Entity

	Sprite *Sprite

	SpriteAnimation *SpriteAnimation
}

type VITransformSystem added in v0.5.0

type VITransformSystem struct {
	Entity ecs.Entity

	Transform *Transform
}

type WatchDrawLayer added in v0.5.0

type WatchDrawLayer interface {
	Entity() ecs.Entity
	Data() *DrawLayer
}

WatchDrawLayer is a helper struct to access a valid pointer of DrawLayer

func WatchDrawLayerComponentData added in v0.5.0

func WatchDrawLayerComponentData(w ecs.BaseWorld, e ecs.Entity) WatchDrawLayer

WatchDrawLayerComponentData gets a pointer getter of an entity's DrawLayer.

The pointer must not be stored because it may become invalid overtime.

type WatchDrawable added in v0.5.0

type WatchDrawable interface {
	Entity() ecs.Entity
	Data() *Drawable
}

WatchDrawable is a helper struct to access a valid pointer of Drawable

func WatchDrawableComponentData added in v0.5.0

func WatchDrawableComponentData(w ecs.BaseWorld, e ecs.Entity) WatchDrawable

WatchDrawableComponentData gets a pointer getter of an entity's Drawable.

The pointer must not be stored because it may become invalid overtime.

type WatchFunction added in v0.5.0

type WatchFunction interface {
	Entity() ecs.Entity
	Data() *Function
}

WatchFunction is a helper struct to access a valid pointer of Function

func WatchFunctionComponentData added in v0.5.0

func WatchFunctionComponentData(w ecs.BaseWorld, e ecs.Entity) WatchFunction

WatchFunctionComponentData gets a pointer getter of an entity's Function.

The pointer must not be stored because it may become invalid overtime.

type WatchLabel added in v0.5.0

type WatchLabel interface {
	Entity() ecs.Entity
	Data() *Label
}

WatchLabel is a helper struct to access a valid pointer of Label

func WatchLabelComponentData added in v0.5.0

func WatchLabelComponentData(w ecs.BaseWorld, e ecs.Entity) WatchLabel

WatchLabelComponentData gets a pointer getter of an entity's Label.

The pointer must not be stored because it may become invalid overtime.

type WatchSprite added in v0.5.0

type WatchSprite interface {
	Entity() ecs.Entity
	Data() *Sprite
}

WatchSprite is a helper struct to access a valid pointer of Sprite

func WatchSpriteComponentData added in v0.5.0

func WatchSpriteComponentData(w ecs.BaseWorld, e ecs.Entity) WatchSprite

WatchSpriteComponentData gets a pointer getter of an entity's Sprite.

The pointer must not be stored because it may become invalid overtime.

type WatchSpriteAnimation added in v0.5.0

type WatchSpriteAnimation interface {
	Entity() ecs.Entity
	Data() *SpriteAnimation
}

WatchSpriteAnimation is a helper struct to access a valid pointer of SpriteAnimation

func WatchSpriteAnimationComponentData added in v0.5.0

func WatchSpriteAnimationComponentData(w ecs.BaseWorld, e ecs.Entity) WatchSpriteAnimation

WatchSpriteAnimationComponentData gets a pointer getter of an entity's SpriteAnimation.

The pointer must not be stored because it may become invalid overtime.

type WatchTileSet added in v0.5.0

type WatchTileSet interface {
	Entity() ecs.Entity
	Data() *TileSet
}

WatchTileSet is a helper struct to access a valid pointer of TileSet

func WatchTileSetComponentData added in v0.5.0

func WatchTileSetComponentData(w ecs.BaseWorld, e ecs.Entity) WatchTileSet

WatchTileSetComponentData gets a pointer getter of an entity's TileSet.

The pointer must not be stored because it may become invalid overtime.

type WatchTransform added in v0.5.0

type WatchTransform interface {
	Entity() ecs.Entity
	Data() *Transform
}

WatchTransform is a helper struct to access a valid pointer of Transform

func WatchTransformComponentData added in v0.5.0

func WatchTransformComponentData(w ecs.BaseWorld, e ecs.Entity) WatchTransform

WatchTransformComponentData gets a pointer getter of an entity's Transform.

The pointer must not be stored because it may become invalid overtime.

type World added in v0.5.0

type World interface {
	ecs.BaseWorld
	Engine() Engine
}

Jump to

Keyboard shortcuts

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