]> Skullheadx's Git Forge - Pygame-Jam.git/commitdiff
Skeleton Spawning Works (need to add portal animation)
authorlbcmk <30442978+lbcmk@users.noreply.github.com>
Wed, 13 Jul 2022 14:34:42 +0000 (10:34 -0400)
committerlbcmk <30442978+lbcmk@users.noreply.github.com>
Wed, 13 Jul 2022 14:34:42 +0000 (10:34 -0400)
Enemy.py
Game.py
PhysicsBody.py

index 9b4f1407dc297ca443f69273999fae45f973b0ec..696c80f6669215d8e32a38f4e8b61cf984e8e461 100644 (file)
--- a/Enemy.py
+++ b/Enemy.py
@@ -252,6 +252,8 @@ class King(Actor):
         self.display = self.run_frames[math.floor(self.current_frame)]
         self.state = "RUN"
 
+        self.skeleton_attack = True;
+
     def update(self, delta, target=None):
         super().update(delta)
         if not self.attacked and target is not None and self.stun_time == 0:
diff --git a/Game.py b/Game.py
index b19e001c41861efc8288121f5a2f633097e3dffb..e263d4cc40bcd8cce00efb581d4584fdb24ca314 100644 (file)
--- a/Game.py
+++ b/Game.py
@@ -30,7 +30,7 @@ class Game:
 
         self.world = World(self.collision_layer)
 
-        enemy_positions, player_position, self.portal_position, heal_positions, spike_positions, skele_positions, king_position = self.world.load_world(
+        enemy_positions, player_position, self.portal_position, heal_positions, spike_positions, self.skele_positions, king_position = self.world.load_world(
             level)
 
         for i in heal_positions:
@@ -52,7 +52,7 @@ class Game:
             self.skeletons = [Skeleton(pos, self.collision_layer["enemy"],
                                   [self.collision_layer["player"], self.collision_layer["world"],
                                    self.collision_layer["enemy"]]) for pos in
-                                    skele_positions]
+                                    self.skele_positions]
             self.king = King(king_position, self.collision_layer["enemy"],
                                   [self.collision_layer["player"], self.collision_layer["world"],
                                    self.collision_layer["enemy"]] )
@@ -72,6 +72,9 @@ class Game:
 
         # self.hints = [(Object((270, 640)), "Hello")]
         self.dialogue = DialogueUI()
+        
+        self.skeleton_spawn_frame = pg.transform.scale(pil_to_game(get_gif_frame(Image.open("Assets/skeleton/skeleton_attack.gif"), 0)), (170, 138))
+        self.skeleton_spawn_coords = []
 
         self.paused = False
         self.PauseMenu = PauseMenu(self.level)
@@ -208,6 +211,25 @@ class Game:
                 self.dialogue.draw(surf, self.player, "This treasure is pennies compared to what I'm after...", 10, 3)
                 self.dialogue.draw(surf, self.player, "But this portal will bring me one dimension closer!", 10, 4)
 
+        if (self.level == 5):
+            if self.king.skeleton_attack == True:
+                for i in range(random.randint(1, 3)):
+                    # if(len(self.collision_layer["enemy"]) < 5 and len(self.skeleton_spawn_coords) < 5):
+                    self.skeleton_spawn_coords.append((random.randint(1100, 2000), random.randint(1900, 2100)))
+                self.king.skeleton_attack = False
+
+
+            for i in range(len(self.skeleton_spawn_coords)):
+                if(self.skeleton_spawn_coords[i][1] <= 1780):
+                    skele = Skeleton(self.skeleton_spawn_coords[i], self.collision_layer["enemy"], [self.collision_layer["player"],self.collision_layer["world"],self.collision_layer["enemy"]])
+                    self.skeletons.append(skele)
+                    self.skeleton_spawn_coords.pop(i)
+                else:
+                    lst = list(self.skeleton_spawn_coords[i])
+                    lst[1] -= 1
+                    self.skeleton_spawn_coords[i] = tuple(lst)
+                    surf.blit(self.skeleton_spawn_frame, get_display_point(self.skeleton_spawn_coords[i]))  
+
         for enemy in self.enemies:
             enemy.draw(surf)
         for enemy in self.skeletons:
index de3fa6c5e67286a0ed88d0f36242441d7e1e1355..abe87a373de7d6c4f4581e5cad488ed5912151e3 100644 (file)
@@ -27,10 +27,14 @@ class PhysicsBody:
         self.collision_layer = collision_layer
         self.collision_mask = collision_mask  # the layer the actor detects collisions against
 
+        self.display_offsets = {"enemy":pg.Vector2(0,0)}
+
         if goon_skin:
             self.display = pg.image.load("Assets/enemy/Pirate_Goon.png")
         else:
-            self.display = pg.image.load("Assets/skeleton/SKELETON.png")
+            display = pg.image.load("Assets/skeleton/SKELETON.png")
+            self.display = pg.transform.scale(display, (50, 50))
+            self.display_offsets["enemy"] = pg.Vector2(25, 10)
 
     def update(self, delta, test=None, test2=None):
         if self.on_ground:
@@ -99,4 +103,4 @@ class PhysicsBody:
     def draw(self, surf):
         # print(self.position, self.velocity)
         pg.draw.rect(surf, self.colour, get_display_rect(self.get_collision_rect()), border_radius=8)
-        surf.blit(self.display,get_display_rect(self.get_collision_rect()))
+        surf.blit(self.display,get_display_rect(self.get_collision_rect()).topleft + self.display_offsets["enemy"])