If you've ever stared out the window of a fast-moving vehicle on a road trip, you've probably experienced the effect of motion parallax.
While staring out the window as the car moves, objects closer to the vehicle, such as a bush near the edge of the road, appear to zoom by your field of vision.
However, objects farther away, such as a distant mountain range, appear to move across your field of vision rather slowly.
Why does this happen?
This effect is know as parallax.
Motion Parallax is a programming assignment (PA) in which students create a scene that emulates the effect of motion parallax. The task is to write a program that draws a landscape scene on a canvas. As the mouse is moves across the canvas, the perspective of the scene should change using parallax principles.
A solution to this PA would utilize math, loops, random, functions, parameters, and graphics.
||The audience for this PA is CS 1, but it could probably also be used for CS 0.|
If given in CS 0, medium - hard.
If given in CS 1, medium.
My solution to this PA depends on a graphics module (
This PA could be modified so that students draw something other than just a landscape.
For example, students could be required to draw a cityscape, seascape, or replicate the scene from a famous painting.
The instructor could also give students the freedom to come up with a scene of their choice, so long as they fit within the instructors requirements.
Even when sticking with a particular scene (such as the landscape show in the provided spec), students can be given room to add custom elements to the scenes that they draw.
The writeup of the PA specification is available here.
This PA was given in CSc 110 at the University of Arizona. Python is the language used in this class. For the graphical component, students were supposed to use the graphics.py module, which is a library that I wrote, and this module uses TKinter. If the course you'd like to use this PA for is python-based, you are welcome to use graphics.py. You could also have students use TKinter directly. This could still be used as a PA for a course that uses a different language, just determine which library you'd like your students to use.
In CSc 110, students are supposed to follow the code style guidelines. You may reference this also, if you'd like.