• Print

Author Topic: Will QB64-GL fix this issue???  (Read 615 times)

JustinRichardsMusic

  • Sr. Member
  • ****
  • Posts: 347
  • Character names can be found in metal from the 90s
    • Email
Re: Will QB64-GL fix this issue???
« Reply #30 on: March 26, 2013, 05:16:47 PM »
The most perfect explanation of anything ever. That makes perfect sense, thank you.

The reason I was checking inkey$ 32 times was to clear the keyboard buffer. It's an old habit. Used to cause problems without it in qb1.1 because if you held a key down to long and the program couldn't keep pace you would get a lag effect and system beeps and all sorts of nonsense.

Now that _KEYHIT is available I will use it instead...

Thanks again,
Justin
James Hetter's Revenge has been unleashed! Follow the games progress here:
http://www.qb64.net/forum/index.php?topic=6762.0

Download the latest version here:
https://www.dropbox.com/s/8p8gguliw1y6ink/Hetters%20Revenge.zip?m

DSMan195276

  • Hero Member
  • *****
  • Posts: 2003
  • Yes
    • Email
Re: Will QB64-GL fix this issue???
« Reply #31 on: March 26, 2013, 09:52:55 PM »
Quote from: JustinRichardsMusic on March 26, 2013, 05:16:47 PM
The most perfect explanation of anything ever. That makes perfect sense, thank you.

The reason I was checking inkey$ 32 times was to clear the keyboard buffer. It's an old habit. Used to cause problems without it in qb1.1 because if you held a key down to long and the program couldn't keep pace you would get a lag effect and system beeps and all sorts of nonsense.

Now that _KEYHIT is available I will use it instead...

Thanks again,
Justin

Glad you understood it :) And gotcha, that's really a non-issue with QB64 though. There's just to many layers honestly, QB64 programs aren't even reading the keyboard buffer directly, they read it off of the underlying OS (More or less) so there is no chance that it'll be to slow or start causing system beeps because the OS will read off the key even before your program can.

While I haven't used _KEYHIT much, it does look like for most cases it can be a drop-in replacement for INKEY$ since the normal keyboard keys return their normal INKEY$ code (So you can just CHR$() to get the character in that case). And _KEYHIT has the advantage of not changing from modifier keys. Speed wise, I think _KEYHIT will give you a bit more speed (If for no other reason then because INKEY$ is more complex for QB64 since it has to copy QBasics behavior). Only checking it once will really be what really speeds things up though. And really, if you're hoping to get, say, 60 FPS on the graphics, that would indicate you're checking the keyboard 60 times a second. I don't know of anybody who can type that fast, so checking even more then that is just unnecessary. ;)

Matt
"Cast your cares on the Lord and he will sustain you; he will never let the righteous be shaken" -- Psalm 55:22
QB64 Linux Installer

  • Print