Exemple #1
0
    def seek(self, target):
        # find vector to target
        desired = Vector.static_sub(target, self.location)
        desired.normalize()

        desired.mult(self.max_speed)

        # Reynold's formula for steering force
        steering_force = Vector.static_sub(desired, self.velocity)
        # apply force
        self.acceleration.add(steering_force)
        # recalc position
        self.velocity.add(self.acceleration)
        self.location.add(self.velocity)
        print(self.location.x, self.location.y)