For “zone collision” I did something like this in Virus Defender:
collision_distance=10
if math.abs(asteroid_x - player_x) < collision_distance and math.abs(asteroid_y - player_y) < collision_distance then
-- game over, man! game over!
end
Basically take the absolute value of the difference between the x’s and y’s of each center. The downside is that this is a square collision area which often doesn’t fit the need.
You could always do some trigonometry to get the direct distance. Something like if math.sqrt((ex-px)^2 + (ey-py)^2) < collision_distance
. Actually that doesn’t look as hard as I thought, but I’m doing trig from memory so I might have done it wrong.
Edit: yeah, I think I got it right, and it wasn’t as complex as I thought. I just tested against a 3-4-5 right triangle in an interactive lua session:
> print(math.sqrt(3^2+4^2)) 5.0