Due Date
-
All work must be submitted by 7:50am on Tuesday, Mar 16.
Submit the programming work online to
http://culearn.colorado.edu. No late work is accepted, so submit
what you have before the due date!
Note: As mentioned in an e-mail, we
will allow one late submission by e-mail for each student,
provided that the student sends the work as soon as possible after the
deadline. Please don't ask for a second late submission, as we will
have to say no.
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.
Programming Style
-
As always, all your work must follow these ten essential style
items. See snowmen.cxx for examples of
this style. Also see
www.cs.colorado.edu/~main/style.html.
Note: We are relaxing the rule for spacing in arithmetic
expressions. Please write the expressions in the way that seems
uncrowded and most readable to you.
The Assignment
-
This is a further modification of the ship in Homework 6 with the
primary goal of allowing the user to interact more fully with the
program. Overall, your new submission (called pilot.cxx) must make
these additions to the program:
- Change the background to a more interesting image. You may
download and use the Hubble Deep-Space Image
or you may create your own background image. The first time that the
background is drawn, you should save it in a stored image buffer (as
shown in lunar lander
program. Later, when the background is redrawn, you should read the
stored image rather than re-reading the file.
The program must still draw the three stars, but you may
delete the vector field if you wish. (Whether or not you draw the
vector field, you must still use the system_ax and system_ay
accelerations affect the ship's velocity at all times.)
-
Draw a more interesting ship than a red ellipse. You must use at least
two fillpoly calls (similar to the latest lunar lander, but don't just
copy that design!)
-
Add these controls to the program:
- The + key makes the program run faster.
- The - key makes the program run slower.
- The left and right arrow keys cause leftward or rightward acceleration
of the ship (think of a thruster being turned on). Repeatedly pressing
the left key will cause more leftward acceleration, and similarly for the
left key. The program should draw a flame to the left when there is a
net rightward acceleration, and a flame to the right when there is a
net leftward acceleration (like the lunar lander). The length of the
flame must be proportional to the amount of acceleration.
- Same thing for the up and down arrows! Unlike the lunar lander,
you should permit a net downward acceleration.
- Clicking the left mouse button causes the ship to immediately jump
to the position where you clicked. (Note: In order to implement this,
you'll need a pixel-to-world coordinate conversion function.)
- Clicking the right mouse button causes the ships current velocity
to immediately change so that it is moving toward the mouse. The
magnitude of this velocity is proportional to the distance between the
mouse and the ship. So, if the mouse is far from the ship, you'll
get a bigger velocity than if it is close.
- Do not end the program when the ship leaves the screen. Keep it running!