[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Angle To Target Function



"Kris Schnee" <kschnee@xxxxxxxxxx> wrote:
> Just thought I'd offer this function, which might be useful for
> characters with following behavior. It finds the angle from one point to
> another, in degrees, with 0 being "up" and 90 being "right." It's
> therefore useful for deciding whether a target is to a character's right
> etc., and it's easily changed if you don't like the scale I used.


This is probably faster. It's in radians, counterclockwise from West.


import math

AngleToTarget = math.atan2