Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- i = 0;
- // Player Input Step
- key_right = keyboard_check(vk_right);
- key_left = -keyboard_check(vk_left);
- key_jump = keyboard_check_pressed(ord('Z'));
- // Input Action Step
- move = key_right + key_left;
- hsp = move * movespeed;
- // Set up gravity
- if vsp < 10 then { vsp += grav };
- // Jumping
- if place_meeting(x,y+1,obj_blockOver) or place_meeting(x,y+abs(hsp),obj_blockOver) or place_meeting(x,y+1,obj_passthroughOver) then
- {
- if key_jump then
- {
- vsp = key_jump * -jumpspeed
- }
- };
- // Springs
- if place_meeting(x,y+1,obj_spring) then
- {
- vsp = -10;
- };
- // Apply Changes
- if move > 0 then image_index = 0;
- if move < 0 then image_index = 1;
- if place_meeting(x+hsp,y,obj_blockOver) or x+hsp-6<0 or x+hsp+7>room_width then
- {
- if !place_meeting(x+sign(hsp),y-1,obj_blockOver) and not x+sign(hsp)-6<0 and not x+sign(hsp)+7>room_width then
- {
- //Any slope (going up)
- while(!place_meeting(x+sign(hsp),y-1,obj_blockOver) and !(x+sign(hsp)-6<0) and !(x+sign(hsp)+7>room_width) and !(i>=abs(hsp*0.6)))
- {
- x += sign(hsp);
- y -= 1;
- i += 1;
- if i >= abs(hsp*0.6) then break;
- };
- }
- else
- {
- while(!place_meeting(x+sign(hsp),y,obj_blockOver) and not x+sign(hsp)-6<0 and not x+sign(hsp)+7>room_width)
- {
- x += sign(hsp);
- }
- }
- hsp = 0;
- };
- //45 degree slopes (going down)
- if !place_meeting(x+hsp,y+abs(hsp),obj_blockOver) and collision_line(x,y+1,x,y+18,obj_blockOver,false,true) then
- {
- x += hsp;
- y += abs(hsp);
- };
- else
- {
- x += hsp;
- };
- if place_meeting(x,y+vsp,obj_blockOver) then
- {
- while(!place_meeting(x,y+sign(vsp),obj_blockOver))
- {
- y += sign(vsp);
- };
- vsp = 0;
- }
- else if place_meeting(x,y+vsp,obj_passthroughOver) and vsp > 0 and !place_meeting(x,y,obj_passthroughOver) then
- {
- while(!place_meeting(x,y+sign(vsp),obj_passthroughOver))
- {
- y += sign(vsp);
- };
- vsp = 0;
- };
- y += vsp;
- x = round(x);
- y = round(y);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement