Page 1 of 1

Pressing keys to make stuff happen

Posted: Wed Jun 06, 2007 1:45 pm
by Chris
Say I'm making a title screen that says "Press space to start." How would I make it so that if I press space, the screen goes CLS and starts my game (i.e., you can actually play a game now that you've pressed space.) Same for enter, and left space, and right space, up down left & right? Once I know this, I'll be set for at least a few days ;)

Posted: Wed Jun 06, 2007 8:46 pm
by Pengwin
There are 2 ways to do this. If you just want the program to pause until space is pressed, then this would suffice:

Code: Select all

100 PRINT "Press SPACE to continue"
110 REPEAT
120 GET A$
130 UNTIL A$=" "
140 CLS
150 REM ... Rest of game
if you want the front screen to animate something whilst waiting for the user to play you could try something like this:

Code: Select all

100 PRINT "Press SPACE to continue"
110 REPEAT
120 REM ..Animation code here
200 UNTIL KEY$=" "
210 CLS
220 REM ... Rest of game
if you choose the first method (without animation) and don't really care what key people press, it could be shortened to:

Code: Select all

100 PRINT "Press any key to continue"
110 GET A$
140 CLS
150 REM ... Rest of game

Posted: Wed Jun 06, 2007 8:50 pm
by Pengwin
Just to re-iterate, these are the definitions from the Oric manual

GET (example GET A$)
Strobes the keyboard and waits until a key is pressed.
KEY$ (example X$=KEY$)
Strobes keyboard. Continues execution, whether or not a key has been pressed. X$ contains value of any key pressed.

Posted: Thu Jun 07, 2007 12:01 am
by Chris
Thanks. I was looking through the manual, but I couldn't find anything like that. I did see "strobes keyboard", though, but I don't know what that means.