readkey() and sticking
SkaxCo

I'm trying to use readkey to move a character across the screen. If you hold down the key, it backlogs the keyboard. Is there any way to clear the keyboard buffer? Like keyboard_clear() or something like that?

Kauhiz

clear_keybufR.T.F.M...

SkaxCo

Thanks

Kauhiz

Sorry, edited

Albin Engström

I'm putting in a little question: when would clear_keybuf be needed? because i've never used it and everything works great..?

Kauhiz

...Please just RTFM, please!

Kris Asick

If you're using readkey() for movement, EXPECT backlog.

You want to be reading the key[] array instead if you want constant movement.

If however you want the ability to move single spaces AND constantly, one method you can do is to check both readkey() and key[] at the same time and only move the character if BOTH return the appropriate value.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

Albin Engström

Kris Asick: Noted, thanks.

Bill Morris

For some applications, you might want to set the delay and repeat rates, with set_keyboard_rate(delay, repeat). Default is 250, 33 (milliseconds). You might want to set it for high speed and use rest() to slow it down where necesary, to vary the speed as the program may require.

But clear_keybuf() is definitely useful for the problem you mentioned. I use in my text editors to reprevent buffer overload when scrolling.

gnolam

... no. For the situation the OP mentioned, the key[] array is the way to go. And you basically never want to use rest() except to yield to the OS.

Thread #590250. Printed from Allegro.cc