RosettaCodeData/Task/Animate-a-pendulum/Commodore-BASIC/animate-a-pendulum-1.basic
2026-04-30 12:34:36 -04:00

24 lines
579 B
Text

10 gosub 1000
20 theta=π/2
30 g=9.81
40 l=0.5
50 speed=0
60 px=20
70 py=1
80 bx=px+l*20*sin(theta)
90 by=py-l*20*cos(theta)
100 print chr$(147);
110 for x=px to bx step (bx-px)/10
120 y=py+(x-px)*(by-py)/(bx-px)
130 print chr$(19);left$(x$,x);left$(y$,y);"."
140 next
150 print chr$(19);left$(x$,bx);left$(y$,by);chr$(113)
160 accel=g*sin(theta)/l/50
170 speed=speed+accel/10
180 theta=theta+speed
190 goto 80
980 rem ** setup strings to be used **
990 rem ** for cursor positioning **
1000 for i=0 to 39:x$=x$+chr$(29):next
1010 for i=0 to 24:y$=y$+chr$(17):next
1020 return