|
Inkey
Apr 24, 2020 2:55:34 GMT -6
Post by johnno56 on Apr 24, 2020 2:55:34 GMT -6
I use inkey in my Asterocks game, which works quite well, for the most part.
When the game asks if I want to play again, inkey is listening for y or n, which it does. If a high score is achieved, then the game asks for the player's name, so it can be added to the high score table. This routine also uses inkey to enter the name... but... the first character of the players name will end up being either "y" or "n"... depending on what was previous pressed.
My question is: Is there a way for RC to clear the keyboard buffer or can some someone suggest a method of typing graphical text onto the screen without using inputS() ?
J
|
|
|
Inkey
Apr 24, 2020 9:52:53 GMT -6
Post by n00b on Apr 24, 2020 9:52:53 GMT -6
Hey Johnno,
Here is an example (Also, I am moving this to the Help needed section):
WindowOpen(0, "3D Vector", WINDOWPOS_CENTERED, WINDOWPOS_CENTERED, 640, 480, 0) CanvasOpen(0, 640, 480, 0, 0, 640, 480, 0)
LoadFont(0,"FreeMono.ttf",16) SetColor(RGB(255,255,255))
ReadInput_Start() ReadInput_ToggleBackspace(True)
user_input$ = ""
while not key(K_ESCAPE) ClearCanvas() user_input$ = ReadInput_Text$ drawText("User Input = " + user_input$, 10, 10)
update() wend
ReadInput_Stop()
|
|
|
Inkey
Apr 24, 2020 10:28:23 GMT -6
Post by johnno56 on Apr 24, 2020 10:28:23 GMT -6
Cool... It's almost 2:20am and I'm not firing on all thrusters. Navigation and life support are compromised. Optical recognition system is losing power... Caffeine is ineffective... I think I will shut down and recharge the system...
As soon as I am fully functional again, I will test your program, then get back to you. Many thanks for the example...
I should have chosen the Help forum... just goes to show you hoo mush sleeep i nee...
|
|
|
Inkey
Apr 25, 2021 11:27:08 GMT -6
Post by rosy on Apr 25, 2021 11:27:08 GMT -6
There is, of course, a way to clean the buffer ... Do Update Loop Until Inkey$=0 But I don't know why Inkey$ works instead of Inkey
|
|
|
Inkey
Apr 25, 2021 11:30:54 GMT -6
Post by tbird on Apr 25, 2021 11:30:54 GMT -6
Another simple way ReadInput_SetText("")
|
|
|
Inkey
Apr 25, 2021 12:30:24 GMT -6
Post by rosy on Apr 25, 2021 12:30:24 GMT -6
Only this "simple way" will not work while the key is still physically held down. I don't know if there is any buffer for INKEY, it seems ReadInput_SetText ("") doesn't apply here.
|
|
|
Inkey
Apr 25, 2021 12:38:56 GMT -6
Post by tbird on Apr 25, 2021 12:38:56 GMT -6
Actually I guess it doesn't apply to johnno56 problem, as for it switching and carrying over as in to fast and button held down we went over this already a simple key timer is used, I use a global one in all my programs and it works super simple, easy to implement.
|
|
|
Inkey
Apr 25, 2021 13:59:27 GMT -6
Post by rosy on Apr 25, 2021 13:59:27 GMT -6
What Key Timer?
|
|