Fixed item crazy sound mismatch. Updated instructions, probably not final version, but at least a place holder.
This commit is contained in:
		| @@ -231,14 +231,14 @@ class Level: | ||||
|  | ||||
|         # Update bouncing items | ||||
|         for item in self.bouncing_items[:]:  # Copy list to allow removal | ||||
|             if not item.update(currentTime): | ||||
|             if not item.update(currentTime, self.player.xPos): | ||||
|                 self.bouncing_items.remove(item) | ||||
|                 if not item.isActive: | ||||
|                     speak(f"{item.soundName} got away!") | ||||
|                 continue | ||||
|                  | ||||
|             # Check for item collection | ||||
|             if abs(item.xPos - self.player.xPos) < 1 and self.player.isJumping: | ||||
|             if abs(item._currentX - self.player.xPos) < 1 and self.player.isJumping: | ||||
|                 play_sound(self.sounds[f'get_{item.soundName}']) | ||||
|                 item.apply_effect(self.player) | ||||
|                 item.isActive = False | ||||
|   | ||||
| @@ -12,33 +12,38 @@ class PowerUp(Object): | ||||
|         ) | ||||
|         self.sounds = sounds | ||||
|         self.direction = direction | ||||
|         self.speed = 0.05  # Base movement speed | ||||
|         self.speed = 0.055  # Base movement speed | ||||
|         self.item_type = item_type | ||||
|         self.channel = None | ||||
|         self._currentX = x  # Initialize the current x position | ||||
|          | ||||
|     def update(self, current_time): | ||||
|         """Update item position""" | ||||
|     def update(self, current_time, player_pos): | ||||
|         """Update item position | ||||
|      | ||||
|         Args: | ||||
|             current_time: Current game time in milliseconds | ||||
|             player_pos: Current player x position | ||||
|         """ | ||||
|         if not self.isActive: | ||||
|             return False | ||||
|              | ||||
|          | ||||
|         # Update position | ||||
|         self._currentX += self.direction * self.speed | ||||
|          | ||||
|      | ||||
|         # Update positional audio | ||||
|         if self.channel is None or not self.channel.get_busy(): | ||||
|             self.channel = obj_play(self.sounds, "item_bounce", self.xPos, self._currentX) | ||||
|             self.channel = obj_play(self.sounds, "item_bounce", player_pos, self._currentX) | ||||
|         else: | ||||
|             self.channel = obj_update(self.channel, self.xPos, self._currentX) | ||||
|              | ||||
|         # Check if item has gone too far (20 tiles) | ||||
|         if abs(self._currentX - self.xRange[0]) > 20: | ||||
|             self.channel = obj_update(self.channel, player_pos, self._currentX) | ||||
|          | ||||
|         # Check if item has gone too far (12 tiles) | ||||
|         if abs(self._currentX - player_pos) > 12: | ||||
|             self.isActive = False | ||||
|             if self.channel: | ||||
|                 self.channel.stop() | ||||
|                 self.channel = None | ||||
|             return False | ||||
|              | ||||
|          | ||||
|         return True | ||||
|          | ||||
|     def apply_effect(self, player): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user