Lets say I make a sport game, 100 meters hurdle. If player tapping the keyboard faster, the character in the game will run faster. If the player holding the keyboard, it will be counted as single press.
This is my best solution but too much of work:
var a_been_pressed = false;
var b_been_pressed = false;
function handle_key_a()
{
a_been_pressed = true;
while (key_a) wait(1);
addPlayerSpeed();
a_been_pressed = false;
}
function handle_key_b()
{
b_been_pressed = true;
while (key_b) wait(1);
addPlayerStamina();
b_been_pressed = false;
}
while (game_running)
{
if (key_a && !a_been_pressed) handle_key_a();
if (key_b && !b_been_pressed) handle_key_b();
wait(1);
}
Or any better solution?