Charlie Veniotย 28th September 2022 at 2:04pm
1 REM ** Ever-Changing Mandala **
2 ' BASED ON: GW-BASIC Made Easy, Chapter 12. File: GWME1211.BAS
100 REM ** Setup **
'โ 110 was SCREEN 1: COLOR 0, 1: CLS : KEY OFF
110 SCREEN _newimage(640,200,9)
120 RANDOMIZE TIMER: DEFINT A-Z
130 REM ** Draw mandala until ESC key is pressed **
'๐
_alert("Press the escape key to pause the program.\n\nWhen the program is paused, press the escape key again to end the program, or press any other key to resume the program.")
'โ 140 was CIRCLE (160, 100), 2, 3: PAINT (160, 100), 3, 3 'Center
140 CIRCLE (320, 100), 2, 3: PAINT (320, 100), 3, 3 'Center
150 WHILE INKEY$ <> CHR$(27)
160 ' Assign random values to variables
170 radius = INT(8 * RND) + 3
'โ 180 OneKolor = INT(3 * RND) + 1: TwoKolor = INT(4 * RND)
180 OneKolor = INT(15 * RND) + 1
'๐
if int(3*rnd) <> 0 then
TwoKolor = INT(16 * RND)
else
TwoKolor = 0
end if
'โ 190 had INT(155
190 DelH = INT(310 * RND) + 10 'Horizontal offset
200 DelV = INT(95 * RND) + 10 'Vertical offset
210 ' Draw and paint circles
'โ lines 220-290: x values all doubled
220 CIRCLE (320 + DelH, 100 + DelV), radius, OneKolor
230 PAINT (320 + DelH, 100 + DelV), TwoKolor, OneKolor
240 CIRCLE (318 - DelH, 100 + DelV), radius, OneKolor
250 PAINT (318 - DelH, 100 + DelV), TwoKolor, OneKolor
260 CIRCLE (318 - DelH, 99 - DelV), radius, OneKolor
270 PAINT (318 - DelH, 99 - DelV), TwoKolor, OneKolor
280 CIRCLE (320 + DelH, 99 - DelV), radius, OneKolor
290 PAINT (320 + DelH, 99 - DelV), TwoKolor, OneKolor
'โ Easing the CPU workload
' The original GW-BASIC code to delay drawing to the screen (CPU intensive)
' I've replaced lines 300 and 310 with the SLEEP statement, which seems to be much less CPU intensive (well, on my quad-core Chromebook)
' 300 delay! = 1 : start! = TIMER
' 310 WHILE TIMER < start! + delay!: WEND 'Pause
SLEEP 0.25
320 WEND
330 REM ** Check to see if more or quit **
340 ky$ = INPUT$(1): IF ky$ <> CHR$(27) THEN 150 'More or quit
'โ350 CLS: SCREEN 0: WIDTH 80: END
350 END