Layer fonctionellent

This commit is contained in:
barraux.a
2022-09-09 07:12:23 +02:00
parent 60d0ae42db
commit 59cdf71d6e
2 changed files with 62 additions and 36 deletions
+31 -14
View File
@@ -5,13 +5,25 @@ import time
class Animation:
""" class de gestion des animations"""
def __init__(self):
self.shape = ['', '']
def __init__(self, x, y, shape):
self.x = x
self.y = y
self.shape = shape
def blink(self):
pass
def blink(self, start_color, end_color):
self.layer = cli.Layer(gui, self.x, self.y, self.shape[0].split('\n'))
for i in range(8):
self.layer.refresh()
if i % 2 == 0:
self.display('right', color = start_color)
else:
self.display('right', color = end_color)
gui.display()
time.sleep(0.4)
del self.layer
def display(self, x, y, side, **kwargs):
def display(self, side, **kwargs):
if side == 'right':
cuted_shape = self.shape[0].split('\n')
else:
@@ -19,18 +31,21 @@ class Animation:
for i in range(len(cuted_shape)):
for key, value in kwargs.items():
if key == 'color':
gui.draw(cuted_shape[i], x, y + i, color=value)
gui.draw(cuted_shape[i], self.x, self.y + i, color=value)
class Personnage(Animation):
def __init__(self, nom):
super().__init__()
self.nom = nom
self.pdv = 2
self.max_pdv = 20
self.xp = 1
self.inv = ['potion']
self.shape = ''
self.shape = ['', '']
self.x = 80
self.y = 5
super().__init__(self.x, self.y, self.shape)
def jet_attaque(self):
return random.randint(20) + self.xp * 2
@@ -82,11 +97,13 @@ gui = cli.Cli(width=120, height=36)
guerrier = Guerrier('arthur')
for i in range(60):
gui.draw(guerrier.nom, 53, 31, color='GREEN')
gui.draw_life(round(guerrier.pdv / guerrier.max_pdv * 100), 30, 30)
Elfe('Legolas').display(110-i*2, 10, 'right', color='BLUE')
gui.wipe()
gui.draw(guerrier.nom, 53, 31, color='GREEN')
gui.draw_life(round(guerrier.pdv / guerrier.max_pdv * 100), 30, 30)
guerrier.display('right', color='BLUE')
gui.display()
gui.display()
time.sleep(0.1)
guerrier.blink('RED', 'WHITE')
gui.display()