diff --git a/assets/textures/boss_fight/boss_sprite/test/none/0.png b/assets/textures/boss_fight/boss_sprite/test/none/0.png new file mode 100644 index 0000000..dc99a26 Binary files /dev/null and b/assets/textures/boss_fight/boss_sprite/test/none/0.png differ diff --git a/assets/textures/boss_fight/boss_sprite/test/none/1.png b/assets/textures/boss_fight/boss_sprite/test/none/1.png new file mode 100644 index 0000000..16df971 Binary files /dev/null and b/assets/textures/boss_fight/boss_sprite/test/none/1.png differ diff --git a/assets/textures/boss_fight/fight_actions_GUI.png b/assets/textures/boss_fight/fight_actions_GUI.png new file mode 100644 index 0000000..c029a28 Binary files /dev/null and b/assets/textures/boss_fight/fight_actions_GUI.png differ diff --git a/assets/textures/boss_fight/player_big/none/0.png b/assets/textures/boss_fight/player_big/none/0.png new file mode 100644 index 0000000..04cf8a2 Binary files /dev/null and b/assets/textures/boss_fight/player_big/none/0.png differ diff --git a/assets/textures/boss_fight/player_big/none/1.png b/assets/textures/boss_fight/player_big/none/1.png new file mode 100644 index 0000000..53e27e3 Binary files /dev/null and b/assets/textures/boss_fight/player_big/none/1.png differ diff --git a/src/engine/boss_fight_manager.py b/src/engine/boss_fight_manager.py index d2d747b..dbe951d 100644 --- a/src/engine/boss_fight_manager.py +++ b/src/engine/boss_fight_manager.py @@ -3,10 +3,15 @@ from src.engine.enums import GameState class BossFightManager: + """Classe permettant de gérer les combats de boss.""" def __init__(self, core: "engine.Engine"): self.boss_name = "none" self.engine = core + self.current_boss_animation = "none" + self.current_player_animation = "none" + def update(self): + """Met à jour le combat de boss.""" if self.engine.game_state == GameState.BOSS_FIGHT: pass diff --git a/src/engine/renderer.py b/src/engine/renderer.py index 59b91ca..c3a1e4a 100644 --- a/src/engine/renderer.py +++ b/src/engine/renderer.py @@ -19,6 +19,10 @@ class Renderer: self.animations: dict[str: Anim] = {} self.boss_fight_animations: dict[str: Anim] = {} + # Variables utilisées pour les combats de boss + self.boss_fight_boss_animations: dict[str: Anim] = {} + self.boss_fight_player_animations: dict[str: Anim] = {} + self.boss_fight_GUI_container = None def load_tile_set(self, file_path: str, tile_size: int): """Charge le jeu de tuiles en utilisant le fichier donné et la taille donnée.""" @@ -60,7 +64,9 @@ class Renderer: self.window.blit(gui_surface, (0, 0)) elif self.engine.game_state == GameState.BOSS_FIGHT: - self.window.fill((255, 0, 0)) + self.window.fill((255, 230, 230)) + self.render_boss_fight_scene(delta) + self.render_boss_fight_gui() # Apres avoir tout rendu, on met à jour l'écran display.update() @@ -69,9 +75,43 @@ class Renderer: """Enregistre une animation.""" self.animations[name] = animation - def register_boss_fight_animation(self, animation: Anim, name: str): - """Enregistre une animation de combat de boss.""" - self.boss_fight_animations[name] = animation + def register_boss_fight_boss_animation(self, animation: Anim, name: str): + """Ajoute une animation pour le boss lors d'un combat de boss.""" + self.boss_fight_boss_animations[name] = animation + + def register_boss_fight_player_animation(self, animation: Anim, name: str): + """Ajoute une animation pour le joueur lors d'un combat de boss.""" + self.boss_fight_player_animations[name] = animation + + def render_boss_fight_scene(self, delta: float): + """Rend les sprites du joueur et du boss lors d'un combat de boss.""" + + # On récupère l'image de l'animation du boss + boss_animation: Anim = self.boss_fight_boss_animations[self.engine.boss_fight_manager.current_boss_animation] + frame = boss_animation.get_frame(delta) + + # On redimensionne l'image + frame = transform.scale(frame, (display.get_window_size()[0] / 5, display.get_window_size()[0] / 5)) + + # On colle le boss à droite de la fenêtre + self.window.blit(frame, (display.get_window_size()[0]-frame.get_width()-display.get_window_size()[0]/20, + display.get_window_size()[1]/4-frame.get_height()/2)) + + # On récupère l'image de l'animation du joueur + player_animation = self.boss_fight_player_animations[self.engine.boss_fight_manager.current_player_animation] + frame = player_animation.get_frame(delta) + + # On redimensionne l'image + frame = transform.scale(frame, (display.get_window_size()[0] / 5, display.get_window_size()[0] / 5)) + + # On colle le joueur à gauche de la fenêtre + self.window.blit(frame, (display.get_window_size()[0]/20, display.get_window_size()[1]/4-frame.get_height()/2)) + + def render_boss_fight_gui(self): + """Rend la barre d'action en bas de l'écran pendant le combat de boss.""" + + resized_container = transform.scale(self.boss_fight_GUI_container, (display.get_window_size()[0], self.boss_fight_GUI_container.get_height()/self.boss_fight_GUI_container.get_width()*display.get_window_size()[0])) + self.window.blit(resized_container, (0, display.get_window_size()[1]-resized_container.get_height())) def render_entities(self, rendered_surface: surface.Surface, gui_surface: surface.Surface, delta: float): """Rend toutes les entités.""" diff --git a/src/main.py b/src/main.py index c99a985..aa8cb9d 100644 --- a/src/main.py +++ b/src/main.py @@ -1,7 +1,8 @@ -import random +import pygame.image from src.engine.animation import Anim from src.engine.engine import Engine +from src.engine.enums import GameState class Game(Engine): @@ -12,6 +13,9 @@ class Game(Engine): self.renderer.load_tile_set("assets/textures/tiles.png", 16) self.create_player_entity() + self.load_boss_fight_assets() + + self.game_state = GameState.NORMAL def create_player_entity(self): """Crée une entité joueur.""" @@ -27,6 +31,17 @@ class Game(Engine): self.camera.follow_entity(player) + def load_boss_fight_assets(self): + """Charge les animations de combat des combats de boss.""" + player_none = Anim(1) + player_none.load_animation_from_directory("assets/textures/boss_fight/player_big/none") + self.renderer.register_boss_fight_player_animation(player_none, "none") + boss_none = Anim(1) + boss_none.load_animation_from_directory("assets/textures/boss_fight/boss_sprite/test/none") + self.renderer.register_boss_fight_boss_animation(boss_none, "none") + + self.renderer.boss_fight_GUI_container = pygame.image.load("assets/textures/boss_fight/fight_actions_GUI.png") + game = Game() game.loop()