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:
+19
@@ -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
|
||||
Reference in New Issue
Block a user