def sloped_xy_pull(self, sprite):
"""
Applies a so-called xy-pull on a Sprite object moving in x-direction in this sloped tile.
An xy-pull is a change in the y-coordinate because of the x-movement (sliding up/down a slope while moving left/right).
:param Sprite sprite: the Sprite object that's moving on the slope
"""
if self.slope == 0 or not self.slope:
return
# the local x value for the Sprite on the tile's internal x-axis (0=left edge of tile)
x_local = max(0, (sprite.rect.left if self.slope < 0 else sprite.rect.right) - self.rect.left)
# the absolute y-position that we will force the sprite into
y = self.rect.bottom - self.get_y(x_local) - sprite.rect.height
sprite.move(None, y, True)
评论列表
文章目录