Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// Approach(a, b, amount)
- // Moves "a" towards "b" by "amount" and returns the result
- // Nice bcause it will not overshoot "b", and works in both directions
- // Examples:
- // speed = Approach(speed, max_speed, acceleration);
- // hp = Approach(hp, 0, damage_amount);
- // hp = Approach(hp, max_hp, heal_amount);
- // x = Approach(x, target_x, move_speed);
- // y = Approach(y, target_y, move_speed);
- if (argument0 < argument1)
- {
- argument0 += argument2;
- if (argument0 > argument1)
- return argument1;
- }
- else
- {
- argument0 -= argument2;
- if (argument0 < argument1)
- return argument1;
- }
- return argument0;
Advertisement
Comments
-
- doesnt even work
-
- it says it undefined value when trying to run the code
-
Comment was deleted
Add Comment
Please, Sign In to add comment
Advertisement