Duke CS Logo CompSci 6: Program Design & Analysis I
(Fall 2009)
Home
Course Information
Calendar
Assignments
Assign 1
Assign 2
Assign 3
Assign 4
Assign 5
Assign 6
Assign 7
Assign 8
Assign 9
APT problems
Resources
Help sessions
Discussion Forum
Blackboard
Oasis

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/assign5_cps006_fall09 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):

  • Levels: Your game should have different levels. To make each level more challenging, you might make each block worth more points, each pattern of blocks more convoluted, or the ball move faster each time. In this case, it may no longer be possible to win the game (or there may be a fixed number of levels). To implement levels successfully, you will need to be very careful about defining variables to control different values in your game (e.g., ball's velocity or score for each block).
  • Power-ups: Anther game, Arkanoid, maintains the basic premise of Breakout, to destroy all of the blocks on the board by bouncing a ball off of them, but adds power-ups. Some blocks drop power-ups when they are destroyed which, when caught by the players paddle, affect the game in various ways: making the paddle longer, speeding up the ball, giving the player extra bouncing balls to use to break the blocks, giving the player lasers with which to destroy the blocks, giving the player a way to escape the level, or almost anything else you can think of.

  • Super-blocks: Blocks can also have other different properties, such as the number of hits needed to destroy them, their worth, or again, almost anything else you can think of.
  • Earn lives: Allow the player to gain an extra life if they reach the end of the second level without having lost a life previously.
  • Get faster: Make the speed of the ball increase as the game proceeds. The speed should be reset back to the original speed when the paddle misses the ball (i.e., it hits the bottom of the window).
  • Get smaller: Make the size of the paddle decrease as the game proceeds. The size should be reset back to the original speed when the paddle misses the ball (i.e., it hits the bottom of the window).
  • Multi-directional paddle: Make the ball bounce differently depending on where it hits on the paddle (the middle third cause the ball to bounce normally, the left and right thirds cause the ball to bounce back in the direction it came).
  • Cheat codes: Add additional cheat codes, e.g., to produce a specific power-up or clear some of the blocks without hitting them with the ball
  • Sticky paddle: Allow the user to "catch" the ball when it hits the paddle and release it at a later time of their choosing.
  • Moving bricks: Make some blocks move during the game (either continuously from the start or as a result of being hit)
  • Hot area: Make special areas of the screen that affect the play of the game (i.e., speed up the ball, add points to the player's score, change the direction of the ball, etc.): this can make your game closer to pinball than Breakout.
  • Better bouncing: Devise better bounce checking that avoids the bug that occasionally causes the ball to get stuck for a few steps in the shape it is bouncing off.

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 assign5. 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 as described here.

Last updated Wed Nov 18 14:00:35 EST 2009