Jump to content
  • Advertisement
Sign in to follow this  
too_many_stars

2D map creators

This topic is 1783 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 have made a couple of 2D levels using SDL where I simply load a tile from a text file which is a set width and height. Then I run two for loops checking collision. Of course, this is rather crude and makes for a "boxy" world.

 

I am wondering if there's a way of creating more advanced shapes such as hills and valleys which already have SDL_Rect built in. I shudder at the thought and the amount of time it would take to craft a hill or a slope if I have to create an SDL_Rect for each pixel height.

 

Of course if this is the only way to do it, then so be it.

 

Thanks,

 

Mike

Share this post


Link to post
Share on other sites
Advertisement

Really, it isn't even relevant to SDL at all, it's entirely part of the game logic (SDL only cares about what you're drawing).

 

Just store collision data alongside the graphic for each tile, i.e. each tile has both a graphic and a collision type that indicates what kind of block is it (e.g. empty, solid, slope, one-way, etc.). You could also assign a collision type to each graphic too, if you need to save space and want to ensure consistency, though storing collision for each tile makes it easy to allow for stuff like hidden passages and the like.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!