Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Handle - Movement & Collisions
- x = round(x);
- y = round(y);
- //Handle - Movement
- hmove = keyboard_check(vk_right) - keyboard_check(vk_left);
- if(place_free(x+hmove, y))
- hspd = speed_max*hmove;
- else
- hspd = 0;
- //Handle - Falling & Jumping
- if(place_free(x, y+vspd+1))
- vspd += speed_fall;
- if(vspd == 0)
- {
- if(place_free(x+hspd, y-1) && !place_free(x, y+1))
- if(keyboard_check(vk_up))
- vspd = -speed_jump;
- }
- //Collision
- if(!place_free(x+hspd, y+vspd))
- {
- if(!place_free(x+hspd, y))
- while(place_free(x+sign(hspd), y))
- x += sign(hspd);
- if(!place_free(x, y+vspd))
- while(place_free(x, y+sign(vspd)))
- y += sign(vspd);
- if(!place_free(x+hspd, y))
- hspd = 0;
- if(!place_free(x, y+vspd))
- vspd = 0;
- if(vspd != 0 && hspd != 0)
- {
- if(place_free(x+hspd, y))
- if(place_free(x, y+vspd))
- while(!place_free(x+hspd, y+vspd) && (hspd*vspd) != 0)
- {
- y++;
- if(!place_free(x+hspd, y))
- hspd = 0;
- if(!place_free(x, y+vspd))
- vspd = 0;
- }
- }
- }
- x += hspd;
- y += vspd;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement