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:
+6
-2
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user