



Code : Tout sélectionner
#Width = 800
#Heigh = 600
#FullScreen = 0
Structure Stars
X.w
Y.w
Color.l
Order.s
EndStructure
NewList Stars.Stars()
InitSprite()
InitKeyboard()
For k = 0 To (#Width+#Heigh)/4
X = Random(#Width-2)
Y = Random(#Heigh-2)
X = X + 1
Y = Y + 1
Color = Random(155)
AddElement(Stars())
Stars()\X = X
Stars()\Y = Y
Stars()\Color = RGB(100+Color, 100+Color, 100+Color)
If Stars()\Color >= $FAFAFA
Stars()\Order = "-"
ElseIf Stars()\Color <= $646464
Stars()\Order = "+"
Else
If Random(1) = 1
Stars()\Order = "+"
Else
Stars()\Order = "-"
EndIf
EndIf
Next k
If #FullScreen
Result = OpenScreen(#Width, #Heigh, 32, "Stars")
Else
If OpenWindow(1, 0, 0, #Width, #Heigh, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "Stars")
Result = OpenWindowedScreen(WindowID(1), 0, 0, 400, 400, 1, 0, 0)
EndIf
EndIf
If Result
Repeat
ClearScreen(0, 0, 0)
If IsSprite(2)
FreeSprite(2)
EndIf
CreateSprite(2, #Width, #Heigh)
If StartDrawing(SpriteOutput(2))
ResetList(Stars())
For k = 0 To (#Width+#Heigh)/4
NextElement(Stars())
Plot(Stars()\X, Stars()\Y, Stars()\Color)
If Stars()\Color >= $FAFAFA
Stars()\Order = "-"
Stars()\Color = Stars()\Color-$050505
done = 1
ElseIf done = 0 And Stars()\Color <= $646464
Stars()\Order = "+"
Stars()\Color = Stars()\Color+$050505
done = 1
ElseIf done = 0 And Stars()\Order = "+"
Stars()\Color = Stars()\Color+$050505
ElseIf done = 0 And Stars()\Order = "-"
Stars()\Color = Stars()\Color-$050505
EndIf
done = 0
Next k
StopDrawing()
EndIf
DisplaySprite(2, 0, 0)
FlipBuffers(1)
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
EndIf