Gathering Info
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
You''re question is rather open ended/vauge. Try starting here, then if you have specific questions, feel free to ask.
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;
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;
EG:class MAPTILE{public: int xLoc; int yLoc; int TerrainType; // Store what land type: sea, grass, rock, etc};// GlobalsMAPTILE 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 }}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement