Untitled patterns

Everything else that doesn't fall into one of the other PB categories.
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Untitled patterns

Post by Olliv »

Hello,

Cleaning my memory, I found this code I don't remember why and how I did it. So, before delete it I publish a copy. Also, the... original idea won't disappear and will be maybe useful for anybody...

Ollivier

Code: Select all

;PB440
    InitSprite()
    InitKeyboard()
    InitMouse()
    ExamineDesktops()
    w = DesktopWidth(0)
    h = DesktopHeight(0)
    d = DesktopDepth(0)
    OpenScreen(w, h, d, "")
    Nb = 99
    Dim DX.F(Nb)
    Dim DY.F(Nb)
    Dim X.F(Nb)
    Dim Y.F(Nb)
    Dim VX.F(Nb)
    Dim VY.F(Nb)
    Dim AX.F(Nb)
    Dim AY.F(Nb)
    Dim C.I(Nb)
    For I = 0 To Nb
        X(I) = Random(w - 1)
        Y(I) = Random(h - 1)
        C(I) = RGB(128 + Random(127), 128 + Random(127), 128 + Random(127) )
    Next I

                N.F = Nb
                h4.F = h / 4.0
    Repeat
        Delay(1)
        ExamineKeyboard()
        ClearScreen(RGB(255, 255, 255) )
        StartDrawing(ScreenOutput() )
            For I = 0 To Nb
                For J = 0 To Nb
                If J <> I
                    xx.F = X(j) - X(i)
                    yy.F = Y(j) - Y(i)
                    xx2.F = (X(j) + DX(j) ) - (X(i) + DX(i) )
                    yy2.F = (Y(j) + DY(j) ) - (Y(i) + DY(i) )
                    Dist.F = Sqr(xx * xx + yy * yy)
                    Dist2.F = Sqr(xx2 * xx2 + yy2 * yy2)
                    AX(I) + (10.0 * xx / Dist / Dist)
                    AY(I) + (10.0 * yy / Dist / Dist)
                    G = 255 - Dist2 * 4
                    G = Dist2 * 4
                    If Dist2 < 64 And Dist < 64
                        LineXY(X(I), Y(I), X(J), Y(J), RGB(G, G, G) )
                    EndIf
                EndIf
                Next
                AX(I) / N
                AY(I) / N
                VX(I) + AX(I)
                VY(I) + AY(I)
                X(I) + VX(I)
                Y(I) + VY(I)
                If X(I) + DX(I) > w: DX(I) - w: EndIf
                If X(I) + DX(I) < 0: DX(I) + w: EndIf
                If Y(I) + DY(I) > h: DY(I) - h: EndIf
                If Y(I) + DY(I) < 0: DY(I) + h: EndIf
            Next I
        StopDrawing()
        FlipBuffers()
        If KeyboardPushed(#PB_Key_Space)
            ClearScreen(RGB(0, 0, 0) )
        EndIf
    Until KeyboardPushed(#PB_Key_Escape)
    CloseScreen()
    End