Microsoft Small Basic

Program Listing: FXD982
SetGW()

Timer.Tick = Tick
Timer.Interval = 0

Sub Tick
Timer.Pause()
Timer.Tick = Tick2
Timer.Resume()
Animation()
EndSub

Sub Tick2
Timer.Pause()
Timer.Tick = Tick3
Timer.Resume()
Animation2()
EndSub

Sub Tick3
Timer.Pause()
Animation3()
EndSub

Sub Animation
X = 200
Y = 5
pace = 0.8

movingBall = Shapes.AddEllipse(20,25)
backLight = Shapes.AddRectangle(200, 25)
Shapes.SetOpacity(backLight, 10)
Shapes.Move(backLight, X, Y)

While "true"
Shapes.Move(movingBall, X, Y)
If X > 378 Or X < 200 Then
pace = -pace
EndIf
X = X + pace
Program.Delay(5)
EndWhile
EndSub

Sub Animation2
X2 = 200
Y2 = 50
pace2 = 0.8

movingBall2 = Shapes.AddEllipse(20,25)
backLight2 = Shapes.AddRectangle(200, 25)
Shapes.SetOpacity(backLight2, 10)
Shapes.Move(backLight2, X2, Y2)

While "true"
Shapes.Move(movingBall2, X2, Y2)
If X2 > 378 Or X2 < 200 Then
pace2 = -pace2
EndIf
X2 = X2 + pace2
Program.Delay(5)
EndWhile
EndSub

Sub Animation3
X3 = 200
Y3 = 105
pace3 = 0.8

movingBall3 = Shapes.AddEllipse(20,25)
backLight3 = Shapes.AddRectangle(200, 25)
Shapes.SetOpacity(backLight3, 10)
Shapes.Move(backLight3, X3, Y3)

While "true"
Shapes.Move(movingBall3, X3, Y3)
If X3 > 378 Or X3 < 200 Then
pace3 = -pace3
EndIf
X3 = X3 + pace3
Program.Delay(5)
EndWhile
EndSub

Sub SetGW
w = 600
h = 350
GraphicsWindow.Width = w
GraphicsWindow.Height = h
GraphicsWindow.BrushColor = "blue"
EndSub