Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A Lava Lamp to stare at.
#1
Something kind of silly but was fun to make.   I started playing with some plasma code and it morphed into a lava lamp somehow.  Never had one in real life.

This runs slow on my older laptop - commenting out the _LIMIT 30 didn't speed it up at all for me.  So if the blobs and plasma go too fast for you on your modern PC, play with the t = TIMER * .7 line to adjust speed.

- Dav

Code: (Select All)
'============
'LAVALAMP.BAS
'============
'By Dav, SEP/2024 for QB64PE

Screen _NewImage(1000, 700, 32)

Do

    Cls

    t = Timer * .7 'control speed here

    'plasma background
    For y = 0 To _Height Step 2
        For x = 0 To _Width Step 2
            r = Int(128 + 127 * Sin((x * .01) + t))
            g = Int(128 + 127 * Sin((y * .01) + t * 1.2))
            b = Int(128 + 127 * Sin((x * .01) + (y * 0.01) + t * .8))
            Line (x, y)-Step(1, 1), _RGBA(r, g, b, 50), BF
        Next
    Next

    'oily plasma blobs
    For y = 50 To _Height - 51
        For x = 325 To 675
            disx = x - _Width \ 2
            dixy = y - _Height \ 2
            wav = Sin(t + dixy * .05 + disx * .05) * 35
            rad = 150 + 50 * Sin(t * 1.5 + dixy * .1) + wav
            pulse = 1 + .5 * Sin(t + dixy * .1)
            If Sqr(disx ^ 2 / (85 * pulse) ^ 2 + dixy ^ 2 / (rad * pulse) ^ 2) < 1 Then
                clr = Int(255 - Sqr(disx ^ 2 + dixy ^ 2) / 2)
                Line (x, y)-Step(1, 1), _RGBA(255, clr, clr / 3, 150), BF
            End If
        Next
    Next

    'draw top half of lamp
    For y = 50 To 350
        wfix = (350 - y) / 3
        Line (325 + wfix, y)-(675 - wfix, y), _RGBA(255, 255, 100, 50), BF
    Next
    'draw bottom half of lamp
    For y = 351 To 650
        wfix = (y - 351) / 3
        Line (325 + wfix, y)-(675 - wfix, y), _RGBA(255, 255, 100, 50), BF
    Next

    'lamp top
    Line (425, 20)-(575, 50), _RGB(150, 100, 0), BF
    Line (425, 20)-(575, 50), _RGBA(255, 255, 100, 75), B

    'lamp base
    Line (375, 650)-(625, 700), _RGB(150, 100, 0), BF
    Line (375, 650)-(625, 700), _RGBA(255, 255, 100, 75), B

    _Display
    _Limit 30

Loop Until InKey$ <> ""

Find my programs here in Dav's QB64 Corner
Reply


Messages In This Thread
A Lava Lamp to stare at. - by Dav - 09-26-2024, 01:48 AM
RE: A Lava Lamp to stare at. - by TerryRitchie - 09-26-2024, 03:12 AM
RE: A Lava Lamp to stare at. - by bplus - 09-26-2024, 03:56 PM
RE: A Lava Lamp to stare at. - by Dav - 09-27-2024, 02:06 PM
RE: A Lava Lamp to stare at. - by TerryRitchie - 09-27-2024, 02:39 PM
RE: A Lava Lamp to stare at. - by Dav - 09-27-2024, 04:08 PM
RE: A Lava Lamp to stare at. - by SMcNeill - 09-27-2024, 04:21 PM
RE: A Lava Lamp to stare at. - by TerryRitchie - 09-27-2024, 08:22 PM
RE: A Lava Lamp to stare at. - by Kernelpanic - 09-27-2024, 07:43 PM
RE: A Lava Lamp to stare at. - by bplus - 09-27-2024, 10:04 PM
RE: A Lava Lamp to stare at. - by Dav - 09-28-2024, 02:25 AM
RE: A Lava Lamp to stare at. - by bplus - 09-28-2024, 02:52 PM
RE: A Lava Lamp to stare at. - by Steffan-68 - 09-28-2024, 04:12 PM
RE: A Lava Lamp to stare at. - by Dav - 09-28-2024, 10:45 PM
RE: A Lava Lamp to stare at. - by Dav - 09-30-2024, 03:12 PM
RE: A Lava Lamp to stare at. - by SMcNeill - 10-05-2024, 07:19 PM
RE: A Lava Lamp to stare at. - by SMcNeill - 09-30-2024, 03:36 PM
RE: A Lava Lamp to stare at. - by Dav - 09-30-2024, 04:43 PM
RE: A Lava Lamp to stare at. - by Dav - 10-05-2024, 07:56 PM
RE: A Lava Lamp to stare at. - by Pete - 10-05-2024, 08:05 PM



Users browsing this thread: 7 Guest(s)