Jump to content
  • Advertisement
Sign in to follow this  

SDLMappy Collision Detection

This topic is 3032 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

Hi guys.

I'm working on a project using the SDL library, and so far everything has been going great. I have a screen with a main character sprite moving on a map imported from Mappy, with the help of the SDLMappy library. I know it's not much, but I'm new to both SDL and game programming.

Anyway, now I want to implement collision detection, so my character would stop going through walls. I'm pretty sure the usage of this function from the SDLMappy API does the trick:

BLKSTR * MapGetBlock (int x, int y);

Returns a BLKSTR pointer, useful for collision detection and examining a block structure. Note: the x and y paramaters are the offset from the left and top of the map in BLOCKS, NOT pixels. Example:
BLKSTR * myblkstr;
myblkstr = MapGetBlock (xoffinblocks, yoffinblocks);
if (myblkstr->tl) { top left collision is set for this block }

but this explanation doesn't help me much (understand at all). Does anyone know how to make this work? Thanks in advance.

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!