NewUserlocation
NewUser.location
O_O
something is different...
Soma
NewUserlocation
NewUser.location
O_O
something is different...
Soma
Fixed it, was missing a dot
Oh u beat me to the punch haha
if I wanted to load the rooms from a file, would be it besomething like this
Code:string line[23]; ifstream tscreen; tscreen.open("rooms.txt"); int num; for (int num = 0; num <= 23; num++) { getline(tscreen, line[num]); cout << line[num] << endl; } tscreen.close();
and the txt file would be like this
Code:Room *rooms = new Room [4]; rooms[0].description = "Crossroads"; rooms[1].description = "Bridge"; rooms[2].description = "Gateset"; rooms[3].description = "Cut Thoat Path"; rooms[3].description = "Cut Thoat Path"; rooms[3].description = "Cut Thoat Path"; rooms[3].description = "Cut Thoat Path"; rooms[3].description = "Cut Thoat Path"; rooms[3].description = "Cut Thoat Path"; rooms[3].description = "Cut Thoat Path"; rooms[3].description = "Cut Thoat Path"; rooms[3].description = "Cut Thoat Path"; rooms[3].description = "Cut Thoat Path"; rooms[3].description = "Cut Thoat Path"; rooms[3].description = "Cut Thoat Path"; rooms[3].description = "Cut Thoat Path"; rooms[3].description = "Cut Thoat Path"; rooms[3].description = "Cut Thoat Path"; rooms[3].description = "Cut Thoat Path";
except that will display it... but could I use something like that but not cout
Ok ill fix that, but would that work? if i minus the cout?
I have about 100 rooms and I dont really want that in my main file
Yeah I thought so, was worth checking .
Well I have put most of snippets together and it all works lovely.
Just wondering if it is possible to put a function in between the moving, using this method.
E.g To move from Room 1 to Room 2 you must answer this question,
to move to Room 2 to Room 4 you must answer this different question
Or is the only way to put a funcion into the room class and dot call it like description once in the room?
Or I could put functions within a class and do something like this right?
cout << "(W)est to: " << NewUser.location->west->description->fone << endl; // where fone is a function in the class
Last edited by Aliaks; 07-16-2009 at 04:59 AM.
Yeah but the only way I can see doing it is putting a function in the class and using some library function that can randomly select a function to be called.
Or when moving to a different area doing the same thing, but I don't know if there is a c++ function that can call randomly a created function.
say I make a math function like ...
and when the user moves from room 1 to room 2 they have to answer that function to move to room 2Code:cout << "What is 10 plus 2?"; cin >> input
but I want a different function between each room
Look at this:
Now, what if we change input from == 'n' to == 12?Code:if (input == 'n' && player.location->north) player.location = player.location->north;
If the input is 12, we set the player's new location to the room that is north of here.Code:int input; cout << "What is 10 + 2?"; cin >> input; if (input == 12 && player.location->north) player.location = player.location->north;
Difficult?