Sign in to follow this  

Collision Detection

This topic is 3659 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, well first off I am making a simple program that has sprite animation and movement. I've got the character moving and animating properly and he moves freely and not tilebased. So basically instead of making a tilemap, I use a giant image of the map, and only draw the portion of the screen at a time, and the image scrolls as you walk. So far it looks good. I know how to do collision detection for the edges of the screen, but what about the actual objects on the map, like trees. I thought about making another image that is a mirror of the map that isn't visible on top of it. All sections that aren't able to be walked on would be black. Perhaps you could check the pixel color? This is where I'm kinda stumped. If it helps at all I am using SDL. Basically, what would be a good strategy for collision detection on a non tile based map.

Share this post


Link to post
Share on other sites
Quote:
I thought about making another image that is a mirror of the map that isn't visible on top of it. All sections that aren't able to be walked on would be black. Perhaps you could check the pixel color?


This is the method I would use (and have used). Although personally I use black for walkable, white for non-walkable, and other colors for other effects, like red when walking there causes damage, or blue when the player is in water so I can add special splash effects.

Share this post


Link to post
Share on other sites
I have a bitmap named Collision_Map. When I want to move my character, I check the pixels on Collision_Map to see if movement in that direction is allowed. I use Allegro, so I just have to call getpixel() to get the pixel. I don't know what you're using, though.

Share this post


Link to post
Share on other sites
what not keep a seperate list of bounding boxs for all the objects in your world, and just check for the ones that are on screen. I'd assume per pixel collision are gonna get pretty processor intensive with alot of moving objects on the screen.

Share this post


Link to post
Share on other sites
Well for non-static elements that is what I will do, like adding objects or people. For my background image, it is a pretty complex forest with turns and twists in the paths and trees grouped up and scattered. It would require a lot of boxes and estimating the coordinates.

Share this post


Link to post
Share on other sites

This topic is 3659 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this