Sir Robin Bravely Ran Away - looked for a more elegant answer and received a class in using Vector

This is exactly what happens in horror-movies. You run away from the monster/killer/… and end up in a corner.
Another way to dodge enemies is to move not directly away from them but 90° to that line:

targetPos = Vector.subtract(self.pos, enemy.pos)
targetPos = Vector.rotate(1.5708) # PI/2 = 1.5708 rad = 90°
self.move(targetPos)

This is especially helpful for dodging projectiles as they move in a straight line, but should work against not so fast enemies as well. You don’t have to use exactly 90°, it is up to you to find the best value.

2 Likes