You'd probably need to use atan(dy/dx). however the usage of atan is a
little problematic since dx is not necessarily unequal zero and it's
(which is the opposite direction).
I recommend using one vector for the direction and speed (with the speed
being the length of the direction vector) and one for the location. So
instead of
x = x + speed * sin(direction * 2*pi)
y = y + speed * cos(direction * 2*pi)
you'd have
Position = Position+Direction ( with Direction = vnormalize(<dx,dy>)*Speed )
if you need to access the former x and y components use
x=Position.x
y=Position.y
Hope that helps!
Regards Roman
Post a reply to this message
|