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)