diff --git a/assets/story/boss_fight/bar_de_vie.png b/assets/story/boss_fight/barre_de_vie.png similarity index 100% rename from assets/story/boss_fight/bar_de_vie.png rename to assets/story/boss_fight/barre_de_vie.png diff --git a/src/scenes/story/boss_fight.py b/src/scenes/story/boss_fight.py index a352a8b..1f36a4f 100644 --- a/src/scenes/story/boss_fight.py +++ b/src/scenes/story/boss_fight.py @@ -5,6 +5,8 @@ Scene de Combat final contre edmond, inspiré du combat d'omega flowey dans unde from enum import Enum import random +import pygame + from engine import CurrentScene, Scene from engine.ecs import World from engine.math import Vec2 @@ -102,6 +104,12 @@ class Player: """ +class LifeBar: + """ + Composant qui represente la barre de vie du joueur. + """ + + def __initialize_world(world: World): """ TODO @@ -130,6 +138,22 @@ def __initialize_world(world: World): Player(), ) + world.new_entity().set( + Sprite( + world[Assets].get_texture("barre_de_vie"), + Vec2(100, 980), + 5, + ), + ) + + surface_carre = pygame.Surface((1240 * world[Life] / 100, 50)) + surface_carre.fill((42, 161, 245)) + world.new_entity().set(Sprite(surface_carre, Vec2(100, 980), 4), LifeBar()) + + surface_carre = pygame.Surface((1240, 50)) + surface_carre.fill((255, 225, 225)) + world.new_entity().set(Sprite(surface_carre, Vec2(100, 980), 3)) + def __move(world: World): """ @@ -229,6 +253,7 @@ def __check_hurt(world: World): entity.destroy() world.new_entity().set(Coroutine(__set_hurtable_hurt(world))) world.set(Hurtable.FALSE) + __update_life_bar(world) def __defeat(world: World): @@ -474,6 +499,16 @@ def __check_key_pressed(world: World): world.new_entity().set(Coroutine(__create_spike(world, 5.0))) +def __update_life_bar(world: World): + for entity in world.query(LifeBar): + if world[Life] == 0: + entity.destroy() + else: + surface_carre = pygame.Surface((1240 * world[Life] / 100, 50)) + surface_carre.fill((42, 161, 245)) + entity[Sprite].texture = surface_carre + + def __new_game_scene() -> Scene: """ Créer une nouvelle scène