Leaf-Spawner für Baum-Tiles initialisieren und Anzahl der gefundenen Spawner ausgeben

This commit is contained in:
Benjamin 2026-05-20 17:25:29 +02:00
parent dfd2baad7a
commit 739481f18a

View file

@ -47,16 +47,16 @@ class Game:
self.player: Player = Player(game=self, pos=(50, 50), size=(8, 15))
self.tilemap: Tilemap = Tilemap(game=self, tile_size=16)
self.leaf_spawners: list[pygame.Rect] = []
self.particles = []
try:
self.tilemap.load(path="map.json")
except FileNotFoundError:
pass
self.leaf_spawners: list[pygame.Rect] = []
self.particles = []
for tree in self.tilemap.extract([("large_decor", 2)], keep=True):
self.leaf_spawners.append(pygame.Rect(left=4 + tree['pos'][0], top=4 + tree['pos'][1], width=23, height=13))
print(len(self.leaf_spawners), "Baum-Spawner gefunden")