Say you have
Rooms map[10]; // there are 10 rooms in the map
Each room has an array of neighbours enum directions { NORTH, EAST, SOUTH, WEST, MAXDIRS };
int neighbours[MAXDIRS];
Having initialised all your data, then moving north say would be simply currentRoom = map[currentRoom].neighbours[NORTH];
Valid moves would be a value of 0 to 9.
Then you can have special values to indicate such things as "Wall" or "This way is magically blocked".
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
I started this a while ago and I have a skeleton of a system on my site with the source and the executable since this was discussed earlier on the forums (search for Several C++ design questions)
The game I have written is pretty much identical to what you are saying accept that currently it supports mob(enemy) scripting, game saves and has a custom equipment system. It's on the devblog section of my site LazyCode.info/DevBlog
Note: It is GPLd as all programs on my site as per the agreement in my Programs page.
ShawnCplus
Code Monkey
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268