Skip to content

Instantly share code, notes, and snippets.

@Shogan
Last active Feb 23, 2022
Embed
What would you like to do?
A simple, retro screensaver written in QBasic
DECLARE SUB delay (seconds!)
SCREEN 13
RANDOMIZE TIMER
DIM prevCircX(1 TO 360)
DIM prevCircY(1 TO 360)
DIM prevInCircX(1 TO 360)
DIM prevInCircY(1 TO 360)
DO
randMaxR = INT((RND * 50) + 1)
circX = INT(RND * 320) + 1
circY = INT(RND * 200) + 1
innerRInc = 1
FOR j = 1 TO randMaxR
' clear old circle ripple
FOR i = 1 TO 360
PRESET (INT(prevCircX(i)), INT(prevCircY(i)))
NEXT
' generate grayscale colour depending how close we are to max radius
grayscale = INT(31 - (15 * (j / randMaxR)))
r = 1 + j
theta = 0
FOR i = 1 TO 360
X = circX + r * COS(theta)
Y = circY + r * SIN(theta)
PSET (INT(X), INT(Y)), INT(grayscale)
prevCircX(i) = X
prevCircY(i) = Y
theta = theta + 2
NEXT
IF (j >= (randMaxR / 2)) THEN
' clear old circle ripple
FOR i = 1 TO 360
PRESET (INT(prevInCircX(i)), INT(prevInCircY(i)))
NEXT
innerRInc = innerRInc + 1
r = 1 + innerRInc
theta = 0
FOR i = 1 TO 360
X = circX + r * COS(theta)
Y = circY + r * SIN(theta)
PSET (INT(X), INT(Y)), INT(grayscale)
prevInCircX(i) = X
prevInCircY(i) = Y
theta = theta + 2
NEXT
END IF
delay .02
NEXT
ESC$ = INKEY$
delay .01
LOOP WHILE ESC$ = ""
SUB delay (seconds!)
start# = TIMER
DO WHILE TIMER - start# < seconds!
LOOP
END SUB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment