![]() ![]() ![]() ![]() Then we will add some code to our kitchen() function for the player to pick up a golden key. To do so we will first initialise a new empty list called inventory using the following line of code that we will place at the very beginning of our code (e.g. We will now add an inventory to our code to let the player collect objects as they progress through the game. Print("- You are entering the kitchen -") Note that for this code to work, you will also need to define a new function for the kitchen: I do wonder why this book was not perfectly aligned? Anyway, let's go back to the hall.") Print("Feeling adventurous, you decide to go through this secret passage and realise that it leads you to the kitchen.") Print("When trying to pick up the book, the book acts as a lever and the bookshelf slides to the left revealing a secret passage.") Option = input("Do you: \n a) pick up this book \n b) Leave this book where it is and go back to the hall").lower() Print("While looking at the books on the bookshelves, you notice that one of the book is not perfectly aligned with the other books.") Print("- You are entering the library -") However we are going to add a secret passage to lead to the kitchen. Looking at the floor plan of the mansion, you will notice that there is only one door to go back to the hall. Here is an example of code for the library() function. We have started the game for you with some (but not all) the options for the user to walk from one room to the other. Write in each room what you would like your program to do when the user enters the room. There could be a random math question to solve in the living room, and if the user does not give the correct answer they lose.There could be a secret passage in the library to lead to the kitchen,.It would then display a different message based on the potion chosen by the user, You could have three magic potions on the kitchen table and your program could ask the user to choose one of them.Maybe a ghost will appear (ASCII Art using the print command) when the user enters the bedroom,.You will decide what happens when the user enters a room. You are going to write a Python game where the user walks within the different rooms of a haunted house. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |