]> Skullheadx's Git Forge - Pygame-Jam.git/commitdiff
boss melee atk
authorSkullheadx <704277@pdsb.net>
Wed, 13 Jul 2022 02:35:17 +0000 (22:35 -0400)
committerSkullheadx <704277@pdsb.net>
Wed, 13 Jul 2022 02:35:17 +0000 (22:35 -0400)
Enemy.py
Game.py
Weapon.py

index 422daac3660d0a0f57204f736e89f1d3b84f1549..a44c77b3685b86a9bed5c197fcec408768a5c906 100644 (file)
--- a/Enemy.py
+++ b/Enemy.py
@@ -3,7 +3,7 @@ from argparse import Action
 from Setup import *
 from Player import Player
 from Actors import Actor
-from Weapon import Sword
+from Weapon import Sword, Lightning
 from Particle import Dust
 
 class Enemy(Actor):
@@ -136,7 +136,7 @@ class Skeleton(Actor):
         self.direction = -1
         self.prev_direction = self.direction
 
-        self.health = 0 # for debugging without getting killed
+        self.health = 0 # for debugging without getting killed
 
         self.weapon = Sword(self.position, (0, 0), self.width, -1)
 
@@ -221,7 +221,7 @@ class King(Actor):
     run_gif = Image.open("Assets/skeleton/skeleton_king_idle.gif")
     run_frames = []
     for i in range(run_gif.n_frames):
-        run_frames.append(pg.transform.scale(pil_to_game(get_gif_frame(run_gif, i)), (160, 240)))
+        run_frames.append(pg.transform.scale(pil_to_game(get_gif_frame(run_gif, i)), (120, 180)))
 
     attack_gif = Image.open("Assets/skeleton/skeleton_king_summon.gif")
     attack_frames = []
@@ -239,11 +239,9 @@ class King(Actor):
         self.direction = -1
         self.prev_direction = self.direction
 
-        # self.health = 0 # for debugging without getting killed
-
-        self.weapon = Sword(self.position, (0, 0), self.width, -1)
-
+        self.health = 1000 # for debugging without getting killed
 
+        self.weapon = Lightning(self.position, (-100 - self.width/2,0), self.width, -1)
         self.buffer = []
 
         self.display_offsets = {"enemy":pg.Vector2(0,0)}
@@ -262,7 +260,7 @@ class King(Actor):
                     self.state = "ATTACK"
                     self.current_frame = 0
                 elif 4 < self.current_frame:
-                    target.attack(self, self.weapon, self.direction)
+                    target.attack(self, self.weapon, math.copysign(1, target.position.x - self.position.x))
 
         # Deals with collision and applying velocity
         self.position, self.velocity = self.move_and_collide(self.position.copy(), self.velocity.copy(), delta)
@@ -276,15 +274,10 @@ class King(Actor):
 
         if self.state == "RUN":
             frame = math.floor(self.current_frame)
-            if self.velocity.x > 0:
-                self.display = self.run_frames[math.floor(frame)]
-                self.display_offsets["enemy"] = pg.Vector2(-30, -35)
-            elif self.velocity.x <= 0:
-                self.display = pg.transform.flip(self.run_frames[math.floor(frame)], True, False)
-                self.display_offsets["enemy"] = pg.Vector2(-90, -35)
-            if frame % 4 == 0 and self.on_ground:
-                Dust(pg.Vector2(self.get_collision_rect().midbottom) + pg.Vector2(math.copysign(1, self.velocity.x) * -self.width/2,-15), 16, self.direction)
-            self.current_frame = (self.current_frame + 0.25) % self.run_gif.n_frames
+            self.display = self.run_frames[math.floor(frame)]
+            self.display_offsets["enemy"] = pg.Vector2(0, -35)
+            self.current_frame = (self.current_frame + 0.025) % self.run_gif.n_frames
+
         elif self.state == "ATTACK":
             frame = math.floor(self.current_frame)
             if self.direction == 1:
@@ -296,6 +289,7 @@ class King(Actor):
             self.current_frame += 0.4
             if math.floor(self.current_frame) >= self.attack_gif.n_frames-1:
                 self.state = "RUN"
+                self.current_frame = 0
 
         # print(self.velocity)
 
@@ -308,10 +302,10 @@ class King(Actor):
 
     def draw(self, surf):
         # self.weapon.draw(surf)
-        # super(Enemy, self).draw(surf)
+        super(King, self).draw(surf)
         surf.blit(self.display, get_display_rect(self.get_collision_rect()).topleft + self.display_offsets["enemy"])
 
         # for b in self.buffer:
         #     pg.draw.rect(surf,(0,0,255),get_display_rect(b),3)
         # self.buffer.append(self.get_collision_rect())
-        # pg.draw.rect(surf, (0, 255, 0), get_display_rect(self.get_collision_rect()), 2)
+        pg.draw.rect(surf, (0, 255, 0), get_display_rect(self.weapon.get_collision_rect()), 2)
diff --git a/Game.py b/Game.py
index b19e001c41861efc8288121f5a2f633097e3dffb..763a14a0f65d17146241cfb10241aead8a02c881 100644 (file)
--- a/Game.py
+++ b/Game.py
@@ -142,7 +142,7 @@ class Game:
                                                   [self.collision_layer["world"], self.collision_layer["body"]], goon_skin=False)
                     self.collision_layer["enemy"].remove(enemy)
                     self.collision_layer["body"].add(self.skeletons[i])
-            self.king.update(delta)
+            self.king.update(delta, self.player)
             if self.king.dead:
                 print("You win!")
 
index 0ecbfd3effe2c310125d534fd835bd7e9cc562e4..74bedd49745bc4ba2c2aed85089c22dc38dbfb0c 100644 (file)
--- a/Weapon.py
+++ b/Weapon.py
@@ -93,3 +93,21 @@ class Sword:
 
     def draw(self, surf, display_offset = pg.Vector2(0,0)):
         surf.blit(self.display, get_display_rect(self.get_collision_rect()).topleft + display_offset)
+class Lightning:
+    width,height = (200,200)
+    damage = -35
+
+    def __init__(self, pos, offset, width,direction):
+        self.position = pg.Vector2(pos)
+        self.offset = pg.Vector2(offset)
+
+    def update(self, delta, pos, direction):
+        self.position = pg.Vector2(pos)
+
+    def get_collision_rect(self):
+        return pg.Rect(self.position - self.offset - pg.Vector2(self.width,self.height/4),(self.width, self.height))
+
+
+    def draw(self, surf, display_offset = pg.Vector2(0,0)):
+        pass
+        # surf.blit(self.display, get_display_rect(self.get_collision_rect()).topleft + display_offset)