Microsoft Small Basic

Program Listing: CFZ944
init()
'================ SHOT'S =====================
GraphicsWindow.PenColor="Red"
For angle = 30 To 60 Step 15
updateCanyon()
alpha = Math.GetRadians(angle)
xpos = ox
ypos = oy
lap= 0.1
vi = 40
gravity = 9.81
time=0
factX=3 'expansion factor X
factY=3 'expansion factor Y
While xpos <= pgW And ypos <= oy
time=time+lap
X=Vi*time * Math.Cos(alpha)
Y=Vi*time * Math.Sin(alpha) - gravity/2 * time*time
xpos = ox+(X*factX)
ypos = oy-(Y*factY)
'
Shapes.Move(ball,xpos-b_w/2,ypos-b_h/2)
GraphicsWindow.DrawEllipse(xpos-1,ypos-1,2,2)
Program.Delay(50)
EndWhile
drawDat()
Program.Delay(1000)
Endfor
'
GraphicsWindow.FontSize=40
GraphicsWindow.DrawBoundText(100,100,200,"OK !")
'============================================
'
'Sub's
'--------
Sub init
pgW = 598
pgH = 428
ox=50
oy=350
drawY=0
GraphicsWindow.Width = pgW
GraphicsWindow.Height = pgH
GraphicsWindow.Top=40
GraphicsWindow.Left=40
GraphicsWindow.CanResize="False"
GraphicsWindow.Title="ballistic shot"
GraphicsWindow.DrawLine(0,oy,pgW,oy)
GraphicsWindow.DrawLine(ox,0,ox,pgH)
'
'Tube canyon
GraphicsWindow.BrushColor="Black"
GraphicsWindow.PenColor="Black"
c_w=15
c_h=8
c_Radio=c_h/2
c_X=ox
c_Y=oy
canyon=Shapes.AddRectangle(c_w,c_h)
Shapes.Move(canyon,ox-c_w/2,oy-c_h/2)
'
'cannon ball
GraphicsWindow.BrushColor="Red"
GraphicsWindow.PenColor="Black"
GraphicsWindow.PenWidth=2
b_w=10
b_h=10
ball=Shapes.AddEllipse(b_w,b_h)
Shapes.Move(ball,ox-b_w/2,oy-b_h/2)
'
'text angle
GraphicsWindow.DrawText(ox-45,oy+10,"Angle")
texAngle=Shapes.AddText("0º")
Shapes.Move(texAngle,ox-35,oy+25)
'
GraphicsWindow.BrushColor="Black"
EndSub
'
Sub updateCanyon
angleCanyon=-angle
Shapes.Rotate(canyon,angleCanyon)
Shapes.SetText(texAngle,(angle)+"º")
EndSub
'
Sub drawDat
xMax=((Vi*Vi)/gravity)*(Math.Sin(alpha*2))
yMax=(Vi*Vi*Math.Sin(alpha)*Math.Sin(alpha))/(gravity*2)
drawY=drawY+20
text1="angle: "+angle+" Vi: "+Vi+" Xmax: "+0.01*(Math.Round(100*xMax))+" Ymax: "+0.01*(Math.Round(100*yMax))
GraphicsWindow.DrawBoundText(50,drawY,300, text1)
Shapes.Move(ball,ox-b_w/2,oy-b_h/2)
EndSub