Decoupling death animation from draw thread.
This commit is contained in:
9
hero.go
9
hero.go
@@ -109,11 +109,9 @@ func (m *Hero) Draw() {
|
|||||||
case HeroActionDefault:
|
case HeroActionDefault:
|
||||||
m.Sprite.DrawImage(heroImage.SubImage(image.Rect(x0, y0, x1, y1)).(*ebiten.Image), nil)
|
m.Sprite.DrawImage(heroImage.SubImage(image.Rect(x0, y0, x1, y1)).(*ebiten.Image), nil)
|
||||||
case HeroActionDying:
|
case HeroActionDying:
|
||||||
m.dyingcount++
|
|
||||||
|
|
||||||
m.Sprite.DrawImage(heroDeath.SubImage(image.Rect(x0, y0, x1, y1)).(*ebiten.Image), nil)
|
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.cycles = 0
|
||||||
m.Action++
|
m.Action++
|
||||||
}
|
}
|
||||||
@@ -124,12 +122,17 @@ func (m *Hero) Draw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Hero) Update() {
|
func (m *Hero) Update() {
|
||||||
|
|
||||||
|
if m.Action == HeroActionDying {
|
||||||
|
m.dyingcount++
|
||||||
|
}
|
||||||
m.cycles++
|
m.cycles++
|
||||||
}
|
}
|
||||||
|
|
||||||
// one hit death for the hero
|
// one hit death for the hero
|
||||||
func (m *Hero) SetHit() {
|
func (m *Hero) SetHit() {
|
||||||
m.Action = MoverActionDying
|
m.Action = MoverActionDying
|
||||||
|
m.dyingcount = 0
|
||||||
m.Angle = 0
|
m.Angle = 0
|
||||||
m.cycles = 0
|
m.cycles = 0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user