N
NoFontNL
Guest
Hey all! I've a small problem when running my platformer game. If I press shift my character needs to run, but it only runs to the right. When I press shift + left arrow key, the player walks to the left and not runs to the left. This is the Run code:
Step Event Player:
So again, the problem is the player only runs to the right, not to the left.
Step Event Player:
Code:
key_left = -(keyboard_check(vk_left));
key_right = (keyboard_check(vk_right));
is_moving = (key_left) || (key_right);
key_jump = (keyboard_check(vk_space));
key_run = (keyboard_check(vk_shift));
move = key_left + key_right;
hsp = move * moveSpeed;
if (key_left = -1){
image_xscale = -4; // Flips player if moving to the left.
}
if (key_right = 1){
image_xscale = 4;
}
if (key_run) && (moveSpeed < 16) && (is_moving) { // If you' re pressing the run key (shift) and you're moving.
moveSpeed += 0.5
if (jumpSpeed < 17.5) {
jumpSpeed += 0.5 // Acceleration: jumpSpeed gets higher with the time you're running.
}
}
if !(key_run) { // If you're not pressing the run key, slowly slow down.
if moveSpeed > 5 {
moveSpeed -= 1;
}
if jumpSpeed > 15 {
jumpSpeed -= 1;
}
}