graphics

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

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

This section is empty.

Functions

func RegisterDrawableComponent

func RegisterDrawableComponent(w ecs.BaseWorld, f ecs.Flag, fn GetDrawableFn)

func SetDrawLayerComponentData

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

SetDrawLayerComponentData updates/adds a DrawLayer to Entity e

func SetParticleEmitterComponentData

func SetParticleEmitterComponentData(w ecs.BaseWorld, e ecs.Entity, data ParticleEmitter)

SetParticleEmitterComponentData updates/adds a ParticleEmitter to Entity e

func SetSpriteAnimationComponentData

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

SetSpriteAnimationComponentData updates/adds a SpriteAnimation to Entity e

func SetSpriteComponentData

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

SetSpriteComponentData updates/adds a Sprite to Entity e

func SetTextLabelComponentData

func SetTextLabelComponentData(w ecs.BaseWorld, e ecs.Entity, data TextLabel)

SetTextLabelComponentData updates/adds a TextLabel to Entity e

func SetTileSetComponentData

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

SetTileSetComponentData updates/adds a TileSet 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

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

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

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 DrawLayer

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

func GetDrawLayerComponentData

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

GetDrawLayerComponentData gets the *DrawLayer of Entity e

type DrawLayerComponent

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

DrawLayerComponent implements ecs.BaseComponent

func GetDrawLayerComponent

func GetDrawLayerComponent(w ecs.BaseWorld) *DrawLayerComponent

GetDrawLayerComponent returns the instance of the component in a World

func (*DrawLayerComponent) Data

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

func (*DrawLayerComponent) Flag

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

Flag returns the

func (DrawLayerComponent) Name

func (DrawLayerComponent) Name() string

Name implements ecs.BaseComponent

func (*DrawLayerComponent) Remove

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

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

func (DrawLayerComponent) UUID() string

UUID implements ecs.BaseComponent

func (*DrawLayerComponent) Upsert

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

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

DrawLayerDrawableSystem implements ecs.BaseSystem

func GetDrawLayerDrawableSystem

func GetDrawLayerDrawableSystem(w ecs.BaseWorld) *DrawLayerDrawableSystem

GetDrawLayerDrawableSystem returns the instance of the system in a World

func (*DrawLayerDrawableSystem) ComponentAdded

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

func (*DrawLayerDrawableSystem) ComponentRemoved

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

func (*DrawLayerDrawableSystem) ComponentResized

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

func (*DrawLayerDrawableSystem) ComponentWillResize

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

func (*DrawLayerDrawableSystem) Disable

func (s *DrawLayerDrawableSystem) Disable()

Disable system

func (*DrawLayerDrawableSystem) Draw

func (s *DrawLayerDrawableSystem) Draw(ctx core.DrawCtx)

Draw draws a drawable by its layer and zindex order

func (*DrawLayerDrawableSystem) DrawPriority

func (s *DrawLayerDrawableSystem) DrawPriority(ctx core.DrawCtx)

DrawPriority is noop as of now

func (*DrawLayerDrawableSystem) Enable

func (s *DrawLayerDrawableSystem) Enable()

Enable system

func (*DrawLayerDrawableSystem) Enabled

func (s *DrawLayerDrawableSystem) Enabled() bool

Enabled checks if enabled

func (DrawLayerDrawableSystem) Name

func (*DrawLayerDrawableSystem) Priority

func (*DrawLayerDrawableSystem) Priority() int64

func (*DrawLayerDrawableSystem) Setup

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

func (DrawLayerDrawableSystem) UUID

UUID implements ecs.BaseSystem

func (*DrawLayerDrawableSystem) Update

func (s *DrawLayerDrawableSystem) Update(ctx core.UpdateCtx)

Update is noop as of now

func (*DrawLayerDrawableSystem) UpdatePriority

func (s *DrawLayerDrawableSystem) UpdatePriority(ctx core.UpdateCtx)

UpdatePriority updates layer changes

func (*DrawLayerDrawableSystem) V

func (s *DrawLayerDrawableSystem) V() *viewDrawLayerDrawableSystem

type Drawable

type Drawable interface {
	DrawMask() core.DrawMask
	SetDrawMask(mask core.DrawMask)
	Draw(ctx core.DrawCtx, t *components.Transform)
	Update(ctx core.UpdateCtx, t *components.Transform)
}

Drawable is the component that controls drawing to the ebiten screen

func GetDrawable

func GetDrawable(w ecs.BaseWorld, e ecs.Entity) Drawable

type DrawableTextLabelSystem

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

DrawableTextLabelSystem implements ecs.BaseSystem

func GetDrawableTextLabelSystem

func GetDrawableTextLabelSystem(w ecs.BaseWorld) *DrawableTextLabelSystem

GetDrawableTextLabelSystem returns the instance of the system in a World

func (*DrawableTextLabelSystem) ComponentAdded

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

func (*DrawableTextLabelSystem) ComponentRemoved

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

func (*DrawableTextLabelSystem) ComponentResized

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

func (*DrawableTextLabelSystem) ComponentWillResize

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

func (*DrawableTextLabelSystem) Disable

func (s *DrawableTextLabelSystem) Disable()

Disable system

func (*DrawableTextLabelSystem) Draw

func (s *DrawableTextLabelSystem) Draw(ctx core.DrawCtx)

Draw noop (drawing is controlled by *Drawable)

func (*DrawableTextLabelSystem) DrawPriority

func (s *DrawableTextLabelSystem) DrawPriority(ctx core.DrawCtx)

DrawPriority noop

func (*DrawableTextLabelSystem) Enable

func (s *DrawableTextLabelSystem) Enable()

Enable system

func (*DrawableTextLabelSystem) Enabled

func (s *DrawableTextLabelSystem) Enabled() bool

Enabled checks if enabled

func (DrawableTextLabelSystem) Name

func (*DrawableTextLabelSystem) Priority

func (*DrawableTextLabelSystem) Priority() int64

func (*DrawableTextLabelSystem) Setup

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

func (DrawableTextLabelSystem) UUID

UUID implements ecs.BaseSystem

func (*DrawableTextLabelSystem) Update

func (s *DrawableTextLabelSystem) Update(ctx core.UpdateCtx)

Update computes labes if dirty

func (*DrawableTextLabelSystem) UpdatePriority

func (s *DrawableTextLabelSystem) UpdatePriority(ctx core.UpdateCtx)

UpdatePriority noop

func (*DrawableTextLabelSystem) V

func (s *DrawableTextLabelSystem) V() *viewDrawableTextLabelSystem

type EmissionProp

type EmissionProp struct {
	Fn      func(ctx core.UpdateCtx, e *ParticleEmitter) bool // use a custom function to emit particles
	T0, T1  float64                                           // emit a particle every Lerp(T0,T1,rand())
	N0, N1  int                                               // emit (N0 >= p > N1) particle(s) every Lerp(T0,T1,rand())
	Enabled bool
}

type GetDrawableFn

type GetDrawableFn func(w ecs.BaseWorld, e ecs.Entity) Drawable

type LayerIndex

type LayerIndex int64

LayerIndex is the layer index

type LayerTuple

type LayerTuple struct {
	Index LayerIndex
	Items *core.EntitySortedList
}

LayerTuple is returned when fetching all layers

type Particle

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

type ParticleEmitter

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

func GetParticleEmitterComponentData

func GetParticleEmitterComponentData(w ecs.BaseWorld, e ecs.Entity) *ParticleEmitter

GetParticleEmitterComponentData gets the *ParticleEmitter of Entity e

func NewParticleEmitter

func NewParticleEmitter(w ecs.BaseWorld) ParticleEmitter

func (*ParticleEmitter) CompositeMode

func (e *ParticleEmitter) CompositeMode() ebiten.CompositeMode

func (*ParticleEmitter) Draw

func (e *ParticleEmitter) Draw(ctx core.DrawCtx, tr *components.Transform)

func (*ParticleEmitter) DrawMask

func (e *ParticleEmitter) DrawMask() core.DrawMask

func (*ParticleEmitter) EmissionProp

func (e *ParticleEmitter) EmissionProp() EmissionProp

func (*ParticleEmitter) Emit

func (*ParticleEmitter) Enabled

func (e *ParticleEmitter) Enabled() bool

func (*ParticleEmitter) MaxParticles

func (e *ParticleEmitter) MaxParticles() int

func (*ParticleEmitter) Props

func (e *ParticleEmitter) Props() ParticleProps

func (*ParticleEmitter) SetCompositeMode

func (e *ParticleEmitter) SetCompositeMode(m ebiten.CompositeMode) *ParticleEmitter

func (*ParticleEmitter) SetDrawMask

func (e *ParticleEmitter) SetDrawMask(mask core.DrawMask)

func (*ParticleEmitter) SetEmissionProp

func (e *ParticleEmitter) SetEmissionProp(prop EmissionProp) *ParticleEmitter

func (*ParticleEmitter) SetEnabled

func (e *ParticleEmitter) SetEnabled(enabled bool) *ParticleEmitter

func (*ParticleEmitter) SetLockedParticles

func (e *ParticleEmitter) SetLockedParticles(locked bool) *ParticleEmitter

func (*ParticleEmitter) SetMaxParticles

func (e *ParticleEmitter) SetMaxParticles(max int) *ParticleEmitter

func (*ParticleEmitter) SetParentLevel

func (e *ParticleEmitter) SetParentLevel(level uint) *ParticleEmitter

func (*ParticleEmitter) SetProps

func (e *ParticleEmitter) SetProps(props ParticleProps) *ParticleEmitter

func (*ParticleEmitter) SetStrategy

func (e *ParticleEmitter) SetStrategy(strategy SpawnStrategy) *ParticleEmitter

func (*ParticleEmitter) Update

func (e *ParticleEmitter) Update(ctx core.UpdateCtx, tr *components.Transform)

type ParticleEmitterComponent

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

ParticleEmitterComponent implements ecs.BaseComponent

func GetParticleEmitterComponent

func GetParticleEmitterComponent(w ecs.BaseWorld) *ParticleEmitterComponent

GetParticleEmitterComponent returns the instance of the component in a World

func (*ParticleEmitterComponent) Data

func (c *ParticleEmitterComponent) Data(e ecs.Entity) *ParticleEmitter

func (*ParticleEmitterComponent) Flag

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

Flag returns the

func (ParticleEmitterComponent) Name

Name implements ecs.BaseComponent

func (*ParticleEmitterComponent) Remove

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

Remove a ParticleEmitter data from entity e

Warning: DO NOT call remove inside the system entities loop

func (*ParticleEmitterComponent) Setup

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

Setup is called by ecs.BaseWorld

Do not call this directly

func (ParticleEmitterComponent) UUID

UUID implements ecs.BaseComponent

func (*ParticleEmitterComponent) Upsert

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

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

type ParticleEmitterSystem

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

ParticleEmitterSystem implements ecs.BaseSystem

func GetParticleEmitterSystem

func GetParticleEmitterSystem(w ecs.BaseWorld) *ParticleEmitterSystem

GetParticleEmitterSystem returns the instance of the system in a World

func (*ParticleEmitterSystem) ComponentAdded

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

func (*ParticleEmitterSystem) ComponentRemoved

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

func (*ParticleEmitterSystem) ComponentResized

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

func (*ParticleEmitterSystem) ComponentWillResize

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

func (*ParticleEmitterSystem) Disable

func (s *ParticleEmitterSystem) Disable()

Disable system

func (*ParticleEmitterSystem) Draw

func (s *ParticleEmitterSystem) Draw(ctx core.DrawCtx)

Draw noop (drawing is controlled by *Drawable)

func (*ParticleEmitterSystem) DrawPriority

func (s *ParticleEmitterSystem) DrawPriority(ctx core.DrawCtx)

DrawPriority noop

func (*ParticleEmitterSystem) Enable

func (s *ParticleEmitterSystem) Enable()

Enable system

func (*ParticleEmitterSystem) Enabled

func (s *ParticleEmitterSystem) Enabled() bool

Enabled checks if enabled

func (ParticleEmitterSystem) Name

func (*ParticleEmitterSystem) Priority

func (*ParticleEmitterSystem) Priority() int64

func (*ParticleEmitterSystem) Setup

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

func (ParticleEmitterSystem) UUID

UUID implements ecs.BaseSystem

func (*ParticleEmitterSystem) Update

func (s *ParticleEmitterSystem) Update(ctx core.UpdateCtx)

Update computes labes if dirty

func (*ParticleEmitterSystem) UpdatePriority

func (s *ParticleEmitterSystem) UpdatePriority(ctx core.UpdateCtx)

UpdatePriority noop

func (*ParticleEmitterSystem) V

func (s *ParticleEmitterSystem) V() *viewParticleEmitterSystem

type ParticleProps

type ParticleProps struct {
	X, Y                                       float64         // initial position
	XVar0, XVar1                               float64         // randomized position range
	YVar0, YVar1                               float64         // randomized position range
	XVelocity, YVelocity                       float64         // initial velocity
	XVelocityVar0, XVelocityVar1               float64         // randomized velocity range
	YVelocityVar0, YVelocityVar1               float64         // randomized velocity range
	XAccel, YAccel                             float64         // initial acceleration
	XAccelVar0, XAccelVar1                     float64         // randomized acceleration range
	YAccelVar0, YAccelVar1                     float64         // randomized acceleration range
	Rotation                                   float64         // initial rotation (radians)
	RotationVar0, RotationVar1                 float64         // randomized initial rotation (radians)
	RotationVelocityVar0, RotationVelocityVar1 float64         // randomized initial rotation velocity (radians/second)
	RotationAccelVar0, RotationAccelVar1       float64         // initial rotation acceleration (radians/second)
	EndRotationAccelVar0, EndRotationAccelVar1 float64         // end rotation acceleration (radians/second)
	InitScale                                  float64         // initial scale
	InitScaleVar0, InitScaleVar1               float64         // randomized initial scale
	EndScale                                   float64         // end scale
	EndScaleVar0, EndScaleVar1                 float64         // randomized end scale
	OriginX, OriginY                           float64         // origin
	Duration                                   float64         // duration
	DurationVar0, DurationVar1                 float64         // randomized duration (seconds)
	HueRotationSpeed                           float64         // hue shift (/second)
	InitColor                                  color.RGBA      // initial color tint modifier
	EndColor                                   color.RGBA      // end color tint modifier
	Source                                     []*ebiten.Image // particle source(s); if it's more than one, it will be randomized
}

func (ParticleProps) NewParticle

func (pp ParticleProps) NewParticle(rng *rand.Rand) Particle

func (*ParticleProps) SetPositionRange

func (pp *ParticleProps) SetPositionRange(xmin, xmax, ymin, ymax float64)

func (*ParticleProps) SetVelocityRange

func (pp *ParticleProps) SetVelocityRange(xmin, xmax, ymin, ymax float64)

type PcAnimClip

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

func (c PcAnimClip) GetEndedEvent() *AnimationEvent

func (PcAnimClip) GetEvents

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

func (PcAnimClip) GetFPS

func (c PcAnimClip) GetFPS() float64

func (PcAnimClip) GetFrameCount

func (c PcAnimClip) GetFrameCount() int

func (PcAnimClip) GetImage

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

func (PcAnimClip) GetMode

func (c PcAnimClip) GetMode() AnimClipMode

func (PcAnimClip) GetName

func (c PcAnimClip) GetName() string

GetName returns the animation clip name

func (PcAnimClip) GetOffset

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

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

func (PcAnimClip) GetRect

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

GetRect returns the drawable bounds

type PcFrame

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

type PrecomputedAnimation

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

func (a *PrecomputedAnimation) Count() int

Count returns the total count of cnimation clips

func (*PrecomputedAnimation) Each

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

Each iterates through all animation clips

func (*PrecomputedAnimation) GetClip

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

GetClip returns an animation clip by index

func (*PrecomputedAnimation) GetClipEvents

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

GetClipEvents returns all animation clip events by the clip index

func (*PrecomputedAnimation) GetClipImage

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

GetClipImage returns the clip image

func (*PrecomputedAnimation) GetClipOffset

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

GetClipOffset returns the clip offset

func (*PrecomputedAnimation) GetClipRect

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

GetClipRect returns the clip Rectangle (bounds)

type SoloDrawableSystem

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

SoloDrawableSystem implements ecs.BaseSystem

func GetSoloDrawableSystem

func GetSoloDrawableSystem(w ecs.BaseWorld) *SoloDrawableSystem

GetSoloDrawableSystem returns the instance of the system in a World

func (*SoloDrawableSystem) ComponentAdded

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

func (*SoloDrawableSystem) ComponentRemoved

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

func (*SoloDrawableSystem) ComponentResized

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

func (*SoloDrawableSystem) ComponentWillResize

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

func (*SoloDrawableSystem) Disable

func (s *SoloDrawableSystem) Disable()

Disable system

func (*SoloDrawableSystem) Draw

func (s *SoloDrawableSystem) Draw(ctx core.DrawCtx)

Draw all solo drawables ordered by entity ID

func (*SoloDrawableSystem) DrawPriority

func (s *SoloDrawableSystem) DrawPriority(ctx core.DrawCtx)

DrawPriority is noop as of now

func (*SoloDrawableSystem) Enable

func (s *SoloDrawableSystem) Enable()

Enable system

func (*SoloDrawableSystem) Enabled

func (s *SoloDrawableSystem) Enabled() bool

Enabled checks if enabled

func (SoloDrawableSystem) Name

func (SoloDrawableSystem) Name() string

func (*SoloDrawableSystem) Priority

func (*SoloDrawableSystem) Priority() int64

func (*SoloDrawableSystem) Setup

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

func (SoloDrawableSystem) UUID

func (SoloDrawableSystem) UUID() string

UUID implements ecs.BaseSystem

func (*SoloDrawableSystem) Update

func (s *SoloDrawableSystem) Update(ctx core.UpdateCtx)

Update calls drawable.Update()

func (*SoloDrawableSystem) UpdatePriority

func (s *SoloDrawableSystem) UpdatePriority(ctx core.UpdateCtx)

UpdatePriority noop

func (*SoloDrawableSystem) V

func (s *SoloDrawableSystem) V() *viewSoloDrawableSystem

type SpawnStrategy

type SpawnStrategy int
const (
	SpawnReplace SpawnStrategy = iota
	SpawnPause   SpawnStrategy = iota
)

type Sprite

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

Sprite is the data of a sprite component.

func GetSpriteComponentData

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

GetSpriteComponentData gets the *Sprite of Entity e

func NewSprite

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

NewSprite creates a new sprite (component data)

func (*Sprite) Draw

func (s *Sprite) Draw(ctx core.DrawCtx, t *components.Transform)

func (*Sprite) DrawMask

func (s *Sprite) DrawMask() core.DrawMask

func (*Sprite) Image

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

func (*Sprite) Origin

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

func (*Sprite) ResetColorMatrix

func (s *Sprite) ResetColorMatrix()

func (*Sprite) RotateHue

func (s *Sprite) RotateHue(theta float64)

func (*Sprite) SetCompositeMode

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

func (*Sprite) SetDrawMask

func (s *Sprite) SetDrawMask(mask core.DrawMask)

func (*Sprite) SetEnabled

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

func (*Sprite) SetImage

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

func (*Sprite) SetOffset

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

func (*Sprite) SetOrigin

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

func (*Sprite) Update

func (s *Sprite) Update(ctx core.UpdateCtx, t *components.Transform)

type SpriteAnimation

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

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

func GetSpriteAnimationComponentData

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

GetSpriteAnimationComponentData gets the *SpriteAnimation of Entity e

func NewSpriteAnimation

func NewSpriteAnimation(fps float64, anim Animation) SpriteAnimation

func (*SpriteAnimation) AddEventListener

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

func (*SpriteAnimation) AddEventListenerW

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

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

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

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

PlayClipIndex plays a clip at index i

func (*SpriteAnimation) PlayClipIndexFrame

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

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

func (*SpriteAnimation) Reversed

func (a *SpriteAnimation) Reversed() bool

func (*SpriteAnimation) SetAnimation

func (a *SpriteAnimation) SetAnimation(anim Animation)

SetAnimation parses the clip map and animations

func (*SpriteAnimation) SetReversed

func (a *SpriteAnimation) SetReversed(reversed bool)

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

type SpriteAnimationComponent

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

SpriteAnimationComponent implements ecs.BaseComponent

func GetSpriteAnimationComponent

func GetSpriteAnimationComponent(w ecs.BaseWorld) *SpriteAnimationComponent

GetSpriteAnimationComponent returns the instance of the component in a World

func (*SpriteAnimationComponent) Data

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

func (*SpriteAnimationComponent) Flag

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

Flag returns the

func (SpriteAnimationComponent) Name

Name implements ecs.BaseComponent

func (*SpriteAnimationComponent) Remove

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

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

UUID implements ecs.BaseComponent

func (*SpriteAnimationComponent) Upsert

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

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

SpriteAnimationSystem implements ecs.BaseSystem

func GetSpriteAnimationSystem

func GetSpriteAnimationSystem(w ecs.BaseWorld) *SpriteAnimationSystem

GetSpriteAnimationSystem returns the instance of the system in a World

func (*SpriteAnimationSystem) ComponentAdded

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

func (*SpriteAnimationSystem) ComponentRemoved

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

func (*SpriteAnimationSystem) ComponentResized

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

func (*SpriteAnimationSystem) ComponentWillResize

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

func (*SpriteAnimationSystem) Disable

func (s *SpriteAnimationSystem) Disable()

Disable system

func (*SpriteAnimationSystem) Draw

func (s *SpriteAnimationSystem) Draw(ctx core.DrawCtx)

Draw noop

func (*SpriteAnimationSystem) DrawPriority

func (s *SpriteAnimationSystem) DrawPriority(ctx core.DrawCtx)

DrawPriority noop

func (*SpriteAnimationSystem) Enable

func (s *SpriteAnimationSystem) Enable()

Enable system

func (*SpriteAnimationSystem) Enabled

func (s *SpriteAnimationSystem) Enabled() bool

Enabled checks if enabled

func (SpriteAnimationSystem) Name

func (*SpriteAnimationSystem) Priority

func (*SpriteAnimationSystem) Priority() int64

func (*SpriteAnimationSystem) Setup

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

func (SpriteAnimationSystem) UUID

UUID implements ecs.BaseSystem

func (*SpriteAnimationSystem) Update

func (s *SpriteAnimationSystem) Update(ctx core.UpdateCtx)

Update plays the animations

func (*SpriteAnimationSystem) UpdatePriority

func (s *SpriteAnimationSystem) UpdatePriority(ctx core.UpdateCtx)

UpdatePriority noop

func (*SpriteAnimationSystem) V

func (s *SpriteAnimationSystem) V() *viewSpriteAnimationSystem

type SpriteComponent

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

SpriteComponent implements ecs.BaseComponent

func GetSpriteComponent

func GetSpriteComponent(w ecs.BaseWorld) *SpriteComponent

GetSpriteComponent returns the instance of the component in a World

func (*SpriteComponent) Data

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

func (*SpriteComponent) Flag

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

Flag returns the

func (SpriteComponent) Name

func (SpriteComponent) Name() string

Name implements ecs.BaseComponent

func (*SpriteComponent) Remove

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

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

func (SpriteComponent) UUID() string

UUID implements ecs.BaseComponent

func (*SpriteComponent) Upsert

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 TextLabel

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

func GetTextLabelComponentData

func GetTextLabelComponentData(w ecs.BaseWorld, e ecs.Entity) *TextLabel

GetTextLabelComponentData gets the *TextLabel of Entity e

func NewTextLabel

func NewTextLabel() TextLabel

func (*TextLabel) ComputedSize

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

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

func (*TextLabel) Draw

func (l *TextLabel) Draw(ctx core.DrawCtx, tr *components.Transform)

func (*TextLabel) DrawMask

func (l *TextLabel) DrawMask() core.DrawMask

func (*TextLabel) FontFaceHeight

func (l *TextLabel) FontFaceHeight() int

FontFaceHeight returns the font height

func (*TextLabel) ResetTextOffset

func (l *TextLabel) ResetTextOffset()

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

func (*TextLabel) SetColor

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

func (*TextLabel) SetDrawMask

func (l *TextLabel) SetDrawMask(mask core.DrawMask)

func (*TextLabel) SetFaceOffset

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

func (*TextLabel) SetFaceOffsetModeAuto

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

func (*TextLabel) SetFilter

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

func (*TextLabel) SetOrigin

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

func (*TextLabel) SetText

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

func (*TextLabel) Update

func (l *TextLabel) Update(ctx core.UpdateCtx, tr *components.Transform)

type TextLabelComponent

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

TextLabelComponent implements ecs.BaseComponent

func GetTextLabelComponent

func GetTextLabelComponent(w ecs.BaseWorld) *TextLabelComponent

GetTextLabelComponent returns the instance of the component in a World

func (*TextLabelComponent) Data

func (c *TextLabelComponent) Data(e ecs.Entity) *TextLabel

func (*TextLabelComponent) Flag

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

Flag returns the

func (TextLabelComponent) Name

func (TextLabelComponent) Name() string

Name implements ecs.BaseComponent

func (*TextLabelComponent) Remove

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

Remove a TextLabel data from entity e

Warning: DO NOT call remove inside the system entities loop

func (*TextLabelComponent) Setup

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

Setup is called by ecs.BaseWorld

Do not call this directly

func (TextLabelComponent) UUID

func (TextLabelComponent) UUID() string

UUID implements ecs.BaseComponent

func (*TextLabelComponent) Upsert

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

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

type TileSet

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

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

func GetTileSetComponentData

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

GetTileSetComponentData gets the *TileSet of Entity e

func NewTileSet

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

func (*TileSet) Draw

func (t *TileSet) Draw(ctx core.DrawCtx, tr *components.Transform)

func (*TileSet) DrawMask

func (s *TileSet) DrawMask() core.DrawMask

func (*TileSet) Origin

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

func (*TileSet) SetCells

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

func (*TileSet) SetColsRows

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

func (*TileSet) SetDB

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

func (*TileSet) SetDrawMask

func (s *TileSet) SetDrawMask(mask core.DrawMask)

func (*TileSet) SetEnabled

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

func (*TileSet) SetOffset

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

func (*TileSet) SetOrigin

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

func (*TileSet) Update

func (t *TileSet) Update(ctx core.UpdateCtx, tr *components.Transform)

type TileSetComponent

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

TileSetComponent implements ecs.BaseComponent

func GetTileSetComponent

func GetTileSetComponent(w ecs.BaseWorld) *TileSetComponent

GetTileSetComponent returns the instance of the component in a World

func (*TileSetComponent) Data

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

func (*TileSetComponent) Flag

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

Flag returns the

func (TileSetComponent) Name

func (TileSetComponent) Name() string

Name implements ecs.BaseComponent

func (*TileSetComponent) Remove

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

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

func (TileSetComponent) UUID() string

UUID implements ecs.BaseComponent

func (*TileSetComponent) Upsert

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

type TiledAnimation struct {
	Clips []TiledAnimationClip
}

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

func (*TiledAnimation) Count

func (a *TiledAnimation) Count() int

Count returns the total count of cnimation clips

func (*TiledAnimation) Each

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

Each iterates through all animation clips

func (*TiledAnimation) GetClip

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

GetClip returns an animation clip by index

func (*TiledAnimation) GetClipEvents

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

GetClipEvents returns all animation clip events by the clip index

func (*TiledAnimation) GetClipImage

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

GetClipImage returns the clip image

func (*TiledAnimation) GetClipOffset

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

GetClipOffset returns the clip offset

func (*TiledAnimation) GetClipRect

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

GetClipRect returns the clip Rectangle (bounds)

type TiledAnimationClip

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

func (c TiledAnimationClip) GetEndedEvent() *AnimationEvent

func (TiledAnimationClip) GetEvents

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

func (TiledAnimationClip) GetFPS

func (c TiledAnimationClip) GetFPS() float64

func (TiledAnimationClip) GetFrameCount

func (c TiledAnimationClip) GetFrameCount() int

func (TiledAnimationClip) GetImage

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

func (TiledAnimationClip) GetMode

func (c TiledAnimationClip) GetMode() AnimClipMode

func (TiledAnimationClip) GetName

func (c TiledAnimationClip) GetName() string

GetName returns the animation clip name

func (TiledAnimationClip) GetOffset

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

GetOffset is anoop for TiledAnimationClip

func (TiledAnimationClip) GetRect

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

GetRect returns the drawable bounds

type VIDrawLayerDrawableSystem

type VIDrawLayerDrawableSystem struct {
	Entity ecs.Entity

	Drawable Drawable

	DrawLayer *DrawLayer

	Transform *components.Transform
}

type VIDrawableTextLabelSystem

type VIDrawableTextLabelSystem struct {
	Entity ecs.Entity

	TextLabel *TextLabel

	Transform *components.Transform
}

type VIParticleEmitterSystem

type VIParticleEmitterSystem struct {
	Entity ecs.Entity

	ParticleEmitter *ParticleEmitter

	Transform *components.Transform
}

type VISoloDrawableSystem

type VISoloDrawableSystem struct {
	Entity ecs.Entity

	Drawable Drawable

	Transform *components.Transform
}

type VISpriteAnimationSystem

type VISpriteAnimationSystem struct {
	Entity ecs.Entity

	Sprite *Sprite

	SpriteAnimation *SpriteAnimation
}

type WatchDrawLayer

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

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

func WatchDrawLayerComponentData

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 WatchParticleEmitter

type WatchParticleEmitter interface {
	Entity() ecs.Entity
	Data() *ParticleEmitter
}

WatchParticleEmitter is a helper struct to access a valid pointer of ParticleEmitter

func WatchParticleEmitterComponentData

func WatchParticleEmitterComponentData(w ecs.BaseWorld, e ecs.Entity) WatchParticleEmitter

WatchParticleEmitterComponentData gets a pointer getter of an entity's ParticleEmitter.

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

type WatchSprite

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

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

func WatchSpriteComponentData

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

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

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

func WatchSpriteAnimationComponentData

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 WatchTextLabel

type WatchTextLabel interface {
	Entity() ecs.Entity
	Data() *TextLabel
}

WatchTextLabel is a helper struct to access a valid pointer of TextLabel

func WatchTextLabelComponentData

func WatchTextLabelComponentData(w ecs.BaseWorld, e ecs.Entity) WatchTextLabel

WatchTextLabelComponentData gets a pointer getter of an entity's TextLabel.

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

type WatchTileSet

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

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

func WatchTileSetComponentData

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.

Jump to

Keyboard shortcuts

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