This function might be useful for newcomers to AppGameKit, wondering
"How can I just make the game wait for x amount of time?"
Here's a quick pause command I wrote and you're welcome to use it, if it helps!
VERSION 1: Super simple. Just works.
The command "Pause(3)" (without the quotes) will pause for 3 seconds.
Accepts decimal fractions, like 0.5 secs etc.
No need to reset timer.
To use it, copy and paste this function into your program:
function pause(delaytime#)
tick#=timer()
repeat
tock#=timer()
sync()
until tock#>(tick#+delaytime#)
endfunction
Uses global variable 'delaytime#', declared elsewhere. Add this line to your main code.
That's it. Now you can use the pause command anywhere in your game!
VERSION 2: Vital extras. Needs additional code.
Exactly as before but with two important new ingredients! I have a situation where the player can access a settings menu at any time.
First, I added a global variable to track and ignore any time that passes while a menu is open, so it doesn't interfere with the pause function's timer.
Second, the code checks if the player is busy pressing GUI buttons during the pause. They should still respond and we need a function to handle that!
function pause(delaytime#)
tick#=timer()
`reset global variable, to ignore time if menu is open
menutime#=0
repeat
tock#=timer()-menutime#
probeinput()
`call your own function to check GUI while paused
sync()
until tock#>(tick#+delaytime#)
endfunction
You'll need to add the extra code yourself, based on how your own game works! This is just to show how you can easily adapt the pause code and make it better.
(edited because there's no preview button!) AGK Linux user.
Tessellatus - a game of chance for Android.