Sign in to follow this  
QuackCoder

Writing an Input class

Recommended Posts

[size="3"] I don't know about others but game inputs are making me confused.

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

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

[/size]

Share this post


Link to post
Share on other sites
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this