Post by jeano on May 9, 2024 0:10:20 GMT
Hello,
I'm a little befuddled with the use of KEYHIT and KEYDOWN, and I'm hoping someone can help clarify.
(All the examples I see only are exact copies of the wiki pages on qb64.com, and I find these qb64.com pages for these two functions to be confusing... so it's confusion upon confusion!)
So, I've created a game loop that uses _keyhit to detect user input and move a character on-screen. I initially tried INKEY$ for this, but it didn't seem to work.
Now, I'd like to add functionality to the game, where the player hits Ctrl-1, Ctrl-2, etc to perform some action. But, I'm confused as to how I can add this to my current code.
Can someone give me guidance with this?
My current loop is currently this:
I'm a little befuddled with the use of KEYHIT and KEYDOWN, and I'm hoping someone can help clarify.
(All the examples I see only are exact copies of the wiki pages on qb64.com, and I find these qb64.com pages for these two functions to be confusing... so it's confusion upon confusion!)
So, I've created a game loop that uses _keyhit to detect user input and move a character on-screen. I initially tried INKEY$ for this, but it didn't seem to work.
Now, I'd like to add functionality to the game, where the player hits Ctrl-1, Ctrl-2, etc to perform some action. But, I'm confused as to how I can add this to my current code.
Can someone give me guidance with this?
My current loop is currently this:
do
k% = _KeyHit
If k% = 18432 Then newx = newx - 1: wantstomove = True ' player wants to go up
If k% = 20480 Then newx = newx + 1: wantstomove = True ' player wants to go down
If k% = 19200 Then newy = newy - 1: wantstomove = True ' player wants to go left
If k% = 19712 Then newy = newy + 1: wantstomove = True ' player wants to go right
If k% = 81 Or k% = 113 Then goto PrepToQuitGame
If k% = 15104 Then GoTo ShowtheF1Menu
If k% = 15360 Then GoTo ShowtheF2Menu
' Is there something I can do here to allow for Ctrl-1, Ctrl-2, etc??????
' is it something like if k% = the_ascii_code_for_1 + _keydown(100306) ????
'... do things with newx and newy
ShowtheF1Menu:
'stuff
ShowtheF2Menu:
'other stuff
PrepToQuitGame:
'more stuff
loop