T
temmieflakes42
Guest
this is my first time using gamemaker so sorry for any naive mistakes but, im having some difficulties getting my sprites to change when i move. ive got the movement all set up but the keyboard checks i added in aren't working, could somebody please tell me why?
heres the code:
heres the code:
Code:
//Get the player's input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_up);
//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;
if (place_meeting(x,y+1,obj_wall))
{
vsp = key_jump * -jumpspeed
}
//Horizontal Collision
if (place_meeting(x+hsp,y,obj_wall))
{
while(!place_meeting(x+sign(hsp),y,obj_wall))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,obj_wall))
{
while(!place_meeting(x,y+sign(vsp),obj_wall))
{
y += sign(vsp);
}
vsp = 0;
if(keyboard_check(ord("vk_left"))) then { x -= global.runspeed }
if(keyboard_check(ord("vk_left"))) then sprite_index = sprite_comp_walkleft
if(keyboard_check(ord("vk_right"))) then { x += global.runspeed }
if(keyboard_check(ord("vk_right"))) then sprite_index = sprite_comp_walkright
if(keyboard_check(ord("vk_up"))) then { y -= global.runspeed }
if(keyboard_check(ord("vk_up"))) then sprite_index = sprite_comp_jump
if(keyboard_check(ord("vk_up + vk_right"))) then { y -= global.runspeed }
if(keyboard_check(ord("vk_up + vk_right"))) then sprite_index = sprite_comp_jumpright
if(keyboard_check(ord("vk_up + vk_left"))) then { y -= global.runspeed }
if(keyboard_check(ord("vk_up + vk_left"))) then sprite_index = sprite_comp_jumpleft
}
y += vsp;