Microsoft Small Basic

Program Listing: GQJ530
'Krueg Trigonometry Lesson
GraphicsWindow.Width = 800
GraphicsWindow.Height = 600
GraphicsWindow.Top = 5
GraphicsWindow.Left = 5
GraphicsWindow.BackgroundColor = "Black"
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.PenColor = "White"
cross = Shapes.AddEllipse(26,26)
cross1 = Shapes.AddLine(10,13,16,13)
cross2 = Shapes.AddLine(13,10,13,16)
gun = Shapes.AddRectangle(3,35)
gx = 400 'Gun X-position
gy = 510 'Gun Y-position

Mouse.HideCursor()
GraphicsWindow.MouseMove = target

Sub target
tx = GraphicsWindow.MouseX 'Target X-position
ty = GraphicsWindow.MouseY 'Target Y-position
Shapes.Move(cross ,tx-13,ty-13)
Shapes.Move(cross1,tx-13,ty-13)
Shapes.Move(cross2,tx-13,ty-13)
ga = Math.GetDegrees(Math.ArcTan((gx-tx)/(gy-ty)))
Shapes.Rotate(gun,-ga)
Shapes.Move(gun,gx,gy)
EndSub