Following is my code for my platformer. However, in the //Run with left shift//
section when I made the image speed change, the speed is still the same and doesn't change so is there any piece of code that is preventing this task?
///Get player's input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space);
key_jump_held = keyboard_check(vk_space);
key_shoot = keyboard_check(ord("D"));
//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;
if (place_meeting(x, y+1, Obj_Floor))
{
vsp = key_jump * -jumpspeed;
}
if (vsp < 0) && (!key_jump_held) vsp = max(vsp,0)
//Run with left shift
if (keyboard_check(vk_lshift))
{
movespeed = 5;
image_speed = 0.14;
}
if (keyboard_check_released(vk_lshift))
{
movespeed = 3;
image_speed = 0.025;
}
//Shooting direction
if (keyboard_check(vk_right))
{
mpfacing = 0;
}
if (keyboard_check(vk_left))
{
mpfacing = 180;
}
//Shooting
if (keyboard_check(ord("D"))) && (canshoot = true)
{
instance_create(x+13, y-0.5, Obj_MP_Laser);
canshoot = false;
alarm[1] = 30;
}
//Horizontal Collision
if (place_meeting(x+hsp, y, Obj_Floor))
{
while(!place_meeting(x+sign(hsp), y, Obj_Floor))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
//Vertical Collision
if (place_meeting(x, y+vsp, Obj_Floor))
{
while(!place_meeting(x, y+sign(vsp), Obj_Floor))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
//Animate
if (move != 0)
{
image_xscale = move;
}
if (place_meeting(x, y+1, Obj_Floor))
{
if (move != 0)
{
sprite_index = CalvinWalking;
image_speed = 0.05;
}
else
{
sprite_index = CalvinStanding;
image_speed = 0.025;
}
}
else
{
if (vsp < 0) sprite_index = CalvinJumping
else sprite_index = CalvinJumping
}