]> Skullheadx's Git Forge - Pygame-Jam.git/commitdiff
fixed jump on head so it pushes u
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Fri, 8 Jul 2022 04:27:42 +0000 (00:27 -0400)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Fri, 8 Jul 2022 04:27:42 +0000 (00:27 -0400)
Actors.py
Enemy.py

index 28d82f98a7ecf204f6f4f1753025202838d510d7..16979bb859e2d69e6edea1fa8e76ce469b4cf215 100644 (file)
--- a/Actors.py
+++ b/Actors.py
@@ -96,6 +96,10 @@ class Actor:
 
         self.velocity += pg.Vector2(0.5 * v, -1)
 
+    def push2(self, direction):
+        self.velocity += pg.Vector2(0.5 * direction, -1)
+
+
     def move_and_collide(self, pos, vel, delta):
         pos.x += vel.x * delta
         collision_rect = self.get_collision_rect(pos)
index cb3059c773d7d923244a73a8036c1f284aa97ff8..54f71be0d6a9be16b72c2d5569a7a23ceab2eca4 100644 (file)
--- a/Enemy.py
+++ b/Enemy.py
@@ -28,7 +28,7 @@ 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 * 0.8 + self.width + target.width)
-            if random.random() < 2.25/fps and not self.weapon.attacking and self.weapon.get_collision_rect().colliderect(target.get_collision_rect()):
+            if random.random() < 3/fps and not self.weapon.attacking and self.weapon.get_collision_rect().colliderect(target.get_collision_rect()):
                 self.weapon.swing()
                 target.attack(self, self.weapon)
         self.dizzy_time -= delta
@@ -47,8 +47,7 @@ class Enemy(Actor):
     def knockout(self, node):
         self.dizzy_time = 100
         self.modify_health(-25, None)
-        node.on_ground = True
-        node.jump()
+        node.push2(math.copysign(1,self.velocity.x))
         # self.crouch(1000)
 
     def draw(self, surf):