From: Skullheadx <704277@pdsb.net> Date: Thu, 7 Jul 2022 00:44:56 +0000 (-0400) Subject: assets X-Git-Url: http://git.skullheadx.com/batman.png?a=commitdiff_plain;h=7b3d9d0fc70c2fd6abcf54a5e638e4a5a290ec76;p=Pygame-Jam.git assets --- diff --git a/Assets/GrassBlock.png b/Assets/GrassBlock.png new file mode 100644 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 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 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 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 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 index 0000000..1752c6c Binary files /dev/null and b/Assets/Water.png differ diff --git a/Enemy.py b/Enemy.py index 4382fc1..3a26398 100644 --- 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 689ca77..343be76 100644 --- 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) diff --git a/Weapon.py b/Weapon.py index a70c2f1..7394eec 100644 --- 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)