tingemask02
Member
Hello. In a game I am currently developing, I have made the character be able to move. All is working, but I was wondering if I could make it so if you hold down "shift" and press the arrow keys, it will make you walk faster. Here are the lines of code connected to the player. (the first one is a create Event, the second is a step event, the code is also in game maker language)
GML:
xspd = 0;
yspd = 0;
move_spd = 1;
GML:
right_key = keyboard_check(vk_right);
left_key = keyboard_check(vk_left);
down_key = keyboard_check(vk_down);
up_key = keyboard_check(vk_up);
xspd = (right_key - left_key) * move_spd;
yspd = (down_key - up_key) * move_spd;
//collisions
if place_meeting(x + xspd, y, obj_wall) == true
{
xspd = 0;
}
if place_meeting(x, y + yspd, obj_wall) == true
{
yspd = 0;
}
x += xspd;
y += yspd;