2D map creators

Started by
3 comments, last by Ronnie Mado Solbakken 10 years, 8 months ago

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

Advertisement

As I understand it, you can store a slope type metadata in the map file on how steep a slope is; and handle the player's position on said slope by using some simple trig. There's an article I read about it, using Megaman X's level as an example. Here:

http://higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/

This can be done in SDL.

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.

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

Thanks for the reply guys, I will try to craft something this weekend and see how it goes taking your advice into consideration.

Mike

(deleted)

- Awl you're base are belong me! -

- I don't know, I'm just a noob -

This topic is closed to new replies.

Advertisement