• Advertisement
Sign in to follow this  

Writing an Input class

This topic is 2308 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

I don't know about others but game inputs are making me confused.

My thoughts of such a class...Keyboard:
1. A property to hold the key being pressed.
2. A method which should be invoked on onKeyDown event and set the above property.
3. A method which should be invoked on onKeyUp event and unset the above property.

But is this right? Do I need more property/methods?

Share this post


Link to post
Share on other sites
Advertisement
Some suggestions:

- You could move both methods into one. SetKey(bool) should fit fine.

- Of course you at least need a method to check if the key-state is actually being set. However, you could need more than that: Most games will need a method to check if a key is hold down, but also if it is just pressed (quicktime-events for example), etc.

I hope this helps you get on thinking. It depends on the game you are making, but keep in mind that pushing and hplding a
button for example are different thimgs (jist as mouse-click and mouse-drag)..

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement