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 / [SOLVED] WAITKEY

Author
Message
kebang
7
Years of Service
User Offline
Joined: 24th Feb 2014
Location:
Posted: 21st Jul 2021 05:25
I've written a very, very simple program to graphically display a problem (Inglenook Shunting Puzzle). It works fine, but I want it rerun upon a keypress. In other basics I would use something like WAITKEY. How can I do this in AGK

The author of this post has marked a post as an answer.

Go to answer

Loktofeit
AGK Developer
12
Years of Service
User Offline
Joined: 21st Jan 2009
Location: Sarasota, FL
Posted: 21st Jul 2021 07:47
GetRawKeyPressed() is probably the command you want.

In the example below, it waits for the user to press Space (scancode 32).




More info: https://www.appgamekit.com/documentation/Reference/Input-Raw/GetRawKeyPressed.htm
LynxJSA's web games/quizzes - LynxJSA's Android apps
AGK Resource Directory
"Stick to a single main loop (DO...LOOP) and loop through it every frame.
Do everything inside functions.
Use finite state machines to control your game.
Use lots and lots of source files.
PartTimeCoder
AGK Tool Maker
6
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 21st Jul 2021 17:37
For 'Any' key use GetRawLastKey()

But ...

AGK Help wrote: " This function continue to return the last key pressed even when the key has been released. "


So you must store the key and check if its changed

Virtual Nomad
Moderator
15
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 22nd Jul 2021 04:44 Edited at: 22nd Jul 2021 04:46
This post has been marked by the post author as the answer.
this might be closer to true WaitKey() ?

assuming the buffer was empty before calling? (i don't see a ClearBuffer() command but GetCharBuffer() clears it, so...)
[My Itch.io Home] [Community Apps on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
PartTimeCoder
AGK Tool Maker
6
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 22nd Jul 2021 15:41
That does negate the need of a variable, I like it.
kebang
7
Years of Service
User Offline
Joined: 24th Feb 2014
Location:
Posted: 23rd Jul 2021 06:28
Thank you all so much. V.Nomad solution worksfine.
Have moved onto recreating a racing game I wrote in Dark Basic about 20 yrs ago. New problem is how to make sprite background invisible. The background is black but Its still visible..
Conjured Entertainment
AGK Developer
15
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 28th Jul 2021 20:35
Quote: "GetCharBuffer()"

I don't remember having noticed that one before, which is surprising having such a small list of raw inputs, just always used key pressed/released/state or last key.

Triggering that on RETURN/ENTER key would be really handy for lots of things.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1

Login to post a reply

Server time is: 2021-07-31 09:33:15
Your offset time is: 2021-07-31 09:33:15