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
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$ <> ""