You are on page 1of 14

Brick Breaker Final

Report

1.AIM:- CREATE A BRICK BREAKER


GAME
2 INTRODUCTION

We made an interactive game based upon the classic game brick breaker.
The object of brick breaker is to break the bricks that are distributed around the
top of the game screen. The bricks are broken after coming in contact with a
ball that bounces around the screen. At the bottom is a paddle that in the classic
game moves based on user input. The user has to make sure the ball bounces
off the paddle without going off the bottom of the screen. In our
implementation, instead of using arrow keys to control the paddle’s position,
we use a camera to track the position of an actual Ping-Pong paddle held by
the user. The control of the game paddle with an actual Ping-Pong paddle
improves the user experience.

We chose the game brick breaker because it is already a fun game that
we knew we could improve using an actual Ping-Pong paddle. The actual
paddle made the game more interactive and allowed us to take the users’
instinctual movements to allow for a better user experience, in much the same
way that current generation video games are employing the technology (e.g.
Microsoft Kinect, Nintendo Wii, PlayStation Move).

Our game was designed to be retro and fun. The overall game experience is
shown below in Figure 1. At the very bottom left there is the 6.111 labkit that
is performing the logic of the game. In the center is the visual game display. To
the right is the actual paddle being tracked by the camera. To the right of the
camera are the speakers that provide sound during the game.

A view of the all essential components to the game. The game consists
of a screen (center) that shows the gameplay. There is a camera pointed
towards to the user who holds a paddle. To the left, there is the labkit
with an FPGA that processes the game. There are also speakers here
shown to the right that play background music and sound effects

1
Figure 1: Block diagram of system. The video processing module takes
in video and will give information about the paddle’s location to the
game logic. The game logic uses the paddle’s location to determine what
happens in the game and what should be displayed. These game events
are sent to the sound output module to play the appropriate sound.

Fig 1

3. COURSE OUTCOME :

1. Develop program using Object oriented methodology in java


2. Apply concept of inheritance foe code re-usability
3. Develop a program using multi threading

4. LITERATURE REVIEW

1.Historical significance:

Website: https://www.geeksforgeeks.org/

One of the oldest video game developers is Atari. The name of this company was
such a household name that here in Turkey we would call arcades “Atari Halls”. The
antique video game Breakout that Atari developed in 1976 is a simple yet important
game. It’s released as an improved version of Atari’s first game Pong. (The game
where you play table tennis with two on screen rectangles.) The game is the
brainchild of Atari’s founder Nolan Bushnell. The first Breakout game symbolizes a
prisoner breaking the walls with the shackles on his feet and was originally
developed by Steve Wozniak and Steve Jobs for an arcade machine. This black and
2
white game that was colorized with the help of cellophane would be an inspiration
for the new games with its software, controls, and chipset design.

Super Breakout, the successor to Breakout, was released as a game that was as plain
and simple as possible in 1978. It had clever and innovative features such as the
multiple balls mode which increased the number of interactable objects on the screen.
It had its place as a favorite in arcade centers in the first half of 1980’s.

2.Algorithmic Approach:

Website: https://www.codingninjas.com/codestudio/library/feasibility-study

In the realm of artificial intelligence and computer science, Brick Breaker serves as a
fundamental benchmark for testing algorithms and graphics. Researchers have
developed various algorithms to play Brick Breaker optimally, ranging from brute-
force methods to heuristic-based approaches. Classic algorithms such as Minimal and
Alpha-Beta Pruning have been extensively studied and applied to Brick Breaker,
demonstrating their effectiveness in game

3.Educational Applications:

Brick Breaker is widely recognized for its satisfactional value, particularly in the
context of teaching logic, problem-solving, and critical thinking skills. Educators
have integrated brick breaker into curriculum activities to engage students

3
5.ACTION PLAN:

Sr.No Details of Activity PLAN START PLAN FINISH


DATE DATE

1 Searching topic for Micro-Project 15-1-2024 25-1-2024

2 Collect information from internet 30-1-2024 10-2-2024


and textbook

3 Arrange all information in MS- 20-2-2024 25-2-2024


Word

4 Prepare algorithm and flowchart 27-2-2024 1-3-2024

5 Write Source code 5-3-2024 8-3-2024

6 Prepare Report 12-3-2024 15-3-2024

7 Print Report 20-3-2024 23-3-2024

4
6. ACTUAL METHODOLOGY USED:

6.1 Working

● Translation: Concept of translation is used in our game while moving the paddle
as well as while the ball is in motion rebounding from the different surfaces.

● Scaling: Concept of scaling can be seen in our game when the difficulty changes,
the scaling of the paddle differs. When the level is easy we scale the paddle smaller
and when the level is hard we scale the paddle longer

● Drawing Circle: For drawing the ball we used the concept of drawing connected
triangles continuously to give it an image of a 2D Ball. One triangle is defined for
each vertex presented after the first two vertices. Vertices 1 , n + 1 , and n + 2 define
triangle n . N - 2 triangles are drawn.

● Drawing Polygons: Different shapes were drawn using the inbuilt polygon
function and defining the appropriate vertices which matches the shape of the
polygon.

● Game Concept: Brick Breaker is a famous retro game where we have to destroy
all the bricks and the ball should not fall. If the ball falls the game will restart. The
main player of the game is paddle, we have to save the ball from going below by the
paddle and at the same time try to hit as many bricks as possible.

● Difficulty Levels: To ensure the users interest in the game we came up with
different levels and difficulties, the concepts for the level are described below:

a) Changing Size of Paddle: For this we changed the position of the vertices while
defining the polygon, That way we can make the paddle smaller or bigger.

b) Changing the speed of the Ball: For this particular feature we decided to have a
rate variable which on increasing gives us a high speed of the ball and vice versa.
This rate depends on the x-coordinate and the y-coordinate. The more the rate means
the faster the x and y coordinates will change.

● Keyboard Inputs: Now for playing the game the user needs some kind of input to
give. This can be done very easily by using a glut function ‘keyboard’ and then by
specifying the role of the keys in the switch case. In each switch case you need to
define what that key will do.

● Hitting the Brick: This is the concept which comes into play when the ball hits the
brick. This function defines the trajectory of the ball after hitting. We used the
concept by applying the if else conditions and accordingly changing the direction of
the ball.

5
● Trajectory of the Ball: The concept used for this particular feature of our game
which handles the motion of the ball along with the rebounding from various
surfaces. Here one condition is for increasing the rate after some successive
collisions and another condition is to make the changes for the different directions of
the ball after rebounding.

6.2 Algorithm
Initialization

Create a game window with appropriate dimensions and set up a rendering engine
(e.g., Pygame, Unity, etc.).
Initialize the game state variables:
Score: Starting score set to 0.
Lives: Starting lives set to a predefined value (e.g., 3).
Level: Starting level set to 1.
Brick grid: Generate a grid of bricks with different colors and arrangement. Each
brick can have properties like health, score value, etc.
Paddle: Create a paddle object and position it at the bottom center of the window.
Ball: Create a ball object and position it above the paddle. Set its initial velocity .
Game loop:
Start the main game loop.
Handle user input:
Check for keyboard or mouse input to move the paddle horizontally.
Update the position of the paddle based on user input.
Update the position of the ball:
Move the ball based on its current velocity.
Check for collisions with the walls, paddle, and bricks.
If a collision occurs, adjust the ball's velocity accordingly.
Check for win/lose conditions:
If the ball goes below the paddle:
Decrement a life.
If lives are zero, end the game.
Reset the ball position above the paddle.
If all bricks are destroyed:
Increment the level.
Generate a new grid of bricks with increased difficulty.
Reset the ball position above the paddle.
Render the updated game state (paddle, ball, bricks, score, lives, etc.) on the screen

6
6.3 FLOWCHART

7
6.4 PROGRAM CODE:

Import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class BrickBreaker extends JFrame {


private final int WIDTH = 800;
private final int HEIGHT = 600;
private final int PADDLE_WIDTH = 100;
private final int PADDLE_HEIGHT = 10;
private final int BALL_DIAMETER = 20;
private final int BRICK_WIDTH = 80;
private final int BRICK_HEIGHT = 20;
private final int BRICK_ROWS = 5;
private final int BRICK_COLS = 10;
private final int INITIAL_DELAY = 1000;
private final int DELAY = 10;

private int paddleX;


private int ballX;
private int ballY;
private int ballXDir = 1;
private int ballYDir = -1;
private boolean[][] bricks;

public BrickBreaker() {
setSize(WIDTH, HEIGHT);
setTitle("Brick Breaker");
setResizable(false);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(null);

paddleX = WIDTH / 2 - PADDLE_WIDTH / 2;


ballX = WIDTH / 2 - BALL_DIAMETER / 2;
ballY = HEIGHT - 50 - BALL_DIAMETER;

bricks = new boolean[BRICK_ROWS][BRICK_COLS];


for (int i = 0; i < BRICK_ROWS; i++) {
for (int j = 0; j < BRICK_COLS; j++) {
bricks[i][j] = true;
}
}

addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
int key = e.getKeyCode();
if (key == KeyEvent.VK_LEFT && paddleX > 0) {
paddleX -= 20;
}
if (key == KeyEvent.VK_RIGHT && paddleX < WIDTH - PADDLE_WIDTH) {
paddleX += 20;
}
}
});

Timer timer = new Timer(DELAY, new ActionListener() {


@Override
8
public void actionPerformed(ActionEvent e) {
ballX += ballXDir;
ballY += ballYDir;

if (ballX <= 0 || ballX >= WIDTH - BALL_DIAMETER) {


ballXDir = -ballXDir;
}

if (ballY <= 0 || ballY >= HEIGHT - BALL_DIAMETER) {


ballYDir = -ballYDir;
}

if (ballY + BALL_DIAMETER >= HEIGHT - 50 &&


ballX >= paddleX && ballX <= paddleX + PADDLE_WIDTH) {
ballYDir = -ballYDir;
}

for (int i = 0; i < BRICK_ROWS; i++) {


for (int j = 0; j < BRICK_COLS; j++) {
if (bricks[i][j]) {
int brickX = j * BRICK_WIDTH;
int brickY = i * BRICK_HEIGHT;
Rectangle brick = new Rectangle(brickX, brickY, BRICK_WIDTH,
BRICK_HEIGHT);
Rectangle ball = new Rectangle(ballX, ballY, BALL_DIAMETER,
BALL_DIAMETER);
if (brick.intersects(ball)) {
bricks[i][j] = false;
ballYDir = -ballYDir;
}
}
}
}

repaint();
}
});
timer.setInitialDelay(INITIAL_DELAY);
timer.start();
}

@Override
public void paint(Graphics g) {
super.paint(g);

g.setColor(Color.BLACK);
g.fillRect(0, 0, WIDTH, HEIGHT);

g.setColor(Color.WHITE);
g.fillRect(paddleX, HEIGHT - 50, PADDLE_WIDTH, PADDLE_HEIGHT);

g.setColor(Color.RED);
g.fillOval(ballX, ballY, BALL_DIAMETER, BALL_DIAMETER);

g.setColor(Color.GREEN);
for (int i = 0; i < BRICK_ROWS; i++) {
for (int j = 0; j < BRICK_COLS; j++) {
if (bricks[i][j]) {
g.fillRect(j * BRICK_WIDTH, i * BRICK_HEIGHT, BRICK_WIDTH,
BRICK_HEIGHT);
}
}
}
}
9
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new BrickBreaker().setVisible(true);
}
});
}
}

7. ACTUAL RESOURSES USED

Sr.No Hardware specification Specification

1. Processor Ryzen 5

2. Random access Meomory(RAM) 16 GB(Minimum)

3. Hard Drive (HDD) 512GB

Sr.No Software specification Specificaton

1. Operating system Windows

2. Software Notepad/command prompt

3. Language used Java

10
8.RESULT:

11
9.CONCLUSION:
In all, Jemale and Jonathan had a lot of fun creating and playing Brick Breaker.
Brick Breaker was a successful educational experience that solidified our
understanding of Verilog and hardware electronics. Brick Breaker successfully ran
at the end of the semester and provided a fun experience to those who stopped by
the lab bench to try it out. Brick Breaker demonstrated our learning and new found
expertise in Verilog coding
BREAK BREAKER (platformer) is a Breakout clone[2] in which the player must
smash a wall of bricks by deflecting a bouncing ball with a paddle. The paddle may
move horizontally and is controlled with the BlackBerry's trackwheel, the computer's
mouse or the touch of a finger (in the case of touchscreen). The player gets three
lives to start with; a life is lost if the ball hits the bottom of the screen. When all the
bricks have been destroyed, the player advances to a new, harder level. There are 34
levels. Many levels have unbreakable silver bricks. If all lives are lost, the game is
over.

12
10 FUTURE SCOPE:

 The BREAK BREAKER game project presents several avenues for future
development and expansion:
 AI Opponent: Integrate an artificial intelligence (AI) opponent using advanced
algorithms like Minimal or neural networks. This would enable single-player
mode where users can play at varying difficulty levels
 Online Multiplayer: Implement online multiplayer functionality, allowing
users to play against friends or random opponents over the internet. This could
involve networking protocols such as TCP/IP or Web-socket for real-time
gameplay.
 Customization Options: Add features for customizing the game, such as
selecting different leveles, choosing alternative themes, and adjusting game
rules (e.g., requiring more fast gameplay).
 Enhanced User Interface: Improve the user interface with more intuitive
controls, interactive animations, and visually appealing graphics. Incorporate
sound effects and background music to enhance the overall gaming experience
 Statistics and Leader-boards: Implement tracking of game statistics, including
win-loss records, average game duration, and win streaks. Introduce leader-
boards to showcase top players and encourage competition. database
 BREAK BREAKER some in which players can shoot flaming fireballs or play
with more than one ball if the player gets a power up.

13
11.REFERENCE

• www.google.com
• www.youtube.come
• https://www.lovelycoding.org/games.io system

14

You might also like