lordmauve / pgzero

A zero-boilerplate games programming framework for Python 3, based on Pygame.
https://pygame-zero.readthedocs.io/
GNU Lesser General Public License v3.0
527 stars 191 forks source link

add move_towards fct in Actor #277

Open yansnow78 opened 2 years ago

yansnow78 commented 2 years ago

add move_towards fct in Actor the change in code is inspired from pgzhelper def move_towards(self, direction:Union[int, float, Actor, _Coordinate], distance, stop_on_target=True): what it does: """move actor position of a certain distance in pixels in a certain direction this direction can be an angle in degrees or an Actor or a point coordinate"""

orignally in pgzhelper, there was much more function but move_towards can do all maybe the function point_towards will be cool to have to this is what was orignally in pgzhelper

  direction:float
  def move_towards(self, actor, dist): # move in direction to another actor
  def point_towards(self, actor): # point in direction to another actor
  def move_in_direction(self, dist): # move in direction to self.direction
  def move_forward(self, dist): # move in direction to self.anlge
  def move_left(self, dist): # move in direction to self.angle+90
  def move_right(self, dist): # move in direction to self.angle-90
  def move_back(self, dist): # move in direction opposite to -self.angle