Input gathering problem

Started by
2 comments, last by neodingo 18 years, 10 months ago
Alright here's the deal. I'm creating a tetris clone here and I'm working on my input gathering. I'm using HGE and Visual Studio 2005 Beta. My problem is that HGE uses a frame func which is called every frame, if I gather input there, the movement is far too fast for tetris, especially when I rotate the pieces. I can check the time and only allow input after a certain amount of time has passed, say a tenth of a second. This method seems a little stupid however, anyone have a similar experience and know how to properly throttle the input speed?
Advertisement
The problem you are facing is about how to handle the imput routine. You must never delay the input polling routine as it will cause a lot of input misses. You must gather the input and increment the throttle by the help of a timer. You can apply the throttle updation after the timer gets over and then reset it again. Hope this helps!
Quote:Original post by sriniatig
The problem you are facing is about how to handle the imput routine. You must never delay the input polling routine as it will cause a lot of input misses. You must gather the input and increment the throttle by the help of a timer. You can apply the throttle updation after the timer gets over and then reset it again. Hope this helps!


Basically what he's saying is this:

Update your input every frame. Let's say you have an action called "rotate piece left" that is associated with the 'W' key press. When the "rotate piece left" function is called, a RotateLeft timer starts counting down to 0. Until the timer has reached 0, ignore all 'W' presses (don't call the function until the timer is 0). In this way, you still poll input every frame, but you don't allow the same action to be made more frequently than X, where X is what you start your timer at.
Okay, so allow input to be made each from but once that particular action has been handled, don't allow it again till a certain time frame has passed, that way the user can, say rotate the piece only every 1/10th of a second, but he can still do other input while that buffer is in place. Thanks alot.

This topic is closed to new replies.

Advertisement