More sounds added. Warning for edge of grave added, but it's not quite right yet.
This commit is contained in:
100
levels/1.json
100
levels/1.json
@@ -8,7 +8,14 @@
|
||||
},
|
||||
"objects": [
|
||||
{
|
||||
"x_range": [5, 7],
|
||||
"x": 5,
|
||||
"y": 3,
|
||||
"sound": "coin",
|
||||
"collectible": true,
|
||||
"static": true
|
||||
},
|
||||
{
|
||||
"x_range": [15, 17],
|
||||
"y": 3,
|
||||
"sound": "coin",
|
||||
"collectible": true,
|
||||
@@ -19,21 +26,104 @@
|
||||
"y": 0,
|
||||
"enemy_type": "goblin",
|
||||
"health": 5,
|
||||
"damage": 1,
|
||||
"damage": 2,
|
||||
"attack_range": 1,
|
||||
"movement_range": 5
|
||||
},
|
||||
{
|
||||
"x": 50,
|
||||
"x": 30,
|
||||
"y": 3,
|
||||
"sound": "coin",
|
||||
"collectible": true,
|
||||
"static": true
|
||||
},
|
||||
{
|
||||
"x": 40,
|
||||
"y": 0,
|
||||
"hazard": true,
|
||||
"sound": "grave",
|
||||
"static": true,
|
||||
"zombie_spawn_chance": 100
|
||||
"zombie_spawn_chance": 10
|
||||
},
|
||||
{
|
||||
"x_range": [45, 47],
|
||||
"y": 3,
|
||||
"sound": "coin",
|
||||
"collectible": true,
|
||||
"static": true
|
||||
},
|
||||
{
|
||||
"x": 55,
|
||||
"y": 3,
|
||||
"sound": "coin",
|
||||
"collectible": true,
|
||||
"static": true
|
||||
},
|
||||
{
|
||||
"x": 60,
|
||||
"y": 0,
|
||||
"enemy_type": "goblin",
|
||||
"health": 5,
|
||||
"damage": 2,
|
||||
"attack_range": 1,
|
||||
"movement_range": 5
|
||||
},
|
||||
{
|
||||
"x": 70,
|
||||
"y": 0,
|
||||
"hazard": true,
|
||||
"sound": "grave",
|
||||
"static": true,
|
||||
"zombie_spawn_chance": 15
|
||||
},
|
||||
{
|
||||
"x_range": [80, 82],
|
||||
"y": 3,
|
||||
"sound": "coin",
|
||||
"collectible": true,
|
||||
"static": true
|
||||
},
|
||||
{
|
||||
"x": 90,
|
||||
"y": 0,
|
||||
"hazard": true,
|
||||
"sound": "grave",
|
||||
"static": true,
|
||||
"zombie_spawn_chance": 20
|
||||
},
|
||||
{
|
||||
"x": 100,
|
||||
"y": 3,
|
||||
"sound": "coin",
|
||||
"collectible": true,
|
||||
"static": true
|
||||
},
|
||||
{
|
||||
"x": 110,
|
||||
"y": 0,
|
||||
"hazard": true,
|
||||
"sound": "grave",
|
||||
"static": true,
|
||||
"zombie_spawn_chance": 25
|
||||
},
|
||||
{
|
||||
"x_range": [120, 123],
|
||||
"y": 3,
|
||||
"sound": "coin",
|
||||
"collectible": true,
|
||||
"static": true
|
||||
},
|
||||
{
|
||||
"x": 130,
|
||||
"y": 0,
|
||||
"hazard": true,
|
||||
"sound": "grave",
|
||||
"static": true,
|
||||
"zombie_spawn_chance": 30
|
||||
}
|
||||
],
|
||||
"boundaries": {
|
||||
"left": 0,
|
||||
"right": 500
|
||||
"right": 150
|
||||
}
|
||||
}
|
||||
|
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/game_over.ogg
(Stored with Git LFS)
Normal file
BIN
sounds/game_over.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
sounds/get_coin.ogg
(Stored with Git LFS)
BIN
sounds/get_coin.ogg
(Stored with Git LFS)
Binary file not shown.
BIN
sounds/get_hand_of_glory.ogg
(Stored with Git LFS)
Normal file
BIN
sounds/get_hand_of_glory.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
sounds/get_jack_o_lantern.ogg
(Stored with Git LFS)
Normal file
BIN
sounds/get_jack_o_lantern.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
sounds/life_up.ogg
(Stored with Git LFS)
Normal file
BIN
sounds/life_up.ogg
(Stored with Git LFS)
Normal file
Binary file not shown.
12
src/level.py
12
src/level.py
@@ -148,14 +148,24 @@ class Level:
|
||||
if not obj.isActive:
|
||||
continue
|
||||
|
||||
# Handle grave edge warnings
|
||||
if obj.isHazard:
|
||||
distance = abs(self.player.xPos - obj.xPos)
|
||||
# Check if within 1 tile and moving
|
||||
|
||||
if distance <= 1 and not self.player.isJumping:
|
||||
# Play edge warning sound (don't need to track the channel)
|
||||
self.sounds['edge'].play()
|
||||
|
||||
if obj.is_in_range(self.player.xPos):
|
||||
if obj.isCollectible and self.player.isJumping:
|
||||
currentPos = round(self.player.xPos)
|
||||
if currentPos not in obj.collectedPositions:
|
||||
self.sounds[f'get_{obj.soundName}'].play()
|
||||
speak(f"Collected {obj.soundName}")
|
||||
obj.collect_at_position(currentPos)
|
||||
self.player.collectedItems.append(obj.soundName)
|
||||
if obj.soundName == "coin":
|
||||
self.player._coins += 1
|
||||
elif obj.isHazard and not self.player.isJumping:
|
||||
self.sounds[obj.soundName].play()
|
||||
speak("You fell in an open grave!")
|
||||
|
@@ -19,7 +19,7 @@ class Player:
|
||||
# Inventory system
|
||||
self.inventory = []
|
||||
self.collectedItems = []
|
||||
self.coins = 0
|
||||
self._coins = 0
|
||||
|
||||
# Combat related attributes
|
||||
self.weapons = []
|
||||
@@ -103,6 +103,10 @@ class Player:
|
||||
if self._lives > 0:
|
||||
self._health = 10 # Reset health if we still have lives
|
||||
|
||||
def get_coins(self):
|
||||
"""Get remaining coins"""
|
||||
return self._coins
|
||||
|
||||
def get_lives(self):
|
||||
"""Get remaining lives"""
|
||||
return self._lives
|
||||
|
Reference in New Issue
Block a user