Lab 7

Manipulating Drawing Objects

First download the files shown at the bottom of this page, and create a project in Eclipse with them.  One quick way to do this is to copy these files into some particular directory that you create.  Then within Eclipse make a new project, but rather than accept the default directory, select the directory you just created.  Presto, you've got your files in an Eclipse project, without having to copy and paste them individually into classes you had to individually create.

0. Draw a single Square on the middle left of the screen.

Use one of the 4 Square objects already declared (Square s0,s1,s2,s3;)  

Pressing the 'w' and 's' keys should move this Square up and down. If it is not already there, write this code in the handleKeyPress() method of the Board.java class to do this. In other words, if 'w' is pressed you want to do something like:

     s0.slowMoveVertical( -10);

1. Similarly draw a Square on the middle right of the screen. Pressing the 'i' and 'k' keys should move this up and down.

2. Add a smaller square just inside each of the above two squares (so each larger square will have inside of it a smaller square, for a total of 4 squares on the screen). It should also move together with the larger square.

3. Add the ability to "shoot" the smaller square across the board, when the 'a' key is pressed for the left player, and when the 'l' key is pressed for the right player.

4. Add the code to "block" the opponents small square coming towards your side, add score (implement on the iPhone/Android, become rich).

Note that your program will only handle a single key press event at a time, so you can't really move the two squares simultaneously.

When done, zip together your files and submit your single, zipped file on Blackboard, one file per team (only 1 person should submit, but make sure to put both (or all 3 of) your names in the comments at the top of each of your files).  Note that you have until 11 AM on Thursday to submit.

To zip files first find out exactly where your files are being stored in your workspace.  If you aren't sure, right click on one of your class files within Eclipse and choose properties and pay attention to the path name.  Then use your file browser (Command-shift-O) to find that directory.  Use command-click to select the multiple .java files, then right-click and select Compress Items.  The resulting file Archive.zip is what you should then turn in to Blackboard.