scrOrbit

Orbits the object around a point

 Script

/// orbit script
/* makes the object orbit around some point or an object
 dont try to set this by hand. use scrMakeOrbit to set all variables for this.
*/
if orbit == true {
    if instance_exists(orbit_obj_name) { 
        with(orbit_obj_name) { // grab orbitX from orbitObject
            if (other.orbit_obj = id) { other.orbit_x = x; other.orbit_y = y }
        }
    }
    // rad calculation
    if (orbit_flux) { // if flux enabled
        if (orbit_flux_smth) { // smth
            orbit_flux_smth_counter += orbit_rad_dev; // increase counter by script given val
            var orbit_smth_limit = orbit_rad_max - orbit_rad_min; // define limits for smth
            orbit_rad = (orbit_smth_limit/2)*sin(degtorad(orbit_flux_smth_counter))+((orbit_rad_max+orbit_rad_min)/2)
        } else { // not smth
            if (orbit_rad_inc) { // If orbit_rad_inc flag is true
                orbit_rad += orbit_rad_dev // Increase orbit_rad by fixed val
            } else {
                orbit_rad -= orbit_rad_dev // Decrease orbit_rad by fixed val
            }
            if (orbit_rad > orbit_rad_max) { orbit_rad = orbit_rad_max; orbit_rad_inc = false;} // set to limit + set flag
            if (orbit_rad < orbit_rad_min) { orbit_rad = orbit_rad_min; orbit_rad_inc = true;} // set to limit + set flag
        }
    } else { // no fluctuation [go to orbit_rad_max]
        if (orbit_rad < orbit_rad_max) { orbit_rad += orbit_rad_dev; } // you're not at max. keep going 
        if (orbit_rad > orbit_rad_max) { orbit_rad = orbit_rad_max; } // you're at max congrats
        if (orbit_rad < orbit_rad_min) { orbit_rad = orbit_rad_min; } // you were below the min. wtf?
    }
    if (orbit_clockwise) { // clockwise
        orbit_ang -= orbit_sp; // incriment ang
    } else { // counterclockwise
        orbit_ang += orbit_sp; // incriment ang
    }
    // make the shit spin yo
    x = orbit_x + orbit_rad * cos(orbit_ang * pi / 180);
    y = orbit_y - orbit_rad * sin(orbit_ang * pi / 180);
}