Fixed collision detection in probes

This was a problem before when the probe hit an object that was further than
another object first. Now we traverse all objects all the time to find the
closest one. \o/
This commit is contained in:
sm
2014-01-16 00:56:35 -08:00
parent 72d5a1a64c
commit 7971198c17
4 changed files with 156 additions and 30 deletions
+6 -2
View File
@@ -62,7 +62,9 @@ func (p *Projectile) Tick(g *game) {
collision, _, pos := v.RectIntersection(obj.Bounds, p.Position, travel)
if collision {
arrived = true
p.Position = pos
if pos != nil {
p.Position = *pos
}
obj.Hp -= p.Damage
// if obj.Hp < 0 {
// delete(g.obstacles, i)
@@ -70,7 +72,9 @@ func (p *Projectile) Tick(g *game) {
}
}
} else {
p.Position = pos
if pos != nil {
p.Position = *pos
}
}
if arrived || hit_player {