Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- from random import randrange,randint
- import replit
- from replit import clear
- clear()
- gameOver = False
- print("Use command 'help' for help")
- x = input("Pick a FLOOR size (recommended 10): ")
- x = int(x) + 1
- #General Variable Bank
- door_xy_bottom = [x-1,x//2]
- door_xy_top = [-1*(x),x//2]
- sword = [randint(0,x-1),randint(0,x-1)]
- stone = [randint(0,x-1),randint(0,x-1)]
- CHAR_XY = [x//2,x//2]
- ROOM = 1
- FLOOR = 1
- pls = '+'
- DUNGEON = [
- [ #First FLOOR of the DUNGEON
- [(x)* [pls] for i in range(x)], #ROOM 1 (0)
- [(x)* [pls] for i in range(x)], #ROOM 2 (1)
- [(x)* [pls] for i in range(x)], #ROOM 3 (2)
- [(x)* [pls] for i in range(x)], #ROOM 4 (3)
- [(x*2)* [pls] for i in range(x*2)] #ROOM 5 (4)
- ],
- [ #second FLOOR of the DUNGEON
- [(x)* pls] for i in range(x)],
- ]
- #DUNGEON Generation
- def dngn():
- global FLOOR
- global ROOM
- global DUNGEON
- a = FLOOR - 1
- r = ROOM - 1
- if r == 0:
- DUNGEON[a][r][CHAR_XY[0]][CHAR_XY[1]] = '@'
- #Places the bottom door 'D'
- DUNGEON[a][r][door_xy_bottom[0]][door_xy_bottom[1]] = 'D'
- if r > 0:
- DUNGEON[a][r][CHAR_XY[0]][CHAR_XY[1]] = '@'
- #Places the bottom and top door 'D'
- DUNGEON[a][r][door_xy_bottom[0]][door_xy_bottom[1]] = 'D'
- DUNGEON[a][r][door_xy_top[0]][door_xy_top[1]] = 'D'
- if r == 4:
- DUNGEON[a][r][CHAR_XY[0]][CHAR_XY[1]] = '@'
- #Places the top door 'D'
- DUNGEON[a][r][door_xy_top[0]][door_xy_top[1]] = 'D'
- print("FLOOR " + str(FLOOR) + " ROOM " + str(ROOM))
- print('\n'.join(' '.join(row) for row in DUNGEON[a][r]))
- #Possible Player Actions
- def plyrMove():
- global CHAR_XY
- global FLOOR
- global ROOM
- t = input("What do you want to do?: ")
- if t == "help":
- clear()
- print(
- 'left - Moves the player left\n' +
- 'right - Moves the player right\n' +
- 'up - Moves the player up\n' +
- 'down - Moves the player down\n' +
- 'grab - Grabs item in a chosen direction\n' +
- 'fight - Fights a monster in a chosen direction'
- )
- i = input('Press enter to continue')
- clear()
- dngn()
- plyrMove()
- elif t == "left" or t == 'a':
- clear()
- CHAR_XY[1] -= 1
- dngn()
- elif t == "right" or t == 'd':
- clear()
- CHAR_XY[1] += 1
- dngn()
- elif t == "up" or t == 'w':
- clear()
- CHAR_XY[0] -= 1
- dngn()
- elif t == "down" or t == 's':
- clear()
- CHAR_XY[0] += 1
- dngn()
- elif t == '+':
- clear()
- ROOM = ROOM + 1
- if ROOM == 6:
- ROOM = 1
- FLOOR = FLOOR + 1
- dngn()
- else:
- clear()
- t = input('Invalid move! Press enter to retry!')
- clear()
- dngn()
- plyrMove()
- #Stagnant Generators (Does not refresh every turn)
- #Places 0-4 random swords throughout the entire FLOOR
- for i in range(4):
- DUNGEON[FLOOR-1][randint(0,4)][sword[0]][sword[1]] = '/'
- #Game loop
- dngn()
- while gameOver == False:
- plyrMove()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement