feat: item

- Create item.py
- Add update to remove expired items
- Add item settings for spawn interval, despawn timer, and size
This commit is contained in:
Berger Lena
2026-05-08 15:03:41 +02:00
parent 872786c8e3
commit 11ece2ee54
2 changed files with 30 additions and 9 deletions
+19
View File
@@ -0,0 +1,19 @@
import pygame
import random
from src.settings import (
ITEM_SPAWN_INTERVAL, ITEM_SHOPPING_TIMER, ITEM_SIZE,
COLOR_HP_BAR_YELLOW, COLOR_HP_BAR_BG
)
# remove expired items
def update(self, room_rect, blocked_rects):
now = pygame.time.get_ticks()
remaining_items = []
for item in self.items:
if item.is_expired() == False:
remaining_items.append(item)
# replace the old list with the new temp_list
self.items = remaining_items