Pendulum

Charlie Veniot 15th December 2022 at 1:04am
' Based on https://rosettacode.org/wiki/Animate_a_pendulum#FreeBASIC
' BASIC Anywhere Machine version by Charlie Veniot

Dim As Double theta, g, l, accel, speed, px, py, bx, by
theta = _PI/2
g = 9.81
l = 1
speed = 0
px = 320
py = 10
Screen _newimage(640,340, 12 )
Do
    bx=px+l*300*Sin(theta)
    by=py-l*300*Cos(theta)
    Cls
    Circle (bx,by),15, 14, , , ,F
    Line (px,py)-(bx,by),14
	 if by < 10 then sound 40,3
    accel=g*Sin(theta)/l/100
    speed=speed+accel/100
    theta=theta+speed
    Sleep 0.0625
Loop