Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Initialize Variables
- grav = 1;
- hsp = 0;
- vsp = 1;
- jumpspeed = 10;
- movespeed = 15;
- --------------------------------------------------
- //Get the player's input
- key_right = keyboard_check(vk_right);
- key_left = -keyboard_check(vk_left);
- key_jump = keyboard_check_pressed(vk_space);
- //React to inputs
- move = key_left + key_right;
- hsp = move * movespeed;
- if (vsp < 10) vsp += grav;
- if (place_meeting(x,y+1,obj_scenario))
- {
- vsp = key_jump * -jumpspeed
- }
- //Horizontal Collision
- if (place_meeting(x+hsp,y,obj_scenario))
- {
- while(!place_meeting(x+sign(hsp),y,obj_scenario))
- {
- x += sign(hsp);
- }
- hsp = 0;
- }
- x += hsp;
- //Vertical Collision
- if (place_meeting(x,y+vsp,obj_scenario))
- {
- while(!place_meeting(x,y+sign(vsp),obj_scenario))
- {
- y += sign(vsp);
- }
- vsp = 0;
- }
- y += vsp;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement