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

@@ -14,6 +14,8 @@ class Player:
self.jumpDuration = 1000 # Jump duration in milliseconds
self.jumpStartTime = 0
self.isJumping = False
self.isRunning = False
self.runMultiplier = 1.5 # Same multiplier as jumping
self.facingRight = True
# Stats and tracking
@@ -26,11 +28,14 @@ class Player:
self.sounds = sounds
# Footstep tracking
self.baseStepDistance = 0.8
self.baseStepInterval = 250
self.stepDistance = self.baseStepDistance
self.minStepInterval = self.baseStepInterval
self.distanceSinceLastStep = 0
self.stepDistance = 0.8
self.lastStepTime = 0
self.minStepInterval = 250 # Minimum milliseconds between steps
self.footstepSound = "footstep"
self.isRunning = False
self.runMultiplier = 1.5
# Inventory system
self.inventory = []
@@ -61,8 +66,8 @@ class Player:
def should_play_footstep(self, currentTime):
"""Check if it's time to play a footstep sound"""
return (self.distanceSinceLastStep >= self.stepDistance and
currentTime - self.lastStepTime >= self.minStepInterval)
return (self.distanceSinceLastStep >= self.get_step_distance() and
currentTime - self.lastStepTime >= self.get_step_interval())
def update(self, currentTime):
"""Update player state"""
@@ -76,6 +81,10 @@ class Player:
self.isInvincible = True
self.invincibilityStartTime = pygame.time.get_ticks()
def extra_life(self):
"""Increment lives by 1"""
self._lives += 1
def get_jack_o_lanterns(self):
"""Get number of jack o'lanterns"""
return self._jack_o_lantern_count
@@ -84,6 +93,10 @@ class Player:
"""Add a jack o'lantern"""
self._jack_o_lantern_count += 1
def add_guts(self):
"""Apply guts, increase max_health by 2"""
self._maxHealth += 2
def throw_projectile(self):
"""Throw a jack o'lantern if we have any"""
if self.get_jack_o_lanterns() <= 0:
@@ -96,6 +109,18 @@ class Player:
'direction': 1 if self.facingRight else -1
}
def get_step_distance(self):
"""Get step distance based on current speed"""
if self.isRunning or self.isJumping:
return self.baseStepDistance / self.runMultiplier
return self.baseStepDistance
def get_step_interval(self):
"""Get minimum time between steps based on current speed"""
if self.isRunning or self.isJumping:
return self.baseStepInterval / self.runMultiplier
return self.baseStepInterval
def get_health(self):
"""Get current health"""
return self._health
@@ -104,6 +129,12 @@ class Player:
"""Get current max health"""
return self._maxHealth
def get_current_speed(self):
"""Calculate current speed based on state"""
baseSpeed = self.moveSpeed
if self.isJumping or self.isRunning: return baseSpeed * self.runMultiplier
return baseSpeed
def set_footstep_sound(self, soundName):
"""Set the current footstep sound"""
self.footstepSound = soundName
@@ -122,8 +153,7 @@ class Player:
pygame.mixer.stop()
cut_scene(self.sounds, 'lose_a_life')
if self._lives > 0:
self._health = self._maxHealth # Reset health if we still have lives
speak(f"{self._lives} lives remaining")
self.reset_on_death()
def set_max_health(self, value):
"""Set max health"""
@@ -137,6 +167,13 @@ class Player:
"""Get remaining lives"""
return self._lives
def reset_on_death(self):
"""Reset player state after death"""
self._health = self._maxHealth
self.isJumping = False
self.isRunning = False
self.xPos = 0
def add_weapon(self, weapon):
"""Add a new weapon to inventory and equip if first weapon"""
self.weapons.append(weapon)