update
This commit is contained in:
parent
2992f4f408
commit
4f46de8d00
3330 changed files with 394553 additions and 76939 deletions
41
.config/Code/User/History/-4c5a7b2f/gDco.py
Normal file
41
.config/Code/User/History/-4c5a7b2f/gDco.py
Normal 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: ')
|
Loading…
Add table
Add a link
Reference in a new issue