]> Skullheadx's Git Forge - Pygame-Jam.git/commitdiff
Merge branch 'main' of https://github.com/Skullheadx/Pygame-Jam
authorlbcmk <30442978+lbcmk@users.noreply.github.com>
Wed, 13 Jul 2022 14:42:52 +0000 (10:42 -0400)
committerlbcmk <30442978+lbcmk@users.noreply.github.com>
Wed, 13 Jul 2022 14:42:52 +0000 (10:42 -0400)
1  2 
Enemy.py
Game.py
PhysicsBody.py

diff --cc Enemy.py
index 696c80f6669215d8e32a38f4e8b61cf984e8e461,f0a3ad745a78b27cfb4176593f0ddd3b5128bd2b..a4d5d25d109a7577b387c27f4da70f5681c747a6
+++ 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 e263d4cc40bcd8cce00efb581d4584fdb24ca314,f1f9e3f2bbb5318af2c62bce0abda86b9b7171be..aa00b82311457bebde9182112994d3a19e42c82d
+++ 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]
 -                          skele_positions]
+         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]
          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)
                  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.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.level == 5):
++            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 abe87a373de7d6c4f4581e5cad488ed5912151e3,8a8c35923f987a28a527ac1a7c4c7d126121f33c..6b2959ce73358bcf77ebf1eee775640a501443a1
@@@ -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: