]> Skullheadx's Git Forge - Pygame-Jam.git/commitdiff
no running sound after jumping bug fix
author711215 <711215@pdsb.net>
Mon, 11 Jul 2022 19:46:22 +0000 (15:46 -0400)
committer711215 <711215@pdsb.net>
Mon, 11 Jul 2022 19:46:22 +0000 (15:46 -0400)
Player.py
main.py

index 292aed8bf4e34bb14f03b3acee45d1090032656d..ccf6ddd7cd4c6cf0773a74184ff49a4afd740c11 100644 (file)
--- a/Player.py
+++ b/Player.py
@@ -65,6 +65,8 @@ class Player(Actor):
         self.direction = -1
 
         self.state = "IDLE"
+        self.previous_state = "IDLE"
+        self.previous_ground_state = self.on_ground
         self.current_frame = 0
         self.display = self.idle_frames[0]
         self.display_offsets = {"weapon": pg.Vector2(0, 0), "player": pg.Vector2(0, 0)}
@@ -82,12 +84,11 @@ class Player(Actor):
         # Get and handle input
         self.handle_input()
 
-        # if self.potion_cooldown > 0:
-        # threading.Thread(Potion.cooldown)
-
         if len(self.potion_bag) > 0:
             self.potion_bag[0].get_input(self)
 
+        print(self.state, self.previous_state)
+
         # Deals with collision and applying velocity
         self.position, self.velocity = self.move_and_collide(self.position.copy(), self.velocity.copy(), delta)
 
@@ -154,6 +155,15 @@ class Player(Actor):
 
             self.current_frame = (self.current_frame + 0.5) % self.run_gif.n_frames
 
+        if self.state == "RUN":
+            if self.previous_state != "RUN":
+                self.running_sound_channel.play(self.running_sound, -1)
+
+            if self.on_ground == True and self.previous_ground_state == False:
+                self.running_sound_channel.play(self.running_sound, -1)
+                
+        self.previous_state = self.state
+        self.previous_ground_state = self.on_ground
         return self.position - center
 
     def handle_input(self):
@@ -166,7 +176,7 @@ class Player(Actor):
             if self.state != "ATTACK":
                 if self.state != "RUN":
                     self.current_frame = 0
-                    self.running_sound_channel.play(self.running_sound, 999)
+                    
                 self.state = "RUN"
             self.move_left()
             # if (self.lastValueL == False):
@@ -187,7 +197,7 @@ class Player(Actor):
             if self.state != "ATTACK":
                 if self.state != "RUN":
                     self.current_frame = 0
-                    self.running_sound_channel.play(self.running_sound, 999)
+                    
                 self.state = "RUN"
 
             self.move_right()
diff --git a/main.py b/main.py
index a401dd6290292081eb5069730c94bf4223fa4ae8..0a33b6353a6e135d7d07dc0432c881d163149e76 100644 (file)
--- a/main.py
+++ b/main.py
@@ -14,7 +14,7 @@ is_running = True
 # scene = TransitionScene()
 scene = DevLevelSelect()
 old_level = 0
-level = 5
+level = 0
 next_level = 0
 
 while is_running: