Enlever le débogueur
(vous pouvez utiliser la souris)
Code : Tout sélectionner
; mini demo 2D - répulsion - Pf Shadoko - 2023
ExamineDesktops()
Define i,j,n,rnd,a.f,l=256,ex=DesktopWidth(0),ey=DesktopHeight(0),ry.f=ey/1080,ex2=ex/2,ey2=ey/2,ex3=ex*1.5,ey3=ey*1.5
InitSprite():InitKeyboard():InitMouse()
OpenWindow(0, 0, 0, ex,ey, "", #PB_Window_BorderLess):OpenWindowedScreen(WindowID(0), 0, 0, ex,ey, 0, 0, 0)
For i=1 To 6
CreateSprite(i,l,l,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(i))
DrawingMode(#PB_2DDrawing_Gradient| #PB_2DDrawing_AllChannels)
GradientColor(0,$ffffFFFF)
GradientColor(1,RGBA(Random(128),Random(128),Random(128),255))
CircularGradient(l*0.3, l*0.3, l*0.5)
Circle(l*0.5, l*0.5, l*0.5)
StopDrawing()
Next
Structure spoint
x.f
y.f
r.f
m.f
sprite.l
EndStructure
n=200
Dim p.spoint(n)
RandomSeed(4)
For i=0 To n
With p(i)
rndf.f=Random(999)/1000
rnd=Int(rndf*rndf*5)+1
If i=0:rnd=6:EndIf
\x=Random(ex)
\y=Random(ey)
\r=rnd*15*ry
\m=rnd*rnd*6000*ry*ry
\sprite=rnd
EndWith
Next
Define.f f,fx,fy, x,y,m,dx,dy,l2
MouseLocate(ex2,ey2)
Repeat
While WindowEvent():Wend
ExamineKeyboard():ExamineMouse()
ClearScreen(RGB(0,0,0))
For j=0 To n:x=p(j)\x:y=p(j)\y:m=p(j)\m:fx=0:fy=0
For i=0 To n:If i=j:Continue:EndIf
With p(i)
dx=\x-x:dx=Mod(dx+ex3,ex)-ex2
dy=\y-y:dy=Mod(dy+ey3,ey)-ey2
l2=Sqr(dx*dx+dy*dy):If l2<10:l2=10:EndIf:f=\m/(l2*l2*l2):fx+dx*f:fy+dy*f
EndWith
Next
p(j)\x=Mod(p(j)\x-fx+ex,ex)
p(j)\y=Mod(p(j)\y-fy+ey,ey)
Next
If MouseDeltaX():mouseon=1:EndIf
If mouseon:p(0)\x=MouseX():p(0)\y=MouseY():Else:a+0.01:p(0)\x=Cos(a)*ex/3+ex/2:p(0)\y=Sin(a)*ey/3+ey/2:EndIf
For i=0 To n
With p(i)
ZoomSprite(\sprite,\r*2,\r*2):DisplayTransparentSprite(\sprite,\x-\r,\y-\r,255)
EndWith
Next
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or MouseButton(3)