Added calculation of MaxHoverCount by gameSpeed

This commit is contained in:
Nikolya Andreychik
2021-04-07 14:09:07 -07:00
parent b73916ac03
commit 6f246354c7
+4 -15
View File
@@ -142,6 +142,9 @@ class Player(pygame.sprite.Sprite):
elif event.key in self.buttonsJump: elif event.key in self.buttonsJump:
self.isDownJump = False self.isDownJump = False
def calcMaxHoverCount(self, speed):
return 26.57 - 6.23*math.log(speed) + 23.82*(1/speed) + 0.086*speed
def update(self): def update(self):
self.updateCount += 1 self.updateCount += 1
@@ -168,21 +171,7 @@ class Player(pygame.sprite.Sprite):
gameSpeed = self.mainGameClass.getGameSpeed() gameSpeed = self.mainGameClass.getGameSpeed()
if self.isJumping: if self.isJumping:
if gameSpeed <= 2: maxHoverCount = 40 maxHoverCount = self.calcMaxHoverCount(gameSpeed)
elif gameSpeed <= 4: maxHoverCount = 28
elif gameSpeed <= 5: maxHoverCount = 23
elif gameSpeed <= 7: maxHoverCount = 20
elif gameSpeed <= 8: maxHoverCount = 18
elif gameSpeed <= 10: maxHoverCount = 16
elif gameSpeed <= 11: maxHoverCount = 15
elif gameSpeed <= 13: maxHoverCount = 14
elif gameSpeed <= 15: maxHoverCount = 13
elif gameSpeed <= 17: maxHoverCount = 12
elif gameSpeed <= 22: maxHoverCount = 11
elif gameSpeed <= 26: maxHoverCount = 10
elif gameSpeed <= 32: maxHoverCount = 9
elif gameSpeed <= 43: maxHoverCount = 8
else: maxHoverCount = 7
if self.isDownJump and self.hoverCount < maxHoverCount: if self.isDownJump and self.hoverCount < maxHoverCount:
self.speed -= gameSpeed/8 * ( self.speed -= gameSpeed/8 * (