Created
November 11, 2016 20:42
-
-
Save dmsnell/ca6006893f30bcd90c01dac4659d8f7f to your computer and use it in GitHub Desktop.
Drawing a fractal in BASIC
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
SCREEN 12 | |
CLS | |
RANDOMIZE TIMER | |
maxx = 640 | |
maxy = 480 | |
x1% = INT(RND * maxx) + 1 | |
y1% = INT(RND * maxy) + 1 | |
TYPE VERTEX | |
XC AS DOUBLE | |
YC AS DOUBLE | |
END TYPE | |
DIM POINTS(3) AS VERTEX | |
POINTS(1).XC = 0 | |
POINTS(1).YC = maxy | |
POINTS(2).XC = maxx / 2 | |
POINTS(2).YC = 0 | |
POINTS(3).XC = maxx | |
POINTS(3).YC = maxy | |
WHILE INKEY$ = "" | |
P = INT(RND * 3) + 1 | |
x1 = x1 - ((x1 - POINTS(P).XC) / 2) | |
y1 = (y1 - ((y1 - POINTS(P).YC) / 2)) | |
PSET (x1, y1), 11 | |
WEND | |
DO: LOOP WHILE INKEY$ = "" | |
DO | |
CLS | |
POINTS(1).XC = INT(RND * maxx) + 1 | |
POINTS(1).YC = INT(RND * maxy) + 1 | |
POINTS(2).XC = INT(RND * maxx) + 1 | |
POINTS(2).YC = INT(RND * maxy) + 1 | |
POINTS(3).XC = INT(RND * maxx) + 1 | |
POINTS(3).YC = INT(RND * maxy) + 1 | |
WHILE INKEY$ <> CHR$(27) | |
P = INT(RND * 3) + 1 | |
x1 = x1 - ((x1 - POINTS(P).XC) / 2) | |
y1 = (y1 - ((y1 - POINTS(P).YC) / 2)) | |
PSET (x1, y1), 10 | |
WEND | |
LOOP | |
DO: LOOP WHILE INKEY$ = "" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment