Question

IN PYTHON Up until now, we have learned about printing text to the screen, functions, parameters,...


IN PYTHON

Up until now, we have learned about printing text to the screen, functions, parameters, loops, how to get input from users, text processing, and how to use if/else statements to have different execution paths. Everything we need in order to make our first game! For this assignment write a text-adventure game. Your game must have the following:

  • at least 4 choices the player must make
  • a different outcome for each of the 4 choices

For extra points, draw an ASCII Art image above the text before your choices.

What you need to worry about:

  • If the user puts in a value that is not a valid option, you should give them some helpful feedback and re-prompt them. You don't need to worry about the wrong data type being entered.
  • You need to have at least 4 if statements in your code
  • You need to have at least 4 functions in your code that take parameters
  • You can have riddles or other puzzles as well, or provide the player with options they must pick from.

This will probably be the longest program you have written to date. If you are struggling to figure out what your adventure should be, try taking your favorite TV show, video game, movie, or book and converting some of it into a choose your own adventure type of story. For inspiration, you can play some old acclaimed and renowned text adventure games like Zork, or The Hitchhikers Guide to the Galaxy

0 0
Add a comment Improve this question Transcribed image text
Answer #1
This code is an basic working demo of game zork with 
 4 if statements
 4 functions that take parameters



def endgame(param):
    

    # End of game
    while loop == 11:
        if loop == 11:
            print("---------------------------------------------------------")
            print("You have entered a mud-floored room.")
            print("Lying half buried in the mud is an old trunk, bulging with jewels.")
            last_inp = input("What do you do? ")

        if last_inp.lower() == ("open trunk"):
            print("---------------------------------------------------------")
            print("You have found the Jade Statue and have completed your quest!")
        else:
            print("---------------------------------------------------------")

        # Exit loop at the end of game
        exit_inp = input("Do you want to continue? Y/N ")
        if exit_inp.lower() == ("n"):
            exit()
        if exit_inp.lower() == ("y"):
            loop = 4


def thirdloop():
    while loop == 10:
        if loop == 10:
            print("---------------------------------------------------------")
            print("You are in a tiny cave with a dark, forbidding staircase leading down.")
            print("There is a skeleton of a human male in one corner.")
            cave_inp = input("What do you do? ")

        if cave_inp.lower() == ("descend staircase"):
            loop = 11
            endgame(loop)
        elif cave_inp.lower() == ("take skeleton"):
            print("---------------------------------------------------------")
            print("Why would you do that? Are you some sort of sicko?")
        elif cave_inp.lower() == ("smash skeleton"):
            print("---------------------------------------------------------")
            print("Sick person. Have some respect mate.")
        elif cave_inp.lower() == ("light up room"):
            print("---------------------------------------------------------")
            print("You would need a torch or lamp to do that.")
        elif cave_inp.lower() == ("break skeleton"):
            print("---------------------------------------------------------")
            print("I have two questions: Why and With What?")
        elif cave_inp.lower() == ("go down staircase"):
            loop = 11
            endgame(loop)
        elif cave_inp.lower() == ("scale staircase"):
            loop = 11
            endgame(loop)
        elif cave_inp.lower() == ("suicide"):
            print("---------------------------------------------------------")
            print("You throw yourself down the staircase as an attempt at suicide. You die.")
            print("---------------------------------------------------------")
            suicide_inp = input("Do you want to continue? Y/N ")
            if suicide_inp.lower() == ("n"):
                exit()
            if suicide_inp.lower() == ("y"):
                loop = 11
                endgame(loop)
        elif cave_inp.lower() == ("scale staircase"):
            loop = 11
            endgame(loop)
        else:
            print("---------------------------------------------------------")


def grateeast(inp):
    while loop == 9:
        if loop == 9:
            print("---------------------------------------------------------")
            print("You are in a clearing, with a forest surrounding you on all sides. A path leads south.")
            print("There is an open grating, descending into darkness.")
            grating_inp = input("What do you do? ")

        if grating_inp.lower() == ("go south"):
            print("---------------------------------------------------------")
            print("You see a large ogre and turn around.")
        elif grating_inp.lower() == ("descend grating"):
            lo = 10
            thirdloop(lo)
        else:
            print("--------------------")

def southwest(l):
    loop=l
    while loop == 8:
        if loop == 8:
            print("---------------------------------------------------------")
            print("This is a forest, with trees in all directions. To the east, there appears to be sunlight.")
            forest_inp = input("What do you do? ")

        if forest_inp.lower() == ("go west"):
            print("---------------------------------------------------------")
            print("You would need a machete to go further west.")
        elif forest_inp.lower() == ("go north"):
            print("---------------------------------------------------------")
            print("The forest becomes impenetrable to the North.")
        elif forest_inp.lower() == ("go south"):
            print("---------------------------------------------------------")
            print("Storm-tossed trees block your way.")
        elif forest_inp.lower() == ("go east"):
            loop = 9
            grateeast(loop)
        else:
            print("---------------------------------------------------------")

#
loop = 4



while True:
    # First Input Loop
    while loop == 4:
        if loop == 4:
            print("------------------Welcome Abroad--------------")
            print("You are standing in an open field west of a white house, with a boarded front door.")
            print("(A secret path leads southwest into the forest.)")
            print("There is a Small Mailbox.")
            second = input("What do you do? ")

        if second.lower() == ("take mailbox"):
            print("---------------------------------------------------------")
            print("It is securely anchored.")
        elif second.lower() == ("open mailbox"):
            print("---------------------------------------------------------")
            print("Opening the small mailbox reveals a leaflet.")
        elif second.lower() == ("go east"):
            print("---------------------------------------------------------")
            print("The door is boarded and you cannot remove the boards.")
        elif second.lower() == ("open door"):
            print("---------------------------------------------------------")
            print("The door cannot be opened.")
        elif second.lower() == ("take boards"):
            print("---------------------------------------------------------")
            print("The boards are securely fastened.")
        elif second.lower() == ("look at house"):
            print("---------------------------------------------------------")
            print(
                "The house is a beautiful colonial house which is painted white. It is clear that the owners must have been extremely wealthy.")
        elif second.lower() == ("go southwest"):
            l=8
            southwest(l)
        elif second.lower() == ("read leaflet"):
            print("---------------------------------------------------------")
            print("Welcome to the Unofficial Python Version of Zork. Your mission is to find a Jade Statue.")
        else:
            print("---------------------------------------------------------")

Add a comment
Know the answer?
Add Answer to:
IN PYTHON Up until now, we have learned about printing text to the screen, functions, parameters,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help on these functions PYTHON 3. The information about the functions is in the...

    I need help on these functions PYTHON 3. The information about the functions is in the first two pics. Scenario The Pokemon franchise consists of over 60 video games, 15 movies, several TV shows, a trading card game, and even a musical. It has been around for over two decades and at this point has fans of all ages. Because of this, people have become somewhat analytical about how they play the games. To help players of the Pokemon video...

  • can someone help me with this C++ problem write your game() function and 3+ functions that...

    can someone help me with this C++ problem write your game() function and 3+ functions that simulate the game of Jeopardy Dice according to the following game mechanics and specifications. Game Mechanics There are two players: the user and the computer, who alternate turns until one of them reaches 80 points or higher. The user is always the first player and starts the game. If any player reaches 80 points or more at the end of their turn, the game...

  • write a program for python 3 write the functions that could be used in an implementation...

    write a program for python 3 write the functions that could be used in an implementation of the game tic-tac-toe. Below are the definitions of the different functions. The code to test each function is currently in the main() of the lab10.py file. • A function to build the board. This method should create a list of the numbers 1 – 9 and return that list. build_board () -> list • A void function to display the board. (see the...

  • Please do it by C++ programming! By completing this project, you will demonstrate your understanding of:...

    Please do it by C++ programming! By completing this project, you will demonstrate your understanding of: 1) Arithmetic operations (addition, subtraction, multiplication, division, modulus) 2) Conditional statements (If, If-Else, If-ElseIf-Else, Conditional Operator, Switch) 3) Precondition, postcondition, and indexing loops (Do-While, While, For) 4) Standard text file operations (open, close, read, write) 5) Modularizing code by breaking into functions (including functions with input parameters, and ones that return a specific data type) There is a number guessing game similar to MasterMind...

  • Written in Python In this lab, you are to build a trivia game. The game should...

    Written in Python In this lab, you are to build a trivia game. The game should present each question – either in order or randomly – to the player, and display up to four possible answers. The player is to input what they believe to be the correct answer.   The game will tell the player if they got it right or wrong and will display their score. If they got it right, their score will go up. If they got...

  • In this module you learned about File Handling. You began learning about how data can be...

    In this module you learned about File Handling. You began learning about how data can be imported into, manipulated in, and exported from a program. Alter the assignment from Ch6 (Magic 8 Ball Game) so that it reads the Magic 8 Ball game sayings from a file and loads them into an array. The rest of the program should be the same. Previous Game: "The magic ball eight was created in the 50's and was produced by mattel. Eight Ball...

  • 1) Up until now we have always ignored air resistance. We should now add it. Let...

    1) Up until now we have always ignored air resistance. We should now add it. Let us just think of simple 1-dimensional problem, dropping a ball of mass m from a height H but with air resistance. We can model the air resistance as a force proportional to the velocity, fair = bu. The coefficient b is a constant. (For this problem you can use calculus textbooks or wolfram alpha to do the calculus.) • What are the units on...

  • In the lectures about lists we have seen some Python code examples that involve the processing of...

    In the lectures about lists we have seen some Python code examples that involve the processing of lists containing weather statistics. The original source of the values shown in the slides was taken from part of the Environment Canada website that serves up historical data: http://climate.weather.gc.ca/historical_data/search_historic_data_e.html    Data can be provied by that website using the Comma Separated Value (CSV) format which is stored in text files normally using a CSV suffix. We will not work directly with such files in...

  • Neo needs to break into the server room, but he has only partial information about the...

    Neo needs to break into the server room, but he has only partial information about the code that opens the door. Parts of the code are known, and other parts have been narrowed down to several options, which are listed inside parentheses. He also knows the sum of all of the digits in the code. Write a recursive method that will find the correct code. If the given pattern was “1(2,34)5(3,2)”, then the code must start with 1 and have...

  • please explain the answer 1) Up until now we have always ignored air resistance. We should...

    please explain the answer 1) Up until now we have always ignored air resistance. We should now add it. Let us just think of simple 1-dimensional problem, dropping a ball of mass m from a height H but 2 with air resistance. We can model the air resistance as a force proportional to the velocity, fair = bv. The coefficient bis a constant. (For this problem you can use calculus textbooks or wolfram alpha to do the calculus.) What are...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT