diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..023a2d8 Binary files /dev/null and b/icon.png differ diff --git a/src/engine/plugins/pygame.py b/src/engine/plugins/pygame.py index a0b916c..4a6ffd7 100644 --- a/src/engine/plugins/pygame.py +++ b/src/engine/plugins/pygame.py @@ -4,7 +4,7 @@ Définit un plugin qui gère les évenements pygame. from engine import * from engine.math import Vec2 -import pygame +import pygame, os class PygamePlugin(Plugin): @@ -12,6 +12,9 @@ class PygamePlugin(Plugin): Plugin qui gère les évenements pygame. """ + def __init__(self, title: str = "Game") -> None: + self.title = title + @staticmethod def _find_surface_rect() -> tuple[float, float, float, float]: width, height = pygame.display.get_surface().get_size() @@ -26,11 +29,14 @@ class PygamePlugin(Plugin): return rect @staticmethod - def _initialize(world: World) -> None: + def _initialize(world: World, title: str) -> None: """ Initialize pygame et les ressources. """ pygame.init() + if os.path.exists("icon.png"): + pygame.display.set_icon(pygame.image.load("icon.png")) + pygame.display.set_caption(title) pygame.display.set_mode((800, 600), pygame.RESIZABLE) # Initialisation des ressources @@ -112,7 +118,9 @@ class PygamePlugin(Plugin): Paramètres: game: Le jeu auquel appliquer le plugin. """ - game.add_pre_startup_tasks(self._initialize) + game.add_pre_startup_tasks( + lambda world: PygamePlugin._initialize(world, self.title) + ) game.add_pre_update_tasks(self._check_events) game.add_post_render_tasks(self._update_display) game.add_post_shutdown_tasks(self._terminate) diff --git a/src/main.py b/src/main.py index 404f88d..52f9f18 100644 --- a/src/main.py +++ b/src/main.py @@ -19,7 +19,7 @@ from random import random # Initialisation -game = Game(TimePlugin(), PygamePlugin(), RenderPlugin()) +game = Game(TimePlugin(), PygamePlugin("Guess The Number"), RenderPlugin()) # On créer une tache pour afficher des sprites