include "sdl.inc"

SetDisplay 800,600,1
SetCaption "SDL STARS" 

Type Star
   sys xStar 
   sys yStar 
   sys speed 
End Type

Dim Stars(450) As Star
sys xRes =800
sys yRes =600 

Function InitStars()
sys i
For i = 1 To 450
   Stars(i).xStar = Rand(1, xRes -2)
   Stars(i).yStar = Rand(1, yRes -2)
   Stars(i).speed = Rand(1, 4)
Next 
End Function

Function MoveStars()
sys i
For i = 1 To 450 
   SetPixel Stars(i).xStar,Stars(i).yStar, Rand(64,255),255,255
   Stars(i).xStar = Stars(i).xStar + Stars(i).speed
   iF Stars(i).xStar > xRes
      Stars(i).xStar = 0
      Stars(i).yStar = Rand(1, yRes -2)
      Stars(i).speed = Rand(1, 4)
   End iF
Next
End Function

InitStars()

While Key(27)=0
ClsColor 0,0,0
MoveStars
Flip
SetFps 120
Wend
Ends