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.
AM2R-TimeTrials/scripts/turn_towards_direction.gml

22 lines
666 B

/// turn_towards_direction(direction, turnspeed)
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;