Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Character Keys Control.. Confused..

This topic is 6676 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

OK, I got a character and I have 8 keys to control it, the NumPad. So, when I''m pressing the key 2, my flag, say KeyDown becomes true. But if I press simultaneously two keys like 2 and 1, then my flags for them becomes true and it calculates the direction to move to. So, I just asking what I have to do with it''s movements: to use like If DownKey=True and LeftKey=false and RightKEy=False and so on, for each press, or there is another way to do that? Like some of DINPUT operations? I didn''t get to DInput yet, but if it''s a way to solving my prob,I''ll go on it. Thanks!!

Share this post

Link to post
Share on other sites
In DirectInput you can save the state of all the keys into a keys[] array which you can then access like: keys[DIK_UP] (for the up key). This is basically a system like what you have described.

Is your first question asking what to do if more than one key is down? You could set up some sort of order of importance for the keys and just check if the most important are down first in an if statment, then use ''if else'' for all the others. You could also set a flag like ''alreadyMoved'' to true when the character has moved.

- Daniel
VG Games

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!