completed animation setup and code based solely on LDTK settings
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
package components
|
||||
|
||||
import "github.com/hajimehoshi/ebiten/v2"
|
||||
|
||||
type Animation struct {
|
||||
Show bool
|
||||
Index int
|
||||
Loop bool
|
||||
Tiles []*ebiten.Image
|
||||
Width, Height int // single sprite measurements
|
||||
}
|
||||
@@ -1,19 +1,5 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
)
|
||||
|
||||
// virtual location, aka tile address
|
||||
|
||||
type Renderable struct {
|
||||
Pos *Position // just for debugging, will not used as positiion!
|
||||
Image *ebiten.Image
|
||||
DamageImage *ebiten.Image
|
||||
Damaged int
|
||||
Shader *ebiten.Shader
|
||||
}
|
||||
|
||||
// only tile entities will have those
|
||||
type Tilish struct{}
|
||||
type Solid struct{}
|
||||
|
||||
43
components/renderable.go
Normal file
43
components/renderable.go
Normal file
@@ -0,0 +1,43 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user