Posts

Showing posts from January, 2021

Brick Breaker-Develop a game in java.

Image
I have used IDE Eclipse. This is how the game looks. 1. we have a slider that can move left and right using left and right arrows. 2. we have a red color ball 3. we have a matrix of black bricks, when the ball hits the brick , the brick disappears and the score increases by 5. 4. when the ball hits the slider ,it bounces back towards the bricks(upward). 5. Press ENTER to start a new game. Source Code: MAIN CLASS public class Main { public static void main(String args[]) { JFrame obj=new JFrame(); GamePlay gamePlay=new GamePlay(); obj.setBounds(10,10,700,600); obj.setTitle("BreakOut Ball"); obj.setResizable(false); obj.setVisible(true); obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); obj.add(gamePlay); } } GAMEPLAY CLASS public class GamePlay extends JPanel implements KeyListener,ActionListener{ private boolean play=false; private int score=0; private int totalBricks=21;  private Timer timer; private int delay=8; private int player