Handling animations underwater
This commit is contained in:
parent
07c79e8f7a
commit
b09d747efe
@ -65,7 +65,7 @@ class Player(Movable):
|
|||||||
# Small leap in order to get out of the water
|
# Small leap in order to get out of the water
|
||||||
self.leaptimer = 1
|
self.leaptimer = 1
|
||||||
self.leapmaxtimer = 0.5
|
self.leapmaxtimer = 0.5
|
||||||
self.leapmargin = 35 # Vertical margin for the leap
|
self.leapmargin = 30 # Vertical margin for the leap
|
||||||
|
|
||||||
self.gravityway = 1
|
self.gravityway = 1
|
||||||
|
|
||||||
@ -73,7 +73,6 @@ class Player(Movable):
|
|||||||
|
|
||||||
if not self.hitpose:
|
if not self.hitpose:
|
||||||
|
|
||||||
|
|
||||||
if self.water and self.rect.y>self.water.rect.y: # Reverse gravity underwater
|
if self.water and self.rect.y>self.water.rect.y: # Reverse gravity underwater
|
||||||
if self.gravityway == 1:
|
if self.gravityway == 1:
|
||||||
self.gravityway = -1
|
self.gravityway = -1
|
||||||
@ -120,6 +119,7 @@ class Player(Movable):
|
|||||||
self.onceilling = False
|
self.onceilling = False
|
||||||
if self.checkcollisions(0,self.gravityway):
|
if self.checkcollisions(0,self.gravityway):
|
||||||
self.onground = True
|
self.onground = True
|
||||||
|
self.leaptimer = self.leapmaxtimer
|
||||||
self.candash = True
|
self.candash = True
|
||||||
self.canfastfall = True
|
self.canfastfall = True
|
||||||
if self.fastfall:
|
if self.fastfall:
|
||||||
@ -213,5 +213,5 @@ class Player(Movable):
|
|||||||
self.game.globals["cameray"] = self.rect.center[1]-self.game.globals["camerah"]/2
|
self.game.globals["cameray"] = self.rect.center[1]-self.game.globals["camerah"]/2
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
sprite = self.game.pygame.transform.flip(self.sprite,self.flipx,False)
|
sprite = self.game.pygame.transform.flip(self.sprite,self.flipx,self.gravityway<0 and not self.leaptimer<0)
|
||||||
self.game.window.blit(sprite,[self.rect[0]-self.game.globals["camerax"],self.rect[1]-self.game.globals["cameray"]])
|
self.game.window.blit(sprite,[self.rect[0]-self.game.globals["camerax"],self.rect[1]-self.game.globals["cameray"]])
|
||||||
|
Loading…
Reference in New Issue
Block a user