Fixed attack sound sometimes not playing. Fixed a problem where a single attack was doing multiple attack damage. The means I reaqlly need to reword the first three levels, because they are very hard now lol.
This commit is contained in:
		
							
								
								
									
										15
									
								
								src/level.py
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/level.py
									
									
									
									
									
								
							| @@ -198,19 +198,14 @@ class Level: | ||||
|         # Only get attack range if attack is active | ||||
|         if self.player.currentWeapon and self.player.currentWeapon.is_attack_active(currentTime): | ||||
|             attackRange = self.player.currentWeapon.get_attack_range(self.player.xPos, self.player.facingRight) | ||||
|          | ||||
|  | ||||
|             # Check for enemy hits | ||||
|             for enemy in self.enemies: | ||||
|                 if enemy.isActive and enemy.xPos >= attackRange[0] and enemy.xPos <= attackRange[1]: | ||||
|                     if self.weapon_hit_channel is None or not self.weapon_hit_channel.get_busy(): | ||||
|                         self.weapon_hit_channel = self.sounds[self.player.currentWeapon.hitSound].play() | ||||
|                         self.weapon_hit_channel = play_sound(self.sounds[self.player.currentWeapon.hitSound]) | ||||
|  | ||||
|                     enemy.take_damage(self.player.currentWeapon.damage) | ||||
|                 else: | ||||
|                     # Reset weapon hit channel when not attacking | ||||
|                     if self.weapon_hit_channel is not None and not self.weapon_hit_channel.get_busy(): | ||||
|                         self.weapon_hit_channel = None | ||||
|                     # Only damage and play sound if this is a new hit for this attack | ||||
|                     if self.player.currentWeapon.register_hit(enemy, currentTime): | ||||
|                         play_sound(self.sounds[self.player.currentWeapon.hitSound]) | ||||
|                         enemy.take_damage(self.player.currentWeapon.damage) | ||||
|  | ||||
|             # Check for coffin hits | ||||
|             for obj in self.objects: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user