44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
|
|
package components
|
||
|
|
|
||
|
|
import (
|
||
|
|
"openquell/config"
|
||
|
|
|
||
|
|
"github.com/hajimehoshi/ebiten/v2"
|
||
|
|
)
|
||
|
|
|
||
|
|
// virtual location, aka tile address
|
||
|
|
type Animation struct {
|
||
|
|
Active bool // animation is running
|
||
|
|
Loop bool // remove the entity if false, loop endless otherwise
|
||
|
|
Index int // where we are currently
|
||
|
|
Tiles []*ebiten.Image
|
||
|
|
Width, Height int // single sprite measurements
|
||
|
|
Timer Timer
|
||
|
|
Trigger string
|
||
|
|
}
|
||
|
|
|
||
|
|
type Renderable struct {
|
||
|
|
Pos *Position // just for debugging, will not used as positiion!
|
||
|
|
Image *ebiten.Image
|
||
|
|
DamageImage *ebiten.Image // FIXME: put into its own struct
|
||
|
|
Damaged int
|
||
|
|
Shader *ebiten.Shader
|
||
|
|
Animate Animation
|
||
|
|
Hidden bool
|
||
|
|
}
|
||
|
|
|
||
|
|
func (render *Renderable) StartAnimation() {
|
||
|
|
render.Hidden = true
|
||
|
|
render.Animate.Active = true
|
||
|
|
render.Animate.Timer.Start(config.ANIMATION_STARTWAIT)
|
||
|
|
|
||
|
|
switch render.Animate.Trigger {
|
||
|
|
case "OnCollision":
|
||
|
|
fallthrough
|
||
|
|
case "OnDestruct":
|
||
|
|
render.Animate.Loop = false
|
||
|
|
case "OnIdle":
|
||
|
|
render.Animate.Loop = true
|
||
|
|
}
|
||
|
|
}
|