Degtorad

From Game Editor

Revision as of 01:03, 4 May 2011 by Skydereign (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

double degtorad(double a);

degtorad returns the radian equivalent of angle a. Useful as certain functions, like cos, sin, and other trig functions require radian input.


Example: Keep the nob of an on screen joystick in a circle around the base. Uses distance, direction, cos, and sin.

joystickNob -> Draw actor -> Script Editor

if(distance(x,y,joystickBase.x, joystickBase.y)>50)
{
    double ang = degtorad(direction(joystickBase.x, joystickBase.y, x, y));
    x=joystickBase.x-cos(ang);
    y=joystickBase.y+sin(ang);
}