Professional Documents
Culture Documents
Me Project Breakout Java
Me Project Breakout Java
Overview
Objective
Java is widely used by game development companies and for creating mobile games. And
this fact shouldn’t come as much of a surprise, given how versatile the language is and given
its rich collection of open-source material. Many of the world’s top mobile games have been
developed in Java. Minecraft, Mission Impossible III, and Asphalt 6 are just a few popular
names you are probably familiar with. We will be creating a game using new java concepts
like AWT, Swing etc.
Project Context
Breakout Ball game is a widely used game which was developed in the 1970s. In Breakout, a
layer of bricks lines the top third of the screen and the goal is to destroy them all. A ball
moves straight around the screen, bouncing off the top and two sides of the screen. When a
brick is hit, the ball bounces back and the brick is destroyed. The player loses a turn when
the ball touches the bottom of the screen; to prevent this from happening, the player has a
horizontally movable paddle to bounce the ball upward, keeping it in play. The player uses
the platform to keep the ball running. The goal is to break the bricks without missing the
ball with your platform. The project makes use of Java swing, OOPS concepts and much
more.
Here, you will use new java concepts of beginner level (AWT, Swing, JFrame, JPanel etc).
This game is not meant to be the next most sold game but just a platform from which to
learn and maybe inspire someone to be the next most successful developer in the world ;)
https://www.youtube.com/embed/F-bxvt_Ez08
Primary goals
1. The player should be able to start the game in the terminal by pressing the ENTER key.
2. The player should be able to move the paddle sideways using the Leftwards and the
Rightwards Arrow on the keyboard.
3. Once the player loses the ball, i.e. when the ball touches the bottom of the screen, the
game ends.
4. Breaking each brick should provide the player a certain number of points. Let's say
each brick contains 5 points, if a player breaks 10 such bricks, he gets 50 points.
5. Once the game ends, the terminal will present the final score of the player and give him
the option to restart the game again.
Task 1
Setting up the development environment
First you need to set up the development environment for the Java GUI project. For this, you
need to install Java 8 or higher. Additionally you need a code-editor or IDE to write the
code.
Requirements
1. Install Java (JDK 1.8)
2. Install any IDE- IntelliJ (Community edition) or Eclipse or VS Code
3. Do the environment setup for Java on your local machine
4. Create a Java project using Command Line App as the template
5. Provide the project name and the base package
Check the version of java to know whether you have successfully installed it or not-
java -version
References
• Installing Java
• Installing Eclipse
• Installing IntelliJ IDEA
• Installing Visual Studio Code
Tip
• You can use online IDE as well. For that you don't need to install any IDEs for that
instance. Check it out!
• Online IDE
Expected Outcome
You should be able to set up the initial development environment required to develop the
game.
Task 2
Design the Game terminal
Game terminal is the window where the game is to be played. It consists of the following
aspects: - Window size (length, breadth and height) - Window visibility - Game title -
Default close operation
Requirements
1. Create a Main class inside the base package
2. Import Java Swing dependency
3. Create a JFrame object to implement the GUI functionality
4. Design the window terminal by writing your code
References
• Java Swing
• Java JFrame
• Interactive Console Application
Bring It On!
You can use other Java Frameworks as well apart from JFrame to implement a graphical
user interface. Find it out!
Expected Outcome
You should be able to view the game terminal.
Task 3
Design the gameplay
Game design sits under the broader field of game development and refers to the use of
creativity and design to develop a game for entertainment or educational purposes. Games
can be characterized by "what the player does" and "what the player experiences". This is
often referred to as gameplay.
Gameplay design is responsible for the central part of the game experience – how it plays. It
plans and defines the game’s structure, its rules, characters, objects, props and thinks about
different modes of play.
Requirements
1. Create a Gameplay class inside the base package
2. Import Java AWT and Swing dependencies
3. Extend the JPanel container class by implementing KeyListner and ActionListner
interfaces. Check out more on these classes and interfaces:
● JPanel
● ActionListner
● KeyListner
4. Design the background template
5. Implement the code for ball positioning
6. Implement the code for moving the paddle using KeyEvent and ActionEvent
References
• Java AWT Package
• AWT Graphics class
Bring It On!
You can use Java Applet to run a game in a web browser. Find it out!
Expected Outcome
You should be able to view the gameplay in the terminal.
Task 4
Design the props (bricks) using 2D Array
Breakout begins with four to eight rows of bricks, with each two rows a different color. The
color order from the bottom up is yellow, green, orange and red. Using a single ball, the
player must knock down as many bricks as possible by using the walls and/or the paddle
below to ricochet the ball against the bricks and eliminate them. If the player's paddle
misses the ball's rebound, they will lose a turn.
Requirements
1. Create a Map Generator class inside the base package
2. Import Java AWT dependency
3. Design the bricks
4. Implement the code for the bricks to disappear once the ball hits
5. Implement the code for calculating the score in the 'Gameplay' class
References
• Java Graphics2D
Bring It On!
Use of Graphics2D will help to draw the bricks over the terminal
Expected Outcome
You should be able to view the entire game in the terminal.
Task 5
Run the game in the terminal
Wrap up the code of the game and start it off right away using the terminal directly.
Requirements
1. Build the project
2. Import any dependencies, if left
3. Run the Main() class
4. Play the game in the terminal
Congratulations!!! You have successfully started your game!
References
• Java Graphics2D
Bring It On!
Play different brick breaker games from Google Play and try to implement them yourself!
Expected Outcome
You should be able to play the game in the terminal.