Original Post
I've been messing around with an isometric tileengine and have been trying different ways of making the map. I began checking through the code in Jim Adam's Programming rpgs in directx. I later made most of the tilecode myself to get some practise and wrote the map structure in classes (Option 1). I've later found out some shortcomings by checking the IsoMetrix engine and reading some articles on gamedev. If I were to make a height/layer array for each map coordinate I can stack things like walls on top of each other (Option 3). What I'm really wondering is what would be the optimal way to go regarding memory use and speed of the game. Do I really have to worry much about it since the area won't be big enough to slow things down anyway? It seems like option 3 is the best way to go, or maybe a combination of options 3 and 4. It just seems like it will use a lot of memory because each coordinate has so many arrays. These examples aren't complete, just to show what they would look like.
Option 1:
// Class heavy approach. More function calls.
class cLayer {
char *data; // get data by using data[Column*Width+Row]
long texture;
}
class cMap {
cLayer* layer[3]; // or vector <cLayer*> layer;
}
Option 2:
// A middle thing. Not really that nice to work with...
typedef struct {
char tile;
} sTile;
class cMap {
sTile map[3][10][10];
}
Option 3:
// struct w/ height and layer info on each tile.
// Possible waste of memory?
typedef struct {
char num_tiles;
char height[10];
char tile[10];
char layer[10];
} sTile;
class cMap {
sTile map[10][10];
}
Option 4:
// Linked list
struct sTile {
struct sTile *next;
char tile;
};