collides = pg.sprite.spritecollide(self.player,self.walls,False)
if self.player.vel.y > 0: # only if falling
if collides:
if self.player.pos.y < collides[0].rect.bottom:
self.player.pos.y = collides[0].rect.top + 1 # collision
self.player.vel.y = 0 # Set to zero so player wont sink through platform
当我的玩家跳跃时,这仅在顶部边缘不相交,所以就像涂鸦跳跃式游戏一样,无论它来自哪个角度,我都希望我的玩家从墙上弹起。