0% found this document useful (0 votes)
44 views17 pages

Ajp 4

Uploaded by

Janhavi Hude
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views17 pages

Ajp 4

Uploaded by

Janhavi Hude
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

• Rationale:

- The Brick Breaker game project in Advanced Java is designed to provide a


comprehensive learning experience for students and developers, covering a range of
programming concepts, game development principles, and software
engineering practices.

- The Brick Breaker game is a classic arcade game that has been popular for decades,
and its simplicity and familiarity make it an ideal choice for a programming project. The
game requires a range of programming skills. By developing a Brick Breaker game,
students and developers can demonstrate their understanding of these concepts and
develop a range of skills that are essential for building more complex games
and applications.

- The Brick Breaker game project in Advanced Java offers a range of benefits: -Improved
programming skills, Game development knowledge, software engineering skill,
problem solving skill.

• Uses of Brick Breaker Game:

Creating a Brick Breaker Game using Server Socket, and a Graphical User Interface
(GUI) has several practical uses, both for educational purposes and real-world applications.
Here are some key uses of such a project:

1. Game Development Frameworks

➢ Javax or Swing: Developing the game can help in understanding Java GUI frameworks
like JavaFX or Swing. This includes creating windows, handling graphics, and managing
layouts.

➢ Game Engines: It can also serve as an introduction to game engines and libraries such as
LibGDX or jMonkeyEngine.

1
2. Practical GUI Development

➢ User-friendly Interface: Developing a GUI for the chat application helps you learn how
to create intuitive interfaces using Java libraries like Swing or JavaFX.

➢ Interactive Features: You can implement buttons for sending messages, displaying user
statuses, and handling notifications, enhancing your GUI design skills.

3. Data Handling

➢ Message Broadcasting: A chat application using a server socket allows broadcasting


messages to all clients connected to the server.

➢ File Sharing: Extend the application to support file sharing between users in addition to
messages.

4. Error Handling.

➢ Disconnection Handling: Learn how to handle scenarios where a client disconnects


unexpectedly.

➢ Reconnection Strategies: Implement features to allow clients to reconnect to the server


without losing messages.

5. Game Design Practice

➢ User Experience (UX): Developers can study user interactions, feedback, and design
principles by creating and refining the game.

2
• Importance:

1. Hand-Eye Coordination

• Brick Breaker games improve hand-eye coordination as players must align the paddle
with the ball's trajectory and predict where it will land.

2. Reflexes and Reaction Time

• The game requires players to respond quickly, enhancing their reaction speed. This can
translate to improved reflexes in real-world tasks.

3. Problem-Solving and Strategy

• Players often need to strategize to brick all bricks with limited lives or moves, promoting
creative thinking and planning.

4. Focus and Concentration

• To succeed, players must stay focused and avoid distractions. This can help improve
attention span and concentration in other activities.

5. Stress Relief

• The repetitive nature and the satisfaction of bricking bricks can have a calming effect,
making it a relaxing way to relieve stress.

6. Educational Uses in Programming and Game Design

• Brick Breaker is a popular project for beginners in programming and game development,
as it introduces physics, collision detection, and basic graphics.

7. Memory Improvement

• With the need to track multiple elements (like the ball and paddle position), the game can
support memory retention skills, especially when players anticipate the ball's path.

8. Entertainment

• It’s a fun way to pass the time and engage in light entertainment, making it accessible to
people of all ages.

3
• History:

Creating a Brick out-style game (often called "Brick Breaker ") in advanced Java involves
several key concepts and components. Here’s an overview of the historical context and the
main elements involved in developing such a game

• Origins of Brick out: The original Brick out game was developed by Atari in 1976. It was
a simple game where players controlled a paddle to bounce a ball and brick bricks. This
concept has been a staple in game development and inspired many iterations and clones.

• Evolution of Java: Java, introduced by Sun Microsystems in 1995, became popular for
game development due to its platform independence and rich set of libraries. With the
introduction of Java 2 (J2SE), graphical programming became easier with the Swing and
AWT libraries.

• Game Development Frameworks: Over the years, various frameworks and libraries have
been developed to facilitate game creation in Java, including LibGDX, LWJGL, and JavaFX.
These tools provide more advanced graphics handling and easier input management

• Actual Methodology Followed:

i. Discussion with our subject teacher about micro project.

ii. Selection of project name.

iii. To collect basic information about project.

iv. Discussion with group members about requirements.

v. To divide work into group members.

vi. To start actual working on project with proper knowledge.

Vii. To take guidance of teacher to remove mistakes.

4
● Actual Resources Used:

Name of
Sr. No. Specifications Quantity
Resources

AMD Ryzen 5 5500U with Radeon


1 Laptop Graphics,2.10 GHz,8.00 GB RAM, 1
64-bit operating system

2 Application Notepad++ 1

3 Website www.google.com -

5
• Implementation of project:

//Gameplay

import javax.swing.JPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.Timer;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Graphics2D;
import java.awt.Font;

//constructor of the Gameplay that is used in main file

public class Gameplay extends JPanel implements KeyListener , ActionListener{

// declearining the varibals

private boolean play = false;


private int score = 0;

private int totalBricks =21;


private Timer timer;
private int delay = 3;

private int playerX=310;

private int ballposX =120;


private int ballposY =350;
private int ballXdir =-1;
private int ballYdir =-2;

6
//for rectangle obj
private MapGenerator map;

public Gameplay(){
//constructor of MapGenerator
map = new MapGenerator(3,7);

addKeyListener(this);
setFocusable(true);
setFocusTraversalKeysEnabled(false);
timer = new Timer(delay ,this);
timer.start();
}
//graphic import
public void paint(Graphics g){
//background
g.setColor(Color.CYAN);
g.fillRect(1,1,692,592);

//drawing map
map.draw((Graphics2D)g);;

// creat the boudes


g.setColor(Color.WHITE);
g.fillRect(0,0,3,592);
g.fillRect(0,0,692,3);
g.fillRect(691,0,3,592);

//score
g.setColor(Color.white);
g.setFont(new Font("serif" , Font.BOLD ,25));
g.drawString(""+score,590,30);

7
//paddel
g.setColor(Color.green);
g.fillRect(playerX,550,100,8);

//ball
g.setColor(Color.yellow);
g.fillOval(ballposX,ballposY,20,20);

//for game winning


if(totalBricks <= 0){
play= false;
ballXdir = 0;
ballYdir =0;
g.setColor(Color.red);
g.setFont(new Font("serif",Font.CENTER_BASELINE,30));
g.drawString("You Won , Scores is :"+score,260,300);

g.setFont(new Font("serif",Font.CENTER_BASELINE,20));
g.drawString("Press Enter to Restart",230,350);

//for game over


if(ballposY > 570){
play= false;
ballXdir = 0;
ballYdir =0;
g.setColor(Color.red);
g.setFont(new Font("serif",Font.CENTER_BASELINE,30));
g.drawString("Game Over , Scores is :"+score,190,300);

g.setFont(new Font("serif",Font.CENTER_BASELINE,20));
g.drawString("Press Enter to Restart",230,350);

8
//dispose(); causes the JFrame window to be destroyed and cleaned up by the operating
system
g.dispose();

@Override
public void actionPerformed(ActionEvent e){
timer.start();
if(play){
//for rectangle plate

if(new Rectangle(ballposX, ballposY,20,20).intersects(new


Rectangle(playerX,550,100,8))){
ballYdir=-ballYdir;
}
//mam.map is 1st map is -> map.draw((Graphics2D)g);; and 2nd ones is public int
map[][];
A: for(int i=0;i< map.map.length;i++){
for(int j=0;j<map.map[0].length;j++ ){
if(map.map[i][j] > 0){
int brickX = j*map.brickWidth +80;
int brickY = i*map.brickHeight +50;
int brickWidth =map.brickWidth;
int brickHeight=map.brickHeight;

Rectangle rect = new Rectangle(brickX , brickY,brickWidth,brickHeight);


Rectangle ballRect =new Rectangle(ballposX,ballposY,20,20);
Rectangle brickRect=rect;

if(ballRect.intersects(brickRect)){
map.setBrickValue(0,i, j);
totalBricks--;
score+=5;

9
if(ballposX + 19 <= brickRect.x || ballposX +1 >= brickRect.x + brickRect.width){
ballXdir = -ballXdir;

}
else {
ballYdir = -ballYdir;
}

brick A;

}
}

//ball movement
ballposX +=ballXdir;
ballposY += ballYdir;

if(ballposX < 0){

ballXdir=- ballXdir;
}

if(ballposY < 0){

ballYdir=- ballYdir;
}

if(ballposX >670){

ballXdir=- ballXdir;
}
10
}

repaint();

@Override
public void keyTyped(KeyEvent e){

@Override
public void keyReleased(KeyEvent e){

@Override
public void keyPressed(KeyEvent e){

if(e.getKeyCode()== KeyEvent.VK_RIGHT){
if(playerX >= 600){
playerX=600;
}
else {
moveRight();
}
}

if(e.getKeyCode()== KeyEvent.VK_LEFT){
if(playerX <= 10){
playerX=10;
}
else {
moveLeft();
}
11
}

if(e.getKeyCode()== KeyEvent.VK_ENTER){
if(!play){
play=true;
ballposX=120;
ballposY=350;
ballXdir =-1;
ballYdir = -2;
playerX = 310;
score=0;
totalBricks =21;
map=new MapGenerator(3, 7);
repaint();

public void moveRight(){


play = true;
playerX+=20;
}

public void moveLeft(){


play = true;
playerX-=20;
}}

12
• //MapGenerator

import java.awt.Graphics2D;
import java.awt.Color;
import java.awt.BasicStroke;

public class MapGenerator {


public int map[][];
public int brickWidth;
public int brickHeight;

public MapGenerator(int row,int col){


map=new int[row][col];
for(int i=0;i < map.length;i++){
for(int j=0;j < map[0].length;j++){
map[i][j]=1;
}
}

brickWidth=540/col;
brickHeight=150/row;
}

public void draw(Graphics2D g){


for(int i=0;i<map.length;i++){
for(int j=0;j<map[0].length;j++){
if(map[i][j] > 0){
g.setColor(Color.BLUE);
g.fillRect(j * brickWidth +80 , i * brickHeight + 50 , brickWidth ,brickHeight);

g.setStroke(new BasicStroke(3));
g.setColor(Color.CYAN);
g.drawRect(j * brickWidth +80 , i * brickHeight + 50 , brickWidth
,brickHeight);

13
}
}
}
public void setBrickValue( int value,int row, int col){
map[row][col]=value;
}

• //Main file

import javax.swing.JFrame;

public class Main{

public static void main (String[] args){


JFrame obj=new JFrame();
//obj of Gameplay
Gameplay gamePlay = new Gameplay();

obj.setBounds(10,10,700,600);
obj.setTitle("Brickout Ball");
obj.setResizable(false);
obj.setVisible(true);
obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//adding the object in gameplay
obj.add(gamePlay);

}
}

14
• Output of code:

15
● Skill Developed :

i. Management and Detailed Planning.

ii. Communication and presentation skill.

iii. Ability to need deadlines and work as part of team.

iv. How to analyse the data, Basic knowledge of package and Exception handling.

16
• Application :

• Here’s a short list of applications for a Brick Breaker Game project using Java:

1. User Interface Design

2. Testing and Debugging

3. Data Persistence

4. Game Development Fundamentals

• Area of future improvement:

• Here are some areas for future improvement in a Java-based Brick Beaker Game:

1.Gamification of Education.

2.Multiplayer and Social Features.

3.Cross-Platform Availability.

4.Language and Cultural Diversity

17

You might also like