Hello, I am trying to code an adventure game for one of my classes, so far I have this. I have a question though. Once i go the main menu how would allow my program to continue with the game where it left off at? Also, I want to make an inventory that will allowed players to pick up certain weapons/armor through the game. Once they've decided to pick up or not how would I allowed them to look at their inventory and equip/look at something? Also there will be at least 1 boss battle, how should i go about a combat system?
Hmm, I'll have to look into that, i'm not familiar with the code you type. I want to also have it so the user can pick up an item and use it. For example a key to unlock a door.
I would suggest that you learn OOP first since this kind of games can become quite complex and without a proper design you will and up with a mess. In addition to @Sh0es code you would also need a player class, a command parser....
Okay here is what I have now, I still am at a delima though for making my cases, I can't have two case 1's so i don't know what to do. also I decided not to do an inventory because i think it was too much for me at this tie
#include <iostream>
#include <string>
#include <cstdlib>
usingnamespace std;
string userOption;
int userMainMenu;
int userChoice;
int userChoice2;
void screamForHelpScene1() {
cout << "You hear someone running towards you as you scream bloody murder. A gaurd comes around the corner and yells 'What the hell is wrong with you" << endl;
cout << "What would you like to say?" << endl;
cout << "Why am I here?" << endl;
cout << "Where am I?" << endl;
cout << "Ask both" << endl;
cout << "Remain silent" << endl;
cin >> userChoice2;
switch (userChoice2) {
case 1:
cout << "The guard looks at you and says 'Ha! How should I know, I'm just the guard doing my job, now shut up or you'll wish you were somewhere else'" << endl;
cout << "The guard walks away laughing at you." << endl;
cout << "What would you like to do?" << endl;
cout << "1. Scream for help again" << endl;
cout << "2. Look for a way out of the cell." << endl;
cout << "3. Cry" << endl;
cin >> userChoice;
break;
case 1:
cout << "";
break;
default:
cout << "That is not an option please try again.";
}
}
void mainMenu() {
switch (userChoice) {
case 0:
cout << "------------------------------------------------------" << endl;
cout << " MAIN MENU " << endl;
cout << "If you can't figure out what to do keep trying! No one said it was easy to " << endl << "escape prison!" << endl;
cout << "To quite the game type 'quit'" << endl;
cout << "To continue type 'continue'. " << endl;
cin >> userOption;
break;
}
}
void gameFunction() { // the actual function of the main game itself.
string userName;
cout << "What is your name?" << endl;
cin >> userName;
cout << "Hello " << userName << " welcome to the the game" << endl;
cout << "You wake up feeling dazed, you don't know where you are but after gathering your senses you realize you're in a prison cell. It's small, there's no one around you that you can see." << endl;
cout << "What would you like to do?" << endl;
cout << "1. Scream for help" << endl;
cout << "2. Look for a way out of the cell." << endl;
cout << "3. Sit there and do nothing." << endl;
cout << "4. Cry." << endl;
cin >> userChoice2;
switch(userChoice2) {
case 1:
screamForHelpScene1();
}
}
void startMenu() { // the opening menu for the game
string userStart;
cout << "--------------------------------------------------------------------" << endl;
cout << "Hello, welcome to Prison Escape by Brandon Cavendish!" << endl;
cout << "At any point in the game type 'help' to go to the main menu." << endl;
cout << "Type '1' to start your adventure!" << endl;
cin >> userChoice;
switch (userChoice) {
case 1:
screamForHelpScene1();
break;
}
}
int main() {
startMenu();
mainMenu();
}