Input problems
Sylvarant

I'm making a start screen in wich you can choose from 3 options New Game, Load Game and Quit game by pressing up or down the problem is the keyboard input is collected way to fast. Is there any thing I can do against this?

Here's part of the code

1// looping
2// check for input
3 // key up
4 if(key[KEY_UP]){
5 // New game is selected
6 if (select_start == 0){
7 select_start = 2;}
8 // otherwise
9 else {
10 select_start--;}
11 }
12 // key down
13 if(key[KEY_DOWN]){
14 // Quit game is selected
15 if (select_start == 2){
16 select_start = 0;}
17 // otherwise
18 else{
19 select_start ++;}
20 }
21// the switch , depending on select start
22 switch(select_start){

Kitty Cat

You want to check if a key was pressed, not if it's being held down. Use keypressed and readkey.

TeamTerradactyl

You can also have a key-input delay.

When a key is pressed, set a timer. If they're still holding down the same key when the timer runs out, count it as "another" keypress. This way, they don't have to hit the same key a hundred times to move the cursor around, but they also don't get the key moving so quickly that it's impractical.

If they let up on the key, clear the timer. This DOES allow for someone to hit the key very quickly to move the cursor faster than your timer would allow, and it prevents the timer from continuing to think a DIFFERENT key should wait until it's done counting before it accepts its input.

Just my 2 cents...

Thread #588560. Printed from Allegro.cc