From ea2bc80c274fa9b825d303098fe137f4862179aa Mon Sep 17 00:00:00 2001 From: Benjamin Date: Fri, 12 Jun 2026 17:48:59 +0200 Subject: [PATCH] =?UTF-8?q?Ladelevel-Methode=20hinzugef=C3=BCgt,=20um=20Ka?= =?UTF-8?q?rten=20dynamisch=20zu=20laden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/game.py b/game.py index 86bdd4e..ae48433 100644 --- a/game.py +++ b/game.py @@ -74,10 +74,7 @@ class Game: self.tilemap: Tilemap = Tilemap(game=self, tile_size=16) - try: - self.tilemap.load(path="map.json") - except FileNotFoundError: - pass + self.load_level(0) self.leaf_spawners: list[pygame.Rect] = [] self.enemys: list[Enemy] = [] @@ -101,6 +98,12 @@ class Game: self.scroll: list[float] = [0, 0] # self.boost: bool = False + def load_level(self, map_id: int): + try: + self.tilemap.load(path="data/maps/" + str(map_id) + ".json") + except FileNotFoundError: + pass + def run(self) -> None: while self.running: self.display.blit(self.assets["background"], (0, 0))