• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM keyboard_check(variable)

B

bctype108

Guest
I have run into a little problem trying to create a game engine in Gamemaker:Studio and decided to come here for help. Basically the function I am trying to create is tds_move. It would work like this:
Code:
tds_move(key_up, key_down, key_left, key_right, spd)
So for example:
Code:
tds_move(vk_up, vk_down, vk_left, vk_right, 5)
So heres what I have in the script:
Code:
///tds_move(key_up, key_down, key_left, key_right, spd)
key_up = keyboard_check(argument0)
key_down = -keyboard_check(argument1)
key_left = -keyboard_check(argument2)
key_right = keyboard_check(argument3)
yspeed = key_up+key_down*spd
xspeed = key_left+key_right*spd
So the problem I am having is getting keyboard_check to recognise the argument as the key to check...
 

jo-thijs

Member
That's not your problem.
Your problem is lack of parantheses.

This:
Code:
yspeed = key_up+key_down*spd
xspeed = key_left+key_right*spd
should be:
Code:
yspeed = (key_up + key_down) * argument4;
xspeed = (key_left + key_right) * argument4;
Another problem you have, is that you make key_down negative.
key_down should be set to keyboard_check(argument) without the minus sign.
Then you would also change (key_up + key_down) to (key_up - key_down).

A third problem you have, is that you seem to ignore GameMaker's inverted y-axis.

And a final problem you might be having is that you don't execute the script in the step event.

However, arguments are passed correctly to keyboard_check, there's no issue there.
 
Top