Originally Posted by
whiteflags
It has been a long time since I actually visited the sister site. I could swear the site had some information on vector, map and friends when I used the site, but that appears to be gone. Anyway, even when I first started, I carefully selected a book. Since you're being pressured into using the STL,
Accelerated C++ comes to mind. It talks about vector as early as chapter 5.
You may just be taking on more than you can chew at this point but in the spirit of being helpful I will try to turn one of laserlight's suggestions into simple English.
The word list in this statement is just a list and not a data structure as far as I can tell. In fact, vector is recommended. I think I know why vector is recommended: because in the absence of a better idea, vector is one of the simplest data structures. (Simplicity in computing does not always mean poor, by the way.)
There has to be a direct connection between the simple fact of where the player is and these pointers to other places contained in the individual rooms. One of your game's most basic jobs is to track movement to keep the game going. So, in your mind's eye, if it's possible travel in four directions from the middle room of the game board, you would have the nearest north, south, east and west rooms in the list pertaining to the middle room. If then you went into the south room you would have a different list of options pertaining to that room, including one option to go back.
It will be important for the rooms to take on responsibilities if you want the game to be organized. Room objects will have to spawn characters and items that belong there, etc, as much as "spawn" can mean in a p&p adventure. That is how you cut down on massive data migration.
Okay, now for a question that has been bothering me a long time...
What's an object?
I get that if I define a structure, or a class, or whatever in main I'm creating a copy of that specifically for main, and that I can even create multiple copies of the same structure/class if the variables of that structure/class applied to two different things I wanted to program about (say I wanted to make two different monsters appear in the game and one monster was just the same as an earlier version with stronger stats so I'd code:
Code:
struct monster {
int claws;
int teeth;
int tentacles;
};
int main()
{
monster little_monster;
monster big_monster;
little_monster.claws = 1;
little_monster.teeth = 1;
little_monster.tentacles = 1;
big_monster.claws = 5;
big_monster.teeth =5;
big_monster.tentacles =5;
}
)
But are those two structures in main objects? And what's so special about them being objects?
I'm sorry if it's an impossibly stupid question, but it just seems like everything I've bumped into is an object and it's very hard to determine what that means, especially when everyone keeps referring to my game rooms as objects when I've been using functions for that, like this:
Code:
void rooms::training_room (int& player_race_reference, int hard_knock_conversation_choice_one, int examine_locker, int spiked_horse_shoes, int first_visit, int group_conversation_choice_one, int group_conversation_choice_two, char*& player_name_reference)
{
if (first_visit=1)
{cout <<"TRAINING ROOM\n";
cout <<"0000000000000000000000000000000000000000000000\n";
cout <<"0 () () () () 0\n";
cout <<"0 KICKING BAGS 0\n";
cout <<"0 0\n";
cout <<"0------- ______________________ -------0\n";
cout <<"0 | | | | 0\n";
cout <<"0 WEAPON| | | | 0\n";
cout <<"0 LOCKER| | EXERCISE MAT | | COT 0\n";
cout <<"0 | | | | 0\n";
cout <<"0 | | (STALLION) | | 0\n";
cout <<"0 | | | -------0\n";
cout <<"0------- |______________________| |\n";
cout <<"0 DOOR|\n";
cout <<"0 (ZEBRA) |\n";
cout <<"0 (STALLION) 0\n";
cout <<"0 DOOR 0\n";
cout <<"00000000_____000000000000000000000000000000000\n\n";
cout << "You find yourself in what looks like a gym or training room, there is a row of kicking bags and practice dummies along one wall and much of the floor is covered in mats. There is also a heavy wire mesh case filled with various implements of destruction sitting along a wall. A muscle bound gray earth pony with a steely look in his eyes resides here.\n\n";
cout << "However, he isn't the only one in the room. A startlingly handsome white earth pony stands there talking to a zebra stallion with a perplexing ribbon in his hair. \nThey turn to face you as you enter. The mare nods to the white pony.\n\nThe white pony walks up and holds out his hoof, \"Organizer Blueblood at your service. I have to say, that was pretty impressive. You saved a lot of lives out there and we are definitely grateful\"\n\n The gray earth pony nods. \"Definitely a good show, but we should really get him back home. We can't keep him here.\"\n\n1. He's right.\n2. Don't do that! After what I pulled they'd take my head off!\n\n";
while (group_conversation_choice_one != 1 && group_conversation_choice_one !=2)
{
cout << "Choose an option: ";
cin >> group_conversation_choice_one;
switch (group_conversation_choice_one)
{
case 1:
cout << "Blueblood shakes his head. \"That's probably not a good idea... I think you've already figured this out, but your army days are over.\" \nWind nodded, \"You did the right thing, but... you won't like what'll happens if you go back there.\" \nYou knod. She's proabaly right. \nBlueblood sighs and turns back to you. \"Don't worry, we'll find a way to help you out.\" \n\n";
break;
case 2:
cout << "The muscular stallion narrows his eyes. \"We still can't afford to keep you ar-.\" \n\"Hard Knock, what's wrong with you?\" Blueblood cuts in. \"This pony saved all of our lives.\" \nThe gray pony (Hard Knock you suppose) shakes his head. \"Boss, this pony is an obvious security risk. If he ain't a plant he's at the very least someone they'll be looking for real hard.\" \nBlueblood tilts his head and raises an eyebrow, \"First of all, they're probably looking for all of us pretty hard. Secondly... you really think it's more likely that this stallion's a spy so devoted to Seasons that he's willing to throw away his body parts than it is that he's just some pony who made a decent split decision to help us?\" \nHard knock leans back against the weapons locker and folds his hooves. The zebre looks at the floor uncertainly.
if (wind_opinion >= 2)
{
cout << "Wind speaks up. \"I don't know much about him, but he's a good patient at least. I think we should give him the benefit of the doubt.\" \nThe gray pony and the zebra still look uncertain.\n\n"
}
cout << "Blueblood sighs and turns back to you. \"Don't worry, we'll find a way to help you out.\" \n\n";
break;
}
cout << "\"Anyway,\" He continued \"nopony, or zebra...\" The zebra stallion with the ribbon blushed. \"is going to be able to go anywhere untill Archer gets back from foraging at the very least, so we might as well get to know our new friend. What's your name?\" \n\n";
cout << "\"" << player_name_reference << "\" you reply. \n\n";
cout << "\"Well," << player_name_reference << ", this is Hard Knock,\" he says gesturing to the grey earth pony,\"and this is Ura, you've allready met Wind.\" \n\n";
// You need to continue writing the above cout statement
}
}
}
((Note: I'm fully aware that this code is incomplete, and also that that weird pointer-reference hybrid monstrosity thing will give you nightmares. I'm sorry about that, I have no Idea what horrors I've unleashed upon the world.))
So basically what my assumption had been was that I would set up if statements within the functions such that different things would be occurring in the rooms depending on how the players actions would modify global variables.
Does that make my room an object? Or are functions automatically not objects?
Note: I thank you guys for your advice. Seriously, you are an awesome and incredibly helpful community and I'm sorry if I just don't get it sometimes