***please note, i have typed a fairly long explanation, but it would probably only take someone a few minutes to answer my question***
I am building a text adventure game in c++ ("move north", "unlock door", that type of game).
At the moment i am concentrating on just building a simple game engine consisting of just being able to move from one location (room) to another.
I have already achieved this first part, and this is roughly how it works:
locationClass - contains locationID, description and all exits and where they lead to (i.e. "int north = 2", would mean that an exit is available north and it leads to location 2).
MapClass - this acts as a container class for all locationClass objects.
playerClass - contains currentLocation which would be the locationID of the relevant locationClass object.
1. The current location is displayed on screen. Lets assume the player types the command "north".
2. The current locationID is retrieved from the player class
3. The locationClass object that matches this ID is checked to see if has an available exit north.
4. lets assume that it does, and that "int north = 2".
5. the players currentLocation is updated to 2, and the new locations description is displayed.
That's pretty much it. The problem is i need to use a different system of how to move the player around and check what exits are available from what locations. What i need is the game working like above but with an adjacency matrix as a "map" for my game.
Everytime the player types a command, the adjacency matrix would need to be checked to see if the move is possible. This is what i need someone to help me with.
Can someone explain the steps required for this process? For this example it would be fine to stick to 5 locations in the map. So the matrix could look like this, for example: