def tick(self, game_loop):
"""
Needs to be called by the GameObject at some point during the GameObject's `tick` method.
:param GameLoop game_loop: the currently playing GameLoop object
"""
obj = self.game_object
self.reset()
if self.game_obj_cmp_anim and self.game_obj_cmp_anim.flags & Animation.get_flag("paralyzes"):
return
# look for edges ahead -> then change direction if one is detected
# - makes sure an enemy character does not fall off a cliff
if (not (game_loop.frame % 3) and self.check_cliff_ahead()) or obj.rect.x <= 0 or obj.rect.x >= obj.x_max:
self.toggle_direction()
self.commands["left" if self.flipped else "right"] = True
评论列表
文章目录