Collision detection in SDL...
Ok I'm making a top view game in SDL. (Similar look to the old RPG's for NES and such but an action game) Well I need help w/ collision detection. Is there anyway in SDL to make it so that if the player sprite hits a certain color on another sprite (ex: color 255, 0, 255 on the background) it will stop? Like not make it so that it stops when it hits the whole sprite.. Just areas of it. (certain colors of it would probably be the easiest way right?)
Thanks.
That is certainly possible, but there are a thousand other ways to do collision detection and pixel collisions are a tad bit expensive all things considered. Have you considered some kind of simple bounding geometry yet (circles, boxes, polygons) ?
What that dude said.
The other way to do it, and it is fairly expensive, is to test each pixel color against each other and when you get the one you want (or should i say dont want), stop the sprite.
Click Here for the getpixel function..so you would getpixel the two pixels you are checking and compare them.
Peice of pie.
The other way to do it, and it is fairly expensive, is to test each pixel color against each other and when you get the one you want (or should i say dont want), stop the sprite.
Click Here for the getpixel function..so you would getpixel the two pixels you are checking and compare them.
Peice of pie.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement