Browse Source

Bug fixed: character jumping on the air

Zero! Studio 1 year ago
parent
commit
0658168a27
1 changed files with 5 additions and 6 deletions
  1. 5 6
      jogai/character.py

+ 5 - 6
jogai/character.py

@@ -374,8 +374,11 @@ class Character(pygame.sprite.Sprite):
         self.jump_force = force
         self.jump_counter = force
 
-        if not self.is_jumping and (
-            not key or _get_keys()[utils.eval_key(key)]
+        if (
+            not self.is_jumping
+            and not key
+            or _get_keys()[utils.eval_key(key)]
+            and bool(self.calculate_collisions((self.x, self.y + 1)))
         ):
             self.is_jumping = True
             if _('jump') in self.animation_filenames.keys():
@@ -901,10 +904,6 @@ class Character(pygame.sprite.Sprite):
             else:
                 self._jump_counter = settings.CHARACTER_DEFAULT_JUMP_FORCE
                 self.is_jumping = False
-                if _('stop') in self.animation_filenames.keys():
-                    self.load(
-                        self.animation_filenames[_('stop')], preserve_size=True
-                    )
 
     def _update_rect_position(
         self,