Added weapon sprite into the mix.

This commit is contained in:
2024-11-07 17:39:39 -05:00
parent 0648ed3658
commit 8bf6e56398
3 changed files with 30 additions and 6 deletions

14
hero.go
View File

@@ -55,12 +55,14 @@ type Hero struct {
Angle float64
Pos Coordinates
Origin Coordinates
Lastpos Coordinates
Action HeroAction
cycles int
rotating bool
Toggled bool
Hit bool
Touched bool
Left bool
dyingcount int
}
@@ -105,18 +107,24 @@ func (m *Hero) Draw() {
x0 := 48 * idx
x1 := x0 + 48
op := &ebiten.DrawImageOptions{}
if m.Left {
op.GeoM.Scale(-1, 1)
op.GeoM.Translate(MOVER_WIDTH, 0)
}
switch m.Action {
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), op)
case HeroActionDying:
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), op)
if m.dyingcount >= 31 {
m.cycles = 0
m.Action++
}
case HeroActionExploding:
m.Sprite.DrawImage(heroDeath.SubImage(image.Rect(48*3, 0, 48*4, 48)).(*ebiten.Image), nil)
m.Sprite.DrawImage(heroDeath.SubImage(image.Rect(48*3, 0, 48*4, 48)).(*ebiten.Image), op)
default:
}
}