Collision detection is the bane of my existance

Right now I’m trying to develop a collision detection system that won’t bog down the flash scene as the number of objects increase. The current method I’m using involves drawing a collision buffer, which then gets checked against by each object in the scene. Basically, I cycle through an array which contains the location of all objects on the scene and draw a collision sprite. This buffer is a grayscale image, and I simply check each movement location for each object against this image. If the pixel that the object wants to move into is black, no movement occurs.It works flawlessly as far as actually preventing collision, no matter how many objects are on the screen. The problem arrises because I have to draw a new collision map for each object in the scene. Each single objects collision map does not include it’s own collision sprite, so that it doesn’t register as colliding with itself. As the number of objects increase, the number of collision maps that have to be draw each frame also increases. This is a problem, since basically to draw 1 frame with 10 objects, I end up having to draw 11 frames. Not efficient at all.

Some ideas that have gone through my head include setting each collision sprite to a different color, but then the problem of depth buffering comes into effect. Since the draw order is determined by the objects location in the array, the last object draw will have it’s entire collision sprite overlap other sprites, thereby making it impossible to check if it is colliding with another object. What I need to figure out is a method for ignoring the object that is checking for collision’s collision sprite.


Leave a Reply

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

You are commenting using your 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: