CompSci 6 Spring 2010: Assignment 6

Due: Thursday, March 18 - 11:59pm

30 points

Breakout

Breakout is a popular extension to the game of Pong that was described at the time of its invention as "the ultimate in Pong". Breakout was designed by Steve Jobs, current CEO of Apple Computer. But it was Job's friend Steve Wozniak who did most of the work on Breakout, not Jobs. However, when Jobs received a $5,000 bonus for the work, he told Wozniak it was only $700 and gave Wozniak his "half" --- $350. Years later this truth would come out and it would add to the already increasing friction between the two which eventually lead to Steve Wozniak quitting Apple.

Specification

In Breakout a ball bounces around the screen and destroys blocks as it bounces into them. The ball can bounce off of the top and sides of the screen; however, if the ball moves off the bottom of the screen, the player loses a life and the ball is reset to the center of the screen. The player controls a paddle at the bottom of the screen to block the ball from moving off the bottom. If the player misses blocking the ball three times, the game should end and display a message that the player is the loser. If all the blocks are cleared from the screen, the level should end and a new one loaded. If the player clears a number of levels, the game ends with a message that declares the player as a winner.

You will be given a nonfunctional version of the game in which a ball starts in the middle of the screen keeps moving forever and bounces around, never stopping. For this assignment, you will create a more complete game where the ball bounces off the wall, paddle, and blocks. If a block is hit by the ball, it will disappear. You should also include indicators that show how many lives the player has remaining and how many blocks have been cleared (i.e., a score).

Note, you will have to spend some time choosing fixed values for the size of the paddle, speed of the ball, and size of the blocks in order to ensure the game is fun to play. Include some discussion of why you chose the values you did in your code's comments.

How-to

You are given a lot of starter code that handles drawing balls, blocks, and the panel. You can snarf the code using project assignments/assign6_cps006_spring10 or browse the code online. All of the code that you will write should be in the yourwork package. The executable is the Main class.

Unfortunately, the game is not complete. For example, the ball does not currently bounce off the walls, paddle, or blocks. You need to implement this functionality as well as some of the basic game behavior.

Below is a suggested roadmap for your project:

  1. BouncingBall: Make the ball bounce off the walls by finishing the update method
  2. Mover: Determine whether a point intersects with a moving object by completing the intersects method
  3. Block: Make the ball bounce off blocks by updating the bounce method. Blocks have a health attribute. Each time a block is hit, its health should be decremented by one.
  4. Paddle: You can move the paddle with the A and D keys. You may notice that the paddle can keep moving left or right until it is off the screen. Add the necessary code to the update method, so the paddle cannot leave the bounds of the canvas.

  5. Game: At this point, your program should have implement a very basic version of the game in which the ball starts in the middle of the screen and bounces around, never stopping. However, the ball still does not actually interact with the paddle and blocks. Most of the game play has not been implemented yet, and all of the blocks are an indistinguishable color of gray.

    The Game class handles the game play. You will need to complete the following methods.

    1. makeRandomColor:: This method is called when the blocks are added to the Canvas in addBlocks. Currently, it returns a boring color of gray that makes it very difficult to tell where one block ends and another begins. makeRandomColor should return a random color with red, green, and blue values randomly distributed between 0 and 255.

    2. update:: This method is called every time step by the Canvas class. update should enforce the rules of the game by:
      1. Determining whether the player missed the ball, so the player should lose a life and start a new turn.
      2. Making the ball bounce off the paddle if the ball intersects with the paddle.
      3. Making the ball bounce off a block if the block records a bounce (see the step in Block). Once the block's health is 0, then you should removeupdateValue method for the Game's score (i.e., myScore) to add one to the score.
      4. Adding cheat/test codes. To make it easier to test and grade your project, you should add the following "cheat codes", i.e., key values that the player can press during the game to produce the given effect without having to play the game to achieve it:

        • when the player presses the 'L' key, adds 5 additional lives to the player
        • when the player presses the 'R' key, resets the ball and paddle to their home position
    3. addLabels: Add a status label that indicates how many lives a player has left. The ValueText class places Strings on the game canvas. Using myScore and myLevel as models, add a myLives field.

In CompSci 6 assignments, you should always use the Tasks View to find all of the TODOs in the code that mark each place where you are expected to add code.


Extra Credit

Once you have the basic game working, you can add a variety of features to make your game more fun to play (listed below in the order that you should attempt them):

For other variations of Breakout, consider these examples: Worms Breakout, Vortex, Circus Atari, or Ballistik.

Note: to expect a grade in the A range, you should implement at least two of the extra credit options listed above. Please include, in your README, a description of the extra credit features you attempted so that there is less chance we miss them when we are grading your assignment.


Submitting Your Work

When you are satisfied you have completed the problems above, you should submit your project through Eclipse using assignment name assign6. A submission is not considered complete unless it includes all the Java code for the project (both what you have written and the code provided when you downloaded the project) and a README file.