fixed projectile explosions pos

This commit is contained in:
Fraser Graham 2013-10-28 07:54:49 -07:00
parent 5c77e373c3
commit 235fc1ce6f

View File

@ -35,15 +35,18 @@ func (p *Projectile) Tick(g *game) {
r_dest := v.RectFromPoint(p.MoveTo, 3.0)
travel := newPos.Sub(p.Position)
arrived, _, _ := v.RectIntersection(r_dest, p.Position, travel)
arrived, _, pos := v.RectIntersection(r_dest, p.Position, travel)
if !arrived {
for _, obj := range g.obstacles {
collision, _, _ := v.RectIntersection(obj.Bounds, p.Position, travel)
collision, _, pos := v.RectIntersection(obj.Bounds, p.Position, travel)
if collision {
arrived = true
p.Position = pos
}
}
} else {
p.Position = pos
}
if arrived || hit_player {