2D map

Started by
3 comments, last by kontrolkl 18 years, 6 months ago
Hello, I'm planning to make a small game like a FF game with SDL. What would be the best way to make a map? or section of map. and is there any tutorials that's explain it somewhere? Thank.
Advertisement
There's a pretty decent selection of articles on Isometric and Tile-Based Games here on GDNET.

Basically though, its all the same: you have an array of tiles
+ + + + + + + ++ + + ++ + + +

There are a lot of different ways to define "tiles", in my engine each tile is a pointer to an instance of a Sprite, which is a pointer to an SDL_Quad wrapper and an SDL_Surface wrapper.

For the actual storage in the array, I'd suggest a 1-dimensional array. You can get/set 2D data with the algorithm
position = y * x_size + x

I render the map with an "offset", which is essentially a value added to the coordinates of each Sprite. This allows me to scroll the map and such.

Additionally, you'll only want to blit the tiles which are visible, and blah blah so on. All this is in the articles which can be found in the above link. If you have any more specific questions, feel free to ask.
Thank you also answered some of my other questions ^^
I wrote a really simple tilemap example I was going to turn into a tutorial a while back. Here is the link. I hope it helps a little.
Evillive2
Thank, I'll take a look at it!

This topic is closed to new replies.

Advertisement