
One good way of making an animation is by simulating a physical system and illustrating the variables in that system using a dynamically changing graphical display.

The classic such physical system is a simple gravity pendulum.



Task

Create a simple physical model of a pendulum and animate it.




make "angle 45
make "L 1
make "bob 10
 
to draw.pendulum
  clearscreen
  seth :angle+180		; down on screen is 180
  forward :L*100-:bob
  penup
  forward :bob
  pendown
  arc 360 :bob
end
 
make "G   9.80665
make "dt  1/30
make "acc 0
make "vel 0
 
to step.pendulum
  make "acc  -:G / :L * sin :angle
  make "vel   :vel   + :acc * :dt
  make "angle :angle + :vel * :dt
  wait :dt*60
  draw.pendulum
end
 
hideturtle
until [key?] [step.pendulum]