Advertisement
Wyverm

Untitled

Mar 23rd, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. import random
  2. from random import randrange,randint
  3. import replit
  4. from replit import clear
  5. clear()
  6.  
  7. gameOver = False
  8. print("Use command 'help' for help")
  9. x = input("Pick a FLOOR size (recommended 10): ")
  10. x = int(x) + 1
  11.  
  12. #General Variable Bank
  13. door_xy_bottom = [x-1,x//2]
  14. door_xy_top = [-1*(x),x//2]
  15.  
  16. sword = [randint(0,x-1),randint(0,x-1)]
  17. stone = [randint(0,x-1),randint(0,x-1)]
  18.  
  19. CHAR_XY = [x//2,x//2]
  20.  
  21. ROOM = 1
  22. FLOOR = 1
  23.  
  24. pls = '+'
  25.  
  26. DUNGEON = [
  27. [ #First FLOOR of the DUNGEON
  28. [(x)* [pls] for i in range(x)], #ROOM 1 (0)
  29. [(x)* [pls] for i in range(x)], #ROOM 2 (1)
  30. [(x)* [pls] for i in range(x)], #ROOM 3 (2)
  31. [(x)* [pls] for i in range(x)], #ROOM 4 (3)
  32. [(x*2)* [pls] for i in range(x*2)] #ROOM 5 (4)
  33. ],
  34. [ #second FLOOR of the DUNGEON
  35. [(x)* pls] for i in range(x)],
  36. ]
  37.  
  38.  
  39. #DUNGEON Generation
  40. def dngn():
  41. global FLOOR
  42. global ROOM
  43. global DUNGEON
  44.  
  45. a = FLOOR - 1
  46. r = ROOM - 1
  47.  
  48.  
  49. if r == 0:
  50. DUNGEON[a][r][CHAR_XY[0]][CHAR_XY[1]] = '@'
  51. #Places the bottom door 'D'
  52. DUNGEON[a][r][door_xy_bottom[0]][door_xy_bottom[1]] = 'D'
  53.  
  54.  
  55. if r > 0:
  56. DUNGEON[a][r][CHAR_XY[0]][CHAR_XY[1]] = '@'
  57. #Places the bottom and top door 'D'
  58. DUNGEON[a][r][door_xy_bottom[0]][door_xy_bottom[1]] = 'D'
  59. DUNGEON[a][r][door_xy_top[0]][door_xy_top[1]] = 'D'
  60.  
  61.  
  62. if r == 4:
  63. DUNGEON[a][r][CHAR_XY[0]][CHAR_XY[1]] = '@'
  64. #Places the top door 'D'
  65. DUNGEON[a][r][door_xy_top[0]][door_xy_top[1]] = 'D'
  66. print("FLOOR " + str(FLOOR) + " ROOM " + str(ROOM))
  67. print('\n'.join(' '.join(row) for row in DUNGEON[a][r]))
  68.  
  69. #Possible Player Actions
  70. def plyrMove():
  71. global CHAR_XY
  72. global FLOOR
  73. global ROOM
  74.  
  75. t = input("What do you want to do?: ")
  76. if t == "help":
  77. clear()
  78. print(
  79. 'left - Moves the player left\n' +
  80. 'right - Moves the player right\n' +
  81. 'up - Moves the player up\n' +
  82. 'down - Moves the player down\n' +
  83. 'grab - Grabs item in a chosen direction\n' +
  84. 'fight - Fights a monster in a chosen direction'
  85. )
  86. i = input('Press enter to continue')
  87. clear()
  88. dngn()
  89. plyrMove()
  90. elif t == "left" or t == 'a':
  91. clear()
  92. CHAR_XY[1] -= 1
  93. dngn()
  94. elif t == "right" or t == 'd':
  95. clear()
  96. CHAR_XY[1] += 1
  97. dngn()
  98. elif t == "up" or t == 'w':
  99. clear()
  100. CHAR_XY[0] -= 1
  101. dngn()
  102. elif t == "down" or t == 's':
  103. clear()
  104. CHAR_XY[0] += 1
  105. dngn()
  106. elif t == '+':
  107. clear()
  108. ROOM = ROOM + 1
  109. if ROOM == 6:
  110. ROOM = 1
  111. FLOOR = FLOOR + 1
  112. dngn()
  113. else:
  114. clear()
  115. t = input('Invalid move! Press enter to retry!')
  116. clear()
  117. dngn()
  118. plyrMove()
  119.  
  120. #Stagnant Generators (Does not refresh every turn)
  121. #Places 0-4 random swords throughout the entire FLOOR
  122. for i in range(4):
  123. DUNGEON[FLOOR-1][randint(0,4)][sword[0]][sword[1]] = '/'
  124.  
  125. #Game loop
  126. dngn()
  127. while gameOver == False:
  128. plyrMove()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement