Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.28 KB | None | 0 0
  1. import random
  2. import time
  3. import sys
  4. from SharkLearn.Adventure import p1_level, p2_level, p3_level, p4_level, p5_level, p6_level, p7_level, p8_level, \
  5.     p9_level, p10_level
  6. from SharkLearn.Classes2 import Trap, pl2, pl1, pl3, pl4, SizeAndPos, Position, start_pos
  7.  
  8. # Player Selection
  9.  
  10. player_selection = int(input("Select a player:\n\t1. jack\n\t2. Sharkbound\n\t3. Psuedo\n\t4. Anna\n> "))
  11. if player_selection == 1:
  12.     player_level = p1_level
  13.     player = pl1
  14.  
  15. elif player_selection == 2:
  16.     player_level = p2_level
  17.     player = pl2
  18.  
  19. elif player_selection == 3:
  20.     player_level = p3_level
  21.     player = pl3
  22.  
  23. elif player_selection == 4:
  24.     player_level = p4_level
  25.     player = pl4
  26.  
  27. else:
  28.     print('Invalid Number')
  29.  
  30. # Starting text and level
  31.  
  32. print('You wake up in a dark room, with very faint torches on the walls, you stand up,'
  33.       ' and walk through the door-frame in-front of you.....'
  34.       )
  35. time.sleep(1)
  36. print(f'You are level {player_level}')
  37.  
  38. # Controls
  39.  
  40. print('\nThe controls are w (up), a (left), s (down), d (right) and /size (gets room size)\n')
  41. time.sleep(0.5)
  42.  
  43. # Trap Code
  44.  
  45. traps = (
  46.     'fell into a pit trap!',
  47.     'stepped onto a pressure plate, which shot down spikes from the ceiling!',
  48.     'activated a trip wire, which proceeded to shoot spikes from the walls',
  49.     'opened a booby-trapped trapdoor, with explosives!'
  50. )
  51.  
  52. escape_chance = (
  53.     1,
  54.     0
  55. )
  56.  
  57. trap = random.choice(traps)
  58.  
  59. # Temperature
  60.  
  61. temps = (
  62.     'cold',
  63.     'hot',
  64.     'cold',
  65.     'hot',
  66.     'cold',
  67.     'hot',
  68.     'freezing',
  69.     'boiling',
  70. )
  71. temp = random.choice(temps)
  72.  
  73. # Brightness
  74.  
  75. brights = (
  76.     'dim',
  77.     'dim',
  78.     'dim',
  79.     'dim',
  80.     'bright',
  81.     'bright',
  82.     'bright',
  83.     'just about see-able'
  84. )
  85.  
  86. brightness = random.choice(brights)
  87.  
  88. # Room Code
  89.  
  90. trap_position = Trap(start_pos.size_of_room)
  91.  
  92. def touch_wall():
  93.     if player.position.x == start_pos.size_of_room + 1 or player.position.y == start_pos.size_of_room + 1:
  94.         print('\nYou touched the spike walls.\n\033[31;10m YOU DIED!')
  95.         sys.exit(15)
  96.     if player.position.x == -1 or player.position.y == -1:
  97.         print('\nYou touched the spike walls.\n\033[31;10m YOU DIED!')
  98.         sys.exit(15)
  99.  
  100.  
  101. def touch_trap():
  102.     if player.position.x == trap_position.x_pos_trap and player.position.y == trap_position.y_pos_trap:
  103.         print(f'You {trap}')
  104.         escape = random.choice(escape_chance)
  105.         if escape == 0:
  106.             print('\tBut you\033[32;10m ESCAPED!')
  107.         elif escape == 1:
  108.             print('\tYOU\033[31;10m DIED!')
  109.             sys.exit(15)
  110.  
  111.  
  112. print(f'The room is {temp}, {brightness}, and there might be a trap!')
  113. print(f'\nYou start in a room that is {start_pos.size_of_room} high and {start_pos.size_of_room} wide,'
  114.       f' your starting position is x: {start_pos.starting_x}, and y: {start_pos.starting_y}')
  115. in_room = True
  116. while in_room:
  117.     w_a_s_d = input('Enter a control: ')
  118.     if w_a_s_d == 'w':
  119.         print(f'\nYou chose up')
  120.         direction1 = 'w'
  121.     elif w_a_s_d == 'a':
  122.         print(f'\nYou chose left')
  123.         direction1 = 'a'
  124.     elif w_a_s_d == 's':
  125.         print(f'\nYou chose down')
  126.         direction1 = 's'
  127.     elif w_a_s_d == 'd':
  128.         print(f'\nYou chose right')
  129.         direction1 = 'd'
  130.     elif w_a_s_d == '/size':
  131.         print(f'The room size is {start_pos.size_of_room} high and {start_pos.size_of_room} wide.')
  132.         continue
  133.     else:
  134.         print('\nInvalid Control')
  135.         continue
  136. # if choosing
  137.  
  138.     if direction1 == 'w':
  139.         player.position.move_up()
  140.         touch_wall()
  141.         touch_trap()
  142.         print(f'\033[30;0m You are now x: {player.position.x}, y: {player.position.y}')
  143.  
  144.     elif direction1 == 's':
  145.         player.position.move_down()
  146.         touch_wall()
  147.         touch_trap()
  148.         print(f'\033[30;0m You are now x: {player.position.x}, y: {player.position.y}')
  149.  
  150.     elif direction1 == 'a':
  151.         player.position.move_left()
  152.         touch_wall()
  153.         touch_trap()
  154.         print(f'\033[30;0m You are now x: {player.position.x}, y: {player.position.y}')
  155.  
  156.     elif direction1 == 'd':
  157.         player.position.move_right()
  158.         touch_wall()
  159.         touch_trap()
  160.         print(f'\033[30;0m You are now x: {player.position.x}, y: {player.position.y}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement