Question

In: Computer Science

Create a program that will take the user through an attempted dungeon escape. The user will...

Create a program that will take the user through an attempted dungeon escape.

The user will represent a player and the player will have a variable to represent the HP (Hit Points) which will default to 50.

Menu

The program will start with the following menu:

Welcome to dungeon escape.

1) Play the game

2) Exit the game

If option 1 is chosen, the game is played, if not the program will end.

First Set of Doors

If option 1 is chosen, the following message will display

Welcome player. You wake up in a dark hallway, and three doors appear to be your way out

. Which door will you choose? 1, 2, or 3.

prompt> You will choose one door to be a trap door. Create a constant variable to hold the value of the door that will be the trap door.

Hint

const int TRAPDOOR = 3;

If the player chooses the trap door, you will display a game over message and exit the program

Example message:

You open the door and are instantly thrown into an abyss. Better luck next time. GAME OVER.

If the player chooses the other 2 doors, the player will have their HP increased by 50 and move on to the next set of doors are displaying the following message

You pass through the door and sense of strength come over you. Your new HP is [HP value]

Second Set of Doors

You will give the player the following prompt:

You see another set of three doors.

Which door will you choose? 1, 2, or 3.

Prompt>

This time two doors will be trap doors. Create two constants to hold the value of the doors that will be trap doors

. If the player chooses the either trap door constant you will display a distinct message for each trap door and decrease the HP by 50.

Example message for Trap 1:

You open the door and are attacked by an Ogre. You escape but your HP is now [HP value].

Example message for Trap 2:

You open the door and are attached by a banshee. Your escape but your HP is now [HP value]. If the player chooses the last door, display the following message: You open the door and…. nothing happens. Lucky you!

Boss Fight

If a player makes it this far, Display the message:

You see no obstacles and your HP is now [HP value]. Press any non-space key when ready

Hint: You can use cin to read a character here. When the user presses any key, you will have to compare the user’s HP. If the user’s HP is greater than 50 display the following message: You see a dragon appear before you. It breathes fire upon you but you managed to escape with small wounds. Congratulations, you’ve escaped the dungeon! If the user’s HP is equal or less than 50 display the following message: You see a dragon appear before you. It breathes fire upon you and your weak body is engulfed immediately. Game over!

Solutions

Expert Solution

#include<bits/stdc++.h>
using namespace std;

int main()
{
   int n,HP=0;
   cout<<"Welcome to dungeon escape.\n1) Play the game\n2) Exit the game"<<endl;
   cin>>n;
   if(n!=1)//if user want to exit
   {
       return 0;
   }
  
   //first set of doors
   const int TRAPDOOR=3;
   int door1;
   cout<<"Welcome player.\nYou wake up in a dark hallway, and three doors appear to be your way out.\nWhich door will you choose? 1, 2, or 3."<<endl;
   cin>>door1;
   if(door1==TRAPDOOR)//failed at first door
   {
       cout<<"You open the door and are instantly thrown into an abyss. Better luck next time. \nGAME OVER."<<endl;
       return 0;
   }
  
   //Passed first door and entered second door
   HP+=50;
   int door2;
   const int TRAPDOOR1=2,TRAPDOOR2=1;
   cout<<"You pass through the door and sense of strength come over you. Your new HP is "<<HP<<endl;
   cout<<"You see another set of three doors.\nWhich door will you choose? 1, 2, or 3."<<endl;
   cin>>door2;
   if(door2==TRAPDOOR1)
   {
       HP-=50;
       cout<<"You open the door and are attacked by an Ogre. You escape but your HP is now 0."<<endl;
   }
   else if(door2==TRAPDOOR2)
   {
       HP-=50;
       cout<<"You open the door and are attached by a banshee. Your escape but your HP is now 0."<<endl;
   }
   else //In my opinion is this part HP should increase but its not mentioned
   {
       //HP+=50;
       cout<<"You open the door and…. nothing happens. Lucky you!"<<endl;
   }
   cout<<"\nBOSS FIGHT"<<endl;
   char c;
   cout<<"You see no obstacles and your HP is now"<<HP<<".Press any non-space key when ready"<<endl;
   cin>>c;
   if(HP>50)
   {
       cout<<"You see a dragon appear before you. It breathes fire upon you but you managed to escape with small wounds. \nCongratulations, you’ve escaped the dungeon!"<<endl;
   }
   else
   {
       cout<<"You see a dragon appear before you. It breathes fire upon you and your weak body is engulfed immediately. \nGame over!"<<endl;
   }
  
}

It's working fine


Related Solutions

Create a program (Python) YourFirstnameLastnameA06b.py to ask the user to create a password: The user will...
Create a program (Python) YourFirstnameLastnameA06b.py to ask the user to create a password: The user will first enter a password, then enters the same password again; If the second input is the same as first one, the user successfully creates the password. Print “Well done.”; Otherwise, the user will be directed to repeat the whole process (go to step 1.)
(JAVA) Create a program that prompts the user for an age input. The program defines the...
(JAVA) Create a program that prompts the user for an age input. The program defines the age group of the user. Follow the table below to construct the output for your program. Age Age Group 0 Baby 1-3 Toddler 4-11 Child 12-17 Teenager 18-21 Young Adult 22-64 Adult 65+ Senior Negative Number Invalid Input Sample Input Enter an age: 18 Sample Output: You are a young adult. Sample Input Enter an age: 29 Sample Output: You are an adult. Sample...
Create a Python program that: Allows the user to enter a phrase or sentence. The program...
Create a Python program that: Allows the user to enter a phrase or sentence. The program should then take the phrase or sentence entered Separate out the individual words entered Each individual word should then be added to a list After all of the words have been place in a list Sort the contents of the list Display the contents of the sorted list with each individual word displayed on a separate line Display a message to the user indicating...
5. Take user input and give corresponding output. User will enter a sentence. The program will...
5. Take user input and give corresponding output. User will enter a sentence. The program will output the word that appears most frequently in this sentence. If there are multiple words with same frequency, output the first of these words. Please enter a sentence: I like batman because batman saved the city many times. The most frequent word is: batman The frequency is: 2 PYTHON
Create in Java a program that will prompt the user to enter aweight for a...
Create in Java a program that will prompt the user to enter a weight for a patient in kilograms and that calculates both bolus and infusion rates based on weight of patient in an interactive GUI application, label it AMI Calculator. The patients weight will be the only entry from the user. Use 3999 as a standard for calculating BOLUS: To calculate the BOLUS you will multiply 60 times the weight of the patient for a total number. IF the...
Create in java a program that will prompt the user to enter a weight for a...
Create in java a program that will prompt the user to enter a weight for a patient in kilograms and that calculates infusion rates based on weight of patient in an interactive GUI application, label it HEPCALC. The patients’ weight will be the only entry from the user. To calculate the infusion rate you will multiply 12 times the weight divided by 50 for a total number. The end result will need to round up or down the whole number....
Create a java program that will do the following: Create a method called getInt.Allow the user...
Create a java program that will do the following: Create a method called getInt.Allow the user to enter up to 20 student names,and for each student 3 quiz scores (in the range 0-100). Once input is done, display each student’s name, their three quiz scores, and their quiz score average, one student per line. The output table does not need to line up perfectly in columns.Use dialog boxes for all input and output.Use the method to input the three scores.Parameter...
5) Create the following in a Java program Create a scanner Prompt the user to enter...
5) Create the following in a Java program Create a scanner Prompt the user to enter the name where the box of mail is shipping from and create the variable and relate to scanner Prompt the user to enter the name of destination where the box of mail will be shipped and create the variable and relate to scanner Prompt the user to enter the weight of the package and create variable to relate to scanner Calculate cost of shipping...
JAVA Take in a user input. if user input is "Leap Year" your program should run...
JAVA Take in a user input. if user input is "Leap Year" your program should run exercise 1 if user input is "word count" your program should run exercise 2 Both exercises should run in separate methods Exercise 1: write a java method to check whether a year(integer) entered by the user is a leap year or not. Exercise 2: Write a java method to count all words in a string.
1) Create a "Can I be President?" program. The program determines if the user meets the...
1) Create a "Can I be President?" program. The program determines if the user meets the minimum requirements for becoming the President of the United States. Use user input. The rules for being president of the U.S. are: Older than 35 Resident of US for 14 Years Natural born citizen Print True if the person could be president and False if they can't be president. 2) Alter one line of that program to be a "I can't be President?" game....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT