Bullet support
This commit is contained in:
15
hero/hero.go
15
hero/hero.go
@@ -6,6 +6,7 @@ import (
|
||||
"gitlab.com/kbr4/9heroja/collision"
|
||||
"gitlab.com/kbr4/9heroja/configuration"
|
||||
"gitlab.com/kbr4/9heroja/resources"
|
||||
"gitlab.com/kbr4/9heroja/weapons"
|
||||
"image"
|
||||
"image/color"
|
||||
"log"
|
||||
@@ -248,3 +249,17 @@ func (h *Hero) HandleCollisionEvent(other collision.Collidable) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Hero) Fire(fire bool, offsetX float64, offsetY float64) (bullet *weapons.Handgun) {
|
||||
if fire {
|
||||
bullet = weapons.NewHandgun()
|
||||
bullet.X = h.X + (resources.HeroTileSize / 2) - offsetX
|
||||
bullet.Y = h.Y + (resources.HeroTileSize / 2) - offsetY
|
||||
bullet.OffsetX = offsetX
|
||||
bullet.OffsetY = offsetY
|
||||
bullet.Fire(h.direction)
|
||||
return bullet
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user