Simplified collision detection works well

So, I replaced my original collision detection system for the graphics engine with a more simplified version. What it does is given three arguments, an index value of the sprite to check collision for, a sprite type for the types of objects to check collision against and the distance to check against collision, it cycles through all objects on the stage. If the object is of the right sprite type and isn’t the sprite being checked, it then checks to see if it is at least within the distance in both the x and y direction. If so, a specific distance using the Pythagorean theorem (Yay for Pythagoras), is used to see if it is less than distance away. If so, it returns true. If not, false. Obviously a simplistic form of my previous version. It works very well though, with 50 objects on the stage, I see little to no performance decrease.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: