From 1897114236bc4f6d789a721cc6b3b060e6fada84 Mon Sep 17 00:00:00 2001 From: iegod Date: Thu, 7 Nov 2024 15:01:10 -0500 Subject: [PATCH] Decoupling death animation from draw thread. --- hero.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hero.go b/hero.go index 48c2d51..0b57dd0 100644 --- a/hero.go +++ b/hero.go @@ -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 }