Sign in to follow this  
deathwearer

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 this post


Link to post
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this