I'm new to C++ and object oriented programming. I've done some really basic stuff, but I wanted to try something a little more advanced. I'm trying to put together a text adventure game. Something that would start out simple, but I could improve over time if I wanted to.
I have the basic idea down for the game, but I'm having trouble figuring out how to structure the different rooms.
I want the rooms set up so they each have values places on 4 directional values
The values of each would give the number of the room you'd go to if you typed N,S,E, or W.
Then I want a class type to define the different attributes of each room. Then I want a currentroom function to preform tasks based on the values of the room the player is currently in.
I have the class sort of set up, but I don't know how I should store the data for each room or how I would retrieve it.
To me this doesn't seem like it should be extremely difficult, but I haven't been able to figure it out, and if any documentation explains how to do it, this little ArtGeek hasn't been able to get it through her thick skull.
Sorry for longwindedness :)
Well, the common way is to store it in a file but there are more methods than time to recount them. Have a look on my site here for an example of one of the 1000's of ways.
perhaps you would want characters then initialize the integers like...
(btw: C++ is not completely object oriented, and in my opinion, not at all)
printf("Where do you want to move? [N/E/S/W]: ");
//code for north here
//code for east here
//... continuing switch case
Just so you know you can make it
So you wont have to do double switch statements
...or use toupper(ans);/tolower(ans)l; n ctype.h (or your compiler specific) to use a single case either uppercase or lowercase in your switch statements.