]> Skullheadx's Git Forge - Pygame-Jam.git/commitdiff
Fixed a double dash bug
authorlbcmk <30442978+lbcmk@users.noreply.github.com>
Thu, 7 Jul 2022 22:15:48 +0000 (18:15 -0400)
committerlbcmk <30442978+lbcmk@users.noreply.github.com>
Thu, 7 Jul 2022 22:15:48 +0000 (18:15 -0400)
Player.py

index 24d58f7fcb95ad87eb8aace580bf7f54e994ed1a..e25333f4c338f1c0ac11d7ec195008609889f287 100644 (file)
--- a/Player.py
+++ b/Player.py
@@ -47,13 +47,12 @@ class Player(Actor):
             if(self.lastValueL == False):
                 timeSincePressed = datetime.utcnow() - self.lastPressedLeft
                 timeSinceLastDash = datetime.utcnow() - self.lastDash
-
+                if(timeSinceLastDash >= self.dashCooldown): self.dashPossible = True
+                else: self.dashPossible = False
                 if(timeSincePressed < self.timeBetweenDoublePress and self.dashPossible == True):
                     self.move_left(self.dashSpeed) # change this to change how the player dashes (maybe replace with a custom dash function)
                     self.dashPossible = False
                     self.lastDash = datetime.utcnow()
-                if(timeSinceLastDash >= self.dashCooldown):
-                    self.dashPossible = True
                 self.lastPressedLeft = datetime.utcnow()            
             
         if pressed[pg.K_d] or pressed[pg.K_RIGHT]:
@@ -61,12 +60,12 @@ class Player(Actor):
             if(self.lastValueR == False):
                 timeSincePressed = datetime.utcnow() - self.lastPressedRight
                 timeSinceLastDash = datetime.utcnow() - self.lastDash
+                if(timeSinceLastDash >= self.dashCooldown):     self.dashPossible = True
+                else:   self.dashPossible = False
                 if(timeSincePressed < self.timeBetweenDoublePress and self.dashPossible == True):
-                    self.move_right(self.dashSpeed) # change this to change how the player dashes (maybe replace with a custom dash function)
-                    self.dashPossible = False
                     self.lastDash = datetime.utcnow()
-                if(timeSinceLastDash >= self.dashCooldown):
-                    self.dashPossible = True
+                    self.dashPossible = False
+                    self.move_right(self.dashSpeed) # change this to change how the player dashes (maybe replace with a custom dash function)
                 self.lastPressedRight = datetime.utcnow()        
         
         self.lastValueL = pressed[pg.K_a] or pressed[pg.K_LEFT]