Last active
February 23, 2022 19:54
-
-
Save Shogan/f5a3043531a4d8a20ef455939fe75322 to your computer and use it in GitHub Desktop.
A simple, retro screensaver written in QBasic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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