Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.20 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.     '\033[31;10m 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.     'found a booby-trapped trapdoor, with explosives!'
  50. )
  51.  
  52. escape_chance = (
  53.     1,
  54.     1,
  55.     0
  56. )
  57.  
  58. trap = random.choice(traps)
  59.  
  60. # Temperature
  61.  
  62. temps = (
  63.     'cold',
  64.     'hot',
  65.     'cold',
  66.     'hot',
  67.     'cold',
  68.     'hot',
  69.     'freezing',
  70.     'boiling',
  71. )
  72. temp = random.choice(temps)
  73.  
  74. # Brightness
  75.  
  76. brights = (
  77.     'dim',
  78.     'dim',
  79.     'dim',
  80.     'dim',
  81.     'bright',
  82.     'bright',
  83.     'bright',
  84.     'just about see-able'
  85. )
  86.  
  87. brightness = random.choice(brights)
  88.  
  89. # Room Code
  90.  
  91. trap_position = Trap(start_pos.size_of_room)
  92.  
  93.  
  94. def touch_wall():
  95.     if player.position.x == start_pos.size_of_room + 1 or player.position.y == start_pos.size_of_room + 1:
  96.         print('\nYou touched the spike walls, YOU LOSE!')
  97.         sys.exit(15)
  98.     if player.position.x == -1 or player.position.y == -1:
  99.         print('\nYou touched the spike walls, YOU LOSE!')
  100.         sys.exit(15)
  101.  
  102.  
  103. def touch_trap():
  104.     if player.position.x == trap_position.x_pos_trap or player.position.y == trap_position.x_pos_trap:
  105.         print(f'You {trap}')
  106.         escape = random.choice(escape_chance)
  107.         if escape == 0:
  108.             print('But you escaped!')
  109.         elif escape == 1:
  110.             print('You died!')
  111.             sys.exit(15)
  112.  
  113.  
  114. print(f'The room is {temp}, and {brightness}, and there might be a trap!')
  115. print(f'\nYou start in a room that is {start_pos.size_of_room} x {start_pos.size_of_room}, your starting position is x: '
  116.       f'{start_pos.starting_x}, and y: {start_pos.starting_y}')
  117. in_room = True
  118. while in_room:
  119.     w_a_s_d = input('Enter a control: ')
  120.     if w_a_s_d == 'w':
  121.         print(f'\nYou chose up')
  122.         direction1 = 'w'
  123.     elif w_a_s_d == 'a':
  124.         print(f'\nYou chose left')
  125.         direction1 = 'a'
  126.     elif w_a_s_d == 's':
  127.         print(f'\nYou chose down')
  128.         direction1 = 's'
  129.     elif w_a_s_d == 'd':
  130.         print(f'\nYou chose right')
  131.         direction1 = 'd'
  132.     elif w_a_s_d == '/size':
  133.         print(f'The room size is {start_pos.size_of_room} x {start_pos.size_of_room}.')
  134.         continue
  135.     else:
  136.         print('\nInvalid Control')
  137.         sys.exit(25)
  138.  
  139. # if choosing
  140.  
  141.     if direction1 == 'w':
  142.         player.position.move_up()
  143.         touch_wall()
  144.         touch_trap()
  145.         print(f' You are now x: {player.position.x}, y: {player.position.y}')
  146.  
  147.     elif direction1 == 's':
  148.         player.position.move_down()
  149.         touch_wall()
  150.         touch_trap()
  151.         print(f' You are now x: {player.position.x}, y: {player.position.y}')
  152.  
  153.     elif direction1 == 'a':
  154.         player.position.move_left()
  155.         touch_wall()
  156.         touch_trap()
  157.         print(f' You are now x: {player.position.x}, y: {player.position.y}')
  158.  
  159.     elif direction1 == 'd':
  160.         player.position.move_right()
  161.         touch_wall()
  162.         touch_trap()
  163.         print(f' You are now x: {player.position.x}, y: {player.position.y}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement