top of page

LOADING...

SCREECH

Vintage & Modern Tech Blog

  • Stephen Nichol

<5 Min BASIC #11 - Planetary Approach

Here's a little space fun, making use of the Sinclair BASIC circle command and a FOR...NEXT loop.

Image of planetary approach ZX Spectrum

Restart the ZX Spectrum and enter this listing in BASIC:

1 REM Under 5 min BASIC#11 2 REM Planetary Approach 3 REM Ste Nichol/Loading Screech 4 REM 29th April 2017 10 BORDER 0: PAPER 0: INK 7: CLS 20 PRINT AT 2,2;"*" 30 PRINT AT 10,30;"*" 40 FOR r=1 TO 30 STEP 2 50 CIRCLE 128,81,r 60 NEXT r 70 PAUSE 0

Explanation/Refresher Lines 1 to 4 are REMarks, comments that do not affect the running of the program. Line 10 sets up the display colour attributes. Lines 20 and 30 print a couple of stars. Line 40 sets up the FOR...NEXT loop Line 50 draws a circle in the middle of the screen (high-res co-ordinates x=128,y=81) with radius 'r' pixels. Line 60 increases r by 2 (STEP 2) Line 70 waits for a keypress before ending the program.

Exercises 1. Change the STEP 2 in Line 40 to STEP 4 and run. 2. Change the STEP 2 in Line 40 to STEP 1 and run. 3. Change line 40 to FOR r=30 to 1 STEP -1 and watch what happens. Hint - don't ignore the minus.

Thanks for reading!

Stephen

98 views

Related Posts

See All
bottom of page