...well, in just a few short lines you've pretty much done what it's taken me nearly 500 to do. Currently, all my location-relevant things are tied up in one class - like so
Code:
class location
{
public:
location(); //constructor
~location(); //deconstructor
void set_terrain(int x, int y, int terrtype); //sets the terrain type at location x,y to type terrtype
void set_itemno(int x, int y, int number); //sets the number of items at location x,y
void set_item(int x, int y, int stack); //sets the item type at location x,y in part 'stack' of the pile there
void set_monst(int x, int y); //sets any monsters at location x,y
void set_build(int x, int y); //sets any buildings at location x,y
void set_char(int x, int y); //sets the character at position x,y
void printloc(int x1, int y1, int x, int y); //prints location x1,y1 at cursor location x,y
int checkpass(int x, int y); //checks if there is a wall/door at location x,y
void set_move(char x); //moves the character in direction x (78946123 inputs)
int set_closedoor(char x); //closes a door in direction x (78946123 inputs)
int fileread(char filename[50]); //reads a file from file 'filename'
int terrain[600][600];
int itemno[600][600];
int item[600][600][5];
int monst[600][600];
int build[600][600];
};
At the moment, there's an overlay of 4 other maps containing information about items, monsters, buildings (I'm not quite sure where I'm going with that one), etc. I'm thinking of making a global array and defining types via enum - something like
Code:
enum{ TERRAIN,
ITEM,
MONST,
TYPES}
int map [600][600][TYPES];
Which would make things a lot easier.... Your movement code is so simple. Mine involves checking for keypress, then turning the keypress into a direction, then checking if there's anything in that direction, then moving or not moving. However, what makes it a lot more complex is that not all of the map is displayed on the screen - as you can see, there's the possibility for a map of up to 600x600 tiles (which I'll probably figure out a little better in the future when I get an idea for what a standard map size should be), but the map display will only be 100x30 (if I can ever figure out how to lock the console into those proportions), so I have to deal with four variables, the displayed x and y, and the actual x and y. Still, at the moment I can read a map and run around bumping into things and opening and closing doors. No time, monsters, or objects yet, but first I need to figure out a scrolling method and a look command, and maybe a save command too.