Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /Player movement
- key_left = keyboard_check(vk_left);
- key_right = keyboard_check(vk_right);
- key_jump = keyboard_check(vk_space);
- // Calculate movement
- var move = key_right - key_left;
- hsp = move * walkspd;
- vsp = vsp + grv;
- if (place_meeting(x, y+1,oWall)) && (key_jump)
- {
- vsp = -7;
- show_debug_message("Jumping from wall!");
- }
- if (place_meeting(x, y+1,oFloor)) && (key_jump)
- {
- vsp = -7;
- show_debug_message("Jumping from floor!");
- }
- if (place_meeting(x, y+1,oDirt)) && (key_jump)
- {
- vsp = -7;
- show_debug_message("Jumping from floor!");
- }
- //horizontal collision
- if (place_meeting(x + hsp,y,oFloor))
- {
- while (!place_meeting(x+sign(hsp),y,oFloor))
- {
- x = x + sign(hsp);
- }
- hsp = 0
- }
- if (place_meeting(x + hsp,y,oDirt))
- {
- while (!place_meeting(x+sign(hsp),y,oDirt))
- {
- x = x + sign(hsp);
- }
- hsp = 0
- }
- if (place_meeting(x + hsp, y, oWall))
- {
- while (!place_meeting(x+sign(hsp), y, oWall))
- {
- x = x + sign(hsp);
- }
- hsp = 0;
- }
- if (place_meeting(x + hsp, y, oStone))
- {
- while (!place_meeting(x+sign(hsp), y, oStone))
- {
- x = x + sign(hsp);
- }
- hsp = 0;
- }
- x = x + hsp;
- //vertical collision
- if (place_meeting(x,y + vsp,oFloor))
- {
- while (!place_meeting(x,y+sign(vsp),oFloor))
- {
- y = y + sign(vsp);
- }
- vsp = 0;
- }
- if (place_meeting(x,y + vsp,oStone))
- {
- while (!place_meeting(x,y+sign(vsp),oStone))
- {
- y = y + sign(vsp);
- }
- vsp = 0;
- }
- if (place_meeting(x,y + vsp,oDirt))
- {
- while (!place_meeting(x,y+sign(vsp),oDirt))
- {
- y = y + sign(vsp);
- }
- vsp = 0;
- }
- if (place_meeting(x,y + vsp, oWall))
- {
- while (!place_meeting(x,y+sign(vsp),oWall))
- {
- y = y + sign(vsp);
- }
- vsp = 0;
- }
- y = y + vsp;
- //animation
- if (!place_meeting(x,y+1,oWall))
- {
- sprite_index = sPlayerW;
- image_speed = 0;
- if (sign(vsp) > 0) image_index = 1; else image_index = 0;
- }
- else {
- image_speed = 1
- if (hsp == 0)
- {
- sprite_index = sPlayer;
- }
- else
- {
- sprite_index = sPlayerA;
- }
- }
- if (!place_meeting(x,y+1,oFloor))
- {
- sprite_index = sPlayerW;
- image_speed = 0;
- if (sign(vsp) > 0) image_index = 1; else image_index = 0;
- }
- else {
- image_speed = 1
- if (hsp == 0)
- {
- sprite_index = sPlayer;
- }
- else
- {
- sprite_index = sPlayerA;
- }
- }
- if (!place_meeting(x,y+1,oStone))
- {
- sprite_index = sPlayerW;
- image_speed = 0;
- if (sign(vsp) > 0) image_index = 1; else image_index = 0;
- }
- else {
- image_speed = 1
- if (hsp == 0)
- {
- sprite_index = sPlayer;
- }
- else
- {
- sprite_index = sPlayerA;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement