New items added..

This commit is contained in:
Storm Dragon
2025-02-06 02:31:57 -05:00
parent c29bcd40b7
commit 8f57069c98
13 changed files with 178 additions and 133 deletions

View File

@@ -1,11 +1,12 @@
import random
from libstormgames import *
from src.item_types import ItemProperties
from src.object import Object
from src.powerup import PowerUp
import random
class CoffinObject(Object):
def __init__(self, x, y, sounds, level):
def __init__(self, x, y, sounds, level, item="random"):
super().__init__(
x, y, "coffin",
isStatic=True,
@@ -13,9 +14,10 @@ class CoffinObject(Object):
isHazard=False
)
self.sounds = sounds
self.level = level # Store level reference
self.level = level
self.is_broken = False
self.dropped_item = None
self.specified_item = item
def hit(self, player_pos):
"""Handle being hit by the player's weapon"""
@@ -23,23 +25,31 @@ class CoffinObject(Object):
self.is_broken = True
play_sound(self.sounds['coffin_shatter'])
self.level.player.stats.update_stat('Coffins broken', 1)
# Stop the ongoing coffin sound
if self.channel:
obj_stop(self.channel)
self.channel = None
# Mark coffin as inactive since it's broken
self.isActive = False
# Randomly choose item type
item_type = random.choice(['hand_of_glory', 'jack_o_lantern'])
# Determine item to drop
if self.specified_item == "random":
item_type = ItemProperties.get_random_item()
else:
# Validate specified item
if ItemProperties.is_valid_item(self.specified_item):
item_type = self.specified_item
else:
# Fall back to random if invalid item specified
item_type = ItemProperties.get_random_item()
# Create item 1-2 tiles away in random direction
direction = random.choice([-1, 1])
drop_distance = random.randint(1, 2)
drop_x = self.xPos + (direction * drop_distance)
self.dropped_item = PowerUp(
drop_x,
self.yPos,