Global keyboard states
- by Petr Abdulin
I have following idea about processing keyboard input. We capture input in "main" Game class like this:
protected override void Update(GameTime gameTime)
{
this.CurrentKeyboardState = Keyboard.GetState();
// main :Game class logic here
base.Update(gameTime);
this.PreviousKeyboardState = this.CurrentKeyboardState;
}
then, reuse keyboard states (which have internal scope) in all other game components. The reasons behind this are 1) minimize keyboard processing load, and 2) reduce "pollution" of all other classes with similar keyboard state variables.
Since I'm quite a noob in both game and XNA development, I would like to know if all of this sounds reasonable.