Microsoft Small Basic

Program Listing: LBW566
Init()
While (Draw = 1)
'To be in progress
If Clock.ElapsedMilliseconds - Start > MiSec Then
ShowInProgress()
Start = Clock.ElapsedMilliseconds
EndIf
'Show Shape Reticle with random position
Speed = Math.GetRandomNumber(250) + 100
x2 = Math.GetRandomNumber(gw)
y1 = Math.GetRandomNumber(gh)
Shapes.Animate(drop1,x1,y1,Speed)
Shapes.Animate(drop2,x2,y2,Speed)
Program.Delay(speed*1.5)
' Random object
If (i = 0) Then
a = Math.GetRandomNumber(5)
EndIf
'Draw objects
If (a = 1 Or a = 2) Then
DrawEorR()
ElseIf (a = 3) Then
DrawTriangle()
Speed = Speed / 2
ElseIf (a > 3) Then
DrawLine()
EndIf
EndWhile
'At end
Shapes.HideShape(drop1)
Shapes.HideShape(drop2)
GraphicsWindow.BrushColor = CBack
GraphicsWindow.FillRectangle(10,h-25,w-20,15)
Program.Delay(3000)

'***************************************************************************

Sub Init
gw = 600
gh = 400
w = gw
h = gh + 30
GraphicsWindow.Width = w
GraphicsWindow.Height = h
GraphicsWindow.Top = 0
GraphicsWindow.Left = 0
GraphicsWindow.BackgroundColor = "LightYellow"
CBrush = GraphicsWindow.BrushColor
CBack = GraphicsWindow.BackgroundColor
FSB = (w-20) / 100
L = 0
P = 0
Start = Clock.ElapsedMilliseconds
MiSec = 200
Draw = 1
i = 0
x1 = 0
y1 = 0
xx1 = gw
yy1 = 0
drop1 = Shapes.AddLine(x1,y1,xx1,yy1)
Shapes.ShowShape(drop1)
x2 = 0
y2 = 0
xx2 = 0
yy2 = gw
drop2 = Shapes.AddLine(x2,y2,xx2 ,yy2)
Shapes.ShowShape(drop2)
Col = GraphicsWindow.GetRandomColor()
EndSub ' Init

Sub DrawEorR
i = i + 1
If (i = 1) Then
px1 = x2
py1 = y1
Else
i = 0
px2 = x2
py2 = y1
If (px1 > px2) then
pxx = px1
px1 = px2
px2 = pxx
pyy = py1
py1 = py2
py2 = pyy
EndIf
If (py1 > py2) then
pyy = py1
py1 = py2
py2 = pyy
EndIf
px2 = px2 - px1
py2 = py2 - py1
setColour()
GraphicsWindow.BrushColor = Col
If (a = 1) Then
GraphicsWindow.FillRectangle(px1,py1,px2,py2)
Else
GraphicsWindow.FillEllipse(px1,py1,px2,py2)
EndIf
EndIf
EndSub 'DrawEorR

Sub DrawTriangle
i = i + 1
If i = 1 Then
px1 = x2
py1 = y1
ElseIf i = 2 Then
px2 = x2
py2 = y1
ElseIf i = 3 Then
i = 0
px3 = x2
py3 = y1
setColour()
GraphicsWindow.FillTriangle(px1,py1,px2,py2,px3,py3)
EndIf
EndSub 'DrawTriangle

Sub DrawLine
i = i + 1
If i = 1 Then
px1 = x2
py1 = y1
Else
i = 0
px2 = x2
py2 = y1
setColour()
GraphicsWindow.DrawLine(px1,py1,px2,py2)
EndIf
EndSub 'DrawLine

Sub setColour
OldCol = Col
While (Col = OldCol And Col <> "#000000000")
Col = GraphicsWindow.GetRandomColor()
GraphicsWindow.BrushColor = Col
GraphicsWindow.PenColor = Col
EndWhile
EndSub 'setColour

Sub ShowInProgress
If L < w-20 Then
L = L + FSB
P = 10
GraphicsWindow.BrushColor = "DarkBlue"
GraphicsWindow.FillRectangle(10,h-25,L,15)
Else
FT = FT + 1
If FT = 1 Then
MiSec = MiSec * 4
EndIf
P = P + (FSB*4)
If P >= w-20-(3*FSB) Then
P = 10 + (3*FSB)
Draw = 0 'End
EndIf
GraphicsWindow.BrushColor = "DarkBlue"
GraphicsWindow.FillRectangle(10,h-25,w-20,15)
GraphicsWindow.BrushColor = "LightGray"
GraphicsWindow.FillRectangle(P, h-25, FSB, 15)
GraphicsWindow.BrushColor = "Gray"
GraphicsWindow.FillRectangle(P+FSB, h-25, (FSB*2), 15)
GraphicsWindow.BrushColor = "LightGray"
GraphicsWindow.FillRectangle(P+(3*FSB), h-25, FSB, 15)
EndIf
EndSub 'Fortschrittsbalken