Decoupling death animation from draw thread.

This commit is contained in:
2024-11-07 15:01:10 -05:00
parent 87e40226c7
commit 1897114236

View File

@@ -109,11 +109,9 @@ func (m *Hero) Draw() {
case HeroActionDefault:
m.Sprite.DrawImage(heroImage.SubImage(image.Rect(x0, y0, x1, y1)).(*ebiten.Image), nil)
case HeroActionDying:
m.dyingcount++
m.Sprite.DrawImage(heroDeath.SubImage(image.Rect(x0, y0, x1, y1)).(*ebiten.Image), nil)
if m.dyingcount > 60 {
if m.dyingcount >= 31 {
m.cycles = 0
m.Action++
}
@@ -124,12 +122,17 @@ func (m *Hero) Draw() {
}
func (m *Hero) Update() {
if m.Action == HeroActionDying {
m.dyingcount++
}
m.cycles++
}
// one hit death for the hero
func (m *Hero) SetHit() {
m.Action = MoverActionDying
m.dyingcount = 0
m.Angle = 0
m.cycles = 0
}