Last active
December 20, 2018 12:32
-
-
Save kylemcdonald/0bfe41bc921866cbad765d20d74d303d to your computer and use it in GitHub Desktop.
Some of the first generative code I ever wrote, for QBASIC. Written some time between 1997-2003.
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 redrawLine (n%) | |
DECLARE SUB drawDots (ntot%) | |
DECLARE SUB drawLines (ntot%) | |
CLS | |
SCREEN 12 '7 is white, 8 is gray, screen 7 is 320x200, screen 9 is 640x350, screen 12 is 640x480 | |
ntot% = 55 | |
DIM SHARED m(ntot%, 3) 'm(numberDot, [x, y, connected Dot, distance]) | |
DIM SHARED bound(1) | |
bound(0) = 640 | |
bound(1) = 460 | |
FOR n% = 0 TO ntot% | |
RANDOMIZE (TIMER * n%) | |
FOR xy% = 0 TO 1 | |
m(n%, xy%) = INT(RND * bound(xy%)) | |
IF m(n%, xy%) < 0 THEN | |
m(n%, xy%) = m(n%, xy%) * -1 | |
END IF | |
NEXT xy% | |
NEXT n% | |
FOR n% = 0 TO ntot% | |
m(n%, 3) = 100 | |
FOR j% = 0 TO ntot% | |
IF j% = n% THEN | |
ELSE | |
dist% = SQR(((m(j%, 0) - m(n%, 0)) ^ 2) + ((m(j%, 1) - m(n%, 1)) ^ 2)) | |
IF dist% < m(n%, 3) THEN | |
m(n%, 3) = dist% | |
m(n%, 2) = j% | |
redrawLine (n%) | |
END IF | |
END IF | |
NEXT j% | |
NEXT n% | |
drawLines (ntot%) | |
drawDots (ntot%) | |
SUB drawDots (ntot%) | |
FOR n% = 0 TO ntot% | |
PSET (m(n%, 0), m(n%, 1)), 7 | |
NEXT n% | |
END SUB | |
SUB drawLines (ntot%) | |
FOR n% = 0 TO ntot% | |
LINE (m(n%, 0), m(n%, 1))-(m(m(n%, 2), 0), m(m(n%, 2), 1)), 8 | |
NEXT n% | |
END SUB | |
SUB redrawLine (n%) | |
RANDOMIZE TIMER | |
LINE (m(n%, 0), m(n%, 1))-(m(m(n%, 2), 0), m(m(n%, 2), 1)), INT(RND * 11), , INT(RND * 16) | |
PSET (m(n%, 0), m(n%, 1)), 7 | |
PSET (m(m(n%, 2), 0), m(m(n%, 2), 1)), 7 | |
END SUB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment