Target Strategy¶
-
quest.contrib.target_strategy.distance(a, b)[source]¶ A helper function to find the distance between two points. Uses the pythagorean theorem!
- Parameters
a – (x, y) point
b – (x, y) point
-
class
quest.contrib.target_strategy.TargetStrategy[source]¶ A strategy to go toward a target until the target is reached (or another condition is satisfied). Then re-choose the target.
-
epsilon¶ A distance to consider “close enough,” used to decide if the sprite reached its target. (If you insist on exactly reaching the target, the sprite will always overshoot a little, causing it to jiggle in place forever.)
-
choose_course(sprite, game)[source]¶ Returns a (x, y) vector representing the chosen course.
First, makes sure the sprite has a target. Then checks to see if a new target is needed. If so, chooses a new target. If not, sets the course toward the target.
-
setup_sprite(sprite, game)[source]¶ Makes sure the sprite has a target set.
- Parameters
sprite – The sprite who is about to act.
-
needs_new_target(sprite, game)[source]¶ Decides whether the sprite needs a new target. By default, a sprite needs a new target if it has (nearly) reached its original target.
-