CS120
Programming Assignment #4
Due on or before Friday, Septermber 20 at 11:59 PM.
For this assignment you will be creating a simple text-based
adventure game. Each "room" in the adventure should be
represented by its own function. (A "room" just represents a
particular area, not necessarily a literal room.)
If you have never seen or played a text-based adventure game, an article about an early game can be found here:
ADVENT
Requirements:
- Each "room" should have its own number in the code. This is so that the code
can refer to each room by a unique number. Each room function should print
some text describing the room and have some options
for where the player can go next. You may also include some options for
what the player can do in that room. Your game should have at least four rooms.
- Each "room" function should return an integer value representing the room the player is in or moving into.
For example, if the player is in room 3 and chooses to go north, which takes them to room 6, the function for room 3 should return the value 6 indicating the number of the new room the player is moving into.
If the player doesn't move from a room, the room function should return its own number.
- The main() function should have a switch statement that selects which room function to call next.
- At least two of the "room" functions should include a static variable that keeps track of whether that particular room has been entered before.
Your program must do something different the first time the room is entered.
For example, the first time (and only the first time) that the room is entered, the player should get an object.
- There should be at least one "score" variable, such as the amount of gold collected, the number of butterflies rescued, the number of clues found, the number of lives lost, the amount of health remaining, etc.
This variable should change as the player moves between rooms. There should be a separate function that prints the value of this variable for the player.
That is, it should print something like:
Oxygen Remaining: 120
for any room the character enters.
Variables of this sort should probably be "global", meaning that all functions in the program can access them.
- Remember to put a comment at the beginning of the code with
your name, section number, assignment number, etc.
Turn in: Use the script command to demonstrate how your program runs.
Place the output from the script command into file named Assignment4output.txt.
In the sample output, make sure you show what happens each time a room is entered, both the first time and successive times.
Turn in a copy of your program code and the Assignment4output.txt file to Canvas.