New weapon, witch's broom, added. New enemy type, witch, added.
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
"x_range": [21, 29],
|
||||
"y": 0,
|
||||
"enemy_type": "goblin",
|
||||
"health": 4,
|
||||
"health": 2,
|
||||
"damage": 2,
|
||||
"attack_range": 1,
|
||||
"attack_pattern": {
|
||||
@@ -37,7 +37,7 @@
|
||||
"hazard": true,
|
||||
"sound": "grave",
|
||||
"static": true,
|
||||
"zombie_spawn_chance": 15
|
||||
"zombie_spawn_chance": 10
|
||||
},
|
||||
{
|
||||
"x_range": [33, 38],
|
||||
@@ -61,7 +61,8 @@
|
||||
"x": 55,
|
||||
"y": 3,
|
||||
"sound": "coffin",
|
||||
"type": "coffin"
|
||||
"type": "coffin",
|
||||
"item": "guts"
|
||||
},
|
||||
{
|
||||
"x_range": [65, 70],
|
||||
@@ -74,7 +75,7 @@
|
||||
"x_range": [71, 79],
|
||||
"y": 0,
|
||||
"enemy_type": "goblin",
|
||||
"health": 5,
|
||||
"health": 2,
|
||||
"damage": 2,
|
||||
"attack_range": 1,
|
||||
"attack_pattern": {
|
||||
@@ -93,7 +94,7 @@
|
||||
"hazard": true,
|
||||
"sound": "grave",
|
||||
"static": true,
|
||||
"zombie_spawn_chance": 20
|
||||
"zombie_spawn_chance": 10
|
||||
},
|
||||
{
|
||||
"x_range": [105, 108],
|
||||
@@ -127,11 +128,52 @@
|
||||
"sound": "coin",
|
||||
"collectible": true,
|
||||
"static": true
|
||||
},
|
||||
{
|
||||
"x": 160,
|
||||
"y": 0,
|
||||
"hazard": true,
|
||||
"sound": "grave",
|
||||
"static": true,
|
||||
"zombie_spawn_chance": 10
|
||||
},
|
||||
{
|
||||
"x": 170,
|
||||
"y": 3,
|
||||
"sound": "coffin",
|
||||
"type": "coffin",
|
||||
"item": "extra_life"
|
||||
},
|
||||
{
|
||||
"x_range": [175, 180],
|
||||
"y": 3,
|
||||
"sound": "coin",
|
||||
"collectible": true,
|
||||
"static": true
|
||||
},
|
||||
{
|
||||
"x": 185,
|
||||
"y": 0,
|
||||
"hazard": true,
|
||||
"sound": "grave",
|
||||
"static": true,
|
||||
"zombie_spawn_chance": 10
|
||||
},
|
||||
{
|
||||
"x_range": [189, 198],
|
||||
"y": 0,
|
||||
"enemy_type": "witch",
|
||||
"health": 4,
|
||||
"damage": 2,
|
||||
"attack_range": 1.5,
|
||||
"attack_pattern": {
|
||||
"type": "patrol"
|
||||
}
|
||||
}
|
||||
],
|
||||
"boundaries": {
|
||||
"left": 0,
|
||||
"right": 170
|
||||
"right": 200
|
||||
},
|
||||
"footstep_sound": "footstep_tall_grass"
|
||||
}
|
||||
|
BIN
sounds/_edge.ogg
(Stored with Git LFS)
Normal file
BIN
sounds/_edge.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
sounds/get_cauldron.ogg
(Stored with Git LFS)
Normal file
BIN
sounds/get_cauldron.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
sounds/get_witch_broom.ogg
(Stored with Git LFS)
Normal file
BIN
sounds/get_witch_broom.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
sounds/player_broom_attack.ogg
(Stored with Git LFS)
Normal file
BIN
sounds/player_broom_attack.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
sounds/player_broom_hit.ogg
(Stored with Git LFS)
Normal file
BIN
sounds/player_broom_hit.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
sounds/witch.ogg
(Stored with Git LFS)
Normal file
BIN
sounds/witch.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
sounds/witch_dies.ogg
(Stored with Git LFS)
Normal file
BIN
sounds/witch_dies.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
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)
|
||||
|
@@ -8,6 +8,8 @@ class ItemType(Enum):
|
||||
HAND_OF_GLORY = auto()
|
||||
JACK_O_LANTERN = auto()
|
||||
EXTRA_LIFE = auto()
|
||||
CAULDRON = auto()
|
||||
WITCH_BROOM = auto()
|
||||
|
||||
class ItemProperties:
|
||||
"""Manages item properties and availability"""
|
||||
@@ -23,7 +25,9 @@ class ItemProperties:
|
||||
ItemType.GUTS: "guts",
|
||||
ItemType.HAND_OF_GLORY: "hand_of_glory",
|
||||
ItemType.JACK_O_LANTERN: "jack_o_lantern",
|
||||
ItemType.EXTRA_LIFE: "extra_life"
|
||||
ItemType.EXTRA_LIFE: "extra_life",
|
||||
ItemType.CAULDRON: "cauldron",
|
||||
ItemType.WITCH_BROOM: "witch_broom"
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
@@ -129,6 +129,10 @@ class Player:
|
||||
"""Get current max health"""
|
||||
return self._maxHealth
|
||||
|
||||
def restore_health(self):
|
||||
"""Restore health to maximum"""
|
||||
self._health = self._maxHealth
|
||||
|
||||
def get_current_speed(self):
|
||||
"""Calculate current speed based on state"""
|
||||
baseSpeed = self.moveSpeed
|
||||
|
@@ -1,5 +1,6 @@
|
||||
from libstormgames import *
|
||||
from src.object import Object
|
||||
from src.weapon import Weapon
|
||||
|
||||
class PowerUp(Object):
|
||||
def __init__(self, x, y, item_type, sounds, direction):
|
||||
@@ -44,12 +45,18 @@ class PowerUp(Object):
|
||||
"""Apply the item's effect when collected"""
|
||||
if self.item_type == 'hand_of_glory':
|
||||
player.start_invincibility()
|
||||
elif self.item_type == 'cauldron':
|
||||
player.restore_health()
|
||||
elif self.item_type == 'guts':
|
||||
player.add_guts()
|
||||
elif self.item_type == 'jack_o_lantern':
|
||||
player.add_jack_o_lantern()
|
||||
elif self.item_type == 'extra_life':
|
||||
player.extra_life()
|
||||
elif self.item_type == 'witch_broom':
|
||||
broomWeapon = Weapon.create_witch_broom()
|
||||
player.add_weapon(broomWeapon)
|
||||
player.equip_weapon(broomWeapon)
|
||||
|
||||
# Stop movement sound when collected
|
||||
if self.channel:
|
||||
|
@@ -10,6 +10,19 @@ class Weapon:
|
||||
self.lastAttackTime = 0
|
||||
self.hitEnemies = set()
|
||||
|
||||
@classmethod
|
||||
def create_witch_broom(cls):
|
||||
"""Create the witch's broom weapon"""
|
||||
return cls(
|
||||
name="witch_broom",
|
||||
damage=3,
|
||||
range=2.5,
|
||||
attackSound="player_broom_attack",
|
||||
hitSound="player_broom_hit",
|
||||
cooldown=500,
|
||||
attackDuration=200
|
||||
)
|
||||
|
||||
def can_attack(self, currentTime):
|
||||
"""Check if enough time has passed since last attack"""
|
||||
return currentTime - self.lastAttackTime >= self.cooldown
|
||||
|
Reference in New Issue
Block a user