|
by Lee French March 1999 I've heard a lot of people recently asking about dynamic arrays for maps of any size within tile editors. Well here is a tutorial that should help you get started pronto. First of all, lets consider what we want as map data. We want a list of tile ID's that correspond to tiles within a datafile, we want the tiles type (e.g. whether it is walkable, animated etc). So we'd define a structure such as:-
So we have created a new type called map tile. Now we need to know how to declare our map tile. If we had fixed map sizes we could declare it as follows:- MAPTILE Map[MAPX][MAPY]; Since we want a variable sized map, we have to think a bit more cleverly. Also, we want to implement variable layers into the map. In order to use variable map sizes we have to setup the Map like this:- MAPTILE ***Map; Looks strange doesn't it? Trust me, I thought this at first. What we now want to do is dynamically add each element to the Map pointer:-
And that's it, simple. No error checking has been included here but a cannot overemphasize enough how important this is. Now we want to access the map pointer to initialize the values:-
And that's it, a simple way to create a dynamic map array. Please do not hesitate to contact me if you have any comments to make on this tutorial. In fact this is my first ever attempt at a tutorial so be easy :) Dynamic Tile Maps 1.0 is copyright 1999 Lee French. All rights reserved. Freely distributable if unmodified and in its entirety. http://members.tripod.co.uk/lpfglc/ leef@pronexus.co.uk Discuss this article in the forums
See Also: © 1999-2011 Gamedev.net. All rights reserved. Terms of Use Privacy Policy
|