def check_cliff_ahead(self):
"""
Checks whether there is a cliff ahead (returns true if yes).
"""
obj = self.game_object
tile_w = obj.stage.screen.tmx_obj.tilewidth
tile_h = obj.stage.screen.tmx_obj.tileheight
# check below character (c=character sprite, _=locateObject (a stripe with x=x width=w-6 and height=3))
# ccc -> walking direction
# ccc
# _
w = max(tile_w * 1.5, obj.rect.width - 6)
col = obj.stage.locate((obj.rect.right - tile_w - w) if self.flipped else (obj.rect.left + tile_w),
obj.rect.bottom - tile_h * 0.5,
w,
tile_h * 1.75,
Sprite.get_type("default"))
if not col or isinstance(col.sprite2, LiquidBody):
return True
return False
# checks whether an enemy is in sight
评论列表
文章目录