Jump to content
  • Advertisement
Sign in to follow this  
SwindIer

Collision detection in SDL...

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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) ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
The getPixel() way seems like it would be the easiest to do. You see I could do boundries, but I have many different backgrounds when you walk around. So I would have to define each boundry for each screen. Doing that would be probably just as taxing on the CPU as the pixel way.. :-\

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!