diff --git a/5. spraitu_atteli/main.py b/5. spraitu_atteli/main.py index 8e75f90..dbe3410 100644 --- a/5. spraitu_atteli/main.py +++ b/5. spraitu_atteli/main.py @@ -40,8 +40,11 @@ enemies = pygame.sprite.Group() all_sprites = pygame.sprite.Group() all_sprites.add(player) +bg = pygame.image.load("sprites/background.png").convert() + # Main loop while running: + screen.blit(bg, (0,0)) # Look at every event in the queue for event in pygame.event.get(): # Did the user hit a key? @@ -61,8 +64,6 @@ while running: enemies.add(new_enemy) all_sprites.add(new_enemy) - # Fill the background with white - screen.fill((255, 255, 255)) # Get all the keys currently pressed pressed_keys = pygame.key.get_pressed() @@ -77,6 +78,8 @@ while running: for entity in all_sprites: screen.blit(entity.surf, entity.rect) + + # Check if any enemies have collided with the player if pygame.sprite.spritecollideany(player, enemies): # If so, then remove the player and stop the loop diff --git a/sprites/background.png b/sprites/background.png new file mode 100644 index 0000000..282089d Binary files /dev/null and b/sprites/background.png differ