MCPcopy Create free account
hub / github.com/aosabook/500lines / _moveForward

Function _moveForward

blockcode/code/turtle.js:76–89  ·  view source on GitHub ↗
(distance)

Source from the content-addressed store, hash-verified

74
75
76 function _moveForward(distance){
77 var start = position;
78 position = {
79 x: cos(direction) * distance * PIXEL_RATIO + start.x,
80 y: -sin(direction) * distance * PIXEL_RATIO + start.y
81 };
82 if (pen){
83 ctx.lineStyle = color;
84 ctx.beginPath();
85 ctx.moveTo(start.x, start.y);
86 ctx.lineTo(position.x, position.y);
87 ctx.stroke();
88 }
89 }
90
91 function penUp(){ pen = false; }
92 function penDown(){ pen = true; }

Callers 4

drawTurtleFunction · 0.85
drawCircleFunction · 0.85
forwardFunction · 0.85
backFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected