accurate collition positioning
This commit is contained in:
parent
235fc1ce6f
commit
a4b539e79d
@ -137,7 +137,7 @@ func (p *player) Tick(g *game) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
move_vector := new_heading.Scale(p.Robot.Speed * delta)
|
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 {
|
if collision {
|
||||||
p.Robot.Collision = true
|
p.Robot.Collision = true
|
||||||
if hit_player != nil {
|
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.Speed = (hit_player.Robot.Speed * 0.1)
|
||||||
hit_player.Robot.Heading = p.Robot.Heading
|
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.Health -= int(p.Robot.Speed / 10.0)
|
||||||
p.Robot.MoveTo = &p.Robot.Position
|
p.Robot.MoveTo = &p.Robot.Position
|
||||||
p.Robot.Speed = (p.Robot.Speed * 0.1)
|
p.Robot.Speed = (p.Robot.Speed * 0.1)
|
||||||
|
Loading…
Reference in New Issue
Block a user