Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How about some vector noodles?
#19
I did this yesterday, thought better of it and didn't post. Now I think worse of it Big Grin Big Grin Big Grin

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 + ...
Reply


Messages In This Thread
How about some vector noodles? - by TerryRitchie - 05-13-2024, 03:30 PM
RE: How about some vector noodles? - by bplus - 05-13-2024, 04:43 PM
RE: How about some vector noodles? - by Sprezzo - 05-13-2024, 05:42 PM
RE: How about some vector noodles? - by GareBear - 05-13-2024, 08:17 PM
RE: How about some vector noodles? - by bplus - 05-13-2024, 11:33 PM
RE: How about some vector noodles? - by NakedApe - 05-14-2024, 01:15 AM
RE: How about some vector noodles? - by Sprezzo - 05-14-2024, 04:11 PM
RE: How about some vector noodles? - by bplus - 05-14-2024, 04:26 PM
RE: How about some vector noodles? - by Sprezzo - 05-14-2024, 04:28 PM
RE: How about some vector noodles? - by bplus - 05-14-2024, 04:40 PM
RE: How about some vector noodles? - by Sprezzo - 05-14-2024, 06:44 PM
RE: How about some vector noodles? - by Dav - 09-17-2024, 11:06 AM
RE: How about some vector noodles? - by bplus - 09-17-2024, 03:01 PM
RE: How about some vector noodles? - by bplus - 09-18-2024, 08:07 PM
RE: How about some vector noodles? - by Dav - 09-18-2024, 10:37 PM
RE: How about some vector noodles? - by bplus - 09-18-2024, 10:51 PM
RE: How about some vector noodles? - by sbblank - 09-18-2024, 11:13 PM



Users browsing this thread: 3 Guest(s)