CS 010 - Introduction to Computer Science I
Assignment 5:

DUE: May 13th before 2:00pm


Collaboration Policy

Limited collaboration is OK. You may do the following while writing a programming assignment: discuss general solution ideas with your study group members or have members observe a run of your program, and offer their ideas on its behavior. You should *never* look at someone else's code for the assignment to figure out how to do your own program. It is very hard to write your own unique solution once you have seen someone else's. If you need someone to look at your code to give advice, you should see your TA or instructor. Of course, copying code from ANY source (any book, current or past student, past solutions, or the web) is STRICTLY FORBIDDEN.


Code that is turned in, must be contained in a .cpp file named main.cpp. Files of any other format will not be graded (e.g. main.doc, main.txt, etc…).

You must turn your work in from a lab computer on campus.

Turn in online to as5 folder. If you turn your assignment in to the wrong folder, your assignment may not be graded. If it is graded, you will lose 20 pts (out of 100).

If your program does not compile, you will receive a 0 out of 100!

Programs that do not have the readme file turned in with the main.cpp file will not be graded.

Remember to include the following header information at the top of your program, failure to do so will result in lose of points.

// Course: CS 10
//
// Lecture Section: ... 001 or 002
// Lab Section: ... 021, 022, etc)
//
// Assignment #: ... assignment 2, 3, etc.
//
// Last Name: Enter your LAST (family) name here (eg, Doe)
// First Name: Enter your FIRST (given) name here (eg, John)
//
// ID Number: Enter your ID number here (eg, 860-00-0000)
// lab login id: Enter your cs10 login here (eg, jdoe)
//
// Email address: Enter your UCR email address here (eg, jdoe@cs.ucr.edu)
//

// =======================================================================



Problem Definition:

    For this assignment you will write a program that does some simple animation. A space ship will initially be drawn on the left side of the window, and then appear to *slide* to the right at a constant speed. Once the ship moves outside of the window, you will print the message "goodbye!" to the middle of the window.
    To draw the ship, you are required to use a function. The function will be passed a Point that represents the bottom center of the ship. The other points used to draw the lines for your ship, should be relative to this point's position. The function should return void.
    When the ship moves from left to right, it should do so slowly enough that it can be seen. A simple while loop that moves the ship EVERY iteration would move the ship across the screen so fast that the movement wouldn't be visiable. So, you'll need to figure out how to manage the speed of the animation inside the loop. Also the amount the ship moves each time it is redrawn needs to be picked carefully, a large value will result in *jerky/flickery* motion. You are not allowed to simply move the ship a very small amount each time to get the ship to move slowly.  For example, moving the ship 0.0000001 units each loop iteration.  If you do this, you will get 0 out of 30 points for the rubric item that requires you to make the movement smooth.

Hint:
Figure out a way to not draw the ship EVERY iteration, but every Nth iteration of a loop (you need to find a good value for N). Using another control structure within the main while loop could achieve this.

Example program download
main

The above link is attached to an executable version of the program. Below are instructions to downlaod the program. Note that this will only work on the lab computers, or computers running linux, so it probably won't work if you try to download it from home on a Windows machine.

1) Right click the blue link above, and then select "Save Link Target As..." by left clicking.

2) A message box will open asking you where you want to save the file. Choose from the list of folders by double clicking on the folder that you want to save the game in. If you want to save it in your home directory, you can just left click "save".

3) Now cd into the directory that you saved the game. On the command line type the following command:
chmod u+x main

You will only need to do this once (the first time). You can close the other message box that opens (the one that says Download Manager).

4) From now on, to run the program, you can just type "main" from the command line.


Rubric: (100 pts total)

30 pt(s): Function is used to draw ship from ccc_win_main(), is passed a Point, and returns void.
10 pt(s): Point passed to function is the bottom center of ship drawing, and ship is non-trivial to draw (not just a box or circle!).
30 pt(s): Ship movement is not jerky/flickery, takes at least 3 seconds, and at most 10 seconds to cross window.
20 pt(s): Program prints "GoodBye!" at the moment the ship is no longer visiable.
10 pt(s): Style
- comments
- line wraps
- header info included at top
- spacing
- Indentation
- Good constant/variable names
- No magic numbers

You can also receive penalties for this assignment (see the top of this page), some of which include your program not being graded, or receiving an automatic zero.

Fill out the following form, and turn it in with your program:
readme.txt

Note that you will lose points for style on this assignment!
For coding style requirements see the following link:
http://www.cs.ucr.edu/cs10/cs10_05win/requirements/coding_std.html