GML Inversing a Number

H

Harper

Guest
Hello all!
Say I have a range, from 115 to 200, and the values I am given on that range go up from 115 to 200 but I need to get them to go down from 200 to 115, how would I go about doing that?

Here's my actual code that I've been struggling with (line 4 is the number given that I want to inverse):
Code:
if(instance_exists(obj_ship)) {
    if(collision_circle(x, y, gravity_radius, obj_ship, false, false)) {
        obj_ship.planet_gravity = true;
        draw_set_alpha(distance_to_object(obj_ship) / (gravity_radius - (sprite_width / 2)));
        draw_circle_color(x, y, point_distance(x, y, obj_ship.x, obj_ship.y), c_aqua, c_aqua, true);
    } else obj_ship.planet_gravity = false;
}
 
L

Lonewolff

Guest
Inverse is 1/n.

But I am guessing you don't actually want an inverse.
 

FrostyCat

Redemption Seeker
If a value t varies from 115 to 200, then 315-t varies from 200 to 115.

More generally, if t varies from a to b, then a+b-t varies from b to a.
 
Top