iKotomi
[10] Knight
So I've been working on programming a game engine off and on, and am currently working on input detection. For reference, I'm using C++ and SDL for inputs, graphics, miscellaneous stuff I can't be bothered to learn winapi for. The problem I have is as follows.
The way the computer polls the keyboard, you can only receive one input at a time (press or release). You can sort of get around this by holding internal variables so that, for example, if left is pressed, if the internal variable for down is true, you register a downback motion.
This is all fine in games like shmups, but in fighters there's a big difference between pressing up and right in sequence and up and right simultaneously. A similar problem exists with multiple button commands like A+B+C. To address this, my guess is that you need to read inputs continuously for a very small fraction of a second, and then interpret that, so if say, down and down right are pressed within a millisecond of each other, than that should just be read as downforward.
Does anyone know how small this window should be so that you could read all the inputs without it mushing separate inputs, and avoid problems with the granularity of the cpu clock? Or is there a better way to do this completely?
The way the computer polls the keyboard, you can only receive one input at a time (press or release). You can sort of get around this by holding internal variables so that, for example, if left is pressed, if the internal variable for down is true, you register a downback motion.
This is all fine in games like shmups, but in fighters there's a big difference between pressing up and right in sequence and up and right simultaneously. A similar problem exists with multiple button commands like A+B+C. To address this, my guess is that you need to read inputs continuously for a very small fraction of a second, and then interpret that, so if say, down and down right are pressed within a millisecond of each other, than that should just be read as downforward.
Does anyone know how small this window should be so that you could read all the inputs without it mushing separate inputs, and avoid problems with the granularity of the cpu clock? Or is there a better way to do this completely?