Ladelevel-Methode hinzugefügt, um Karten dynamisch zu laden
This commit is contained in:
parent
aa8f10a08a
commit
ea2bc80c27
1 changed files with 7 additions and 4 deletions
11
game.py
11
game.py
|
|
@ -74,10 +74,7 @@ class Game:
|
||||||
|
|
||||||
self.tilemap: Tilemap = Tilemap(game=self, tile_size=16)
|
self.tilemap: Tilemap = Tilemap(game=self, tile_size=16)
|
||||||
|
|
||||||
try:
|
self.load_level(0)
|
||||||
self.tilemap.load(path="map.json")
|
|
||||||
except FileNotFoundError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
self.leaf_spawners: list[pygame.Rect] = []
|
self.leaf_spawners: list[pygame.Rect] = []
|
||||||
self.enemys: list[Enemy] = []
|
self.enemys: list[Enemy] = []
|
||||||
|
|
@ -101,6 +98,12 @@ class Game:
|
||||||
self.scroll: list[float] = [0, 0]
|
self.scroll: list[float] = [0, 0]
|
||||||
# self.boost: bool = False
|
# 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:
|
def run(self) -> None:
|
||||||
while self.running:
|
while self.running:
|
||||||
self.display.blit(self.assets["background"], (0, 0))
|
self.display.blit(self.assets["background"], (0, 0))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue