Plasma Plus Vonoroi Variation #3
Growing and collapsing points that move around screen:
Code: (Select All)
_Title "Plasma Plus Vonoroi 3" ' b+ 2023-10
' move points that are either holes or humps!
'$If WEB Then
' Import G2D From "lib/graphics/2d.bas"
'$End If
Screen _NewImage(800, 600, 32)
Type Pt_Type
X As Single ' location
Y As Single
DX As Single ' moving points
DY As Single
HoleTF As Long ' TF hole of not (= bump/ hill) here is the new twist!
End Type
Dim Shared As Single Rd, Gn, Bl
Dim Shared As Long NP
ReDim Shared Pt(1 To 1) As Pt_Type
Dim As Long x, y
Dim As Single d, dist, f
Dim As Long i, savei
Dim As Single t
Dim k$
Dim c As _Unsigned Long
Setup
Do
For y = 0 To _Height - 1 Step 2
For x = 0 To _Width - 1 Step 2
d = 10000
For i = 1 To NP
dist = _Hypot(x - Pt(i).X, y - Pt(i).Y)
If dist < d Then d = dist: savei = i
Next
If Pt(savei).HoleTF Then
d = t - d
Else
d = t + d
End If
c = _RGB32(127 + 127 * Sin(Rd * d), 127 + 127 * Sin(Gn * d), 127 + 127 * Sin(Bl * d))
Line (x, y)-Step(2, 2), c, BF
Next
Next
For i = 1 To NP ' move along
If Pt(i).X + Pt(i).DX < 0 Or Pt(i).X + Pt(i).DX > _Width - 1 Then Pt(i).DX = -Pt(i).DX
If Pt(i).Y + Pt(i).DY < 0 Or Pt(i).Y + Pt(i).DY > _Height - 1 Then Pt(i).DY = -Pt(i).DY
Pt(i).X = Pt(i).X + Pt(i).DX: Pt(i).Y = Pt(i).Y + Pt(i).DY
Next
t = t + 1
k$ = InKey$
If Len(k$) Then
Setup: t = 0
End If
_Display
_Limit 30 'ha!
Loop Until _KeyDown(27)
Sub Setup
Dim As Long i
Rd = Rnd * Rnd: Gn = Rnd * Rnd: Bl = Rnd * Rnd
NP = Int(Rnd * 50) + 3
ReDim Pt(1 To NP) As Pt_Type
For i = 1 To NP
Pt(i).X = Int(Rnd * _Width)
Pt(i).Y = Int(Rnd * _Height)
Pt(i).DX = (2 * Int(Rnd * 2) - 1) * (Rnd * 5 + .5)
Pt(i).DY = (2 * Int(Rnd * 2) - 1) * (Rnd * 5 + .5)
Pt(i).HoleTF = Int(Rnd * 2)
Next
End Sub
b = b + ...