Topic 1 - Variables and Data Types
Topic 2 - Conditionals and Strings
Topic 3 - Loops
Topic 4 - Arrays
Topic 5 - File Handling
Semester 1 Projects
Topic 6 - Classes/Objects and Methods
Topic 7 - ArrayLists
Semester Projects

Introduction

You should do this project if…

  • You feel somewhat comfortable with Java and would like to explore more about classes and objects.
  • You would like to understand how simple computer graphics work.
  • You are interested in creating games, but not story lines. While there is some room for extension, the game won’t change a whole lot.
  • You would like a fun project with a moderate amount of challenge.
  • You enjoy choosing colors, fonts, shapes and sounds to improve a program.

Starter Code Files

https://github.com/emlag/Breakout

Introduction

Your job in this assignment is to write the classic arcade game of Breakout, which was invented by Steve Wozniak before he founded Apple with Steve Jobs. It is a large project, but entirely manageable as long as you break the problem up into pieces. The decomposition is discussed in these instructions and there are several suggestions for staying on top of things.

In Breakout, the initial configuration of the world appears as shown below. The colored rectangles in the top part of the screen are bricks, and the slightly larger rectangle at the
bottom is the paddle. The paddle is in a fixed position in the vertical dimension, but moves left and right across the screen along with the mouse until it reaches the edge of its space.

A complete game consists of three turns. On each turn, a ball is launched from the center of the window toward the bottom of the screen at a random angle. That ball bounces off the paddle and the walls of the world, in accordance with the physical principle generally expressed as “the angle of incidence equals the angle of reflection” (which turns out to be very easy to implement as discussed later in this writeup). Thus, after two bounces one off the paddle and one off the right wall the ball might have the trajectory shown in the second diagram. (Note that the dotted line is there to show the ball’s path and won’t appear on the screen)

As you can see from the second diagram, the ball is about to collide with one of the bricks on the bottom row. When that happens, the ball bounces just as it does on any other collision, but the brick disappears. The third diagram shows what the game looks like after that collision and after the player has moved the paddle to put it in line with the oncoming ball. The play on a turn continues in this way until one of two conditions occurs:

  1. The ball hits the lower wall, which means that the player must have missed it with the paddle. In this case, the turn ends and the next ball is served if the player has any turns left. If not, the game ends in a loss for the player.
  2. The last brick is eliminated. In this case, the player wins, and the game ends immediately. After all the bricks in a particular column have been cleared, a path will open to the top wall. When this situation occurs, the ball will often bounce back and forth several times between the top wall and the upper line of bricks without the user ever having to worry about hitting the ball with the paddle. This condition is called “breaking out” and gives meaning to the name of the game. It is important to note that, even though breaking out is a very exciting part of the player’s experience, you don’t have to do anything special in your program to make it happen. The game is simply operating by the same rules it always applies: bouncing off walls, clearing bricks, and otherwise obeying the laws of physics.

Starter Code

Take a look at the initial contents of Breakout.java file. This file takes care of the following details:
• It includes the imports you will need for writing the game.
• It defines the named constants that control the game parameters, such as the dimensions of the various objects. Your code should use these constants internally so that changing them in your file changes the behavior of your program accordingly. Success in this assignment will depend on breaking up the problem into manageable pieces and getting each one working before you move on to the next. The next few sections describe a reasonable staged approach to the problem.

Project Setup

Possible Troubleshooting