Original Post
I'm taking my first plunge into writing some collision detection but I've been running into some walls. I know there's ALOT of material on this site, much of which I have looked at. I figure I'd get some suggestions from the forums on my particular situation while I continue to read. So obviously, I'm writing a game. (AllegroGL, C++) I have a working map and sprite engine. I started with a simple set of loops to address sprite + map collision;
for (int s=0;s<=SPRITENUM;s++)
{
if (Sprites[s].Active)
{
// Start
for (int y=0; y<=MAPY; y++)
{
for (int x=0; x<=MAPX; x++)
{
}
}
// End
}
}
Obviously no actual collision detection is happening, but my problem is... This destroys frame rate. As it is there. I understand why however. SPRITENUM is 100, and MAPX/Y are also 100. 100x100x100 loops (worst case) is ALOT of work. I'd hate to think of what it would be like if I put actual code in these loops. So, my question is.. if that loop alone kills framerate, how are you SUPPOSED to do collision efficiently? If I comment out the code between //start and //end the framerate is more or less normal. So if anyone has any thoughts or recommended reading it would be greatly appreciated. Arith