fixed projectile explosions pos

This commit is contained in:
Fraser Graham 2013-10-28 07:54:49 -07:00
parent 5c77e373c3
commit 235fc1ce6f
1 changed files with 5 additions and 2 deletions

View File

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