Passage à travers les semi plateformes
This commit is contained in:
parent
2019416980
commit
5f4d490f07
@ -58,6 +58,14 @@ class Player(BaseObject):
|
|||||||
else:
|
else:
|
||||||
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)
|
||||||
|
|
||||||
|
# Je passe en dessous des semi-plateformes
|
||||||
|
if not self.checkcollisions(0,1,semi=False):
|
||||||
|
semi = self.checkcollisions(0,1,classic=False)
|
||||||
|
if semi!=self.checkcollisions(0,0,classic=False) and semi:
|
||||||
|
if keys["down"]["timer"]==1:
|
||||||
|
self.rect.bottom = semi.top+1
|
||||||
|
|
||||||
|
|
||||||
self.game.globals["camerax"] = self.rect.center[0]-self.game.globals["cameraw"]/2
|
self.game.globals["camerax"] = self.rect.center[0]-self.game.globals["cameraw"]/2
|
||||||
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
|
||||||
|
|
||||||
@ -106,16 +114,17 @@ class Player(BaseObject):
|
|||||||
ver-=diffy
|
ver-=diffy
|
||||||
self.rect[1]+=diffy
|
self.rect[1]+=diffy
|
||||||
|
|
||||||
def checkcollisions(self,offx,offy):
|
def checkcollisions(self,offx,offy,classic=True,semi=True):
|
||||||
temprect = self.rect.copy()
|
temprect = self.rect.copy()
|
||||||
temprect[0]+=offx
|
temprect[0]+=offx
|
||||||
temprect[1]+=offy
|
temprect[1]+=offy
|
||||||
result = False
|
result = False
|
||||||
for rect in self.collisionrects:
|
if classic:
|
||||||
if temprect.colliderect(rect):
|
for rect in self.collisionrects:
|
||||||
result = rect
|
if temprect.colliderect(rect):
|
||||||
break
|
result = rect
|
||||||
if not result:
|
break
|
||||||
|
if not result and semi:
|
||||||
for rect in self.semirects:
|
for rect in self.semirects:
|
||||||
if self.rect.bottom<=rect.top:
|
if self.rect.bottom<=rect.top:
|
||||||
if temprect.colliderect(rect):
|
if temprect.colliderect(rect):
|
||||||
|
Loading…
Reference in New Issue
Block a user