AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Funny thonny python 69 code9/25/2023 ![]() get_num_of_enemy () = 0 : 92 print ( "You have slain all the enemies. name ) 88 if weapon in available_weapons : 89 if current_room. lower () 85 available_weapons = 86 for item in backpack : 87 available_weapons. character is not None : 84 weapon = input ( "What will you fight with? > " ). hug () 80 else : 81 print ( "There is no one here to hug" ) 82 elif command = "fight" : 83 if current_room. talk () 75 else : 76 print ( "There is no one here to talk to" ) 77 elif command = "hug" : 78 if current_room. move ( command ) 72 elif command = "talk" : 73 if current_room. lower () 69 70 if command in : 71 current_room = current_room. describe () 67 68 command = input ( "> " ). item = cheese 51 52 ''' 53 # describe the rooms 54 scribe() 55 scribe() 56 lab.describe() 57 ''' 58 59 # initialise variables 60 running = True 61 current_room = cavern 62 backpack = 63 64 # - MAIN LOOP - 65 while running : 66 current_room. description = "wanting to be tickled" 46 47 # add items to rooms 48 cavern. description = "designed to be sat on" 43 44 elmo = Item ( "Elmo" ) 45 elmo. description = "super smelly" 40 41 chair = Item ( "Chair" ) 42 chair. character = nigel 36 37 # create items 38 cheese = Item ( "Cheese" ) 39 cheese. ![]() conversation = "Well youngan, what are you doing here?" 32 33 # add characters to rooms 34 armoury. description = "a burly dwarf with golden bead in woven through his beard." 31 nigel. weakness = "cheese" 28 29 nigel = Friend ( "Nigel" ) 30 nigel. description = "a huge troll with rotting teeth." 27 ugine. link_rooms ( armoury, "west" ) 22 23 24 # create characters 25 ugine = Enemy ( "Ugine" ) 26 ugine. link_rooms ( cavern, "north" ) 20 armoury. link_rooms ( armoury, "south" ) 19 armoury. description = ( "A strange odour hangs in a room filled with unknownable contraptions." ) 16 17 # link rooms 18 cavern. description = ( "The walls are lined with racks that once held weapons and armour." ) 13 14 lab = Room ( "Laboratory" ) 15 lab. ![]() description = ( "A room so big that the light of your torch doesn’t reach the walls." ) 10 11 armoury = Room ( "Armoury" ) 12 armoury. To implement this, add the highlighted code below to main.py:ġ # main.py 2 3 from room import Room 4 from character import Enemy, Friend 5 from item import Item 6 7 # create rooms 8 cavern = Room ( "Cavern" ) 9 cavern. But how will the player know about the help command, without using the help command? Simple, we change the catch-all event handler (under the else:) to inform the user about the help command. To make life easier for new players, we should create a help command which lists all the commands. In addition, if they don’t enter one of the commands, the program only says I don't understand., which is far from helpful. Someone else might not know what they can say. ![]() We know all the commands we can use because we wrote the code. Improve the user experience and user interface We have a fully functioning game, but before we sign-off we need to improve the useability of our program and tidy up our code. Toggle table of contents sidebar Stage 8 - Useability # ![]()
0 Comments
Read More
Leave a Reply. |