< FIVE MINUTE BASIC #3 - Cycling Colour Menu
The following program gives you an arcade-style menu, with text that rotates through the colours available on the ZX Spectrum.
1 REM Cycling Colour Menu
2 REM by Stephen Nichol 2014
3 REM Serious - caution epileptics!
10 BORDER 0: PAPER 0: CLS
20 FOR i=1 TO 5 STEP 1
30 PRINT AT 1,12; INK i;"MY GAME"
40 PRINT AT 3,12; INK i+1;"1.START"
50 PRINT AT 4,12; INK i+2;"2.QUIT"
60 IF INKEY$="1" THEN GO TO 100
70 IF INKEY$="2" THEN STOP
80 NEXT i
90 GO TO 20
100 BORDER 7: PAPER 7: INK 0: CLS
110 PRINT "Welcome to the start of my game"
120 STOP
Explanation/Refresher (if required):
Lines 1 to 3 are REMarks, or in another word - comments. They do not affect the running of the program.
Line 10 sets the border and paper colour to black (0) and then clear the screen. CleaR Screen is necessary, even if the screen is blank already - otherwise the colour change won't take place.
Line 20 sets up a For...Next loop, that will contain our game menu. The For statement tells the ZX Spectrum computer that we want to want to start at colour 1 and end at colour 5.
We are starting at colour 1, because colour 0 is black and that is the colour of our paper - we don't want the text to be invisible.
Line 30 Prints the words "MY GAME" in the centre of the screen, at the top.
You may be wondering why I stopped at colour 5 and not 7. it's because we're going to use algebra in lines 40 and 50. Line 40 prints the text "1.START" in INK i+1, or one colour along from the colour "MY GAME" is printed in.
We do almost the same in Line 50, only "2.QUIT" is printed in INK i+2
Lines 60 and 70 scan for presses of the keyboard, specifically key 1 and key 2.
If key 1 is pressed we go to the start of the game (which obviously does not actually exist in this listing).
If key 2 is pressed then the program will STOP and return to the BASIC editor.
Line 80 moves on to the next ink colour and goes back to the start of the FOR...NEXT loop.
When the For...Next loop reaches colour 5, it ends so - we tell the computer to start it again with Line 90 that states "GO TO 20".
Line 100 is outside the For...Next loop and only happens if key 1 is pressed. Line 100 then changes the paper, border, and ink colours.
Line 110 is where the start of your game could go.
Line 120 STOPs the program.