Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- class dungeon():
- def __init__(self): #
- self.map = [[0,0,0,0,0],
- [0,0,0,0,0],
- [0,0,0,0,0],
- [0,0,0,0,0],
- [0,0,0,0,0]]
- self.spawnpointx = random.randint(0,2)
- self.spawnpointy = random.randint(0, 2)
- self.enemy_room = random.randint(1,2)
- def generatemap(self):
- posx = 0
- posy = 0
- while posx < 5 and posy < 5:
- self.map[posx][posy] = "R"
- posx = posx + 1
- while posx == 5:
- posx = 0
- posy = posy + 1
- posx = 0
- posy = 0
- while posx < 5 and posy < 5:
- if self.enemy_room == 2:
- self.map[posx][posy] = "E"
- self.enemy_room = random.randint(1, 2)
- posx = posx + 1
- while posx == 5:
- posx = 0
- posy = posy + 1
- self.map[self.spawnpointx][self.spawnpointy] = "S"
- return self.map
- def display(self):
- i = 0
- while i < len(self.map):
- print(self.map[i])
- i += 1
- def findlocation(self):
- print("You are in", self.map[self.spawnpointx][self.spawnpointy])
- Dungeon = dungeon()
- Dungeon.generatemap()
- Dungeon.display()
- Dungeon.findlocation()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement