Microsoft Small Basic

Program Listing: ZSP744-0
pivotX = GraphicsWindow.Width /2

armLength = GraphicsWindow.Height - 30
angle = 7.5/12 * 360 ' at rest at 7:30 o'clock
gravity = 9.8 * 4
friction = (100 - 0.02) / 100

arm = Shapes.AddRectangle(armLength*2 2)
bob = Shapes.AddEllipse(60 60)
Shapes.Move(arm pivotX-armLength 0)

pivot = Shapes.AddEllipse(10 10)
Shapes.Move(pivot pivotX-5, -5)

While 0=0
angularAcceleration = (gravity * Math.Sin(Math.GetRadians(angle))) / armLength
angularVelocity = (angularVelocity + angularAcceleration) * friction
angle = angle + angularVelocity

X = armLength * Math.Sin(Math.GetRadians(angle)) + pivotX
Y = -armLength * Math.Cos(Math.GetRadians(angle))

Shapes.Move(bob X-30 Y-30)
Shapes.Rotate(arm angle+90)

Program.Delay(15)
EndWhile