objects have HP now, only direct hits hurt them

This commit is contained in:
Fraser Graham
2013-11-17 08:21:36 -08:00
parent ae9d09596c
commit 4c4c0d4e67
2 changed files with 7 additions and 1 deletions
+5 -1
View File
@@ -51,11 +51,15 @@ func (p *Projectile) Tick(g *game) {
arrived, _, pos := v.RectIntersection(r_dest, p.Position, travel)
if !arrived {
for _, obj := range g.obstacles {
for i, obj := range g.obstacles {
collision, _, pos := v.RectIntersection(obj.Bounds, p.Position, travel)
if collision {
arrived = true
p.Position = pos
obj.Hp -= p.Damage
if obj.Hp < 0 {
delete(g.obstacles, i)
}
}
}
} else {