voici ma version
Code : Tout sélectionner
;***********************************************
;Titre :*etoiles_scintillantes
;Auteur : Zorro
;Date :25/10/2016
;Heure :11:42:32
;Version Purebasic : PureBasic 5.50 (Windows - x86)
;Version de l'editeur :EPB V2.64
; Libairies necessaire : Aucune
;***********************************************
Enumeration
#window = 0
EndEnumeration
ExamineDesktops()
Global Width=DesktopWidth(0)
Global Height =DesktopHeight(0)
Global nbr_etoiles=1500 ; << on peut changer le nombre d'etoiles
Global Taille_etoile=1 ; << on peut changer la taille des etoiles
; #Width = 800
; #Height = 600
Structure Stars
x.i
y.i
couleur.i
EndStructure
Global Dim Stars.Stars(nbr_etoiles)
For i=1 to nbr_etoiles
Stars(i)\x.i=Random(Width-1,1)
Stars(i)\y.i=Random(Height-1,1)
cr.f=Random(255,50)
cv.f=Random(255,25)
cb.f=Random(255,12)
Stars(i)\couleur.i=Rgb(cr,cv,cb)
Next i
;- Initialisation de DirectX
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
MessageRequester("Erreur", "Impossible d'initialiser DirectX", 0)
CloseWindow(#window) : End
EndIf
;- Ouverture de la fenetre et de l'écran
hwnd = OpenWindow(#window, 0, 0, Width, Height, "",#PB_Window_BorderLess )
OpenWindowedScreen(hwnd, 0, 0, Width, Height, 0, 0, 0)
;- début de la boucle
Repeat
ExamineMouse() ; on demande a purebasic de surveiller les event de souris !
ExamineKeyboard() ; on demande a purebasic de surveiller les event de clavier!
evnt=WaitWindowEvent(2)
Select evnt
Case #PB_Event_CloseWindow
End
EndSelect
;- dessin des etoiles
StartDrawing(ScreenOutput())
For i=1 to nbr_etoiles
; Alea
de=random(3,1)
select de
Case 1
cr.f=cr.f+ Sin(degree(i))*10
Case 2
cv.f=cv.f+Sin(degree(i))*10
Case 3
cb.f=cb.f+Sin(degree(i)) *10
EndSelect
if cv>255:cv=255:Endif
if cb>255:cb=255:Endif
if cr<25:cr=25:Endif
if cv<25:cv=25:Endif
if cb<25:cb=25:Endif
Stars(i)\couleur.i=Rgb(cr,cv,cb)
circle(Stars(i)\x.i,Stars(i)\y.i,Taille_etoile,Stars(i)\couleur.i)
Next i
StopDrawing()
StartDrawing(ScreenOutput())
DrawText(10, 10, "touche ESC pour quitter" ,RGB(255,255,0),RGB(0,0,0))
StopDrawing()
FlipBuffers() : ClearScreen(RGB(0,0,0))
Delay(50)
Until KeyboardPushed(#PB_Key_Escape)
;