c++ openGL Continuous button pressing
I'm building some simple game with openGL on C++. I have some movement while pressing some key. I want it to be continuous b开发者_开发技巧ut my problem is that on the first second after pressing the key (on the keyboard) the system refers to it as a single click, my game object makes one move and after a second it stats to move continuously. Some ideas to solve this? Thanks.
You should have a global boolean (or better yet, a struct with all your bools for the different keys) that is set to true on the initial keypress and set to false on key release. Then you check this bool when you do your action.
Use glutKeyboardUpFunc
or glutSpecialUpFunc
if it's a special key. Both tell you when the user has released a key.
精彩评论