Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / AGK Keyboard input

Author
Message
Stephen Elliott
7
Years of Service
User Offline
Joined: 31st Jul 2017
Location:
Posted: 18th Aug 2017 18:46 Edited at: 18th Aug 2017 20:40
I'm not sure why this keyboard check for the Esc Key isn't working? Any ideas?

This works in BASIC



But the loop won't work in C++

easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 19th Aug 2017 05:55 Edited at: 19th Aug 2017 05:58
What happens if you put agk:: Print(agk::GetRawKeyPressed(27)); in your loop? What does it print out?
On a side note, it's better practice to make your loop something like this:

Since you can then use other conditions to break out of the loop too (like pressing an exit button)

I had to put the space in agk:: Print because it was parsing the : P as a smiley face

My Games - Latest WIP - My Website: Immortal.Digital - FB - Twitter
130,000 installs with AppGameKit and counting
Stephen Elliott
7
Years of Service
User Offline
Joined: 31st Jul 2017
Location:
Posted: 19th Aug 2017 10:07 Edited at: 19th Aug 2017 10:40
Good idea about using a bool for looping - thanks.

Quote: "
What happens if you put agk:: Print(agk::GetRawKeyPressed(27)); in your loop? What does it print out?
"


It prints 0 and a key press doesn't change that. Your code doesn't work either unfortunately.
Stephen Elliott
7
Years of Service
User Offline
Joined: 31st Jul 2017
Location:
Posted: 19th Aug 2017 10:31 Edited at: 19th Aug 2017 10:33
Here's the full test program:



MoveShips.h

Attachments

Login to view attachments
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 19th Aug 2017 10:52 Edited at: 19th Aug 2017 10:54
Hm that's very strange...

Maybe try this and see what it prints out


My Games - Latest WIP - My Website: Immortal.Digital - FB - Twitter
130,000 installs with AppGameKit and counting
Stephen Elliott
7
Years of Service
User Offline
Joined: 31st Jul 2017
Location:
Posted: 19th Aug 2017 10:59
It doesn't print anything.
jhanson
7
Years of Service
User Offline
Joined: 19th Jun 2017
Location: USA
Posted: 19th Aug 2017 13:07
Does changing it from GetRawKeyPressed to GetRawKeyReleased or GetRawKeyState help? I've heard of some web browsers being inconsistent in their handling of KeyPress events for the escape key, so maybe something similar is going on here.
Stephen Elliott
7
Years of Service
User Offline
Joined: 31st Jul 2017
Location:
Posted: 19th Aug 2017 13:46 Edited at: 19th Aug 2017 13:49
No luck using any of those commands.

Remember my loop code in BASIC above, with GetRawKeyPressed(27) = 1 works - but NOT IN C++
Stephen Elliott
7
Years of Service
User Offline
Joined: 31st Jul 2017
Location:
Posted: 19th Aug 2017 17:38 Edited at: 19th Aug 2017 23:46
I think I'll use AppGameKit BASIC, at least for now.

A quick conversion in BASIC works.

Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 20th Aug 2017 11:41
You got it wrong , you should not loop yourself inside app::Loop (void) , agk will do that for you , try this


best regards Preben Eriksen,
Stephen Elliott
7
Years of Service
User Offline
Joined: 31st Jul 2017
Location:
Posted: 21st Aug 2017 23:20 Edited at: 22nd Aug 2017 00:37
Ah, I see, Preben. had to re-think my code - works now. Thanks!

Login to post a reply

Server time is: 2024-11-22 02:06:13
Your offset time is: 2024-11-22 02:06:13