Bonk sur le plafond
This commit is contained in:
parent
dff1fa4175
commit
b76e3b45d6
@ -35,6 +35,17 @@ class Player(BaseObject):
|
|||||||
self.onground = True
|
self.onground = True
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# Check if under ceiling
|
||||||
|
self.onceiling = False
|
||||||
|
targetpos = self.getgridpos(0,-1)
|
||||||
|
pos = [targetpos["ul"],targetpos["ur"]]
|
||||||
|
for x in range(pos[0]["x"],pos[1]["x"]+1):
|
||||||
|
if pos[0]["y"]>=0 and pos[0]["y"]<len(self.grid):
|
||||||
|
if x>=0 and x<len(self.grid[pos[0]["y"]]):
|
||||||
|
if self.grid[pos[0]["y"]][x]==1:
|
||||||
|
self.onceiling= True
|
||||||
|
break
|
||||||
|
|
||||||
if not self.onground:
|
if not self.onground:
|
||||||
self.vertical += self.gravity*self.game.dt
|
self.vertical += self.gravity*self.game.dt
|
||||||
self.vertical = min(self.maxgrav,self.vertical)
|
self.vertical = min(self.maxgrav,self.vertical)
|
||||||
@ -44,7 +55,8 @@ class Player(BaseObject):
|
|||||||
else:
|
else:
|
||||||
self.vertical = 0
|
self.vertical = 0
|
||||||
|
|
||||||
print(self.vertical)
|
if self.onceiling and self.vertical < 0:
|
||||||
|
self.vertical = 0
|
||||||
|
|
||||||
self.move(hor*self.speed*self.game.dt,self.vertical*self.game.dt)
|
self.move(hor*self.speed*self.game.dt,self.vertical*self.game.dt)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user