From: lbcmk <30442978+lbcmk@users.noreply.github.com> Date: Wed, 13 Jul 2022 14:34:42 +0000 (-0400) Subject: Skeleton Spawning Works (need to add portal animation) X-Git-Url: http://git.skullheadx.com/life/index.html?a=commitdiff_plain;h=6d46380f4d213db4ffee824a353bb04f4cf2597f;p=Pygame-Jam.git Skeleton Spawning Works (need to add portal animation) --- diff --git a/Enemy.py b/Enemy.py index 9b4f140..696c80f 100644 --- 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 b19e001..e263d4c 100644 --- 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: diff --git a/PhysicsBody.py b/PhysicsBody.py index de3fa6c..abe87a3 100644 --- a/PhysicsBody.py +++ b/PhysicsBody.py @@ -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"])