Added weapon sprite into the mix.
This commit is contained in:
14
hero.go
14
hero.go
@@ -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:
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user