diff --git a/projectile.go b/projectile.go index f5871fc..3515525 100644 --- a/projectile.go +++ b/projectile.go @@ -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 {