Advertisement
HauntJemimah

Untitled

Feb 9th, 2014
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.77 KB | None | 0 0
  1. # Lab 7
  2.  
  3. # 7.1: This game will be a text adventure game
  4.  
  5. # Directions include: north, east, south, or west
  6.  
  7. # 7.2 Sample Run:
  8.  
  9. # You are in a dusty castle room.
  10. # Passages lead to the north and south.
  11. # What direction? n
  12.  
  13. # You are in the armory.
  14. # There is a room off to the south.
  15. # What direction? s
  16.  
  17. # You are in a dusty castle room.
  18. # Passages lead to the north and south.
  19. # What direction? s
  20.  
  21. # You are in a torch-lit hallway.
  22. # There are rooms to the east and west.
  23. # What direction? e
  24.  
  25. # You are in a bedroom. A window overlooks the castle courtyard.
  26. # A hallway is to the west.
  27. # What direction? w
  28.  
  29. # You are in a torch-lit hallway.
  30. # There are rooms to the east and west.
  31. # What direction? w
  32.  
  33. # You are in the kitchen. It looks like a roast is being made for supper.
  34. # A hallway is to the east.
  35. # What direction? w
  36.  
  37. # Can't go that way.
  38. # You are in the kitchen. It looks like a roast is being made for supper.
  39. # A hallway is to the east.
  40. # What direction?
  41.  
  42.  
  43.  
  44.  
  45. # 7.3 Step-by-step Instructions
  46.  
  47. # 1. Create an empty array called room_list
  48.  
  49. # 2. Create a variable called room. Set it equal to an array with five elements.
  50. # For the first element, create a string with description of your first room.
  51. # The last four elements will be the number of the next room if the user goes
  52. # north, east, south, or west. Use None if no room hooks up to it.
  53. # (Do not put None in quotes. It is a special value that represents no value.)
  54.  
  55. # ^ I think he's talking about NoneType or zero, one of the two
  56.  
  57. # 3. Append tis room the room_list
  58.  
  59. # 4. Repeat the prior two steps for each room you want to create.
  60. # Just re-use the room variable.
  61.  
  62. # 5. Create a variable called current_room. Set it to zero.
  63.  
  64. # 6. Using current_room and room_list, print the current room the user is in.
  65. # Run the program and confirm you get output similar to:
  66.  
  67. # ['You are in a room. There is a passage to the north.', 1, None, None, None]
  68.  
  69. # 7. Change the print statement so that you only print the description of the
  70. # room, and not the rooms that hook up to it: You are in a room.
  71. # There is a passage to the north.
  72.  
  73. # 8. Create a variable called done and set it to False.
  74. # Then put the printing of the room description in a while loop that repeats
  75. # until done is set to True.
  76.  
  77. # 9. After printing the room description, add a line of code that asks the
  78. # user what direction they wish to go.
  79.  
  80. # 10. Add an if statement to see if the user wants to go north.
  81.  
  82. # 11. If the user wants to go north, create a variable called next_room
  83. # and get it equal to room_list[current_room][1], which should be the number
  84. # for what room is to the north.
  85.  
  86. # 12. Add another if statement to see if the next room is equal to None.
  87. # If it is, print "You can't go that way."
  88. # Otherwise set current_room equal to next_room.
  89.  
  90. # 13. Test your program. Can you go north to another room?
  91.  
  92. # SIDE NOTE, Redesign the path of these rooms later on to fit the layout
  93. # that the author wants on paper with a paper grid map
  94.  
  95. room_list = []
  96.  
  97. room = [0, 1, 2, 3, 4]
  98.  
  99. # COURTYARD
  100.  
  101. room[0] = "You have entered the castle courtyard. \n\nBirds bounce upon the stony courtyard and fly off into the distant blue sky"
  102.  
  103. # Directions: North, East, South, or West
  104.  
  105. # NORTH (Throne Room aka Room 1)
  106. room[1] = 1
  107.  
  108. # EAST
  109. room[2] = None
  110.  
  111. # SOUTH
  112. room[3] = None
  113.  
  114. # WEST
  115. room[4] = None
  116.  
  117. room_list.append(room)
  118.  
  119. # Golden throne room with silver chalice spewing crimson blood:
  120. room = [0, 1, 2, 3, 4]
  121.  
  122. room[0] = "You have entered what appears to be a throne room, caressed in gold in every direction.\n\nRubies, sapphires, and emeralds sparkle on the throne, while a silver chalice keeps overflowing crimson blood from some unknown source on a pedestal."
  123.  
  124. # Directions: North, East, South, or West
  125.  
  126. # NORTH (Armory aka Room 4)
  127. room[1] = 4
  128.  
  129. # EAST (Dining Room aka Room 3)
  130. room[2] = 3
  131.  
  132. # SOUTH (Courtyard aka Room 0)
  133. room[3] = 0
  134.  
  135. # WEST (Electric Billiard Room aka Room 2)
  136. room[4] = 2
  137.  
  138. room_list.append(room)
  139.  
  140. # Create an electric billiard room with lightning spokes at each corner of the table
  141.  
  142. room = [0, 1, 2, 3, 4]
  143.  
  144. room[0] = "You have entered an electric billiard room. \n\nLightning spokes are at each end of the table and spark blue waves of electricity every five seconds. \n\nThe room is dimly lit but covered in a blue aura."
  145.  
  146. # NORTH
  147. room[1] = None
  148.  
  149. # EAST (Throne Room aka Room 1)
  150. room[2] = 1
  151.  
  152. # SOUTH
  153. room[3] = None
  154.  
  155. # WEST
  156. room[4] = None
  157.  
  158. room_list.append(room)
  159.  
  160. # Green Dining Hall:
  161.  
  162. room = [0, 1, 2, 3, 4]
  163.  
  164. room[0] = "You have opened a huge brown door and walked down marble steps into what appears to be a dining hall. \n\nGreen garland and banners circle the ceiling with matching Bat crests. \n\nThe plates and dining ware are impeccable sterile, and shinking due to the white light cascading through the ceiling's circular window."
  165.  
  166. # NORTH
  167. room[1] = None
  168.  
  169. # EAST
  170. room[2] = None
  171.  
  172. # SOUTH
  173. room[3] = None
  174.  
  175. # WEST (Throne Room aka Room 1)
  176. room[4] = 1
  177.  
  178. room_list.append(room)
  179.  
  180. # Armory:
  181.  
  182. room = [0, 1, 2, 3, 4]
  183.  
  184. room[0] = "You have opened a silver door to enter the armory. \n\nEach delicately crafted piece of armor gives off a green glow, and claymores the size of the tallest man on earth hang on racks on the wall. \n\nEach sword glows red upon your approach to the center of the room and trembles violently, clashing against the wall."
  185.  
  186. # NORTH
  187. room[1] = None
  188.  
  189. # EAST
  190. room[2] = None
  191.  
  192. # SOUTH (Throne Room aka Room 1)
  193. room[3] = 1
  194.  
  195. # WEST
  196. room[4] = None
  197.  
  198. room_list.append(room)
  199.  
  200. current_room = 0
  201.  
  202. next_room = 0
  203.  
  204. # Create a boolean variable for a loop condition:
  205. done = False
  206.  
  207. while done == False:
  208. print("**************************")
  209. print("Welcome to Vampire Castle!")
  210. print("**************************")
  211. print("\n", room_list[next_room][0])
  212. direction = str(input("What direction would you like to go?\nOptions To Type: North, East, South, West.\nPress 'q' to quit."))
  213. direction = direction.lower()
  214. # User Selects North:
  215. if direction == "north":
  216. next_room = room_list[current_room][1]
  217. # User Selects East:
  218. elif direction == "east":
  219. next_room = room_list[current_room][2]
  220. # User Selects South:
  221. elif direction == "south":
  222. next_room = room_list[current_room][3]
  223. # User Selects West:
  224. elif direction == "west":
  225. next_room = room_list[current_room][4]
  226. # User Decides To Quit:
  227. elif direction == "q":
  228. done = True
  229. if direction is None:
  230. print("You can't go that way.")
  231. else:
  232. current_room = next_room
  233.  
  234. # Continue with Step 12
  235.  
  236. # Chapter 7 Lab Link:
  237.  
  238. # http://programarcadegames.com/index.php?chapter=lab_adventure
  239.  
  240. # Chapter 7 Chapter Link;
  241.  
  242. # http://programarcadegames.com/index.php?chapter=introduction_to_lists&lang=en#section_7
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement