Added points system with scoreboard.
This commit is contained in:
		| @@ -24,6 +24,7 @@ class CoffinObject(Object): | ||||
|         if not self.isBroken: | ||||
|             self.isBroken = True | ||||
|             play_sound(self.sounds['coffin_shatter']) | ||||
|             self.level.levelScore += 500 | ||||
|             self.level.player.stats.update_stat('Coffins broken', 1) | ||||
|              | ||||
|             # Stop the ongoing coffin sound | ||||
|   | ||||
							
								
								
									
										11
									
								
								src/enemy.py
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/enemy.py
									
									
									
									
									
								
							| @@ -226,6 +226,17 @@ class Enemy(Object): | ||||
|         if self.channel: | ||||
|             obj_stop(self.channel) | ||||
|             self.channel = None | ||||
|  | ||||
|         # Calculate and award points based on enemy stats | ||||
|         basePoints = self.health * 500 | ||||
|         damageModifier = self.damage * 750 | ||||
|         rangeModifier = self.attackRange * 250 | ||||
|         speedModifier = int(self.movementSpeed * 1000) | ||||
|         totalPoints = max(basePoints + damageModifier + rangeModifier + speedModifier, 1000) | ||||
|      | ||||
|         # Award points | ||||
|         self.level.levelScore += totalPoints | ||||
|  | ||||
|         # Play death sound if available using positional audio | ||||
|         deathSound = f"{self.enemyType}_dies" | ||||
|         if deathSound in self.sounds: | ||||
|   | ||||
| @@ -29,6 +29,7 @@ class Level: | ||||
|         self.isLocked = levelData.get("locked", False)  # Default to False if not specified | ||||
|         self.levelId = levelData["level_id"] | ||||
|         self.levelName = levelData.get("name", "Unnamed Level") | ||||
|         self.levelScore = 0 | ||||
|  | ||||
|         # Get footstep sound for this level, default to 'footstep' if not specified | ||||
|         self.footstepSound = levelData.get("footstep_sound", "footstep") | ||||
| @@ -242,6 +243,7 @@ class Level: | ||||
|             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) | ||||
|                 self.levelScore += 1000  # All items collected points awarded | ||||
|                 item.isActive = False | ||||
|                 self.bouncing_items.remove(item) | ||||
|  | ||||
| @@ -324,6 +326,7 @@ class Level: | ||||
|                     self.player.stats.update_stat('Items collected', 1) | ||||
|                     if obj.soundName == "coin": | ||||
|                         self.player._coins += 1 | ||||
|                         self.levelScore += 100 | ||||
|                         self.player.stats.update_stat('Bone dust', 1) | ||||
|                         if self.player._coins % 5 == 0: | ||||
|                             # Only heal if below max health | ||||
| @@ -337,6 +340,7 @@ class Level: | ||||
|                                 # Extra life | ||||
|                                 self.player._coins = 0 | ||||
|                                 self.player._lives += 1 | ||||
|                                 self.levelScore += 1000 | ||||
|                                 play_sound(self.sounds['get_extra_life']) | ||||
|                 continue | ||||
|  | ||||
| @@ -409,6 +413,9 @@ class Level: | ||||
|                         # Level complete | ||||
|                         pygame.mixer.stop() | ||||
|                         play_sound(self.sounds['end_of_level']) | ||||
|                         self.levelScore += 10000 | ||||
|                         # Actually update the scoreboard with level completion | ||||
|                         self.player.scoreboard.increase_score(self.levelScore) | ||||
|                         return True | ||||
|  | ||||
|         return False | ||||
|   | ||||
| @@ -66,6 +66,8 @@ class Player: | ||||
|             attackDuration=200  # 200ms attack duration | ||||
|         )) | ||||
|  | ||||
|         self.scoreboard = Scoreboard() | ||||
|  | ||||
|     def should_play_footstep(self, currentTime): | ||||
|         """Check if it's time to play a footstep sound""" | ||||
|         return (self.distanceSinceLastStep >= self.get_step_distance() and  | ||||
|   | ||||
| @@ -108,5 +108,8 @@ class PowerUp(Object): | ||||
|             nunchucksWeapon = Weapon.create_nunchucks() | ||||
|             player.add_weapon(nunchucksWeapon) | ||||
|             player.equip_weapon(nunchucksWeapon) | ||||
|             basePoints = nunchucksWeapon.damage * 1000 | ||||
|             rangeModifier = nunchucksWeapon.range * 500 | ||||
|             player.scoreboard.increase_score(basePoints + rangeModifier) | ||||
|             play_sound(self.sounds['get_nunchucks']) | ||||
|             player.stats.update_stat('Items collected', 1) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user