• 13
• 18
• 19
• 27
• 9

SDL Endless Dynamic collision detection of Projectiles

This topic is 2894 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

hi im wondering how to do somthing that i do all the time in flash but cant do here. im trying to make a simple astriods/space invaders game and i would like to test all the collisions like so
Sprite Array[256];
Sprite Array2[256]
CheckAllCollisions() {
for(i=0;i<=256;i++) {
Sprite temp;
temp = Array;
for(j=0;j<=256;j++) {
Sprite temp2;
temp2 = Array2[j];
if(CheckCollision(temp, temp2);
Kill(temp);
Kill(temp);
}
}
}
}

could someone tell me how to do this in SDL. i know how to check collisions between two of my sprites (class i made). it uses a SDL_rectangle that is part of the Sprite class and an SDL_Surface that i use for animation to give Pixel Perfect Collisions. but this method dosnt seem to work. o and yes even though you cant see that i have done it i have populated the arrays.

Share on other sites
Quote:
 could someone tell me how to do this in SDL.
You might be misunderstanding what SDL is exactly. This isn't something that you 'do in SDL'. SDL is a low-level library for handling graphics, sound, input, etc. - it doesn't have anything to do with what you've posted here (aside, perhaps, from the fact that you're making use of SDL's 'rect' structure).

Are you maybe wondering how to do this in the C or C++ programming language? If so, it would probably look largely like what you posted, presuming that the Kill() function does something that makes sense. (Technically, you'd probably want to structure the loop differently so as to avoid redundant checks, and even then, that looks like a lot of tests to be performing - however, those aren't really language-specific issues.)

If that doesn't help, perhaps you could explain in a little more detail how it's not working.