This commit is contained in:
RafayAhmad7548 2024-09-09 16:59:28 +05:00
parent 2992f4f408
commit 4f46de8d00
3330 changed files with 394553 additions and 76939 deletions

View file

@ -0,0 +1,41 @@
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
def move_player(self, direction: str) -> None:
if direction == 'l':
if self.x > 0:
self.x -= 1
elif direction == 'r':
if self.x < 5:
self.x += 1
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:
a = input('enter a direction to move the player: ')