Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Gathering Info

This topic is 5599 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

Howdy, I figured this might be the right forum to get some information on how maps work in this kind of game (2d). To be more specific about what im asking, i just would like someone to explain the basics on how it works, or if you want to, you could point me towards a document or two about making a map system. or if you prfer i could go ask in the newbie hole, since im new at this. thanks ahead, syrm

Share this post

Link to post
Share on other sites
I''m going to assume you''re talking about the actual structure of the maps, not the visual elements (like diamond shaped tiles etc).

Here''s a couple of different ways to store the info about map tiles. A sequential class array (eg: map[50]) or a 2d array (eg: map[50][50]).

Sequential arrays are fun because you need to work out what element to grab out based on tile = (mapwidth * y) + x.

I prefer 2d arrays. You know which tile to grab because you know the x & y of each tile.

Start off by having a tile class, give it the properties you want, then array it. In your initialisation set the x & y properties of the maptiles, then in your map routine (whether you load or create a map) set the terrain type property to the correct value (eg: 0 = sea, 1 = grass, 2 = rocks, etc). If you want other layers (eg: objects to pickup or characters) just add more properties to the class: int object; int unit;

int xLoc;
int yLoc;
int TerrainType; // Store what land type: sea, grass, rock, etc

// Globals
MAPTILE Map[100][100]; // Creates a map class array of 100 * 100

// Somewhere in your initialisation.....
for(int y = 0; y < 100; y++)
for(int x = 0; x < 100; x++)
Map[x][y].xLoc = x; // Set x location
Map[x][y].yLoc = y; // Set y location
Map[x][y].TerrainType = 0; // Set all terrain to sea

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!