Lighthouse Animation Challenge

lighthouseThe purpose of this challenge is to use a Python program to demonstrate how frame-based animations can be implemented.

For this challenge we are using the Processing.py library.

The code below will run the setup() procedure once, when the program starts. Then the animateLighthouse() procedure will be called 20 times per second (based on the frame rate), indefinitely.

This code makes use of two transformations:

  • A translation: 2D translations are often used to re-position or animate objects on screen (gliding effect)
  • A rotation: in this case, a rotation is applied to animate the light beam. The angle of rotation increments by 0.5 degrees between each frame.

lighthouse-translation-rotation

Python Code


Your Challenge


Complete this code to animate the boat:

  • The boat should translate/glide horizontally from left to right.
  • Once the boat fully disappears to the right of the screen, it should reappear to the left.

lighthouse-translation

Share Button
Tagged with: