Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var hsp_final = hsp + hsp_carry;
- hsp_carry = 0;
- var vsp_final = vsp + vsp_carry;
- vsp_carry = 0;
- scrCollide(round(hsp_final), round(vsp_final), par_wall); //First bit is argument0, second is 1 and par_wall is argument2
- x = round(x); y = round(y);
- ///scrCollide
- //This script calculates the exact position of the player in the world and is designed to be used with moving platforms.
- {
- //argument0 - x displacement
- //argument1 - y displacement
- //argument2 - wall parent
- var i,move_check; //Defines Variables
- for (i = abs(argument0)/* hsp_final */; i > 0; /*As soon as i is greater or less than 0, it will stop looping*/ i -= 1)
- {
- if (i < 0) {i = 0;}
- move_check = sign(argument0)*i; //Returns if the number is positive, negative or 0, then multiplies that by 1, seeing if the movement is left or right
- if !(place_meeting(x+move_check,y,argument2))//If not moving into par_wall in either direction
- {
- if instance_exists(obj_rock_crush){
- if !(place_meeting(x+move_check,y,obj_rock_crush)){
- x += move_check; //Then move
- break;
- }
- }
- }
- /*If I haven't hit an obstacle, then it must be safe to move this distance, so I'll move, and then stop the loop because I don't need to check any more'.*/
- }
- for (i = abs(argument1); i > 0; i -= 1)
- {
- if (i < 0) {i = 0;}
- move_check = sign(argument1)*i; //Returns if the number is positive, negative or 0
- if !(place_meeting(x,y+move_check,argument2))
- {
- y += move_check; //The same as above only for verticle movement
- break;
- }
- if !(place_meeting(x-i,y+move_check,argument2)) //If moving upwards, both pieces of code checks to see if par_wall is anywhere diagnolly to the left or right of you
- x -= i/2;
- if !(place_meeting(x+i,y+move_check,argument2)) //If there isn't anything to the left orright, then the player scootches a bit to the left or right i/2
- x += i/2; //In other words, most of the time, your player is constantly scooching left and right. But because the two cancel each other out, the combined motion is always zero.
- //If there IS something to the left of you, your player won't scooch in that direction - which means the overall amount of scooching will be to the right.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement