02-07-2026, 05:36 AM
Remember the original Mystify (https://naalaa.com/forum/thread-202.html) using just 2 coloured lines?
Well... Here is an update... Using four coloured lines... Wow! Twice as many lines. Twice the fun! Nah! Kidding. I just like the cool effect. Enjoy.
Well... Here is an update... Using four coloured lines... Wow! Twice as many lines. Twice the fun! Nah! Kidding. I just like the cool effect. Enjoy.
Code:
' Mystify 2
'
' by johnno56
'
' Based on https://naalaa.com/forum/thread-202.html
set window "Mystify2 '95 Style", 800, 600, false
set redraw off
' Mystify Screensaver Replica for N7
visible ScreenW, ScreenH
ScreenW = 800
ScreenH = 600
' Polygon points (4 corners)
visible pX = [] ' velocities
visible pY = []
visible vX = []
visible vY = []
visible i
' Initialize points and velocities
for i = 0 to 3
pX[i] = rnd(ScreenW)
pY[i] = rnd(ScreenH)
vX[i] = (rnd(10) - 5) + 1 ' Random speed between -4 and 5
vY[i] = (rnd(10) - 5) + 1
next
' Color settings
visible hue = 0
visible r
visible g
visible b
' Main Loop
do
' 1. Fade effect: Draw a semi-transparent black rect over the whole screen
' This makes old lines fade away slowly
' Set alpha colour to 20 ' Lower number = longer trail
set color 0, 0, 0, 10 ' 10
draw rect 0, 0, ScreenW, ScreenH, 1
set color 0, 0, 0 ' Reset alpha for drawing
' 2. Update Position
for i = 0 to 3
pX[i] = pX[i] + vX[i]
pY[i] = pY[i] + vY[i]
' Bounce off walls
if pX[i] < 0 or pX[i] > ScreenW vX[i] = -vX[i]
if pY[i] < 0 or pY[i] > ScreenH vY[i] = -vY[i]
next
' 3. Cycle Color (Simple HSV to RGB conversion)
hue = hue + 0.5
if hue > 360 hue = 0
' Rudimentary rainbow cycle
r = 127 + 127 * sin(hue * 3.14159 / 180)
g = 127 + 127 * sin((hue + 120) * 3.14159 / 180)
b = 127 + 127 * sin((hue + 240) * 3.14159 / 180)
set color r, g, b
' 4. Draw Lines
for i = 0 to 3
' Connect current point to next, wrapping around 3->0
nextPoint = (i + 1) % 4
draw line pX[i], pY[i], pX[nextPoint], pY[nextPoint]
next
' 5. Refresh Screen
redraw
fwait 45 ' 30 to 60
' Exit on escape key press
until keydown(KEY_ESCAPE, true)
Logic is the beginning of wisdom.


