From: lbcmk <30442978+lbcmk@users.noreply.github.com> Date: Wed, 13 Jul 2022 14:42:52 +0000 (-0400) Subject: Merge branch 'main' of https://github.com/Skullheadx/Pygame-Jam X-Git-Url: http://git.skullheadx.com/index.js?a=commitdiff_plain;h=b26b6098acb2397e4ba5894ff133697f1597720b;p=Pygame-Jam.git Merge branch 'main' of https://github.com/Skullheadx/Pygame-Jam --- b26b6098acb2397e4ba5894ff133697f1597720b diff --cc Enemy.py index 696c80f,f0a3ad7..a4d5d25 --- a/Enemy.py +++ b/Enemy.py @@@ -251,20 -254,44 +254,46 @@@ class King(Actor) self.current_frame = 0 self.display = self.run_frames[math.floor(self.current_frame)] self.state = "RUN" + self.arrow_collision_mask, self.arrow_collision_layer = arrow_info + self.ranged_attack = [] - self.skeleton_attack = True; ++ self.skeleton_attack = False; + def update(self, delta, target=None): super().update(delta) - if not self.attacked and target is not None and self.stun_time == 0: + self.attack_cooldown -= delta + self.attack_cooldown = max(0, self.attack_cooldown) + if self.attack_cooldown == 0 and not self.attacked and target is not None and self.stun_time == 0 and not target.attacked: # self.follow_target(target, follow_range=750,stop_dist=target.width/2+self.weapon.width) - if not target.attacked and get_display_rect(self.weapon.get_collision_rect()).colliderect( + # if get_display_rect(self.weapon.get_collision_rect()).colliderect( + # get_display_rect(target.get_collision_rect())): + if self.state != "ATTACK": + self.state = "ATTACK" + self.current_frame = 0 + self.attack_cooldown = random.randint(2,5) * 1000 + + if not get_display_rect(self.weapon.get_collision_rect()).colliderect( get_display_rect(target.get_collision_rect())): - if self.state != "ATTACK": - self.state = "ATTACK" - self.current_frame = 0 - elif 4 < self.current_frame: - target.attack(self, self.weapon, self.direction) + if (self.position - target.position).length_squared() > 750 ** 2: + self.ranged_attack.append(RangedAttack(target.position + pg.Vector2(0,-400),self.arrow_collision_mask, self.arrow_collision_layer)) + self.attack_cooldown = random.randint(5,10) * 1000 + else: + print("Summon Skeles!") + + + # else: + # if self.state != "SUMMON": + # self.state = "SUMMON" + # self.current_frame = 0 + # self.attack_cooldown = random.randint(2,5) * 1000 + if (self.state == "ATTACK") and (2 < self.current_frame) and (not self.attacked) and not target.attacked: + if get_display_rect(self.weapon.get_collision_rect()).colliderect( + get_display_rect(target.get_collision_rect())): + target.attack(self, self.weapon, math.copysign(1, target.position.x - self.position.x)) + # else: + # # if (self.position - target.position).length_squared() > 750 ** 2: + # print('ranged') + # Deals with collision and applying velocity self.position, self.velocity = self.move_and_collide(self.position.copy(), self.velocity.copy(), delta) diff --cc Game.py index e263d4c,f1f9e3f..aa00b82 --- a/Game.py +++ b/Game.py @@@ -48,15 -50,16 +50,16 @@@ class Game [self.collision_layer["player"], self.collision_layer["world"], self.collision_layer["enemy"]]) for pos in enemy_positions] + 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] if king_position is not None: - self.skeletons = [Skeleton(pos, self.collision_layer["enemy"], - [self.collision_layer["player"], self.collision_layer["world"], - self.collision_layer["enemy"]]) for pos in - self.skele_positions] self.king = King(king_position, self.collision_layer["enemy"], - [self.collision_layer["player"], self.collision_layer["world"], - self.collision_layer["enemy"]] ) - + [self.collision_layer["player"], self.collision_layer["world"], + self.collision_layer["enemy"]],(self.collision_layer["world"], self.collision_layer["arrow"])) + else: + self.king = None self.scene = EndScreen() # self.dashMeter = DashMeter(self.player.dashCooldown) @@@ -211,25 -215,6 +218,26 @@@ 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 ++ if self.king is not None: ++ 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 --cc PhysicsBody.py index abe87a3,8a8c359..6b2959c --- a/PhysicsBody.py +++ b/PhysicsBody.py @@@ -27,14 -27,12 +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") + self.display = pg.transform.scale(pg.image.load("Assets/enemy/Goon_Death.png"), (200,200)) + self.offset = pg.Vector2(-50,-65) else: - display = pg.image.load("Assets/skeleton/SKELETON.png") - self.display = pg.transform.scale(display, (50, 50)) - self.display_offsets["enemy"] = pg.Vector2(25, 10) + self.display = pg.transform.scale(pg.image.load("Assets/skeleton/SKELETON.png"), (100,100)) + self.offset = pg.Vector2(0,-self.display.get_height()/2) def update(self, delta, test=None, test2=None): if self.on_ground: