Original Post
I'm working on a sort of Map system. I have a basic enumerator, called STATE which is just the available states of the map tiles (PASS as in you can pass it, BLOCK it's a wall, and SPECIAL meaning it's a door, item, or something 'special'). I then have a basic Tile object, which contains a STATE and X/Y co-ordinates. I want to use a 2 dimensional array of Tile objects to represent the map (As seen in the Map class below), I don't want the size of the map to be known until compile time, so the user (or programmer) could create a map that is 16 x 24 Tiles, or 8 x 4 Tiles, here begins my problem.. How can you define a 2 dimensional 'dynamic' array? Basically, I just want to make sure I'm going about this the correct way (I haven't actually put pen to paper yet, I'm designing and making sure it will all work), because I don't wanna start now, get half way and realise I screwed up. (Which I do all too often with projects), and an understanding of 'Dynamic' multi-dimensional arrays would be cool. --- Edit: Thanks guys, this works perfect now. [Edited by - Chu on August 12, 2006 4:33:12 AM]
enum STATE
{
PASS, BLOCK, SPECIAL
};
class Tile
{
private:
int mX;
int mY;
STATE mCurrentState;
public:
STATE getState();
void setState(STATE state);
void setX(int x);
void setY(int y);
int getX();
int getY();
};
class Map
{
private:
int mWidth;
int mHeight;
Tile mMap[][];
public:
Map(int width, int height);
};