|
|
@ -1,7 +1,7 @@ |
|
|
|
from charaters.personnage import Personnage, ClassType |
|
|
|
from game.personnage import Personnage, ClassType |
|
|
|
|
|
|
|
from graphics.colors import Colors |
|
|
|
from graphics.writer import Layer |
|
|
|
from graphics.engine import Layer |
|
|
|
|
|
|
|
from getkey import keys |
|
|
|
from re import match |
|
|
@ -13,7 +13,8 @@ class GUI(Layer): |
|
|
|
self.current = 0 |
|
|
|
|
|
|
|
self.handle_keys = False |
|
|
|
self.personnage = Personnage(" ", ClassType.GUERRIER) |
|
|
|
#self.personnage = Personnage(" ", ClassType.GUERRIER) |
|
|
|
#self.ennemy = Personnage("Zombie", ClassType.ZOMBIE) |
|
|
|
|
|
|
|
def draw(self): |
|
|
|
super().draw() |
|
|
@ -25,12 +26,16 @@ class GUI(Layer): |
|
|
|
self.put_string(button, x, self.y-10, color) |
|
|
|
x += len(button)+1 |
|
|
|
|
|
|
|
stats = self.personnage.affiche_caracteristiques() |
|
|
|
stats = self.screen.game.personnage.affiche_caracteristiques() |
|
|
|
for i in range(4): |
|
|
|
self.put_string(stats[i], 0, self.y-8+i, [Colors.RED2]) |
|
|
|
for i in range(7): |
|
|
|
self.put_string(stats[i+4], 40, self.y-8+i, [Colors.RED2]) |
|
|
|
|
|
|
|
ennemy_stats = self.screen.game.ennemy.reduced_stats() |
|
|
|
for i in range(3): |
|
|
|
self.put_string(ennemy_stats[i], 80, self.y-8+i, [Colors.BLUE2]) |
|
|
|
|
|
|
|
return self |
|
|
|
|
|
|
|
def key_handler(self, key): |
|
|
@ -38,13 +43,15 @@ class GUI(Layer): |
|
|
|
self.current += 1 |
|
|
|
elif key == keys.LEFT and self.current > 0: |
|
|
|
self.current -= 1 |
|
|
|
elif key == keys.ENTER and self.current == 0: |
|
|
|
attacker = self.screen.game.personnage |
|
|
|
victim = self.screen.game.ennemy |
|
|
|
self.screen.game.attack(attacker, victim) |
|
|
|
|
|
|
|
|
|
|
|
class PopUp(Layer): |
|
|
|
class StartPopUp(Layer): |
|
|
|
def __init__(self, screen, z_index): |
|
|
|
super().__init__(screen, z_index, "popup") |
|
|
|
#screen.add_key_handler(self.key_handler) |
|
|
|
|
|
|
|
self.__classes = ["GUERRIER", "MAGICIEN", "VOLEUR", "ELF"] |
|
|
|
self.__choosen_class = 0 |
|
|
|
self.__username = "" |
|
|
@ -53,12 +60,10 @@ class PopUp(Layer): |
|
|
|
super().draw() |
|
|
|
#bg |
|
|
|
self.rect(self.x//3, self.y//6, self.x//3 + self.x//4, self.y//4 + self.y//3, Colors.WHITEBG) |
|
|
|
|
|
|
|
#name |
|
|
|
self.put_string("Nom: [A-z]", self.x//3 + 1, self.y//6 + 1, [Colors.WHITEBG, Colors.BLACK]) |
|
|
|
self.rect(self.x//3 + 1, self.y//6 + 2, self.x//3 + self.x//4 - 1, self.y//6 + 2, Colors.BLACKBG) |
|
|
|
self.put_string(self.__username, self.x//3 + 1, self.y//6 + 2, [Colors.WHITE, Colors.BLACKBG]) |
|
|
|
|
|
|
|
#Classes |
|
|
|
self.put_string("Classe perso.: SHIFT+[1-4]", self.x//3 + 1, self.y//6 + 4, [Colors.WHITEBG, Colors.BLACK]) |
|
|
|
y = 0 |
|
|
@ -83,4 +88,5 @@ class PopUp(Layer): |
|
|
|
elif key == keys.TAB: |
|
|
|
self.screen.get_layer("gui").handle_keys = True |
|
|
|
self.screen.del_layer("popup") |
|
|
|
self.screen.get_layer("gui").personnage = Personnage(self.__username, ClassType[self.__classes[self.__choosen_class]]) |
|
|
|
self.screen.game.personnage = Personnage(self.__username, ClassType[self.__classes[self.__choosen_class]]) |
|
|
|
#self.screen.get_layer("gui").personnage = Personnage(self.__username, ClassType[self.__classes[self.__choosen_class]]) |