From 7baf56c4fddf7cf380ddd615a4a3e4cea81eb070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?PH=C3=98X?= Date: Sat, 8 Feb 2025 00:48:28 +0530 Subject: [PATCH 1/2] Added enemy class --- enemy.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/enemy.py b/enemy.py index 4bd05e5..41daf6f 100644 --- a/enemy.py +++ b/enemy.py @@ -492,4 +492,22 @@ def update_behavior(self, player): # Update action and reset frame if changed if new_action != self.current_action: self.current_action = new_action - self.current_frame = 0 \ No newline at end of file + self.current_frame = 0 + +class TeleportingMushroom(Mushroom): + + def __init__(self, x, y): + super().__init__(x, y) + self.teleport_timer = 0 + + def update(self, player): + super().update(player) + self.teleport_timer += 1 + if self.teleport_timer > 200: + self.teleport(player) + self.teleport_timer = 0 + + def teleport(self,player): + """Teleport to a random position.""" + self.x = player.x+random.randint(5, 50) + self.y = player.y+random.randint(5, 30) From 657e49dc237ebe1539e7c1d6457c4787a5196d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?PH=C3=98X?= Date: Sat, 8 Feb 2025 00:51:31 +0530 Subject: [PATCH 2/2] Update main.py --- main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 33132d3..b6bb87c 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,7 @@ import sys import random from player import Player -from enemy import FlyingEye, Goblin, Mushroom, Skeleton, EvilWizard, BigFlyingEye, DashingGoblin +from enemy import FlyingEye, Goblin, Mushroom, Skeleton, EvilWizard, BigFlyingEye, DashingGoblin, TeleportingMushroom from weapon import WeaponManager # Initialize Pygame @@ -47,23 +47,23 @@ 'message': "Wave 2: Mini-Boss!" }, { - 'enemies': [(FlyingEye, 8, 1.5), (Goblin, 5, 2)], + 'enemies': [(FlyingEye, 8, 1.5), (Goblin, 5, 2), (TeleportingMushroom, 3, 1)], 'message': "Wave 3: Combined Forces!" }, # Mid-game challenge { - 'enemies': [(Skeleton, 10, 1.5), (FlyingEye, 15, 1)], + 'enemies': [(Skeleton, 10, 1.5), (FlyingEye, 15, 1), (TeleportingMushroom, 4, 1)], 'message': "Wave 4: Skeletons Join the Fray!" }, { - 'enemies': [(Mushroom, 5, 2), (Goblin, 12, 1), (FlyingEye, 10, 1.2)], + 'enemies': [(Mushroom, 5, 2), (Goblin, 12, 1), (FlyingEye, 10, 1.2), (TeleportingMushroom, 6, 1)], 'message': "Wave 5: Unrelenting Onslaught!" }, # Final wave { - 'enemies': [(EvilWizard, 2, 3), (Mushroom, 10, 1), (Goblin, 10, 1.5), (Skeleton, 20, 0.8)], + 'enemies': [(EvilWizard, 2, 3), (Mushroom, 10, 1), (Goblin, 10, 1.5), (Skeleton, 20, 0.8), (TeleportingMushroom, 8, 1)], 'message': "Wave 6: FINAL WAVE: Ultimate Challenge!" } ]