Sub Update
If speed > 50 and Math.GetRandomNumber(60) < speed Then
GraphicsWindow.BackgroundColor = GraphicsWindow.GetRandomColor()
ElseIf speed <= 50 and GraphicsWindow.BackgroundColor <> "black" then
GraphicsWindow.BackgroundColor = "black"
EndIf
For i = 1 To number_of_stars
RemoveStarFromAxis()
' update position of star
distance = Math.SquareRoot(star_x[i]*star_x[i] + star_y[i]*star_y[i])
star_x[i] = star_x[i] + Math.Round(speed * (star_x[i] / distance))
star_y[i] = star_y[i] + Math.Round(speed * (star_y[i] / distance))
' replace star with new one if it is out of view
If (star_x[i] < -250 Or star_x[i] > 250) Or (star_y[i] < -250 Or star_y[i] > 250) Then
' remove old star
Shapes.Remove(star[i])
' calculate star's new position and size
star_x[i] = 50 - Math.GetRandomNumber(100)
star_y[i] = 50 - Math.GetRandomNumber(100)
size = Math.GetRandomNumber(4) + 1
RemoveStarFromAxis()
If speed <= 30 And star_is_stripe[i] Then
Shapes.Remove(star[i])
size = Math.GetRandomNumber(4) + 1
star[i] = Shapes.AddEllipse(size, size)
star_is_stripe[i] = "false"
EndIf
' move star to new position
Shapes.Move(star[i], 250 + star_x[i], 250 + star_y[i])
EndFor
EndSub
Sub OnKeyDown
If GraphicsWindow.LastKey = "Up" and speed < 60 Then
speed = speed + 1
EndIf
If GraphicsWindow.LastKey = "Down" and speed > 1 Then
speed = speed - 1
EndIf
GraphicsWindow.Title = "Speed: " + speed
EndSub
Sub RemoveStarFromAxis
' move star away from the axis of coordinates
If star_x[i] = 0 Then
star_x[i] = 1
EndIf
If star_y[i] = 0 Then
star_y[i] = 1
EndIf
EndSub