You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Turbo-X-Horde-AM2R/Export_Code/gml_Script_turn_towards_dir...

32 lines
654 B

var wdir, turnspeed, tempdir;
wdir = argument0
turnspeed = argument1
if (abs((wdir - direction)) > 180)
{
if (wdir > 180)
{
tempdir = (wdir - 360)
if (abs((tempdir - direction)) > turnspeed)
direction -= turnspeed
else
direction = wdir
}
else
{
tempdir = (wdir + 360)
if (abs((tempdir - direction)) > turnspeed)
direction += turnspeed
else
direction = wdir
}
}
else if (abs((wdir - direction)) > turnspeed)
{
if (wdir > direction)
direction += turnspeed
else
direction -= turnspeed
}
else
direction = wdir