Mystic memories.bas

See if this brings back memories for anyone. (I might not have the name right for this old classic screen saver?)


' Mystic memories.bas SmallBASIC 0.12.9 (B+=MGA) 2017-09-29
' I modified from my posted 2017-09-29 for QB64
' Mystic screen saver as I remember it plus...

option predef antialias off 'runs faster (or smoother) might improve image
randomize timer
dim x(2), y(2), dx(2), dy(2)
for
i = 0 to 2
newPoint i
next
saveX = x : saveY = y : saveDX = dx : saveDY = dy
dmode = 1 : nT = 50
resetPlasma
while 1
cls
color 11
? " Number of triangles = ";nT;" press m for more, l for less,"
? " spacebar to change color, d for duplicate image toggle."
cN = cN - nT + 1
x = saveX : y = saveY : dx = saveDX : dy = saveDY
for i = 0 to 2
updatePoint i
next
saveX = x : saveY = y : saveDX = dx : saveDY = dy
for j = 1 to nT
for i = 0 to 2
updatePoint i
next
changePlasma
for i = 0 to 2
line x(i), y(i), x((i+1) mod 3), y((i+1) mod 3)
next
if dmode = 1 then
for i = 0 to 2
line xmax - x(i), ymax - y(i), xmax - x((i+1) mod 3), ymax - y((i+1) mod 3)
next
end if
next
showpage
delay 10
k = inkey
if k = " " then
resetPlasma
elif k = "d"
dmode = not dmode
elif k = "m"
nT = nT + 1: if nT > 100 then nT = 100
elif k = "l"
nT = nT - 1: if nT < 1 then nT = 1
fi
wend

sub
newPoint(p)
x(p) = RND * xmax
y(p) = RND * ymax
dx(p) = (RND * 10 + 1) * rdir
dy(p) = (RND * 6 + 1) * rdir
end

sub
updatePoint(p)
if x(p) + dx(p) < 0 then dx(p) = -dx(p)
if y(p) + dy(p) < 40 then dy(p) = -dy(p)
if x(p) + dx(p) > xmax then dx(p) = -dx(p)
if y(p) + dy(p) > ymax - 40 then dy(p) = -dy(p)
x(p) = x(p) + dx(p)
y(p) = y(p) + dy(p)
end

sub
changePlasma ()
cN = cN + 1
color rgb(127 + 127 * sin(pR * .2 * cN), 127 + 127 * sin(pG * .2 * cN), 127 + 127 * sin(pB * .2 * cN))
end

sub
resetPlasma ()
pR = rnd ^ 2: pG = rnd ^ 2: pB = rnd ^ 2
end

func
rdir()
IF rnd < .5 THEN rdir = -1 ELSE rdir = 1
end


Not Mystic, and my memories are a little misty. ;-))