You need to create an engine that will run all of this for you.
First you need to decide what you want to be able to do within the game, and put that in the engine. The engine is the workhorse of the game, whereas the game itself is usually just a lot of data files that the engine uses. These files can be changed/edited by an editor (again you must program the editor) to create an entirely different game, but based on the same engine.
Your movement scheme could be coded like this:
I use row and col instead of x,y - it is easier to use row,col when dealing with arrays than x,y which is usually y,x for an array.
Code:
class Location
{
int row;
int column;
const char *LocationName;
public:
Location (int trow,int tcol)
};
class Area
{
int endrow;
int endcolumn;
char *AreaName;
public:
Area(int trow,int tcol,int tendrow,tendcol);
};
class Map
{
Location *Map;
Area *AreasInMap;
int width;
int height;
public:
Map(int twidth,int theight);
int GetMapValue(int row,int col) {return Map[row*width*col];};
Area *GetArea(int row,int col); //return area that row,col lies in
};
You could use base classes and derive from Location, I just chose not to. This is not enough for your game engine, nor is it necessarily error-free as I just typed this in quickly. But it should help you a bit with the structure.
I usually code directions right into a room. Let's say that at map [row*width+col] there is a number 4. That number corresponds to an array element in the room array. The direction array matches the room array exactly (as it pertains to order), so I search the direction array at element 4 to get the valid exits from the room. A 1 usually indicates that direction is valid, and a 0 that it is not. A value higher than 1 could represent locked doors, hidden passages, or any number of things.
Directions can be held in binary and you can use bitwise comparisons to find out which directions are valid for the current room. If you want locked doors, etc., bitwise comparisons are not the best system since they only work with 1's and 0's in your direction number.