• 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!

GameMaker GMS2 keyboard_check ord not working (SOLVED)

S

SmallShank

Guest
Hello Everyone,

I'm new to Game Dev and I'm learning code and starting fresh as of yesterday.

I've been following the tutorials online and I'm stuck with the movement of my object.

I've watched the video and entered the code and it does work, however, I don't want traditional arrow keys to move my character.

I want to use WSAD as movement keys and have used the following code:

if (keyboard_check(ord('D')) x = x + 4;

I'm getting this compile error:

Object: obj_player Event: Step at line 1 : invalid token

If anyone can help explain why the code isn't working I'd be very grateful. I've checked online and read posts and found the ord code and just can't put my finger on it #feelinglikeapropernewb

Thanks guys!
 
S

SmallShank

Guest
GMS2 does not allow to use single-quoted strings for such - change ord('D') to ord("D") and it'll be fine.
Thank you so much for the help. I first off tried your suggestion and it didn't work...then I added 'then' after the keyboard check quotations mark, it worked...then i went back into the code, removed 'then' and it worked fine, as per your suggestion. Maybe it's still a little buggy as in beta :\

Thanks again buddy :)
 
Top