Created
November 7, 2018 18:59
-
-
Save PaulPolaschek/93f0404fde1ed1f8d006c34882c08a12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
""" | |
######################################### | |
#.......................................# | |
#.......................................# | |
######################################### | |
""" | |
maxlines=23 | |
maxchars=60 | |
d=[] | |
# --- generate dungeon --- | |
def generate_dungeon(): | |
for y in range(maxlines): | |
line=[] | |
for x in range(maxchars): | |
if x == 0 or y == 0 or x == (maxchars)-1 or y == maxlines-1: | |
line.append("#") | |
else: | |
line.append(random.choice(("."))) | |
d.append(line) | |
return d | |
# --- generate Monster | |
monster = "M" | |
mx= 40 | |
my= 10 | |
# --- view dungeon --- | |
#print(d) | |
d = generate_dungeon() | |
d0 = d[:] | |
while True: | |
d[my][mx]="M" | |
my+=random.choice((-1,0,0,0,1)) | |
mx+=random.choice((-1,0,0,0,1)) | |
for line in d: | |
for char in line: | |
print(char, end="") | |
print() | |
x=input() | |
if x == "q": | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment