sandmann999
Programmer
I have a game where you use the arrow keys to control your figure arround the screen. Every time you press the arrow key, it calculates a lot of things (besides your characters movement) so meanwhile it loads up a lot of direction presses in the buffer and eventually locks up for a few seconds until they are all used. (Hopefully that's not confusing. If it is, I'll try to reclarify.)
Here's what I do
DO
DO
X$ = INKEY$
LOOP UNTIL X$ <> ""
IF X$ = CHR$(0) + "M" THEN: (move right)
IF X$ = CHR$(0) + "K" THEN: (move left)
IF X$ = CHR$(0) + "P" THEN: (move down)
IF X$ = CHR$(0) + "H" THEN: (move up)
(here i have it redraw the map using data information)
LOOP
So what it does is for every 2 or 3 every times I press an arrow key, it moves my character once or twice. So the arrow key presses continually build up more than they can be processed. I know I could just press the arrow keys less, but I wouldn't want to have to say in a readme.txt telling everyone not to hold down the arrow keys when they move.
Is there any way to just clear out the arrow key presses so that it only registers them right before they're used? I know that in the C language, you just use the command FFLUSH
and that clears out all the previous keyboard input.
Does anyone know how to do it in QBASIC? Thank you in advance.
Here's what I do
DO
DO
X$ = INKEY$
LOOP UNTIL X$ <> ""
IF X$ = CHR$(0) + "M" THEN: (move right)
IF X$ = CHR$(0) + "K" THEN: (move left)
IF X$ = CHR$(0) + "P" THEN: (move down)
IF X$ = CHR$(0) + "H" THEN: (move up)
(here i have it redraw the map using data information)
LOOP
So what it does is for every 2 or 3 every times I press an arrow key, it moves my character once or twice. So the arrow key presses continually build up more than they can be processed. I know I could just press the arrow keys less, but I wouldn't want to have to say in a readme.txt telling everyone not to hold down the arrow keys when they move.
Is there any way to just clear out the arrow key presses so that it only registers them right before they're used? I know that in the C language, you just use the command FFLUSH
and that clears out all the previous keyboard input.
Does anyone know how to do it in QBASIC? Thank you in advance.