]> Skullheadx's Git Forge - Pygame-Jam.git/commitdiff
assets
authorSkullheadx <704277@pdsb.net>
Thu, 7 Jul 2022 00:44:56 +0000 (20:44 -0400)
committerSkullheadx <704277@pdsb.net>
Thu, 7 Jul 2022 00:44:56 +0000 (20:44 -0400)
Assets/GrassBlock.png [new file with mode: 0644]
Assets/LEAFS.png [new file with mode: 0644]
Assets/LEAFS1.png [new file with mode: 0644]
Assets/StoneBlock.png [new file with mode: 0644]
Assets/TREEBARK.png [new file with mode: 0644]
Assets/Water.png [new file with mode: 0644]
Enemy.py
Game.py
Weapon.py

diff --git a/Assets/GrassBlock.png b/Assets/GrassBlock.png
new file mode 100644 (file)
index 0000000..b4a37fc
Binary files /dev/null and b/Assets/GrassBlock.png differ
diff --git a/Assets/LEAFS.png b/Assets/LEAFS.png
new file mode 100644 (file)
index 0000000..5852c7e
Binary files /dev/null and b/Assets/LEAFS.png differ
diff --git a/Assets/LEAFS1.png b/Assets/LEAFS1.png
new file mode 100644 (file)
index 0000000..e57952f
Binary files /dev/null and b/Assets/LEAFS1.png differ
diff --git a/Assets/StoneBlock.png b/Assets/StoneBlock.png
new file mode 100644 (file)
index 0000000..7cf51fc
Binary files /dev/null and b/Assets/StoneBlock.png differ
diff --git a/Assets/TREEBARK.png b/Assets/TREEBARK.png
new file mode 100644 (file)
index 0000000..0a82c72
Binary files /dev/null and b/Assets/TREEBARK.png differ
diff --git a/Assets/Water.png b/Assets/Water.png
new file mode 100644 (file)
index 0000000..1752c6c
Binary files /dev/null and b/Assets/Water.png differ
index 4382fc17ac468f9642a8d28be462e94486967246..3a2639822ff80108e329e7f6756f5861555e5d96 100644 (file)
--- a/Enemy.py
+++ b/Enemy.py
@@ -26,6 +26,8 @@ class Enemy(Actor):
         super().update(delta)
         if target is not None and self.dizzy_time == 0:
             self.follow_target(target,stop_dist=self.weapon.width + self.width + target.width)
+            if self.weapon.get_collision_rect().colliderect(target.get_collision_rect()):
+                self.weapon.swing()
         self.dizzy_time -= delta
         self.dizzy_time = max(0,self.dizzy_time)
 
diff --git a/Game.py b/Game.py
index 689ca77bfe76ac40cae3f7bec04bc9b094533823..343be76ff7fb6150ba201e51c0b2d26613b261aa 100644 (file)
--- a/Game.py
+++ b/Game.py
@@ -43,4 +43,4 @@ class Game:
             block.draw(surf)
 
         self.player.draw(surf)
-        self.pet.draw(surf)
+        self.pet.draw(surf)
index a70c2f182341a0f819b4005c418b0e90735084d3..7394eece09342ef8e0251dfeddba028bbaadb65e 100644 (file)
--- a/Weapon.py
+++ b/Weapon.py
@@ -10,19 +10,32 @@ class Melee:
         self.offset = pg.Vector2(offset)
         self.holder_width = width
 
+        self.direction = direction
+
+        self.display = self.img
+        self.swing_timer = 0
 
     def update(self, delta, pos, direction):
         self.position = pg.Vector2(pos)
         self.direction = direction
 
+        if self.direction == -1:
+            self.display = pg.transform.rotate(self.img, 360 * math.sin(math.radians(self.swing_timer/10)))
+        elif self.direction == 0:
+            self.display = pg.transform.rotate(self.flipped_img, -360 * math.sin(math.radians(self.swing_timer/10)))
+
+        self.swing_timer -= delta
+        self.swing_timer = max(self.swing_timer, 0)
+
     def get_collision_rect(self):
         if self.direction == -1:
             return pg.Rect(self.position - pg.Vector2(self.width,0),(self.width, self.height))
         elif self.direction == 1:
             return pg.Rect(self.position + pg.Vector2(self.holder_width,0),(self.width, self.height))
 
+    def swing(self):
+        if self.swing_timer == 0:
+            self.swing_timer = 1800
+
     def draw(self, surf):
-        if self.direction == -1:
-            surf.blit(self.img, self.get_collision_rect().topleft)
-        else:
-            surf.blit(self.flipped_img, self.get_collision_rect().topleft)
+        surf.blit(self.display, self.get_collision_rect().topleft)