min damage from collisions

This commit is contained in:
Fraser Graham 2013-11-27 08:39:36 -08:00
parent f6c8399699
commit 83f5d51bc4
1 changed files with 10 additions and 3 deletions

View File

@ -268,10 +268,17 @@ func (r *Robot) Tick(g *game) {
move_vector := new_heading.Scale(r.Speed * delta)
collision, intersection_point, hit_robot := r.checkCollisions(g, move_vector)
if collision {
dmg := int(math.Abs(float64(r.Speed)) / 10.0)
if dmg <= 0 {
// All collisions need to do at least a little damage,
// otherwise robots could get stuck and never die
dmg = 2
}
r.Collision = true
if hit_robot != nil {
hit_robot.Health -= int(r.Speed / 10.0)
hit_robot.Speed = (hit_robot.Speed * 0.1)
hit_robot.Health -= dmg
hit_robot.Speed = (hit_robot.Speed * 0.5)
// hit_robot.Heading = r.Heading
}
@ -280,7 +287,7 @@ func (r *Robot) Tick(g *game) {
r.Position = r.Position.Add(move_by)
}
r.Health -= int(r.Speed / 10.0)
r.Health -= dmg
r.MoveTo = &r.Position
r.Speed = (r.Speed * -0.5)
// r.Heading = r.Heading.Scale(-1.0)