diff --git a/assets/story/boss_fight/game_over.mp3 b/assets/story/boss_fight/game_over.mp3 new file mode 100644 index 0000000..034338b Binary files /dev/null and b/assets/story/boss_fight/game_over.mp3 differ diff --git a/src/scenes/base_game.py b/src/scenes/base_game.py index 8d3a62d..32eb3a0 100644 --- a/src/scenes/base_game.py +++ b/src/scenes/base_game.py @@ -3,7 +3,10 @@ Définit 3 scènes de jeu basique """ from enum import Enum +import enum import random +from turtle import position +from winreg import QueryInfoKey import pygame from engine import CurrentScene, KeepAlive, Scene, Plugin from engine.ecs import Entity, World @@ -68,6 +71,15 @@ class PlayAgain: """ +class Historic: + """ + Ressource qui represente les ancien essais et leurs resultats + """ + + def __init__(self) -> None: + self.historique: list[str] = [] + + def __return_to_menu(world: World, _entity: Entity): """ Reviens sur le menu lorsque l'on clique sur la flèche de retour. @@ -77,8 +89,7 @@ def __return_to_menu(world: World, _entity: Entity): def __initialize_world(world: World): - world.set(Number(random.randint(0, 99))) - world.set(IsRunning()) + world.set(Number(random.randint(0, 99)), IsRunning(), Historic()) world.new_entity().set(Sprite(world[Assets].get_texture("background"))) world.new_entity().set( @@ -218,10 +229,17 @@ def __update(world: World): if world[GameMode] != GameMode.LIAR or not lying: for response in world.query(Text, Response): response[Text].text = "Plus petit" - # Sinon il dit l'invers + world[Historic].historique.append( + f"plus petit que {int(entity[Text].text)}" + ) + + # Sinon il dit l'inverse else: for response in world.query(Text, Response): response[Text].text = "Plus grand" + world[Historic].historique.append( + f"plus grand que {int(entity[Text].text)}" + ) # Dans tout les cas world[RemainingAttempts] -= 1 @@ -236,9 +254,15 @@ def __update(world: World): if world[GameMode] != GameMode.LIAR or not lying: for response in world.query(Text, Response): response[Text].text = "Plus grand" + world[Historic].historique.append( + f"plus grand que {int(entity[Text].text)}" + ) else: for response in world.query(Text, Response): response[Text].text = "Plus petit" + world[Historic].historique.append( + f"plus petit que {int(entity[Text].text)}" + ) world[RemainingAttempts] -= 1 for attempts in world.query(Text, Attempts): @@ -279,6 +303,40 @@ def __update(world: World): # on modifie le nombre en ajoutant un nombre de l'intervalle [-3, 3] world[Number] += max(0, min(99, random.randint(-3, 3))) + match world[GameMode]: + case GameMode.CLASSIC: + text_color = pygame.Color(64, 37, 146) + case GameMode.LIAR: + text_color = pygame.Color(57, 160, 0) + case GameMode.CHEATER: + text_color = pygame.Color(133, 51, 25) + + if IsRunning in world: + for i, text in enumerate(world[Historic].historique): + if i <= 7: + world.new_entity().set( + Text( + text, + color=text_color, + position=Vec2(200, (i * 50) + 550), + order=5, + ), + Historic(), + ) + else: + world.new_entity().set( + Text( + text, + color=text_color, + position=Vec2(950, (i * 50) + 150), + order=5, + ), + Historic(), + ) + else: + for entities in world.query(Historic): + entities.destroy() + # Definit la Scene "par defaut" qui contient l'entireté des 3 modes en fonction de GameMode __SCENE = ( diff --git a/src/scenes/story/boss_fight.py b/src/scenes/story/boss_fight.py index 910ad46..cc134b2 100644 --- a/src/scenes/story/boss_fight.py +++ b/src/scenes/story/boss_fight.py @@ -347,6 +347,7 @@ def __defeat(world: World): world.new_entity().set( Sprite(world[Assets].error_texture, order=20), Animation("animation_bg_mort", 24), + Sound(world[Assets].get_sound("game_over"), True, 0.5, 10000), ) elif len(world[Held]) > 0 and len(world.query(Animation)) == 0: world[CurrentScene] = __new_game_scene() @@ -354,6 +355,7 @@ def __defeat(world: World): def __wave(world: World): entities: list[Entity] = [] + yield wait(5) for i, actuel_wave in enumerate(world[Wave].wave_list): print("vague n°" + str(i)) for i, fonction in enumerate(actuel_wave): @@ -639,7 +641,7 @@ def __horizontal_projectile(world: World, left: bool, number: int = 10): HorizontalProjectiles(), Sprite( world[Assets].get_texture("projectiles_coming/0000"), - Vec2(10 if left else render.WIDTH - 10, random.randint(500, 889)), + Vec2(10 if left else render.WIDTH - 51, random.randint(500, 889)), 4, ), animation,