Finding the difference between holding the key and pressing it repeatedly

Started by
0 comments, last by EGD Eric 20 years ago
So far, Win32 has served my purpose just fine for making this game, but now I''m not sure how to figure out the difference between holding a key and pressing it rapidly. What I''ve been doing is just filling a 256 bool array in WinProc, then checking the array for whether a key is down or not. Now, I want the player to be able to shoot rapidly by pressing the key real fast, and shoot at a steady speed by just holding it. I''m not sure how to do that with Win32. Before I go hacking away on this problem, does DirectInput have an easy way of catching the time between button presses?
Advertisement
if (KeyDown(SpaceKey)) {
if (space_keystate == 0) {
// shot wheneva key is hit!
space_keystate = 1;
lastshot = timer + 0.1f;
shoot();
} else {
if {timer > lastshot} {
// shoot every 0.1 sec, when key is held
lastshot = timer + 0.1f;
shoot();
}
}
} else {
space_keystate = 0;
}


something like that would work, could be something better out there, but hey! :D

Dun mes wit me!
Dun mes wit me!

This topic is closed to new replies.

Advertisement