Due: Tuesday, October 4th, by 11:59 PM

Getting Started

Download CS201_Assign3.zip and import it into your Eclipse workspace (File->Import->General->Existing projects into workspace->Archive file.)

You should see a project called CS201_Assign3 in the Package Explorer.

Right click on StartAssignment.java and choose Run As->Java Application. This program will prompt you to enter yes or no. If you enter yes, it will copy your code from Assignment 2, which you will need for this assignment.

Here is a transcript of running this program (user input in bold):

Copy files from CS201_Assign2 (yes/no)? yes
Copied src/edu/ycp/cs201/kaboom/Point.java...
Copied src/edu/ycp/cs201/kaboom/Circle.java...
Copied src/edu/ycp/cs201/kaboom/Rectangle.java...
Copied junit/edu/ycp/cs201/kaboom/PointTest.java...
Copied junit/edu/ycp/cs201/kaboom/CircleTest.java...
Copied junit/edu/ycp/cs201/kaboom/RectangleTest.java...
All files copied successfully (don't forget to refresh the project)

After running the program, right click on the project (CS201_Assign3) and choose Refresh. You should see all of the classes from the previous assignment.

Your Task

Your task is to implement a simple version of the classic video game Kaboom!.

The game consists of the following game play elements:

  • The player controls a bucket, which is at the bottom of the game play field. When the user moves the mouse, the bucket moves left and right.
  • The computer-controlled enemy is the bomber, who moves horizontally at the top of the game play field.
  • The bomber drops bombs, which fall from the top of game play field towards the bottom. If the player catches a bomb in the bucket, the bomb is defused, and the player earns 10 points. If the bomb reaches the bottom of the game play field without being caught, it explodes and the game is over.

Here is an annotated screenshot:


You can try my implementation of the game to see how it works:


On Windows or Mac, you should be able to double click on the jar file and it will run. On Linux, run the command

java -jar kaboom.jar

in the directory in which you save the jar file.

Pressing space pauses the game, and pressing enter starts a new game after the current game is finished.


You will modify two classes: Game and KaboomView.


The Game class will contain all of the game data as fields, and its methods will implement the game play logic.

Important: Keep in mind that Game is an abstract representation of the game data and logic: it has nothing to do with the GUI, and no rendering/drawing should be done in the Game class.

You will need to think about what kind of data is required to represent the game state, and add fields to store this data.

You will need to implement the timerTick method, which will be called about 60 times per second, once for each frame of animation displayed. Each call to timerTick should update the game data:

  • Moving the bomber right or left (in a "random" manner)
  • Possibly causing the bomber to drop a bomb
  • Moving all bombs down towards the bottom of the game play field
  • Moving the bucket based on location information received from the KaboomView. (You will need to think about how to communicate updates of the bucket position to the Game object.)
  • Checking to see if the bucket has caught a bomb
  • Checking to see if any bomb has reached the bottom of the game play field, in which case the game is over

Each time the player catches a bomb using the bucket, his/her score should increase by 10 points.

The bomber should be in constant motion, but (for full credit) should not move in a predictable pattern. Once the bomber is moving in a particular direction (left or right), he should continue to move in that direction for some randomly-chosen length of time between 0.5 and 2 seconds, unless he reaches the edge of the game field.

The Game class can use Rectangle objects to represent the bomber and bucket, and Circle objects to represent bombs. The overlaps method in the Rectangle class will be useful for detecting when the player has caught a bomb with the bucket.

Note that several bombs may be falling at any given time. The Game object will need to use an array or ArrayList to keep track of references to all of the bombs.


The KaboomView class is a JPanel which draws a representation of the data contained in the Game object, and handles mouse movement events.

You will probably only need to change two methods in this class:

  • handleMouseMove is called whenever the mouse is moved. Each time a mouse movement event is handled, the position of the bucket (in the Game object) should be updated.
  • paint is the paint event handler. It should draw a complete rendering of the game data, including the bucket, bomber, bombs, and the player's current score.

When the game ends, the KaboomView should display a "Game Over" message.


For a grade of up to 30/100, allow the player to control the bucket by moving the mouse left and right.

For a grade of up to 40/100, implement a bomber that moves back and forth in a predictable pattern.

For a grade of up to 50/100, allow the bomber to move "randomly" as described above.

For a grade of up to 70/100, implement bombs dropped by the bomber. Multiple bombs should be supported.

For a grade of up to 80/100, allow the bucket to catch the bombs, causing them to disappear, and increasing the player's score by 10 points.

For a grade of up to 90/100, detect when a bomb reaches the bottom of the game play field, causing the game to end and "Game Over" to be displayed.

For a grade of up to 100/100, create JUnit tests for your Game class.

I expect that you will use good coding style (comments, consistent indentation, meaningful names for variables and methods.) I may deduct points for poor coding style.

Options for additional credit

You may add any of the following features for additional credit:

  • Sound effects - up to 5 points
  • Improved graphics - up to 5 points
  • More realistic physics (e.g., accelerating bombs, bombs that don't fall straight down, etc.) - up to 5 points
  • Levels (catch a specified number of bombs, then a new level starts with increased difficulty) - up to 5 points
  • Enhanced game play features (e.g., multiple stacked buckets) - up to 5 points

Be creative, but please keep the game tasteful.

Important: If you implement any of these additional credit features, please add a comment to the top of KaboomView.java explaining which features you added.


When you are done, submit the lab to the Marmoset server using either of the methods below.

Important: after you submit, log into the submission server and verify that the correct files were uploaded. You are responsible for ensuring that you upload the correct files. I may assign a grade of 0 for an incorrectly submitted assignment.

From Eclipse

If you have the Simple Marmoset Uploader Plugin installed, select the project (CS201_Assign3) in the package explorer and then press the blue up arrow button in the toolbar. Enter your Marmoset username and password when prompted.

From a web browser

Save the project (CS201_Assign3) to a zip file by right-clicking it and choosing

Export...->Archive File

Upload the saved zip file to the Marmoset server as assign3. The server URL is