CMPS 160 -- Programming Assignment 1 (warmup)
Due date:
9am, Friday, 10/2/09
Objectives:
This assignment covers the following components:
(i) opening a graphics window,
(ii) basic 2D graphics, and
(iii) simple keyboard interface.
Implement the following in stages:
-
About 10% of functionality:
Open a graphics window of a desired size
and place a red dot at the center.
You probably want to use glVertex2f for the point,
and glColor3f for setting the color.
-
About 60% of functionality:
Next, you want the point to behave like a
projectile.
Use a random number generator and assign it
an initial velocity (specified by an x-component and a y-component)
and direction (specified by an angle, theta, measured counterclockwise
from an easterly direction).
Note, both 0 and 360 degrees point east.
Draw the path of the projectile until it falls out of the window!
-
About 15% of functionality:
Keep shooting more projectiles (each time the user hits the space bar)
from the center of your window. Use a new set of initial velocity and
angle for each projectile.
You can leave the trajectories of previous projectiles.
After enough projectile trajectories are generated,
you should get something like a firework.
-
About 15% of functionality:
Modify the coloring scheme so that the particles change color
over time according to the magnitude of their velocity.
Resource:
The wikipedia page on
trajectory of a projectile provides the equations needed to
calculate the position of the projectile over time.
Note: (x0, y0) is the coodinate at the center of your window,
g is the gravitational constant (9.8 m/s^2),
and t is time.
-
The position of a projectile along its trajectory can be
determined by:
-
x = x0 + t Vx
-
-
The velocity of a projectile along its trajectory can be
determined by:
-
x-component of velocity is constant, so:
Vx = whatever random number generator provided
-
y-component of velocity is affected by gravity and
hence changes over time as follows:
Grading:
This program nominally accounts for 6% of your final grade. We must
be able to compile/test your code. Make sure that the code and accompanying
make/project files, etc. are tested for successful compilation at least on
the PCs in the lab.
Also be sure to include the executable and a README file
in your submission as to which platform to use.
Programs turned in at least a full day early will earn 1% bonus credit. Late
programs will be charged 1% late points. In addition, late programs will not
be accepted 24 hours past due date. Late programs and reports will not be
accepted for the final project. The bonus credits may be accumulated up to a
total of 50% toward program and final project credits. Programs are graded 80%
for functionality and correctness and 20% for style, readability,
documentation/writeup, and efficiency. Additional points may also be earned
for extra features.
Submission:
Submission must be done using the "submit" command from CATS.
- submit cmps160-ap.f09 prog1 prog1.tar, or
- submit cmps160-ap.f09 prog1 prog1.zip
This command should work from unix.ic.ucsc.edu.
Create and submit a subdirectory called prog1.
It should contain the executable and
all the files you have to make your program compile/run.
Tar or zip up prog1 before submitting.
Last modified
Saturday, 03-Oct-2009 14:03:43 PDT.