Pressing keys to make stuff happen
-
- 2nd Star Corporal
- Posts: 29
- Joined: Tue Jun 05, 2007 1:45 am
- Location: Oregon, United States
- Contact:
Pressing keys to make stuff happen
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
There are 2 ways to do this. If you just want the program to pause until space is pressed, then this would suffice:
if you want the front screen to animate something whilst waiting for the user to play you could try something like this:
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 SPACE to continue"
110 REPEAT
120 GET A$
130 UNTIL A$=" "
140 CLS
150 REM ... Rest of game
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
Code: Select all
100 PRINT "Press any key to continue"
110 GET A$
140 CLS
150 REM ... Rest of game