Skip to content
Nucleuz edited this page May 8, 2015 · 9 revisions

About the original Breakout

The original Breakout game consists of lines of bricks at the top of the screen, a paddle (the player) at the bottom of the screen, and a ball that is travelling across the screen. The player has to hit the ball with the paddle and try to destroy all the bricks with the ball. If the player fails at hitting the ball, then the player loses a ball/life.

About our Breakout game

Our version of the game has all the basics of the Breakout game.

The project was created using Slick2D, and it consists of 6 classes:

  • BreakoutGame
  • Player
  • Obstacle
  • Ball
  • Menu
  • Dead

Below is a UML class diagram that describes the structure of our game.

UML Class Diagram

Classes

Below is a brief explanation of each class.

Menu.java

The menu class is very simple and only contains a few variables that are used to set an image as the menu.

Dead.java

The dead class is exactly the same as the Menu class, but just with at different image for when you die.

Player.java

The Player class contains variables for the position of the player, the width and height of the paddle. Getters and setters are implemented in order to get the access to the variables from other classes. A render method is also included, which is draws the image of the player when it is called.

Obstacle.java

The Obstacle class is similar to the Player class, but it just does not contain the draw method. This is because the images get drawn in the main class (BreakoutGame.java)

Ball.java

The Ball class basically contains exactly the same variables as for the Player, but only with a few extra, such as dx and dy, which is used for controlling the directional movement of the ball.

BreakoutGame.java

The BreakoutGame class is the main class. This is where all the other classes are used. There are 4 methods in the class; main, init, update, and render. The main method runs when we start the program. The init method runs right before the game starts, and this is where we initialize all the images for the different obstacles and their position. The update method runs every frame and this is where we move the ball, check for collision and so on. The render method is then used to draw every graphical content, and the render methods in the other classes are also called here.