Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// @description Approach(a, b, amount);
- /// @function Approach
- /// @param a
- /// @param b
- /// @param amount
- // Moves "a" towards "b" by "amount" and returns the result
- // Very usefull because it won't overshoot "b", and works in both directions
- // Examples:
- // speed = Approach(speed, max_speed, acceleration);
- // hp = Approach(hp, 0, damage);
- // hp = Approach(hp, max_hp, heal);
- // exp = Approach(exp, levelUP, monsterXP);;
- if (argument0 < argument1){ // Example(Approach(hp, max_hp, heal(20))): If hp < max_hp
- argument0 += argument2; // Add heal to hp
- if(argument0 > argument1) return argument1; // If hp is now over max hp, return max hp instead(to no overshoot)
- } else { // Another Example: If hp > 0hp and the player suffers damage
- argument0 -= argument2; // Remove from hp the damage value
- if(argument0 < argument1) return argument1; // If the new HP is less then 0, returns 0 instead(to no overshoot)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement