GameMaker: Studio

GameMaker: Studio

Find, play, and make games easily
Discover, rate, and download the best player-created games made in GameMaker: Studio for free. Or try making your own and share with the community. Click here to learn more.
Lexa :) 22 Mar, 2016 @ 10:25am
hey guys i am trying to lower my speed when i press ♥♥♥♥
can you help me to fix that i'm trying to sneak ^^
code(from a beginner):
if(keyboard_check_pressed(vk_shift) && keyboard_check(vk_left) && !keyboard_check(vk_right)) {
hspeed = -2;
}

if(keyboard_check_pressed(vk_shift) && keyboard_check(vk_right) && !keyboard_check(vk_left)) {
hspeed = 2;
}
< >
Showing 1-2 of 2 comments
melon king 4 23 Mar, 2016 @ 12:31am 
You're checking if the player has PRESSed the shift key (the single frame) and not if they are holding it down. Use keyboard_check(vk_shift) instead of keyboard_check_pressed(vk_shift)
Matt 16 Apr, 2016 @ 11:54am 
You should really use variables instead of 'hspeed -= 2'. So, movespeed = 4 (normal run speed), then have movespeed_sneak = 2; in the create event. Also have movespeed_normal = 4; so you can reset it. So then, you can use

key_left = keyboard_check(vk_left);
key_right = keyboard_check(vk_right);
key_sneak = keyboard_check(vk_lshift);

if(key_left || key_right && key_sneak) movespeed = movespeed_sneak;
else movespeed = movespeed_normal;

Not sure if that code works specifically but you get the idea ...
< >
Showing 1-2 of 2 comments
Per page: 1530 50