170,679 views
43 votes
43 votes
It’s time to make some additions to provide more options and interactivity for the player in our adventure game.

Step 1: Make Room(s) for Improvement
At the moment, our game has a great branching room and progression system along with some basic win-or-lose conditions for each room. Let’s add a bit more interactivity to each of these rooms by coding more actions for the player to use. Don’t worry; we don’t have to stray from our original room template. Instead, we can provide more things to do within the rooms we already have, namely:

troll room
dragon room
gold room
For EACH room, identify ONE new prompt and response you could implement that would provide interesting results.

For example, right now, in the troll room, the two existing prompts indicate that the player can either take the treasure or wave their torch and scare the troll. The two existing responses are that the player dies if they choose to take the treasure and that the player advances to the gold room if they choose to wave the torch.

So, in the troll room, we might add a third option that would allow the player to yell at the troll, and the troll’s response could be an uncaring grunt or growl. Then, we could simply run the troll_room() function to repeat the choices, allowing the player to try something else.

These new prompts should NOT send the player to another room; rather, the new prompts you write should simply return the player to the start of the room’s function and prompt them to do something else if they want to.

For this step, do not write any code yet; just identify a new action that would be interesting in each room.

Step 2: Iterate It
Once you’ve identified your new prompt and response for EACH room, create a new PythonAnywhere file called new_room_prompts.py.

Copy the definitions of each room from the lessons into this file so you can add your new code.

Then, code your new prompts and responses into your script, inserting them into the definitions of the rooms ( def troll_room() , etc.) under the existing prompts.

Step 3: Test Your Code
Test each new prompt by running the script to see how the new prompt and response works. Do this every time you add a room’s new actions to ensure you’ll be able to find errors or bugs easily if they occur. Trying to code too many things at once can make it difficult to figure out what went wrong!

User AndrewPolland
by
3.2k points

1 Answer

15 votes
15 votes

Answer:

For the troll room:

New prompt: "Try to negotiate with the troll for the treasure"

New response: "The troll laughs at your attempts to negotiate and demands a higher price for the treasure. You decide it's not worth it and return to the beginning of the room."

For the dragon room:

New prompt: "Offer the dragon a piece of treasure in exchange for safe passage"

New response: "The dragon sniffs the treasure and decides it's not enough. It roars and flames burst from its mouth, forcing you to return to the beginning of the room."

For the gold room:

New prompt: "Attempt to steal some of the gold without being noticed"

New response: "As you try to sneak away with some gold, one of the guards spots you and calls out. You quickly return to the beginning of the room before you get caught."

Step-by-step explanation:

User TIMEX
by
2.8k points