Eclipse homework from 2017
We continue with the last class.
Write a simple animation of a solar eclipse.
Use a wide window, say 1000×200.
The two objects in your animation, sun and moon, will move from left
to right at slightly different speeds. The background of your
window represents the sky.
The moon should be a tiny bit bigger than the sun but move a little faster.
The sun gets a head start, but the moon should be directly in
front of the sun when both are at the center of the windows.
Of course, the background get darker as the moon blocks more of the sun.
If you want to see a real formula for determining how
much darker, look at
Wolfram Mathworld’s
formula for
Circle-Circle Intersection.
By the way, I could never get it to work.
Some works in progress
These will be made readables as the class continues.
-
Phase 0 —
You should already be there.
-
Phase 1 —
Adding a Moon.
-
Phase 2 —
Get the Sun and Moon to meet in the middle.
-
Phase fade
—
See if you can get the sky to darken when the Moon blocks
the sun.
We will need to talk about this.
ofloat sunVisibility(float sunD, float moonD, float distance)
Doing more and more
Work on some of these.
-
Draw a ball that bounces around a box. Assume there is no friction.
-
Animate a ball that bounces straight up-and-down,
but assume gravity exists! (However, still no air friction.)
-
Make a lame game. Every time the mouse is pressed on the ball,
it changes color. I suggest using the HSB color model.