Hi I have a question with regards to storing and retrieving a players location in a game. At the moment I'm working on a text based dungeon game, and one of the things I am having trouble implementing is, a way to move between rooms in the game world (I.E. typing "GO NORTH" and having the player move to the north room). It seems to me that pointers would be an Ideal method of doing this, as all I would have to do is just create a pointer called current_location or some such, and update it every time the player moves to another room in the map. (I already have the directions and a room class done, I just need a way to "link them together" so to speak.)
please note that this is pseudocode:
class player
{
int HP;
int Dex;
int Intel;
int Str;
int Wis;
bool HAS_MAGIC;
int current_room;
*current_loc;
and when the user decides to type in a direction (Say "North", for instance):
if (direction==North){
player.current_room = room.array[1];// now the player goes north
*current_loc = player.current_room;}
This is, in a nutshell, what I want to do. I have it all planned out on paper, but I'm turning to these forums because you guys know your stuff and I would appreciate the help. So if you have any ideas/brainstorms/better methods, feel free to fire away!
*note that my direction system consists solely of enums, as I felt a parser would be a little too difficult to implement.
Thanks for your help!