Jump update (step 2)
This commit is contained in:
@@ -58,9 +58,6 @@ class Player(pygame.sprite.Sprite):
|
||||
def update(self):
|
||||
if not self.speed: self.rect.y += 1
|
||||
|
||||
self.speed += 0.07 * self.gameSpeed
|
||||
self.rect.y += self.speed
|
||||
|
||||
if not self.isDownJump:
|
||||
self.hoverCount = 0
|
||||
|
||||
@@ -81,10 +78,21 @@ class Player(pygame.sprite.Sprite):
|
||||
self.standup()
|
||||
|
||||
if self.isJumping:
|
||||
maxHoverCount = 30
|
||||
if self.isDownJump and self.hoverCount < maxHoverCount:
|
||||
self.speed -= self.gameSpeed/10 * (math.sin(2*math.pi*self.hoverCount/(2*maxHoverCount)+math.pi/2)+1)/2.5+0.2
|
||||
self.hoverCount += 1
|
||||
# maxHoverCount = 30
|
||||
if self.gameSpeed <= 2: maxHoverCount = 30
|
||||
elif self.gameSpeed <= 4: maxHoverCount = 23
|
||||
elif self.gameSpeed <= 8: maxHoverCount = 16
|
||||
elif self.gameSpeed <= 16: maxHoverCount = 9
|
||||
elif self.gameSpeed <= 32: maxHoverCount = 5
|
||||
elif self.gameSpeed <= 64: maxHoverCount = 2
|
||||
else: maxHoverCount = 1
|
||||
|
||||
if self.isDownJump and self.hoverCount < maxHoverCount:
|
||||
self.speed -= self.gameSpeed/8 * ((math.cos(2*math.pi*self.hoverCount/(2*maxHoverCount))+1)/2.5+0.2)
|
||||
self.hoverCount += 1
|
||||
else:
|
||||
self.isJumping = False
|
||||
else:
|
||||
self.speed += 0.07 * self.gameSpeed
|
||||
|
||||
self.rect.y += self.speed
|
||||
|
||||
Reference in New Issue
Block a user