9.4.5 Trail Codehs Page
If you're interested in learning more about the 9.4.5 trail on CodeHS or want to explore additional resources, here are some suggestions:
var MAX_TRAIL_LENGTH = 20; var trail = []; // stores objects x, y 9.4.5 trail codehs
function storeMousePosition(e) // Add new position trail.push(x: e.getX(), y: e.getY()); // Remove oldest if exceeding max length if(trail.length > MAX_TRAIL_LENGTH) trail.shift(); // removes first element If you're interested in learning more about the 9
: Use a timer ( setTimer ) to call a draw function repeatedly. Inside draw , update the ball's position using ball.move(dx, dy) . var trail = []