Updated libstormgames submodule. Added skull storms. Fixed no jack-o-lanterns reported when there actually were. Fixed player being recreated on each new level thus resetting all stats.

This commit is contained in:
Storm Dragon
2025-02-03 02:17:53 -05:00
parent 0a7052094d
commit 1d033e067a
9 changed files with 186 additions and 50 deletions

View File

@@ -26,6 +26,7 @@ class Player:
self.inventory = []
self.collectedItems = []
self._coins = 0
self._jack_o_lantern_count = 0
# Combat related attributes
self.weapons = []
@@ -38,9 +39,6 @@ class Player:
self.invincibilityStartTime = 0
self.invincibilityDuration = 5000 # 5 seconds of invincibility
# Projectiles
self.projectiles = [] # List of type and quantity tuples
# Initialize starting weapon (rusty shovel)
self.add_weapon(Weapon(
name="rusty_shovel",
@@ -63,33 +61,22 @@ class Player:
self.isInvincible = True
self.invincibilityStartTime = pygame.time.get_ticks()
def add_projectile(self, projectile_type):
"""Add a projectile to inventory"""
# Find if we already have this type
for proj in self.projectiles:
if proj[0] == projectile_type:
proj[1] += 1 # Increase quantity
speak(f"Now have {proj[1]} {projectile_type}s")
return
def get_jack_o_lanterns(self):
"""Get number of jack o'lanterns"""
return self._jack_o_lantern_count
# If not found, add new type with quantity 1
self.projectiles.append([projectile_type, 1])
def add_jack_o_lantern(self):
"""Add a jack o'lantern"""
self._jack_o_lantern_count += 1
def throw_projectile(self):
"""Throw the first available projectile"""
if not self.projectiles:
speak("No projectiles to throw!")
"""Throw a jack o'lantern if we have any"""
if self.get_jack_o_lanterns() <= 0:
return None
# Get the first projectile type
projectile = self.projectiles[0]
projectile[1] -= 1 # Decrease quantity
if projectile[1] <= 0:
self.projectiles.pop(0) # Remove if none left
self._jack_o_lantern_count -= 1
return {
'type': projectile[0],
'type': 'jack_o_lantern',
'start_x': self.xPos,
'direction': 1 if self.facingRight else -1
}