tags:

views:

21

answers:

1

Hi, I'm building some simple game with openGL on C++. I have some movement while pressing some key. I want it to be continuous but 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.

+2  A: 

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.

alex
I would add, if you are getting key code as byte, you might store state of each key in char[256]. Or in char[32], if you are clever :)
alxx