2D map

Recommended Posts

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.

Share on other sites
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.

Share on other sites
Thank you also answered some of my other questions ^^

Share on other sites
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.

Share on other sites
Thank, I'll take a look at it!

Create an account

Register a new account

• Partner Spotlight

• Forum Statistics

• Total Topics
627638
• Total Posts
2978327

• 10
• 12
• 22
• 13
• 34