Explore what CodeHS has to offer for districts, schools, and teachers.
Click on one of our programs below to get started coding in the sandbox!
View All
What does this program do?
let ball; function main() { ball = new Circle(40); ball.setPosition(getWidth() / 2, 0) add(ball) setTimer(draw, 20); } function draw() { ball.move(0, 2); } main();
Animates a ball by moving it down the middle of the canvas every 20 milliseconds
Animates a ball by moving it up the middle of the canvas every 20 milliseconds
Animates a ball by moving it to the right from the middle of the canvas every 20 milliseconds
Animates a ball by moving it to the left from the middle of the canvas every 20 milliseconds