min damage from collisions
This commit is contained in:
parent
f6c8399699
commit
83f5d51bc4
13
robot.go
13
robot.go
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user