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

unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 9

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: