dotfiles/.config/Code/User/History/-4c5a7b2f/EEDz.py

34 lines
812 B
Python
Raw Normal View History

2024-09-09 16:59:28 +05:00
import random
class Player:
def __init__(self, name: str) -> None:
self.name = name
self.score = 0
self.health = 100
self.x = 0
self.y = 0
class DungeonGame:
def __init__(self, name: str) -> None:
self.player = Player(name)
self.grid = [[],[],[],[],[]]
self.grid_init()
def grid_init(self):
for row in self.grid:
for i in range(5):
row.append(random.choice(['T', 'H', 'E']))
self.grid[self.player.x][self.player.y] = '@'
def display(self):
for row in self.grid:
for col in row:
print(col, end=' ')
print()
game = DungeonGame('rafay')
while not game_over:
game.display()
a = input('enter a direction to move the player: ')