Lichter zum Leuchten bringen

This commit is contained in:
moritz 2024-07-07 14:23:58 +02:00
parent 753cb75b1d
commit 8369f3d4de
3 changed files with 7 additions and 4 deletions

View file

@ -64,8 +64,11 @@ if __name__ == "__main__":
collisions = pygame.sprite.spritecollide(player.sprite, detectors, False)
for detector in collisions:
for lantern in lanterns:
if lantern.id == detector.id - 1 and lantern.id is not 8 or lantern.id == detector.id + 1 and lantern.id is not 8:
lantern.light_up(176, 179, 0)
if lantern.id == detector.id:
lantern.light_up()
lantern.light_up(255, 255, 0)
if pygame.sprite.spritecollide(player.sprite, streets, False):
player.sprite.set_back()

View file

@ -53,8 +53,8 @@ class Lanterns(pygame.sprite.Sprite):
self.rect = self.image.get_rect(center=(left, top))
self.id = id
def light_up(self):
self.image.fill((255, 255, 0))
def light_up(self, r, g, b):
self.image.fill((r, g, b))
def reset_light(self):
self.image.fill((0, 0, 0))