include "sdl.inc"
SetDisplay 640, 480, 1
SetCaption "SDL PARTICLES"

sys color, anz=5000, speed=2, xScreen=640,yScreen=480
dim stern_x(5000) as sys
dim stern_y(5000) as sys
dim stern_z(5000) as sys

Sub StarInit()
int i
For i=0 to anz
   stern_x(i) = Rand( -(xscreen\2), (xscreen\2)) << 8
   stern_y(i) = Rand( -(yscreen\2), (yscreen\2)) << 8
   stern_z(i) = Rand(speed,255)
Next 
End Sub

Sub StarUpdate()
 int i
For i=0 to anz
   stern_z(i) = stern_z(i) - speed
   if stern_z(i) <= speed then stern_z(i) = 255
   int s_x = (stern_x(i) / stern_z(i)) + (xscreen / 2)
   int s_y = (stern_y(i) / stern_z(i)) + (yscreen / 2)
   int color =300 - stern_z(i)
   SetPixel s_x, s_y,  color << 2, color << 2, color << 2 
Next
End Sub

StarInit
While Key(27)=0 
ClsColor 0,0,0
StarUpdate
Flip
SetFps 60
Wend
Ends