Created
August 21, 2025 10:05
-
-
Save horstjens/0df52780d843e91bbc73f9127433d042 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# lukas rogue 001 | |
level_0 = """ | |
################################################### | |
#.................................................# | |
#.................................................# | |
#.................................................# | |
#.................................................# | |
#.................................................# | |
#.................................................# | |
#.................................................# | |
#.................................................# | |
#.................................................# | |
################################################### | |
""" | |
class Monster: | |
number = 0 | |
zoo = {} | |
def __init__(self,x,y,z): | |
self.x = x | |
self.y = y | |
self.z = z | |
self.number = Monster.number | |
Monster.number+=1 | |
Monster.zoo[self.number] = self | |
class Player(Monster): | |
def __init__(self): | |
super().__init__(1,1,0) | |
self.hitpoints = 100 | |
self.char = "@" | |
hero = Player() | |
dungeon = [] | |
#print(hero.__dict__) | |
def loadlevel(name): | |
level = [list(line) for line in name.splitlines() | |
if len(line.strip()) > 0] | |
dungeon.append(level) | |
def game(): | |
print("welcome to the dungeon, o hero") | |
loadlevel(level_0) | |
while hero.hitpoints > 0: | |
# graphic engine | |
lines = dungeon[hero.z] | |
for y, line in enumerate(lines): | |
for x, char in enumerate(line): | |
for m in Monster.zoo.values(): | |
if m.z == hero.z: | |
if m.x == x: | |
if m.y == y: | |
symbol = m.char | |
break | |
else: | |
symbol = char | |
print(symbol, end="") | |
print() | |
print("status:") | |
command = input(">>>") | |
if command == "quit": | |
break | |
if __name__ == "__main__": | |
game() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment