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