D
Dirokiwi
Guest
i am working on a 2d platform game, so the controls, have to be good. My idea is, that if the player is holding down right arrow key(walking right) and then starts holding down left arrow key, while still holding down the right arrow key, it will move in the left direction. Or if the player is holding down left arrow key(walking left) and then starts holding down right arrow key, while still holding down the left arrow key, it will move in the right direction.
Here is the code I written if the first situation i mentioned occured.
(step event)
if keyboard_check(vk_right)
{
x = x + 4
sprite_index = s_player_run;
image_xscale = 12;
if keyboard_check(vk_left)
{
x = x - 4;
sprite_index = s_player_run;
image_xscale = -12;
}
}
but if I use the same code(almost) for the second situation i mentioned, and the game would sense that i am pressing two keys at once, the player wont move. I recorded a clip, so you can understand better what I am talking about (if you want to have a look at it please on instagram search for dirokiwi123, and there you will see the clip) Please help my idea mentioned in the top of the description become reality.
I will be grateful for any kind of replies. Have a nice day.
Here is the code I written if the first situation i mentioned occured.
(step event)
if keyboard_check(vk_right)
{
x = x + 4
sprite_index = s_player_run;
image_xscale = 12;
if keyboard_check(vk_left)
{
x = x - 4;
sprite_index = s_player_run;
image_xscale = -12;
}
}
but if I use the same code(almost) for the second situation i mentioned, and the game would sense that i am pressing two keys at once, the player wont move. I recorded a clip, so you can understand better what I am talking about (if you want to have a look at it please on instagram search for dirokiwi123, and there you will see the clip) Please help my idea mentioned in the top of the description become reality.
I will be grateful for any kind of replies. Have a nice day.
Last edited by a moderator: