New weapon, witch's broom, added. New enemy type, witch, added.
This commit is contained in:
21
src/enemy.py
21
src/enemy.py
@@ -1,5 +1,6 @@
|
||||
from libstormgames import *
|
||||
from src.object import Object
|
||||
from src.powerup import PowerUp
|
||||
import pygame
|
||||
|
||||
class Enemy(Object):
|
||||
@@ -171,5 +172,25 @@ class Enemy(Object):
|
||||
if deathSound in self.sounds:
|
||||
self.channel = obj_play(self.sounds, deathSound, self.level.player.xPos, self.xPos, loop=False)
|
||||
|
||||
# Handle witch-specific drops
|
||||
if self.enemyType == "witch":
|
||||
# Determine which item to drop
|
||||
hasBroom = any(weapon.name == "witch_broom" for weapon in self.level.player.weapons)
|
||||
itemType = "cauldron" if hasBroom else "witch_broom"
|
||||
|
||||
# Create drop 1-2 tiles away in random direction
|
||||
direction = random.choice([-1, 1])
|
||||
dropDistance = random.randint(1, 2)
|
||||
dropX = self.xPos + (direction * dropDistance)
|
||||
|
||||
droppedItem = PowerUp(
|
||||
dropX,
|
||||
self.yPos,
|
||||
itemType,
|
||||
self.sounds,
|
||||
direction
|
||||
)
|
||||
self.level.bouncing_items.append(droppedItem)
|
||||
|
||||
# Update stats
|
||||
self.level.player.stats.update_stat('Enemies killed', 1)
|
||||
|
||||
Reference in New Issue
Block a user