CS
010 - Introduction to Computer Science I
Assignment 3:
DUE: Monday, 8/9 before 11:00pm
Collaboration is strongly ENCOURAGED. You will be working in teams, but programs must represent YOUR OWN original work. Teams should work on the algorithm together and help debug/test each others code. However, copying code from ANY source (any book, current or past students, past solutions, the web, etc.) is STRICTLY FORBIDDEN. Code between teamates will be similar, but you are not allowed to just copy a teamate's solution.
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 as3 folder. If you turn your assignment in to the wrong folder, your assignment may not be graded. If it is graded, you will lose 2 pts (out of 10).
Remember to include the following header
information at the top of your program;
// last
name, first name
// last 4 digits of SID
// UCR email address
// user name (log in name)
For this assignment you will write a program that draws a ship, and allows the user to move the ship around in the window using keyboard input. The user should be able to move the ship around as long as they want to, but if they move the ship outside of the window, the program should print a message to the screen indicating that the ship has left the window, and wait for the window to be closed.
Before each ship
move, a message will prompt the user to enter either u, d, l, or r
(each corresponding to up, down, left or right respectively). The
window must then be cleared, and the ship redrawn in its new position.
The ship that is
drawn should be the one that you made for assignment 2.
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.
From this point on, any programs turned in that do not compile will receive an automatic zero, no exceptions.
2 pts: Allows user to move the ship around as long as it's inside the window
2 pts: Moves the correct direction based on user's input
2 pts: Clears window and displays message to indicate that the ship moved outside the window
2 pt: Header info (provide correct info specified above)
2 pts: Style (0.5 each)
- Good variable names
- Proper indentation
- Good comments
- No line wraps
Bonus +1 point
Read ahead and figure out how to create a void function. Use
this function to draw your ship when needed. The function must have
both a function decleration, and definition, and specifically must have
the following decleration or you will not receive the extra credit.
//decleration
void draw_ship();
So any time the function call "draw_ship();" is
encountered in the ccc_win_main funtion, it will draw the ship in the
window at the current (x,y) position.