Elliptical Collision Detection

(a work in progress, more details to come)

A few years ago I was trying to build an isometric game in Flash.

One of the things I like about the way Flash handles objects is that they have a “center” point you can set within the object. ┬áIn an isometric object, that would go near the bottom of the object, at the center point of where it’s standing.

Since I didn’t want to do a diamond grid (too simple) or a hex grid (too complicated), I decided to try a more free-form movement strategy, and I figured I could fake collisions pretty well just by checking the distance between the center points.

A quick check verified that I need to use the Pythagorean Theorem:

distance^2 = (horizontal distance)^2 + (vertical distance)^2

which is perfect for top-down, but I wanted a lower camera, which means the vertical distances are closer:

distance^2 = (horizontal distance)^2 + (vertical distance/2)^2

 

So, with that, I can have this guy pushing an ATM around the floor.

 

Leave a Reply