Microsoft Small Basic

Program Listing: XGG295
false = 0
true = 1
R = 100
O = 20
DT = 5
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"
Init()
Play = true
While Play = true

Program.Delay(DT)
ShowTelescopicSight()
ShowClayPigeon()
Collision()
EndWhile
Points = Hit * 10
If Shot < CounterCP Then
If Hit > 0 Then
Points = Points + CounterCP - Shot
EndIf
EndIf
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.FontSize = 50
GraphicsWindow.DrawText(200,gh/2,"Points: "+Points)
Sub Init
MouseClick = false
playerVx = 0
playerVy = 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*0.75
yy4 = R*0.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)
'InitExplosion
For i = 1 to 4
GraphicsWindow.BrushColor = "SaddleBrown"
GraphicsWindow.PenColor = "SaddleBrown"
temp = Shapes.AddEllipse(5, 7)
' Move it immediately off screen so it isn't ever seen
Shapes.Move(temp, 0, -50)
' Save in array
Array.SetValue("explosion", i, temp)
endfor
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
RD1 = Math.GetRandomNumber(150)
If RD1 < 145 Then
CP = 0
Else
RD = Math.GetRandomNumber(100)+50
CounterCP = CounterCP + 1
If CounterCP = 11 Then
CP = false
Play = false
Else
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillRectangle(1,20,120,19)
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.DrawText(1,20,"Clay pigeon: "+CounterCP)
CP = 1
SShot = 0
SS = 1
ZX = 0
ZY = gh
ZXX = Math.GetRandomNumber(10)+4
ZS = ((Math.GetRandomNumber(10)+RD*4)/10000)
Shapes.ShowShape(L4)
DoIt()
EndIf
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
If MouseClick = 1 Then
If SShot < 3 Then
Sound.PlayClick()
If X1+R >= ZX And X1 <= ZX+yy4 And Y1+R >= ZY And Y1 <= ZY+yy4 Then
CP = 0
Shapes.HideShape(L4)
Hit = Hit + 1
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillRectangle(1,1,120,19)
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.DrawText(1,1,"Hits: "+Hit)
exploding = true
explosionX = ZX
explosionY = ZY
While exploding = true
Explosion()
EndWhile
EndIf
Shot = Shot + 1
SShot = SShot + 1
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillRectangle(1,40,120,19)
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.DrawText(1,40,"Shots: "+Shot)
MouseClick = 0
EndIf
Else
If X1+R >= ZX And X1 <= ZX+yy4 And Y1+R >= ZY And Y1 <= ZY+yy4 Then
Shapes.Zoom(L4, SS*1.5, SS*1.5)
EndIf
EndIf
EndSub 'Collision

Sub Explosion
If exploding = true then
' Move along with ground
explosionSize = explosionSize + 2
If explosionSize > 70 then
exploding = false
explosionSize = 0
' Move parts off screen
Shapes.HideShape(Array.GetValue("explosion", 1))
Shapes.HideShape(Array.GetValue("explosion", 2))
Shapes.HideShape(Array.GetValue("explosion", 3))
Shapes.HideShape(Array.GetValue("explosion", 4))
else
' Move all pieces of explosion in four directions
Shapes.ShowShape(Array.GetValue("explosion", 1))
Shapes.ShowShape(Array.GetValue("explosion", 2))
Shapes.ShowShape(Array.GetValue("explosion", 3))
Shapes.ShowShape(Array.GetValue("explosion", 4))
temp = Array.GetValue("explosion", 1)
Shapes.Move(temp, explosionX + explosionSize, explosionY + explosionSize)
temp = Array.GetValue("explosion", 2)
Shapes.Move(temp, explosionX + explosionSize, explosionY - explosionSize)
temp = Array.GetValue("explosion", 3)
Shapes.Move(temp, explosionX - explosionSize, explosionY + explosionSize)
temp = Array.GetValue("explosion", 4)
Shapes.Move(temp, explosionX - explosionSize, explosionY - explosionSize)
Program.Delay(DT)
endif
endif
EndSub 'Explosion

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

Sub OnMouseClick
MouseClick = 1
EndSub 'OnMouseClick