Hopefully fixed a race condition where you could be killed while getting a cauldron and come back to life. Added sound for fill in grave and for survivor bonus.
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								sounds/fill_in_grave.ogg
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								sounds/fill_in_grave.ogg
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								sounds/survivor_bonus.ogg
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								sounds/survivor_bonus.ogg
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										11
									
								
								src/level.py
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/level.py
									
									
									
									
									
								
							| @@ -366,8 +366,8 @@ class Level: | ||||
|             if not obj.is_in_range(self.player.xPos): | ||||
|                 continue | ||||
|  | ||||
|             # Handle collectibles | ||||
|             if obj.isCollectible and self.player.isJumping: | ||||
|             # Handle collectibles (but not if player died this frame) | ||||
|             if obj.isCollectible and self.player.isJumping and not self.player.diedThisFrame: | ||||
|                 currentPos = round(self.player.xPos) | ||||
|                 if currentPos not in obj.collectedPositions: | ||||
|                     play_sound(self.sounds[f'get_{obj.soundName}']) | ||||
| @@ -400,7 +400,7 @@ class Level: | ||||
|                                     self.player._coins = 0 | ||||
|                                     self.levelScore += 2000  # Double score bonus instead of extra life | ||||
|                                     speak("100 bone dust collected! Bonus score!") | ||||
|                                     play_sound(self.sounds['bone_dust']) | ||||
|                                     play_sound(self.sounds.get('survivor_bonus', 'bone_dust'))  # Use survivor_bonus sound if available, fallback to bone_dust | ||||
|                 continue | ||||
|  | ||||
|             # Handle spiderweb - this should trigger for both walking and jumping if not ducking | ||||
| @@ -425,12 +425,13 @@ class Level: | ||||
|             # Handle graves and other hazards | ||||
|             if obj.isHazard and not self.player.isJumping: | ||||
|                 if isinstance(obj, GraveObject): | ||||
|                     can_collect = obj.collect_grave_item(self.player) | ||||
|                     can_collect = obj.collect_grave_item(self.player) and not self.player.diedThisFrame | ||||
|                     can_fill = obj.can_fill_grave(self.player) | ||||
|  | ||||
|                     if can_collect: | ||||
|                         # Successfully collected item while ducking with shovel | ||||
|                         play_sound(self.sounds[f'get_{obj.graveItem}']) | ||||
|                         play_sound(self.sounds.get('fill_in_grave', 'shovel_dig'))  # Also play fill sound | ||||
|                         self.player.stats.update_stat('Items collected', 1) | ||||
|                         # Create PowerUp to handle the item effect | ||||
|                         item = PowerUp(obj.xPos, obj.yPos, obj.graveItem, self.sounds, 1, | ||||
| @@ -446,7 +447,7 @@ class Level: | ||||
|                         continue | ||||
|                     elif can_fill and obj.fill_grave(self.player): | ||||
|                         # Successfully filled empty grave with shovel | ||||
|                         play_sound(self.sounds.get('shovel_dig', obj.soundName))  # Use dig sound if available | ||||
|                         play_sound(self.sounds.get('fill_in_grave', 'shovel_dig'))  # Use fill_in_grave sound if available, fallback to shovel_dig | ||||
|                         self.player.stats.update_stat('Graves filled', 1) | ||||
|                         # Stop grave's current audio channel | ||||
|                         if obj.channel: | ||||
|   | ||||
| @@ -59,6 +59,9 @@ class Player: | ||||
|         self.invincibilityStartTime = 0 | ||||
|         self.invincibilityDuration = 10000  # 10 seconds of invincibility | ||||
|          | ||||
|         # Death state tracking (to prevent revival after death in same frame) | ||||
|         self.diedThisFrame = False | ||||
|  | ||||
|         # Initialize starting weapon (rusty shovel) | ||||
|         self.add_weapon(Weapon( | ||||
|             name="rusty_shovel", | ||||
| @@ -92,6 +95,9 @@ class Player: | ||||
|  | ||||
|     def update(self, currentTime): | ||||
|         """Update player state""" | ||||
|         # Reset death flag at start of each frame | ||||
|         self.diedThisFrame = False | ||||
|          | ||||
|         if hasattr(self, 'webPenaltyEndTime'): | ||||
|             if currentTime >= self.webPenaltyEndTime: | ||||
|                 self.moveSpeed *= 2  # Restore speed | ||||
| @@ -218,6 +224,8 @@ class Player: | ||||
|  | ||||
|         if self._health == 0 and old_health > 0: | ||||
|             self._lives -= 1 | ||||
|             # Mark that player died this frame to prevent revival | ||||
|             self.diedThisFrame = True | ||||
|             # Stop all current sounds before playing death sound | ||||
|             pygame.mixer.stop() | ||||
|             try: | ||||
|   | ||||
| @@ -74,6 +74,7 @@ class PowerUp(Object): | ||||
|                 # In survival mode, give bonus score instead | ||||
|                 level.levelScore += 2000 | ||||
|                 speak("Extra life found! Bonus score in survival mode!") | ||||
|                 play_sound(self.sounds.get('survivor_bonus', 'get_extra_life'))  # Use survivor_bonus sound if available | ||||
|             else: | ||||
|                 player.extra_life() | ||||
|         elif self.item_type == 'shin_bone':  # Add shin bone handling | ||||
|   | ||||
		Reference in New Issue
	
	Block a user