Sine Wave
Log in to post a comment.
// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);
// Global code will be evaluated once.
const turtle = new Turtle();
turtle.penup();
turtle.goto(-110,0);
turtle.pendown();
var x = -110;
var y = 0;
var randomOffset = 0;
angle = 90;
// The walk function will be called until it returns false.
function walk(i)
{
x++;
randomOffset = Math.random() * (Math.abs(-y * 0.3));
y = Math.cos(x /10) * 25 + randomOffset;
turtle.setx(x)
turtle.sety(y);
return i < 250;
}