CSCI 1300
Introduction to Computer Science
Homework 2: The Moving of a Star

Due Date

The due date is 10pm on Friday, Sep 16. Submit the programming work online as described in the to submission directions.

Working Alone

You may talk with other students and instructors about the assignments, but you may not look at or copy code written by others. The penalty for violating this code is an F for the entire semester.

The Assignment

This assignment again opens a graphics window and draws the constellation from the previous assignment (two triangles per star). There are no delays in this drawing, so all the stars will seem to appear at once.

Then all the stars start rotating in a clockwise direction at a rate of 0.04 radians at every 1/30th of a second, and they start dropping down the screen at a rate of 1 pixel at every 1/30th of a second.

The technique that we'll use is called an animation loop with double-buffering. It is not a difficult technique (you will learn it in 50 minutes on Sep 2), but it is not in the textbook, so you must come to lecture!

Program Requirements

Come to lecture. You'll be able to start the work right after we cover animation loops!

  1. Your program must be called movement.cxx. You must submit this file and no other.

  2. The program must correctly spin and drop the stars.

  3. The program must use double-buffering.

  4. The program must end when the topmost star reaches the approximate bottom of the screen.

  5. The main program must have a single animation loop with double-buffering as described in lecture. The last thing in the loop is a 1/30th delay (so you are drawing 30 frames per second). The overall steps in the loop are in this order:
    1. Compute values that are needed for variables such as shift and tilt (and a time value, t, if you wish).
    2. Clear the screen and draw the next frame of the animation.
    3. Swap buffers and delay for 1/30th of a second.

  6. The job of drawing the entire constellation must be done by a function with two parameters called tilt (or some other name if you prefer) and shift. The value of tilt is the total rotation (in radians) that the stars have spun so far from their starting position. The value of shift is the total amount (in pixels) that the stars have dropped so far from their starting position.

  7. The function to draw the constellation must make two calls to your draw_triangle function (from last week's assignment) for each star—and it no longer has any delays.