Removed entropy

This commit is contained in:
theo@manjaro 2021-11-16 16:03:53 +01:00
parent a6e7e0a436
commit 126c66a231
2 changed files with 27 additions and 27 deletions

View File

@ -18,35 +18,13 @@ class Movable(BaseObject):
self.horspd = 0
self.verspd = 0
self.currentspdh = 0
self.currentspdv = 0
self.hrest = 0
self.vrest = 0
self.dechorentropy = 10
self.acchorentropy = 15
self.decverentropy = 100
self.accverentropy = 25
def step(self):
self.entropy()
self.move(self.currentspdh,self.currentspdv)
def entropy(self):
# Horizontal
if abs(self.currentspdh)>abs(self.horspd): # Décelleration
self.currentspdh += (self.horspd - self.currentspdh)*self.game.dt*self.dechorentropy
else:
self.currentspdh += (self.horspd - self.currentspdh)*self.game.dt*self.acchorentropy
# Vertical
if abs(self.currentspdv)>abs(self.verspd): # Décelleration
self.currentspdv += (self.verspd - self.currentspdv)*self.game.dt*self.decverentropy
else: # Acceleration
self.currentspdv += (self.verspd - self.currentspdv)*self.game.dt*self.accverentropy
self.move(self.horspd,self.verspd)
def move(self,movex,movey):
hstoped = False

View File

@ -43,15 +43,35 @@ class Player(Movable):
self.candash = False
self.canfastfall = False
# Small leap in order to get out of the water
self.leaptimer = 1
self.leapmaxtimer = 1
self.leapmargin = 30 # Vertical margin for the leap
self.gravityway = 1
def step(self):
if not self.hitpose:
self.gravityway = 1
if self.rect.center[1]>self.water.rect[1]:
if self.rect.y>self.water.rect.y: # Reverse gravity underwater
if self.gravityway == 1:
self.gravityway = -1
# Décellerer
self.canfastfall = False
self.verspd *= 0.9
else:
if self.gravityway == -1:
self.gravityway = 1
# Décellerer
self.canfastfall = False
self.verspd *= 0.9
if self.water.rect.y-self.leapmargin<=self.rect.y<=self.water.rect.y+self.leapmargin:
self.leaptimer-=self.game.dt # Inside the margin
else:
self.leaptimer = self.leapmaxtimer # Outside, reset the timer
if not self.game.globals["hitpose"]:
keys = self.game.inputs["keys"]
if self.controlled:
@ -87,9 +107,11 @@ class Player(Movable):
self.verspd+=self.verkb
self.jumped = False
if self.onground:
if self.onground or self.leaptimer<0:
if 0<keys["up"]["timer"]<=3:
self.verspd= self.jump*self.gravityway
if self.leaptimer<0 and not self.onground:
self.verspd = -abs(self.verspd) # Small leap
self.jumped = True
super().step()