   Allegro: Collision detection with _getpixel (efficiency)
  I'm a C++/Allegro beginner and coded a collision detection routine (for a platformer) using Allegro's _getpixel command. It checks every pixel of a sprite's bounding box to see if it overlaps a non-transparent area of a bitmap layer and returns 1 if it does. I did this because I needed a 'bounding box/pixel perfect on bitmap layer' collision as it makes doing diagonal platforms and ceilings easier.Both the collision detection and the movement work great so far. The problem is, I'm checking up to 100 objects with this collision routine at once with a while loop, so I'm worried this may result in slowdown on slower machines. I have no idea how efficient using _getpixel is. Is using it for a purpose like that a bad idea?Thanks in advance.   
  It might be a bad idea. It depends on how much of an effect it's really having._getpixel should be implemented as an inline function hence pretty fast - but can still take a while if you call it often enough.You may want to consider optimisation. One such possible optimisation is using bounding boxes and only doing per-pixel tests of the bounding boxes overlap.Your best bet would be to obtain a profiler and find out exactly how much time this C/D is really taking. If you then get the results and it's unacceptable, then optimise it.I used a similar method in my game "Attack of the mutant jellies", except I scanned a circle rather than the boundary. This worked fine as it happened - and was fairly efficient when only checking small numbers (10,20,30 maybe) of objects.Mark   ;  Thanks for the reply. Doing a bounding box/tile check before the actual pixel perfect check sounds like a great idea. I'll also turn off enemies too far away from the screen and skip checking their collisions. That way, there will only be 20 moving sprites at most on the screen.Thanks so far. :)   ;  See the "direct bitmap access" section of the Allegro manual for the fastest way to access them. While _getpixel() is faster than getpixel(), it's still slow compared to direct access.   ;  Will do, thanks!   