Microsoft Small Basic

Program Listing:
Embed this in your website
GraphicsWindow.Show()
fps=50
pgW = 598
pgH = 428
ox=50
oy=350
angle=0
'
init()
'
For ang = 30 To 60 Step 15
  angle=ang
  Shapes.Rotate(canyon,angle)
  Shapes.SetText(texAngle,(90-angle)+"º")
  angleShot=90-angle
  alpha=angleShot*(Math.Pi/180)
  Vi=14 'm/seg
  lap=0.1
  time=0
  xpos=Shapes.GetLeft(ball)
  ypos=Shapes.GetTop(ball)
  gravity=9.8
  While "True"
    time=time+lap
    X=Vi*Math.Cos(alpha)*time
    Y=Vi*Math.Sin(alpha)*time-(gravity*(time*time))/2
    xpos=xpos+X
    ypos=ypos-Y
    Shapes.Move(ball,xpos,ypos)
    GraphicsWindow.PenColor="Red"
    GraphicsWindow.DrawEllipse(xpos+b_w/2,ypos+b_h/2,2,2)
    Program.Delay(200)
    If xpos > pgW Or ypos > oy Then
      Goto EXIT
    EndIf
  EndWhile
  EXIT:
  xMax=((Vi*Vi)/gravity)*(Math.Sin(alpha*2))
  yMax=(Vi*Vi*Math.Sin(alpha)*Math.Sin(alpha))/(gravity*2)
  drawY=drawY+20
  text1="angle: "+angleShot+" 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)
  Program.Delay(1000)
EndFor
'
GraphicsWindow.FontSize=40
GraphicsWindow.DrawBoundText(100,100,200,"why?")

Sub init
  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=8
  c_h=15
  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)
  Shapes.Rotate(canyon,angle)
  '
  '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(angle+"º")
  Shapes.Move(texAngle,ox-35,oy+25)
  '
  GraphicsWindow.BrushColor="Black"
  '
EndSub
Copyright (c) Microsoft Corporation. All rights reserved.