Lesson goal: Computer animation with functions and for-loops

Previous: Animate a single pixel | Home | Next: Animate with laws of physics

Functions, and their ability to run small chunks of code over and over again, are really useful to animate something more complicated than a single pixel. Why? Because we can use the function to draw a more complicated shape (like a person or car), then just use the function in a for-loop during the repeated drawing and erasing.

Now you try. Try fixing the for and color statements to make a pixel move.

Type your code here:

See your results here: