diff --git a/assets/textures/animations/intro/info.json b/assets/textures/animations/intro/info.json index 1b15148..14ca4d6 100644 --- a/assets/textures/animations/intro/info.json +++ b/assets/textures/animations/intro/info.json @@ -1,9 +1,9 @@ { - "end_image": "0000.png", + "end_image": "story/chapter1/background.png", "offset": { "x": 0, "y": 0 }, - "frame_count": 268, + "frame_count": 529, "fps": 60 } \ No newline at end of file diff --git a/assets/textures/menu/background.png b/assets/textures/menu/background.png index 4bcbef6..a385d60 100644 Binary files a/assets/textures/menu/background.png and b/assets/textures/menu/background.png differ diff --git a/assets/textures/story/chapter1/background.png b/assets/textures/story/chapter1/background.png new file mode 100644 index 0000000..0f8c768 Binary files /dev/null and b/assets/textures/story/chapter1/background.png differ diff --git a/src/engine.py b/src/engine.py index e0b49e4..89a5da3 100644 --- a/src/engine.py +++ b/src/engine.py @@ -3,7 +3,6 @@ Un moteur de jeu inspiré de bevy. """ -import glob import json import math import os @@ -281,14 +280,8 @@ class Assets: pygame.draw.rect(error_texture, (255, 0, 255), (128, 128, 128, 128)) self.__error_texture = error_texture.convert(surface) - # Chargement des textures + # Cache des ressources self.__textures: dict[str, pygame.Surface] = {} - for file in glob.iglob("assets/textures/**/*.png", recursive=True): - self.__textures[file[16:].replace("\\", "/")] = pygame.image.load( - file - ).convert_alpha(surface) - - # Création du cache pour les polices self.__fonts: dict[int, pygame.font.Font] = {} def get_texture(self, name: str) -> pygame.Surface: @@ -301,7 +294,16 @@ class Assets: Retourne: La texture qui correspond au nom *name*. """ - return self.__textures.get(name, self.__error_texture) + texture = self.__textures.get(name) + if texture is None: + if os.path.exists(f"assets/textures/{name}"): + texture = pygame.image.load(f"assets/textures/{name}") + if not name.startswith("animations/"): + texture = texture.convert_alpha() + self.__textures[name] = texture + return texture + return self.__error_texture + return texture def get_texture_size(self, name: str) -> Vec2: """ diff --git a/src/main.py b/src/main.py index 0b4f1ae..1754bc0 100644 --- a/src/main.py +++ b/src/main.py @@ -10,7 +10,6 @@ from scenes import menu start_game( { "menu": menu.SCENE, - "classique": menu.SCENE, }, "menu", title="Guess The Number", diff --git a/src/scenes/menu.py b/src/scenes/menu.py index 58c683e..f59edc1 100644 --- a/src/scenes/menu.py +++ b/src/scenes/menu.py @@ -12,9 +12,6 @@ from engine import ( Order, Position, Scene, - Sound, - Text, - TextSize, Texture, World, ) @@ -39,16 +36,6 @@ def __initialize_world(world: World): Initialise le monde du menu. """ world.create_entity(Position(), Order(0), Texture("menu/background.png")) - - world.create_entity( - Position(Display.WIDTH / 2, 200), - Order(1), - Centered(), - Text("Guess The Number"), - TextSize(200), - Sound("pop.ogg", loop=True, callback=lambda _, _a: print("coucou")), - ) - scenes_name = ["classique", "menteur", "tricheur", "histoire"] for i, name in enumerate(scenes_name): __create_button(world, i, name)