From a4b539e79d55886afd179a507edb43f605eb79ab Mon Sep 17 00:00:00 2001 From: Fraser Graham Date: Mon, 28 Oct 2013 21:52:06 -0700 Subject: [PATCH] accurate collition positioning --- player.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/player.go b/player.go index 88488f6..a0f21ae 100644 --- a/player.go +++ b/player.go @@ -137,7 +137,7 @@ func (p *player) Tick(g *game) { } move_vector := new_heading.Scale(p.Robot.Speed * delta) - collision, _, hit_player := p.checkCollisions(g, move_vector) + collision, intersection_point, hit_player := p.checkCollisions(g, move_vector) if collision { p.Robot.Collision = true if hit_player != nil { @@ -145,7 +145,9 @@ func (p *player) Tick(g *game) { hit_player.Robot.Speed = (hit_player.Robot.Speed * 0.1) hit_player.Robot.Heading = p.Robot.Heading } - //p.Robot.Position = intersection_point + move_by := intersection_point.Sub(p.Robot.Position).Scale(0.95) + + p.Robot.Position = p.Robot.Position.Add(move_by) p.Robot.Health -= int(p.Robot.Speed / 10.0) p.Robot.MoveTo = &p.Robot.Position p.Robot.Speed = (p.Robot.Speed * 0.1)