diff --git a/levels/1.json b/levels/1.json index 08005c6..3d37556 100644 --- a/levels/1.json +++ b/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 } } diff --git a/sounds/edge.ogg b/sounds/edge.ogg new file mode 100644 index 0000000..9b829f3 --- /dev/null +++ b/sounds/edge.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a34175e0666fa947e881f25c631a10a14ec03b73f8c2c09fa13c1c09a180003 +size 4909 diff --git a/sounds/game_over.ogg b/sounds/game_over.ogg new file mode 100644 index 0000000..3229974 --- /dev/null +++ b/sounds/game_over.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf0d1e3d02a7624997a70e4334fee089caad95bf4370b73a13502d85e986b786 +size 31987 diff --git a/sounds/get_coin.ogg b/sounds/get_coin.ogg index 9e0b1ff..c1c1094 100644 --- a/sounds/get_coin.ogg +++ b/sounds/get_coin.ogg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6b6c7e8baae9ffe4813433ed4a26269291c6310312cb0d094870fbe4c5fc27ea -size 8961 +oid sha256:075d68c3b7710ed611b3fa1473e3b517b597c1df863065fea14b46dad045fed3 +size 8392 diff --git a/sounds/get_hand_of_glory.ogg b/sounds/get_hand_of_glory.ogg new file mode 100644 index 0000000..b6f21c3 --- /dev/null +++ b/sounds/get_hand_of_glory.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a167123c9a5897728dbdadba95ef83c52ac1cc47841c2477d904581542be6b4b +size 26210 diff --git a/sounds/get_jack_o_lantern.ogg b/sounds/get_jack_o_lantern.ogg new file mode 100644 index 0000000..1969791 --- /dev/null +++ b/sounds/get_jack_o_lantern.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:906835690c10d3fd504f4a4ca157d61b87ae00a052a219bf6c8873651fc7c8b1 +size 23491 diff --git a/sounds/life_up.ogg b/sounds/life_up.ogg new file mode 100644 index 0000000..073b262 --- /dev/null +++ b/sounds/life_up.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0535284b2fff3bf98576ff4a5bc0a7df49b6debd334b2473ae52c9f2032b064b +size 26047 diff --git a/src/level.py b/src/level.py index 8133378..c202aa7 100644 --- a/src/level.py +++ b/src/level.py @@ -139,23 +139,33 @@ class Level: obj.xPos <= attackRange[1] and self.player.isJumping): # Must be jumping to hit floating coffins - if obj.hit(self.player.xPos): - self.bouncing_items.append(obj.dropped_item) - speak(f"{obj.dropped_item.item_type} falls out!") + if obj.hit(self.player.xPos): + self.bouncing_items.append(obj.dropped_item) + speak(f"{obj.dropped_item.item_type} falls out!") def handle_collisions(self): for obj in self.objects: 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!") diff --git a/src/player.py b/src/player.py index db3fab5..2ea56fe 100644 --- a/src/player.py +++ b/src/player.py @@ -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