Need Simple c++ coding Willing to pay.

Hey, i Have to make a "dungeon". I have no idea on about how to do this. But, i have specific instructions, anyone willing to help? Thanks. Willing to pay, need help ASAP! I am a beginner in c++, so the coding has to be "beginners style". If you want to help, jus reply, and i will contact you ASAP.

Instructions:
1. You will need to include 2 header files: iostream to support getting user input and displaying text to the screen, and string to support string datatype used for room descriptions

2. Create a main function

3. The “dungeon rooms” will be modeled using 2 arrays: a string array to hold each room’s text description; and a 2-dimensional integer array to hold each room’s exits.

3A. Declare and initialize a constant integer to represent the number of rooms that your dungeon has. The number of rooms will correspond with the number of elements that your array must contain. In the above example map, the array size would need to be 7 to contain all 7 rooms.

3B. Declare and initialize a constant integer to represent the number of exits that each room may potentially have. There are 4 possible exits: North, East, West, and South.

3C. Declare and initialize a set of constant integer variables that we will use for indexing into the possible exits. Name these variables using all caps to represent that they cannot change value. NORTH=0, EAST=1, WEST=2, SOUTH=3. The reason for having these variables is so that we can more intelligently access the exits from the room_exits array.

3D. Declare a string array to hold your room descriptions. Use an initializer list to add all of your strings into the array. The strings should be inserted into the array in the order that the rooms are numbered in your map. Remember to add commas between each string in the initializer list. An example of the description string for the first room would be: “You have entered the guest bedroom, exits are north, east”

3E. Declare a 2-dimensional integer array to hold each room’s exits. This array should have 2 sizes: the number of rooms (7) and total possible exits (4). Use an initializer list to add all of your room exits. Each room should contain a 4 element array containing the indices to the rooms that connect to it in the order: North of this room, East of this room, West of this room, South of this room. If the room does not have an exit in a particular direction then use a -1 as a flag value to indicate that no exit is in that direction. An example set of exits for the first room would be: {3, 1, -1, -1}. This is because room 0 connects to room 3 to the North, room 0 connects to room 1 in the East, room 0 connects to no rooms to the west, and room 0 connects to no rooms in the south.

4. Declare and initialize a variable for the current room that the player is in. This variable will be an integer and should start at room 0.

5. Declare and initialize a variable to control the game loop. This variable should be of type Boolean and should start as false. You can call this variable “done”

6. Create a while-loop that evaluates ‘done’ to see if the game should continue to run. While the game is not done then run the game-loop. The rest of your code should be contained within this game-loop.

6A. Print to the screen the current room’s description. This can be done by using the value of current room variable as an index into the room_description array. Make sure to add an endl afterwards to end the line.

6B. Create a variable of data type char to hold the user’s input. You can call this variable user_input. The expected input would be n for North, e for East, w for West, s for South, or q for Quit.

6C. Get the user’s input and move it into your user_input variable.

6D. Next we will use a Nested if-else statement to handle the 6 possible user inputs: n/N, e/E, w/W, s/S, q/Q, or anything else.


If the value of the user_input variable is either ‘N’ or ‘n’ then do the following:
a.) Create an integer variable called next_room that will get the room number that is connected to the current_room from this direction (North). This value is accessed from the 2-dimensional room_exits array. The first index used is value of the current_room variable and the second index is the constant variable NORTH.


b.) Next, check if the value for next_room is equal to -1. If it is then print the message: “You can’t go that way.” Else set the value of current_room to be the same as next_room.


Else If the value of the user_input variable is either ‘E’ or ‘e’ then do the following:
a.) Create an integer variable called next_room that will get the room number that is connected to the current_room from this direction (EAST). This value is accessed from the 2-dimensional room_exits array. The first index used is value of the current_room variable and the second index is the constant variable EAST.


b.) Next, check if the value for next_room is equal to -1. If it is then print the message: “You can’t go that way.” Else set the value of current_room to be the same as next_room.



Else If the value of the user_input variable is either ‘W’ or ‘w’ then do the following:
a.) Create an integer variable called next_room that will get the room number that is connected to the current_room from this direction (WEST). This value is accessed from the 2-dimensional room_exits array. The first index used is value of the current_room variable and the second index is the constant variable WEST.

b.) Next, check if the value for next_room is equal to -1. If it is then print the message: “You can’t go that way.” Else set the value of current_room to be the same as next_room.



Else If the value of the user_input variable is either ‘E’ or ‘e’ then do the following:
a.) Create an integer variable called next_room that will get the room number that is connected to the current_room from this direction (SOUTH). This value is accessed from the 2-dimensional room_exits array. The first index used is value of the current_room variable and the second index is the constant variable SOUTH.


b.) Next, check if the value for next_room is equal to -1. If it is then print the message: “You can’t go that way.” Else set the value of current_room to be the same as next_room.



Else If the value of the user_input variable is either ‘Q’ or ‘q’ then do the following:
a.) Print to the screen the message: “Thanks for playing. Good bye.”
b.) Update the value for the control variable of the game-loop named ‘done’ to be true

Else the value of the user_input variable is something else, then do the following:
a.) Print to the screen the message: “I don’t understand that command.”




Additional Notes:
Whenever you print a message to the screen also ensure that you put new line characters so that a new line will be printed.



Bonus:
Add additional functionality to this program beyond the base specifications. I would prefer for you to build a function that would build your room_description array and room_exits array from a text file. This way you could dynamically create new levels. Other suggestions would be to include a random monster encounter and an additional input option to “attack” these monsters and to check your hit point status.





Last edited on
Topic archived. No new replies allowed.