I did this yesterday, thought better of it and didn't post. Now I think worse of it
Let us be saved from vectors!
Code: (Select All)
_Title "bplus overhaul Vector noodling of Terry Ritchie" ' b+ 2nd x 2024-09-18
' Move mouse to attract particles
' Press left mouse button to repel particles
Const PARTICLES = 250000 ' maximum number of particles
Const SWIDTH = 960 ' screen width
Const SHEIGHT = 540 ' screen height
Type PARTICLE ' PARTICLE PROPERTIES
x As Single ' y location
y As Single ' x location
End Type
Dim Particle(PARTICLES - 1) As PARTICLE ' create particles
Dim p As Long ' particle counter
Dim d As Single ' distance between particle and mouse
Dim dx As Single ' difference in x values
Dim dy As Single ' difference in y values
Dim Circ As Long ' picture of a solid circle
Circ = _NewImage(11, 11, 32) ' picture canvas
_Dest Circ ' craw circle
Circle (5, 5), 5
Paint (5, 5)
Randomize Timer
Do ' randomize particles
Particle(p).x = Rnd * SWIDTH
Particle(p).y = Rnd * SHEIGHT
p = p + 1
Loop Until p = PARTICLES
Screen _NewImage(SWIDTH, SHEIGHT, 32) ' start the madness
_ScreenMove 250, 70
_MouseHide
Color &HFF000000, &HFFFFFFFF
Do
Cls
_Limit 120
p = 0
Do
PSet (Particle(p).x, Particle(p).y) ' draw particle
While _MouseInput: Wend
d = _Hypot(_MouseX - Particle(p).x, _MouseY - Particle(p).y) ' distance to mouse
dx = (_MouseX - Particle(p).x)
dy = (_MouseY - Particle(p).y)
If _MouseButton(1) Then ' ' (Rnd - Rnd) * 5 this keeps everything moving left mouse button?
Particle(p).x = Particle(p).x - dx / d + (Rnd - Rnd) * 5 '/d so farther away the slower the effect
Particle(p).y = Particle(p).y - dy / d + (Rnd - Rnd) * 5
Else ' no button
Particle(p).x = Particle(p).x + dx / d + (Rnd - Rnd) * 5 '/d so farther away the slower the effect
Particle(p).y = Particle(p).y + dy / d + (Rnd - Rnd) * 5
End If
p = p + 1
Loop Until p = PARTICLES
_PutImage (_MouseX - 5, _MouseY - 5), Circ
_Display
Loop Until _KeyDown(27)
System
Let us be saved from vectors!
b = b + ...