Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mystify 2
#1
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.

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.
Reply
#2
Watch Mystify melt into a dreamy waltz of drifting circles  Big Grin


Code:
#win32
set window "A Dreamy Waltz", 800, 600, false
set redraw off

'main loop
do
    ' Gentle fade trail
    set color 0, 0, 0, 12; cls
   
    t = t + 0.04
   
    for i = 0 to 5
        phase = i * 1.5
       
        ' motion
        x = width()/2 + 280 * sin(t + phase)
        y = height()/2 + 220 * cos(t * 0.8 + phase * 0.4)
       
        ' Pulsating size
        size = 30 + 20 * sin(t * 2.5 + phase * 2)
       
        ' Continuous color flow
        hue = t * 35 + i * 90
        r = 128 + 127 * sin(hue * 0.02)
        g = 128 + 127 * sin((hue + 120) * 0.02)
        b = 128 + 127 * sin((hue + 240) * 0.02)
        set color r, g, b, 160
       
        ' draw circles
        draw ellipse x - size/2, y - size/2, size, size, true
    next
   
    redraw
    fwait 40
until keydown(KEY_ESCAPE, true)
Reply
#3
Cool... Reminds of a very fast moving "Lava Lamp"... Oh dear... Am I 'that' old that I may have to explain what a Lava Lamp is? lol
Logic is the beginning of wisdom.
Reply
#4
That's a really cool example.
Reply
#5
nice program for relaxing so i made my version
is it similar :


Attached Files Thumbnail(s)
   
Reply
#6
Circles are SO much more soothing than straight lines... Cool...
Logic is the beginning of wisdom.
Reply
#7
Agree, really cool one!
Reply
#8
yes it is
if you change i variable up to 50 then we get
something like circle worms Big Grin

[Image: index.php?action=dlattach;attach=539]


Attached Files Thumbnail(s)
   
Reply
#9
Ok. Now you are showing off... lol... Very cool... Nicely done!
Logic is the beginning of wisdom.
Reply
#10
yes a little bit LOL
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)