Compare commits

..

2 Commits

Author SHA1 Message Date
0648ed3658 Decoupled death animation from draw thread. 2024-11-07 15:02:21 -05:00
1897114236 Decoupling death animation from draw thread. 2024-11-07 15:01:10 -05:00
2 changed files with 11 additions and 5 deletions

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
}

View File

@@ -134,7 +134,7 @@ func (m *Mover) Draw() {
m.Sprite.DrawImage(shadow, op)
m.Sprite.DrawImage(flyeyeImage2.SubImage(image.Rect(x0, y0, x1, y1)).(*ebiten.Image), nil)
case MoverActionDying:
m.dyingcount++
if (m.cycles/5)%2 == 0 {
m.MaksDest.DrawImage(flyeyeImage2.SubImage(image.Rect(x0, y0, x1, y1)).(*ebiten.Image), nil)
@@ -147,7 +147,7 @@ func (m *Mover) Draw() {
} else {
m.Sprite.DrawImage(flyeyeImage2.SubImage(image.Rect(x0, y0, x1, y1)).(*ebiten.Image), nil)
}
if m.dyingcount > 60 {
if m.dyingcount >= 31 {
m.cycles = 0
m.SetHit()
}
@@ -172,6 +172,9 @@ func (m *Mover) Update() {
m.Angle = float64(m.cycles) / (math.Pi * 2)
}
*/
if m.Action == MoverActionDying {
m.dyingcount++
}
m.cycles++
}