Particle Mist Eddies Mod
Code: (Select All)
_Title "Particle Mist Eddies Mod, go ahead and try a keypress" ' b+ mod issues37 QBJS post at Discord
Type Particle
x As Single
y As Single
angle As Single
speed As Single
c As _Unsigned Long
End Type
Const nParticles = 50000
Const Pi = _Pi
Dim Shared cN, pR, pG, pB
Dim p(1 To nParticles) As Particle
Dim t
Dim i As Long
Screen _NewImage(800, 600, 32): _ScreenMove 280, 60
Randomize Timer
For i = 1 To nParticles
p(i).x = Rnd * 800
p(i).y = Rnd * 600
p(i).speed = 0.5 + Rnd * 1.5
p(i).angle = Rnd * Pi * 2
Next
resetPlasma
Do
t = t + 0.03: cN = 0
For i = 1 To nParticles
fieldAngle = SIN(p(i).x / 101 + t) * COS(p(i).y / 103) + _
COS(p(i).x / 157 - t * .5) * SIN(p(i).y / 127) + _
SIN(p(i).x / 83 + t * .7) * SIN(p(i).y / 79 + t)
fieldAngle = fieldAngle + (Rnd - 0.5) * 0.1
p(i).angle = p(i).angle * 0.98 + fieldAngle * 1.0007 '.02
p(i).speed = 0.5 + Abs(Sin(p(i).x / 200 + t)) * 1.5
p(i).x = p(i).x + Cos(p(i).angle) * p(i).speed
p(i).y = p(i).y + Sin(p(i).angle) * p(i).speed
If p(i).x < 0 Then
p(i).x = 800
p(i).y = p(i).y + (Rnd - 0.5) * 20
End If
If p(i).x > 800 Then
p(i).x = 0
p(i).y = p(i).y + (Rnd - 0.5) * 20
End If
If p(i).y < 0 Then
p(i).y = 600
p(i).x = p(i).x + (Rnd - 0.5) * 20
End If
If p(i).y > 600 Then
p(i).y = 0
p(i).x = p(i).x + (Rnd - 0.5) * 20
End If
PSet (p(i).x, p(i).y), Plasma~&
Next
If Len(InKey$) Then resetPlasma
_Limit 60
_Display
Cls
Loop
Function Plasma~& ()
cN = cN + .01 'dim shared cN as _Integer64, pR as long, pG as long, pB as long
Plasma~& = _RGB32(127 + 127 * Sin(pR * cN), 127 + 127 * Sin(pG * cN), 127 + 127 * Sin(pB * cN))
End Function
Sub resetPlasma ()
'dim shared cN as _Integer64, pR as long, pG as long, pB as long
pR = Rnd ^ 2: pG = Rnd ^ 2: pB = Rnd ^ 2: cN = 0
End Sub
press any key to change color scheme.
Works in QBJS too!
Here is issues37 post color scheme which trasitions through beautifully brilliant colors, reduced particles for watery look in QBJS
b = b + ...