Microsoft Small Basic

Program Listing: HKG657
GraphicsWindow.Top = 0
GraphicsWindow.Left = 0
FSH = 768 'max Height
FSW = 1366 'max Width
gh = FSH - 75
gw = FSW - 173
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.BackgroundColor = "LightBlue"
GraphicsWindow.Show()
GraphicsWindow.MouseMove = OnMouseMove
GraphicsWindow.MouseUp = OnMouseClick
Mouse.HideCursor()
GraphicsWindow.BrushColor = "Black"
R = 100
O = 20
Init()
While ("True")
If MouseClick = 1 Then
MouseClick = 0
Collision()
Else
Program.Delay(10)
ShowTelescopicSight()
ShowClayPigeon()
EndIf
EndWhile

Sub Init
MouseClick = 0
x1 = 0
y1 = 0
xx1 = R
yy1 = 0
L1 = Shapes.AddLine(x1,y1,xx1,yy1)
Shapes.SetOpacity(L1, O)
Shapes.ShowShape(L1)
x2 = 0
y2 = 0
xx2 = 0
yy2 = R
L2 = Shapes.AddLine(x2,y2,xx2 ,yy2)
Shapes.SetOpacity(L2, O)
Shapes.ShowShape(L2)
x3 = 0
y3 = 0
xx3 = R
yy3 = R
L3 = Shapes.AddEllipse(xx3 ,yy3)
Shapes.SetOpacity(L3, O)
Shapes.ShowShape(L3)
GraphicsWindow.BrushColor = "SaddleBrown"
GraphicsWindow.PenColor = "SaddleBrown"
xx4 = R/2*1.5
yy4 = R/4*1.5
L4 = Shapes.AddEllipse(xx4 ,yy4)
GraphicsWindow.PenColor = "LightGreen"
GraphicsWindow.BrushColor = "LightGreen"
GraphicsWindow.FillRectangle(0,(gh/2),gw,gh)
CP = 0
ZX = 0
ZY = gh
Shapes.Move(L4,ZX,ZY)
Shapes.HideShape(L4)
EndSub 'Init

Sub ShowTelescopicSight
Shapes.Move(L1,x1,y1+(R/2))
Shapes.Move(L2,x1+(R/2),y1)
Shapes.Move(L3,x1,y1)
EndSub 'ShowTelescopicSight

Sub ShowClayPigeon
If (CP = 1) Then
DoIt()
Else
RD = Math.GetRandomNumber(150)
If RD < 50 Then
CP = 0
Else
CounterCP = CounterCP + 1
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillRectangle(1,20,120,19)
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.DrawText(1,20,"Clay pigeon: "+CounterCP)
CP = 1
SS = 1
ZX = 0
ZY = gh
ZXX = 10
ZS = ((Math.GetRandomNumber(10)+RD*4)/10000)
Shapes.ShowShape(L4)
DoIt()
EndIf
EndIf
EndSub 'ShowClayPigeon

Sub DoIt
ZX = ZX + ZXX
If (ZX > gw) or (ZY > gh) Then
CP = 0
Shapes.HideShape(L4)
EndIf
ZY = ZY - (RD/10)
If (ZY < (RD * 2)) Then
RD = (RD * -1)
EndIf
Program.Delay(10)
Shapes.Move(L4,ZX,ZY)
SS = SS - ZS
ZS = ZS/1.15
Shapes.Zoom(L4, SS, SS)
EndSub ' DoIt

Sub Collision
' x1 + x2 and ZX + ZY
If X1+R >= ZX And X1 <= ZX+yy4 And Y1+R >= ZY And Y1 <= ZY+yy4 Then
Hit = Hit + 1
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillRectangle(1,1,120,19)
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.DrawText(1,1,"Hits: "+Hit)
CP = 0
EndIf
Shot = Shot + 1
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillRectangle(1,40,120,19)
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.DrawText(1,40,"Shots: "+Shot)
EndSub 'Collision

Sub OnMouseMove
x1 = Mouse.MouseX - R
y1 = Mouse.MouseY - R
EndSub 'OnMouseMove

Sub OnMouseClick
Sound.PlayClick()
MouseClick = 1
EndSub 'OnMouseClick