RosettaCodeData/Task/Animate-a-pendulum/FreeBASIC/animate-a-pendulum.basic

23 lines
476 B
Plaintext

Const PI = 3.141592920
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 17 '640x400 graphic
Do
bx=px+l*300*Sin(theta)
by=py-l*300*Cos(theta)
Cls
Line (px,py)-(bx,by)
Circle (bx,by),5,,,,,F
accel=g*Sin(theta)/l/100
speed=speed+accel/100
theta=theta+speed
Draw String (0,370), "Pendulum"
Draw String (0,385), "Press any key to quit"
Sleep 10
Loop Until Inkey()<>""