1

Recently I'm trying to create a Game by myself, and now I run into one question... I want to render my Game at 60 times per second, and that's good, but then I use Directinput8 to get my keyboard and mouse set up, And I Debug my Game... I found my keyboard also get update 60 times per sec. for example I press 'UP' and my menu goes crazy! I know I can use a few variable to fix this, but I also heard that Timer and Threads are helpful, may I ask some guy who once made a Game or know what I should do to give me some advise? Anything will be helpful! thanks! :) By the way I know there are some cool library(like Allegro?) that are done, maybe someone can tell me how did they conquer this "update and render" issue?

Dean
  • 37
  • 2
  • 6
  • 1
    From the MSDN article on DirectInput: *The use of DirectInput for keyboard and mouse input is not recommended. You should use Windows messages instead.* – chris May 18 '14 at 05:05
  • ahh...all right.I guess I just need to adjust my code to use Windows Message then! Thanks for the advise man! – Dean May 18 '14 at 05:33

1 Answers1

1

Often there is a single rendering thread per game. It periodically, say each second, updates the whole screen taking all the input you have at this moment. The input, such as keyboard and mouse, you collect outside of that thread and that thread gets it for each update.

Alexander Kulyakhtin
  • 47,782
  • 38
  • 107
  • 158