This code uses a heading (an angle to slither towards), the sin()
function (which generates values that alternate from -1
to 1
to move the heading left and right), and the randomGaussian()
function (which generates random numbers centered around 0
to add some randomness to the movement) to create a point that loops around like a worm.
This is a companion discussion topic for the original entry at https://happycoding.io/examples/processing/animation/worms