Comme je glande beaucoup au boulot, je m'occupe avec purebasic
aujourd'hui voici ce que j'ai fais :
Code : Tout sélectionner
If InitSprite () = 0
MessageRequester ("Erreur", "Impossible d'initialiser directx", #PB_MessageRequester_Ok)
End
EndIf
#WindowWidth = 400
#WindowHeight = 300
hWnd = OpenWindow(0, 0, 0, #WindowWidth, #WindowHeight, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Test")
If hwnd = 0
MessageRequester ("Erreur", "Impossible d'ouvrir l'écran", #PB_MessageRequester_Ok)
End
EndIf
If OpenWindowedScreen(hWnd, 0, 0, #WindowWidth, #WindowHeight, 1, 0, 0) = 0
MessageRequester ("Erreur", "Impossible d'ouvrir l'écran", #PB_MessageRequester_Ok)
End
EndIf
InitKeyboard ()
ClearScreen (0,0,0)
FlipBuffers ()
ClearScreen (0,0,0)
; ---------- INIT ----------
#nb = 500
Dim x2.f(#nb)
Dim y2.f(#nb)
Dim decalx.f (#nb)
Dim decaly.f (#nb)
Dim dist.f(#nb)
Dim col(#nb)
For i = 1 To #nb
x2.f(i) = (Random (256) - 128)
If x2(i) = 0
x2(i) = 1
EndIf
y2.f(i) = (Random (256) - 128)
If y2(i) = 0
y2(i) = 1
EndIf
dist(i) = Random (20)
If dist(i) = 0
dist(i) = 1
EndIf
col (i) = Abs (x2(i)) + Abs (y2(i))
Next
; --------------------------
Repeat
ExamineKeyboard ()
ClearScreen(0,0,0)
If StartDrawing (ScreenOutput ())
rx2.f = rx2 * 0.99 + (Random (10) - 5) / 1000
ry2.f = ry2 * 0.99 + (Random (10) - 5) / 1000
rx.f = rx * 0.99 + rx2
ry.f = ry * 0.99 + ry2
For i = 1 To #nb
x2.f(i) = rx * dist (i) / 3 + x2(i) * 1.005
y2.f(i) = ry * dist (i) / 3 + y2(i) * 1.005
x.f = (#WindowWidth / 2) + x2(i) + decalx(i) * dist(i)
y.f = (#WindowHeight / 2) + y2(i) + decaly(i) * dist(i)
If x < 0 Or x > #WindowWidth Or y < 0 Or y > #WindowHeight
x2.f(i) = (Random (256) - 128)
If x2(i) = 0
x2(i) = 1
EndIf
y2.f(i) = (Random (256) - 128)
If y2(i) = 0
y2(i) = 1
EndIf
dist.f(i) = Random (20)
If dist(i) = 0
dist(i) = 1
EndIf
decalx.f (i) = -rx * dist (i)
decaly.f (i) = -ry * dist (i)
col (i) = Abs (x2(i)) + Abs (y2(i))
Else
Plot (x,y,RGB (col(i),col(i),col(i)))
EndIf
Next
EndIf
StopDrawing ()
FlipBuffers ()
Until KeyboardPushed (#PB_Key_Escape)