Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 14 of 14

Thread: [Arkanoid]Help

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Location
    Philippines
    Posts
    23
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default [Arkanoid]Help

    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.Random;
    import java.io.*;
    import java.awt.Color;
    import java.awt.event.ActionEvent;
     
    	public class Arkanoid extends JPanel implements ActionListener, KeyListener {
    	static JFrame frame = new JFrame();
    	Timer tm = new Timer(20, this);
     
    	static int BallX=238, BallY=505, BallW=15, BallH=15;
    	static int BarX=220, BarY=520, BarW=50, BarH=10;
     
    	static int x=3     ,y=60 ,  w=30 ,  h=15;
    	static int x1=35   ,y1=60,  w1=30,  h1=15;
    	static int x2=67   ,y2=60,  w2=30,  h2=15;
    	static int x3=99   ,y3=60,  w3=30,  h3=15;
    	static int x4=131  ,y4=60,  w4=30,  h4=15;
    	static int x5=163  ,y5=60,  w5=30,  h5=15;
    	static int x6=195  ,y6=60,  w6=30,  h6=15;
    	static int x7=227  ,y7=60,  w7=30,  h7=15;
    	static int x8=259  ,y8=60,  w8=30,  h8=15;
    	static int x9=291  ,y9=60,  w9=30,  h9=15;
    	static int x10=323 ,y10=60, w10=30, h10=15;
    	static int x11=355 ,y11=60, w11=30, h11=15;
     
    	static int x12=3    ,y12=77,  w12=30,  h12=15;
    	static int x13=35   ,y13=77,  w13=30,  h13=15;
    	static int x14=67   ,y14=77,  w14=30,  h14=15;
    	static int x15=99   ,y15=77,  w15=30,  h15=15;
    	static int x16=131  ,y16=77,  w16=30,  h16=15;
    	static int x17=163  ,y17=77,  w17=30,  h17=15;
    	static int x18=195  ,y18=77,  w18=30,  h18=15;
    	static int x19=227  ,y19=77,  w19=30,  h19=15;
    	static int x20=259  ,y20=77,  w20=30,  h20=15;
    	static int x21=291  ,y21=77,  w21=30,  h21=15;
    	static int x22=323  ,y22=77,  w22=30,  h22=15;
    	static int x23=355  ,y23=77,  w23=30,  h23=15;
     
    	static int x24=3    ,y24=95,  w24=30,  h24=15;
    	static int x25=35   ,y25=95,  w25=30,  h25=15;
    	static int x26=67   ,y26=95,  w26=30,  h26=15;
    	static int x27=99   ,y27=95,  w27=30,  h27=15;
    	static int x28=131  ,y28=95,  w28=30,  h28=15;
    	static int x29=163  ,y29=95,  w29=30,  h29=15;
    	static int x30=195  ,y30=95,  w30=30,  h30=15;
    	static int x31=227  ,y31=95,  w31=30,  h31=15;
    	static int x32=259  ,y32=95,  w32=30,  h32=15;
    	static int x33=291  ,y33=95,  w33=30,  h33=15;
    	static int x34=323  ,y34=95,  w34=30,  h34=15;
    	static int x35=355  ,y35=95,  w35=30,  h35=15;
     
    	static int x36=3    ,y36=113,  w36=30,  h36=15;
    	static int x37=35   ,y37=113,  w37=30,  h37=15;
    	static int x38=67   ,y38=113,  w38=30,  h38=15;
    	static int x39=99   ,y39=113,  w39=30,  h39=15;
    	static int x40=131  ,y40=113,  w40=30,  h40=15;
    	static int x41=163  ,y41=113,  w41=30,  h41=15;
    	static int x42=195  ,y42=113,  w42=30,  h42=15;
    	static int x43=227  ,y43=113,  w43=30,  h43=15;
    	static int x44=259  ,y44=113,  w44=30,  h44=15;
    	static int x45=291  ,y45=113,  w45=30,  h45=15;
    	static int x46=323  ,y46=113,  w46=30,  h46=15;
    	static int x47=355  ,y47=113,  w47=30,  h47=15;
     
    	static int x48=3    ,y48=130,  w48=30,  h48=15;
    	static int x49=35   ,y49=130,  w49=30,  h49=15;
    	static int x50=67   ,y50=130,  w50=30,  h50=15;
    	static int x51=99   ,y51=130,  w51=30,  h51=15;
    	static int x52=131  ,y52=130,  w52=30,  h52=15;
    	static int x53=163  ,y53=130,  w53=30,  h53=15;
    	static int x54=195  ,y54=130,  w54=30,  h54=15;
    	static int x55=227  ,y55=130,  w55=30,  h55=15;
    	static int x56=259  ,y56=130,  w56=30,  h56=15;
    	static int x57=291  ,y57=130,  w57=30,  h57=15;
    	static int x58=323  ,y58=130,  w58=30,  h58=15;
    	static int x59=355  ,y59=130,  w59=30,  h59=15;
     
    	static int x60=3    ,y60=148,  w60=30,  h60=15;
    	static int x61=35   ,y61=148,  w61=30,  h61=15;
    	static int x62=67   ,y62=148,  w62=30,  h62=15;
    	static int x63=99   ,y63=148,  w63=30,  h63=15;
    	static int x64=131  ,y64=148,  w64=30,  h64=15;
    	static int x65=163  ,y65=148,  w65=30,  h65=15;
    	static int x66=195  ,y66=148,  w66=30,  h66=15;
    	static int x67=227  ,y67=148,  w67=30,  h67=15;
    	static int x68=259  ,y68=148,  w68=30,  h68=15;
    	static int x69=291  ,y69=148,  w69=30,  h69=15;
    	static int x70=323  ,y70=148,  w70=30,  h70=15;
    	static int x71=355  ,y71=148,  w71=30,  h71=15;
     
     
     
    	static int velx=0; 
    	static int vely=2;
    	int count=0;
    	int ballspeed=15;
    	static int score=0;
    	static int second=0;
    	static JLabel labeltimers;	
    	static JLabel lblscore;
    	static JLabel ScoreLabel;
     
    	public Arkanoid()
    	{
    	ScoreLabel = new JLabel ("Score:");
    	ScoreLabel.setBounds(5,545,100,20);
    	add(ScoreLabel);
    	labeltimers = new JLabel("0");
    	labeltimers.setBounds(45,545,100,20);
    	add(labeltimers);
     
    		tm.start();
    		setVisible(true);
    		setLayout(null);		
    		this.requestFocus();
    		addKeyListener(this);
            setFocusable(true);
            setFocusTraversalKeysEnabled(false);	
    	}	
    	public void paintComponent(Graphics g)
    	{
    		super.paintComponent(g);
    		g.setColor(Color.BLACK);
    		g.fillOval(BallX, BallY, BallW, BallH);
     
    		g.setColor(Color.BLUE);
    		g.fillRect(BarX, BarY, BarW ,BarH);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x, y, w, h);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x1, y1, w1, h1);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x2, y2, w2, h2);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x3, y3, w3, h3);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x4, y4, w4, h4);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x5, y5, w5, h5);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x6, y6, w6, h6);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x7, y7, w7, h7);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x8, y8, w8, h8);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x9, y9, w9, h9);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x10, y10, w10, h10);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x11, y11, w11, h11);
     
    		g.setColor(Color.RED);
    		g.fillRect(x12, y12, w12, h12);
     
    		g.setColor(Color.RED);
    		g.fillRect(x13, y13, w13, h13);
     
    		g.setColor(Color.RED);
    		g.fillRect(x14, y14, w14, h14);
     
    		g.setColor(Color.RED);
    		g.fillRect(x15, y15, w15, h15);
     
    		g.setColor(Color.RED);
    		g.fillRect(x16, y16, w16, h16);
     
    		g.setColor(Color.RED);
    		g.fillRect(x17, y17, w17, h17);
     
    		g.setColor(Color.RED);
    		g.fillRect(x18, y18, w18, h18);
     
    		g.setColor(Color.RED);
    		g.fillRect(x19, y19, w19, h19);
     
    		g.setColor(Color.RED);
    		g.fillRect(x20, y20, w20, h20);
     
    		g.setColor(Color.RED);
    		g.fillRect(x21, y21, w21, h21);
     
    		g.setColor(Color.RED);
    		g.fillRect(x22, y22, w22, h22);
     
    		g.setColor(Color.RED);
    		g.fillRect(x23, y23, w23, h23);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x24, y24, w24, h23);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x25, y25, w25, h23);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x26, y26, w26, h26);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x27, y27, w27, h27);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x28, y28, w28, h28);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x29, y29, w29, h29);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x30, y30, w30, h30);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x31, y31, w31, h31);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x32, y32, w32, h32);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x33, y33, w33, h33);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x34, y34, w34, h34);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x35, y35, w35, h35);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x36, y36, w36, h35);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x37, y37, w37, h35);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x38, y38, w38, h38);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x39, y39, w39, h39);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x40, y40, w40, h40);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x41, y41, w41, h41);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x42, y42, w42, h42);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x43, y43, w43, h43);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x44, y44, w44, h44);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x45, y45, w45, h45);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x46, y46, w46, h46);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x47, y47, w47, h47);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x48, y48, w47, h47);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x49, y49, w49, h49);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x50, y50, w50, h50);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x51, y51, w51, h51);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x52, y52, w52, h52);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x53, y53, w53, h53);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x54, y54, w54, h54);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x55, y55, w55, h55);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x56, y56, w56, h56);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x57, y57, w57, h57);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x58, y58, w58, h58);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x59, y59, w59, h59);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x60, y60, w60, h60);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x61, y61, w61, h61);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x62, y62, w62, h62);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x63, y63, w63, h63);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x64, y64, w64, h64);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x65, y65, w65, h65);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x66, y66, w66, h66);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x67, y67, w67, h67);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x68, y68, w68, h68);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x69, y69, w69, h69);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x70, y70, w70, h70);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x71, y71, w71, h71);
     
     
     
     
     
     
    	}
    	public void keyPressed(KeyEvent e)
    	{
            int c = e.getKeyCode();
     
            if(c == KeyEvent.VK_LEFT){
                velx=-10;
     
            }
     
            if(c == KeyEvent.VK_RIGHT){
                velx=+10;
     
            }
     
        }
     
     
        public void keyTyped(KeyEvent e){}
     
    	public void keyReleased(KeyEvent e){
            velx=0;
     
        }
     
    	public static void main (String args[]) 
    	{
    		Arkanoid obj = new Arkanoid();	
    		frame.setSize(397,600);
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setVisible(true);
    		frame.add(obj);
    	}
    	public void actionPerformed(ActionEvent e)
    	{
    		BarX=BarX+velx;
    		if(BarX<3)
    		{
    			BarX=3;
    			velx=0;
    		}
    		if(BarX>335)
    		{ 
    			BarX=335;
    			velx=0;
    	}
    	if(((BallY+BallH)==BarY)&&((BallX+BallW)>BarX&&BallX<(BarX+BarW))||(BallY<0)){
    	ballspeed=ballspeed*(-1);
    	}
    	BallY=BallY+ballspeed;
     
    	BallX=BallX+vely;
    	if(BallX<0||BallX>370)
    	{
    	vely=-vely;
    	}
     
    		if(y67+h67>=BallY&&x67+w67>=BallX&&x67<=BallX+BallW&&y67<=BallY||y67<=0){
    		labeltimers.setText(Integer.toString(score));
    		score = score +1;
    		}
     
     
     
    			if(BallY>600){
    			tm.stop();
    			System.exit(0);
    			}		
    			repaint();
     
     
    	}
    	}


    I need a help in my program I'm making a game called Arkanoid/Breakout
    the problem, I don't know how the ball collision to bricks.
    Last edited by Totel; October 7th, 2012 at 08:04 AM.
    public class Newbie
    {
      public static void main (String args[])
      { 
     
    	for(int num=0;num<1;num=num+1)
    	{	
    	System.out.println("Dumb");
    	}
     
     
       }
    }

  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: [Arkanoid]Help

    Consider,
    • Changing the [quote] [/quote] tags above to [code=java] [/code] tags. This will help make your posted code retain its formatting and thus be readable.
    • Put in some effort to explain your problem in detail. Right now about all you've done is to dump your code into the forum and implicitly state "fix this for me". A little explanation can go a long way to helping us understand your problem better and thus better know how to help you.
    • Regarding the above, a rule of thumb that I recommend is that you put in as much effort into asking your question here as you'd like one of the volunteers to put in answering it.


    Good luck!

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Location
    Philippines
    Posts
    23
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [Arkanoid]Help

    There you go I edited it !
    Last edited by Totel; October 7th, 2012 at 08:05 AM.
    public class Newbie
    {
      public static void main (String args[])
      { 
     
    	for(int num=0;num<1;num=num+1)
    	{	
    	System.out.println("Dumb");
    	}
     
     
       }
    }

  4. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: [Arkanoid]Help

    Quote Originally Posted by Totel View Post
    You don't understand the problem in my code ?
    No, not really. What is your question? Where are you stuck precisely?

  5. #5
    Junior Member
    Join Date
    Sep 2012
    Location
    Philippines
    Posts
    23
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [Arkanoid]Help

    Quote Originally Posted by curmudgeon View Post
    No, not really. What is your question? Where are you stuck precisely?

    How about if I will show you the output where I'm stucked

    http://oi50.tinypic.com/20sgaxj.jpg

    I can't hit the bricks using that black ball
    public class Newbie
    {
      public static void main (String args[])
      { 
     
    	for(int num=0;num<1;num=num+1)
    	{	
    	System.out.println("Dumb");
    	}
     
     
       }
    }

  6. #6
    Junior Member
    Join Date
    Sep 2012
    Location
    Philippines
    Posts
    23
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [Arkanoid]Help

    Anyone ? Who can help me ?
    public class Newbie
    {
      public static void main (String args[])
      { 
     
    	for(int num=0;num<1;num=num+1)
    	{	
    	System.out.println("Dumb");
    	}
     
     
       }
    }

  7. #7
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: [Arkanoid]Help

    the problem, I don't know how the ball collision to bricks.
    You have to have some way to know where the bricks are, some way to know where the ball is, and compare the locations to see if the ball has hit a brick.

    Suggested reading: Control Flow Statements Specifically the sub-sections regarding loops. Also do some reading on using objects in java.

  8. #8
    Junior Member
    Join Date
    Sep 2012
    Location
    Philippines
    Posts
    23
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [Arkanoid]Help

    Quote Originally Posted by jps View Post
    You have to have some way to know where the bricks are, some way to know where the ball is, and compare the locations to see if the ball has hit a brick.

    Suggested reading: Control Flow Statements Specifically the sub-sections regarding loops. Also do some reading on using objects in java.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.Random;
    import java.io.*;
    import java.awt.Color;
    import java.awt.event.ActionEvent;
     
    	public class Arkanoid extends JPanel implements ActionListener, KeyListener {
    	static JFrame frame = new JFrame();
    	static JFrame frame2 = new JFrame();
    	Timer tm = new Timer(25, this);
    	static JButton btnStart = new JButton("Start");
    	static int BallX=238, BallY=505, BallW=15, BallH=15;
    	static int BarX=220, BarY=520, BarW=45, BarH=10;
     
    	static int x=3     ,y=60 ,  w=30 ,  h=15, yg=60, ygray=60;
    	static int x1=35   ,y1=60,  w1=30,  h1=15, yg1=60, ygray1=60;
    	static int x2=67   ,y2=60,  w2=30,  h2=15, yg2=60, ygray2=60;
    	static int x3=99   ,y3=60,  w3=30,  h3=15, yg3=60, ygray3=60;
    	static int x4=131  ,y4=60,  w4=30,  h4=15, yg4=60, ygray4=60;
    	static int x5=163  ,y5=60,  w5=30,  h5=15, yg5=60, ygray5=60;
    	static int x6=195  ,y6=60,  w6=30,  h6=15, yg6=60, ygray6=60;
    	static int x7=227  ,y7=60,  w7=30,  h7=15, yg7=60, ygray7=60;
    	static int x8=259  ,y8=60,  w8=30,  h8=15, yg8=60, ygray8=60;
    	static int x9=291  ,y9=60,  w9=30,  h9=15, yg9=60, ygray9=60;
    	static int x10=323 ,y10=60, w10=30, h10=15, yg10=60, ygray10=60;
    	static int x11=355 ,y11=60, w11=30, h11=15, yg11=60, ygray11=60;
     
    	static int x12=3    ,y12=77,  w12=30,  h12=15;
    	static int x13=35   ,y13=77,  w13=30,  h13=15;
    	static int x14=67   ,y14=77,  w14=30,  h14=15;
    	static int x15=99   ,y15=77,  w15=30,  h15=15;
    	static int x16=131  ,y16=77,  w16=30,  h16=15;
    	static int x17=163  ,y17=77,  w17=30,  h17=15;
    	static int x18=195  ,y18=77,  w18=30,  h18=15;
    	static int x19=227  ,y19=77,  w19=30,  h19=15;
    	static int x20=259  ,y20=77,  w20=30,  h20=15;
    	static int x21=291  ,y21=77,  w21=30,  h21=15;
    	static int x22=323  ,y22=77,  w22=30,  h22=15;
    	static int x23=355  ,y23=77,  w23=30,  h23=15;
     
    	static int x24=3    ,y24=95,  w24=30,  h24=15;
    	static int x25=35   ,y25=95,  w25=30,  h25=15;
    	static int x26=67   ,y26=95,  w26=30,  h26=15;
    	static int x27=99   ,y27=95,  w27=30,  h27=15;
    	static int x28=131  ,y28=95,  w28=30,  h28=15;
    	static int x29=163  ,y29=95,  w29=30,  h29=15;
    	static int x30=195  ,y30=95,  w30=30,  h30=15;
    	static int x31=227  ,y31=95,  w31=30,  h31=15;
    	static int x32=259  ,y32=95,  w32=30,  h32=15;
    	static int x33=291  ,y33=95,  w33=30,  h33=15;
    	static int x34=323  ,y34=95,  w34=30,  h34=15;
    	static int x35=355  ,y35=95,  w35=30,  h35=15;
     
    	static int x36=3    ,y36=113,  w36=30,  h36=15;
    	static int x37=35   ,y37=113,  w37=30,  h37=15;
    	static int x38=67   ,y38=113,  w38=30,  h38=15;
    	static int x39=99   ,y39=113,  w39=30,  h39=15;
    	static int x40=131  ,y40=113,  w40=30,  h40=15;
    	static int x41=163  ,y41=113,  w41=30,  h41=15;
    	static int x42=195  ,y42=113,  w42=30,  h42=15;
    	static int x43=227  ,y43=113,  w43=30,  h43=15;
    	static int x44=259  ,y44=113,  w44=30,  h44=15;
    	static int x45=291  ,y45=113,  w45=30,  h45=15;
    	static int x46=323  ,y46=113,  w46=30,  h46=15;
    	static int x47=355  ,y47=113,  w47=30,  h47=15;
     
    	static int x48=3    ,y48=130,  w48=30,  h48=15;
    	static int x49=35   ,y49=130,  w49=30,  h49=15;
    	static int x50=67   ,y50=130,  w50=30,  h50=15;
    	static int x51=99   ,y51=130,  w51=30,  h51=15;
    	static int x52=131  ,y52=130,  w52=30,  h52=15;
    	static int x53=163  ,y53=130,  w53=30,  h53=15;
    	static int x54=195  ,y54=130,  w54=30,  h54=15;
    	static int x55=227  ,y55=130,  w55=30,  h55=15;
    	static int x56=259  ,y56=130,  w56=30,  h56=15;
    	static int x57=291  ,y57=130,  w57=30,  h57=15;
    	static int x58=323  ,y58=130,  w58=30,  h58=15;
    	static int x59=355  ,y59=130,  w59=30,  h59=15;
     
    	static int x60=3    ,y60=148,  w60=30,  h60=15;
    	static int x61=35   ,y61=148,  w61=30,  h61=15;
    	static int x62=67   ,y62=148,  w62=30,  h62=15;
    	static int x63=99   ,y63=148,  w63=30,  h63=15;
    	static int x64=131  ,y64=148,  w64=30,  h64=15;
    	static int x65=163  ,y65=148,  w65=30,  h65=15;
    	static int x66=195  ,y66=148,  w66=30,  h66=15;
    	static int x67=227  ,y67=148,  w67=30,  h67=15;
    	static int x68=259  ,y68=148,  w68=30,  h68=15;
    	static int x69=291  ,y69=148,  w69=30,  h69=15;
    	static int x70=323  ,y70=148,  w70=30,  h70=15;
    	static int x71=355  ,y71=148,  w71=30,  h71=15;
     
    	static int velx=0;
    	static int vely=6;
    	static int count=0;
    	int ballspeed=10;
    	static int score=0;
    	static int second=0;
    	static JLabel labeltimers;
    	static JLabel lblscore;
    	static JLabel ScoreLabel;
     
    	public Arkanoid()
    	{
    	ScoreLabel = new JLabel ("Score:");
    	ScoreLabel.setBounds(5,545,100,20);
    	add(ScoreLabel);
    	labeltimers = new JLabel("0");
    	labeltimers.setBounds(45,545,100,20);
    	add(labeltimers);
     
    		tm.start();
    		setVisible(true);
    		setLayout(null);
    		this.requestFocus();
    		addKeyListener(this);
            setFocusable(true);
            setFocusTraversalKeysEnabled(false);
    	}
    	public void paintComponent(Graphics g)
    	{
     
    		super.paintComponent(g);
     
    		g.setColor(Color.BLACK);
    		g.fillOval(BallX, BallY, BallW, BallH);
     
    		g.setColor(Color.BLUE);
    		g.fillRect(BarX, BarY, BarW ,BarH);
     
    		//Bricks with 3 hits
    		g.setColor(Color.GRAY);
    		g.fillRect(x, yg, w, h);
    		g.setColor(Color.GRAY);
    		g.fillRect(x, ygray, w, h);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x1, yg1, w1, h1);
    		g.setColor(Color.GRAY);
    		g.fillRect(x1, ygray1, w1, h1);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x2, yg2, w2, h2);
    		g.setColor(Color.GRAY);
    		g.fillRect(x2, ygray2, w2, h2);		
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x3, yg3, w3, h3);
    		g.setColor(Color.GRAY);
    		g.fillRect(x3, ygray3, w3, h3);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x4, yg4, w4, h4);
    		g.setColor(Color.GRAY);
    		g.fillRect(x4, ygray4, w4, h4);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x5, yg5, w5, h5);
    		g.setColor(Color.GRAY);
    		g.fillRect(x5, ygray5, w5, h5);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x6, yg6, w6, h6);
    		g.setColor(Color.GRAY);
    		g.fillRect(x6, ygray6, w6, h6);		
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x7, yg7, w7, h7);
    		g.setColor(Color.GRAY);
    		g.fillRect(x7, ygray7, w7, h7);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x8, yg8, w8, h8);
    		g.setColor(Color.GRAY);
    		g.fillRect(x8, ygray8, w8, h8);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x9, yg9, w9, h9);
    		g.setColor(Color.GRAY);
    		g.fillRect(x9, ygray9, w9, h9);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x10, yg10, w10, h10);
    		g.setColor(Color.GRAY);
    		g.fillRect(x10, ygray10, w10, h10);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x11, yg11, w11, h11);
    		g.setColor(Color.GRAY);
    		g.fillRect(x11, ygray11, w11, h11);
     
     
    		//Bricks
    		g.setColor(Color.GRAY);
    		g.fillRect(x, y, w, h);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x1, y1, w1, h1);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x2, y2, w2, h2);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x3, y3, w3, h3);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x4, y4, w4, h4);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x5, y5, w5, h5);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x6, y6, w6, h6);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x7, y7, w7, h7);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x8, y8, w8, h8);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x9, y9, w9, h9);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x10, y10, w10, h10);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x11, y11, w11, h11);
     
    		g.setColor(Color.RED);
    		g.fillRect(x12, y12, w12, h12);
     
    		g.setColor(Color.RED);
    		g.fillRect(x13, y13, w13, h13);
     
    		g.setColor(Color.RED);
    		g.fillRect(x14, y14, w14, h14);
     
    		g.setColor(Color.RED);
    		g.fillRect(x15, y15, w15, h15);
     
    		g.setColor(Color.RED);
    		g.fillRect(x16, y16, w16, h16);
     
    		g.setColor(Color.RED);
    		g.fillRect(x17, y17, w17, h17);
     
    		g.setColor(Color.RED);
    		g.fillRect(x18, y18, w18, h18);
     
    		g.setColor(Color.RED);
    		g.fillRect(x19, y19, w19, h19);
     
    		g.setColor(Color.RED);
    		g.fillRect(x20, y20, w20, h20);
     
    		g.setColor(Color.RED);
    		g.fillRect(x21, y21, w21, h21);
     
    		g.setColor(Color.RED);
    		g.fillRect(x22, y22, w22, h22);
     
    		g.setColor(Color.RED);
    		g.fillRect(x23, y23, w23, h23);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x24, y24, w24, h23);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x25, y25, w25, h23);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x26, y26, w26, h26);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x27, y27, w27, h27);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x28, y28, w28, h28);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x29, y29, w29, h29);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x30, y30, w30, h30);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x31, y31, w31, h31);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x32, y32, w32, h32);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x33, y33, w33, h33);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x34, y34, w34, h34);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x35, y35, w35, h35);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x36, y36, w36, h35);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x37, y37, w37, h35);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x38, y38, w38, h38);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x39, y39, w39, h39);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x40, y40, w40, h40);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x41, y41, w41, h41);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x42, y42, w42, h42);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x43, y43, w43, h43);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x44, y44, w44, h44);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x45, y45, w45, h45);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x46, y46, w46, h46);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x47, y47, w47, h47);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x48, y48, w47, h47);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x49, y49, w49, h49);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x50, y50, w50, h50);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x51, y51, w51, h51);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x52, y52, w52, h52);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x53, y53, w53, h53);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x54, y54, w54, h54);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x55, y55, w55, h55);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x56, y56, w56, h56);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x57, y57, w57, h57);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x58, y58, w58, h58);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x59, y59, w59, h59);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x60, y60, w60, h60);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x61, y61, w61, h61);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x62, y62, w62, h62);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x63, y63, w63, h63);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x64, y64, w64, h64);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x65, y65, w65, h65);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x66, y66, w66, h66);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x67, y67, w67, h67);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x68, y68, w68, h68);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x69, y69, w69, h69);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x70, y70, w70, h70);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x71, y71, w71, h71);
     
    	}
    	public void keyPressed(KeyEvent e)
    	{
            int c = e.getKeyCode();
     
            if(c == KeyEvent.VK_LEFT){
                velx=-10;
     
            }
     
            if(c == KeyEvent.VK_RIGHT){
                velx=+10;
     
            }
     
        }
        public void keyTyped(KeyEvent e){}
     
    	public void keyReleased(KeyEvent e){
            velx=0;
     
        }
     
    	public static void main (String args[])
    	{
    		Arkanoid obj = new Arkanoid();
    		frame.setSize(397,600);
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setVisible(true);
    		frame.add(obj);
    	}
    	public void actionPerformed(ActionEvent e)
    	{
    		BarX=BarX+velx;
    		if(BarX<3)
    		{
    			BarX=3;
    			velx=0;
    		}
    		if(BarX>340)
    		{
    			BarX=340;
    			velx=0;
    		}
    	if(((BallY+BallH)==BarY)&&((BallX+BallW)>BarX&&BallX<(BarX+BarW))||(BallY<0)){
    	ballspeed=ballspeed*(-1);
    	}
    	BallY=BallY+ballspeed;
    	BallX=BallX+vely;
    	if(BallX<0||BallX>370)
    	{
    	vely=-vely;
    	}
     
    		if(y71+h71>=BallY&&x71+w71>=BallX&&x71<=BallX+BallW&&y71<=BallY||y71<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y71=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y70+h70>=BallY&&x70+w70>=BallX&&x70<=BallX+BallW&&y70<=BallY||y70<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y70=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y69+h69>=BallY&&x69+w69>=BallX&&x69<=BallX+BallW&&y69<=BallY||y69<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y69=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y68+h68>=BallY&&x68+w68>=BallX&&x68<=BallX+BallW&&y68<=BallY||y68<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y68=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y67+h67>=BallY&&x67+w67>=BallX&&x67<=BallX+BallW&&y67<=BallY||y67<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y67=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y67+h67>=BallY&&x67+w67>=BallX&&x67<=BallX+BallW&&y67<=BallY||y67<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y67=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y66+h66>=BallY&&x66+w66>=BallX&&x66<=BallX+BallW&&y66<=BallY||y66<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y66=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y65+h65>=BallY&&x65+w65>=BallX&&x65<=BallX+BallW&&y65<=BallY||y65<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y65=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y64+h64>=BallY&&x64+w64>=BallX&&x64<=BallX+BallW&&y64<=BallY||y64<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y64=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y63+h63>=BallY&&x63+w63>=BallX&&x63<=BallX+BallW&&y63<=BallY||y63<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y63=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y62+h62>=BallY&&x62+w62>=BallX&&x62<=BallX+BallW&&y62<=BallY||y62<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y62=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y61+h61>=BallY&&x61+w61>=BallX&&x61<=BallX+BallW&&y61<=BallY||y61<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y61=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y60+h60>=BallY&&x60+w60>=BallX&&x60<=BallX+BallW&&y60<=BallY||y60<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y60=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y59+h59>=BallY&&x59+w59>=BallX&&x59<=BallX+BallW&&y59<=BallY||y59<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y59=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y58+h58>=BallY&&x58+w58>=BallX&&x58<=BallX+BallW&&y58<=BallY||y58<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y58=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y57+h57>=BallY&&x57+w57>=BallX&&x57<=BallX+BallW&&y57<=BallY||y57<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y57=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y56+h56>=BallY&&x56+w56>=BallX&&x56<=BallX+BallW&&y56<=BallY||y56<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y56=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y55+h55>=BallY&&x55+w55>=BallX&&x55<=BallX+BallW&&y55<=BallY||y55<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y55=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y54+h54>=BallY&&x54+w54>=BallX&&x54<=BallX+BallW&&y54<=BallY||y54<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y54=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y53+h53>=BallY&&x53+w53>=BallX&&x53<=BallX+BallW&&y53<=BallY||y53<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y53=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y52+h52>=BallY&&x52+w52>=BallX&&x52<=BallX+BallW&&y52<=BallY||y52<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y52=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y51+h51>=BallY&&x51+w51>=BallX&&x51<=BallX+BallW&&y51<=BallY||y51<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y51=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y50+h50>=BallY&&x50+w52>=BallX&&x50<=BallX+BallW&&y50<=BallY||y50<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y50=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y49+h49>=BallY&&x49+w49>=BallX&&x49<=BallX+BallW&&y49<=BallY||y49<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y49=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y48+h48>=BallY&&x48+w48>=BallX&&x48<=BallX+BallW&&y48<=BallY||y48<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y48=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y47+h47>=BallY&&x47+w47>=BallX&&x47<=BallX+BallW&&y47<=BallY||y47<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y47=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y46+h46>=BallY&&x46+w46>=BallX&&x46<=BallX+BallW&&y46<=BallY||y46<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y46=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y45+h45>=BallY&&x45+w45>=BallX&&x45<=BallX+BallW&&y45<=BallY||y45<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y45=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y44+h44>=BallY&&x44+w44>=BallX&&x44<=BallX+BallW&&y44<=BallY||y44<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y44=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y43+h43>=BallY&&x43+w43>=BallX&&x43<=BallX+BallW&&y43<=BallY||y43<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y43=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y42+h42>=BallY&&x42+w42>=BallX&&x42<=BallX+BallW&&y42<=BallY||y42<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y42=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y41+h41>=BallY&&x41+w41>=BallX&&x41<=BallX+BallW&&y41<=BallY||y41<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y41=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y40+h40>=BallY&&x40+w40>=BallX&&x40<=BallX+BallW&&y40<=BallY||y40<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y40=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y39+h39>=BallY&&x39+w39>=BallX&&x39<=BallX+BallW&&y39<=BallY||y39<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y39=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y38+h38>=BallY&&x38+w38>=BallX&&x38<=BallX+BallW&&y38<=BallY||y38<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y38=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y37+h37>=BallY&&x37+w37>=BallX&&x37<=BallX+BallW&&y37<=BallY||y37<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y37=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y36+h36>=BallY&&x36+w36>=BallX&&x36<=BallX+BallW&&y36<=BallY||y36<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y36=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y35+h35>=BallY&&x35+w35>=BallX&&x35<=BallX+BallW&&y35<=BallY||y35<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y35=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y34+h34>=BallY&&x34+w34>=BallX&&x34<=BallX+BallW&&y34<=BallY||y34<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y34=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y33+h33>=BallY&&x33+w33>=BallX&&x33<=BallX+BallW&&y33<=BallY||y33<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y33=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y32+h32>=BallY&&x32+w32>=BallX&&x32<=BallX+BallW&&y32<=BallY||y32<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y32=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y31+h31>=BallY&&x31+w31>=BallX&&x31<=BallX+BallW&&y31<=BallY||y31<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y31=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y30+h30>=BallY&&x30+w30>=BallX&&x30<=BallX+BallW&&y30<=BallY||y30<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y30=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y29+h29>=BallY&&x29+w29>=BallX&&x29<=BallX+BallW&&y29<=BallY||y29<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y29=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y28+h28>=BallY&&x28+w28>=BallX&&x28<=BallX+BallW&&y28<=BallY||y28<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y28=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}		
     
    		if(y27+h27>=BallY&&x27+w27>=BallX&&x27<=BallX+BallW&&y27<=BallY||y27<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y27=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}		
     
    		if(y26+h26>=BallY&&x26+w26>=BallX&&x26<=BallX+BallW&&y26<=BallY||y26<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y26=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y25+h25>=BallY&&x25+w25>=BallX&&x25<=BallX+BallW&&y25<=BallY||y25<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y25=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y24+h24>=BallY&&x24+w24>=BallX&&x24<=BallX+BallW&&y24<=BallY||y24<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y24=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y23+h23>=BallY&&x23+w23>=BallX&&x23<=BallX+BallW&&y23<=BallY||y23<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y23=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y22+h22>=BallY&&x22+w22>=BallX&&x22<=BallX+BallW&&y22<=BallY||y22<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y22=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y21+h21>=BallY&&x21+w21>=BallX&&x21<=BallX+BallW&&y21<=BallY||y21<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y21=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y20+h20>=BallY&&x20+w20>=BallX&&x20<=BallX+BallW&&y20<=BallY||y20<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y20=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y19+h19>=BallY&&x19+w19>=BallX&&x19<=BallX+BallW&&y19<=BallY||y19<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y19=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}	
     
    		if(y18+h18>=BallY&&x18+w18>=BallX&&x18<=BallX+BallW&&y18<=BallY||y18<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y18=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y17+h17>=BallY&&x17+w17>=BallX&&x17<=BallX+BallW&&y17<=BallY||y17<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y17=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}	
     
    		if(y16+h16>=BallY&&x16+w16>=BallX&&x16<=BallX+BallW&&y16<=BallY||y16<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y16=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y15+h15>=BallY&&x15+w15>=BallX&&x15<=BallX+BallW&&y15<=BallY||y15<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y15=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}	
     
    		if(y14+h14>=BallY&&x14+w14>=BallX&&x14<=BallX+BallW&&y14<=BallY||y14<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y14=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}	
     
    		if(y13+h13>=BallY&&x13+w13>=BallX&&x13<=BallX+BallW&&y13<=BallY||y13<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y13=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y12+h12>=BallY&&x12+w12>=BallX&&x12<=BallX+BallW&&y12<=BallY||y12<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y12=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		} 	
     
    		if(ygray11+h11>=BallY&&x11+w11>=BallX&&x11<=BallX+BallW&&ygray11<=BallY||ygray11<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray11=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(yg11+h11>=BallY&&x11+w11>=BallX&&x11<=BallX+BallW&&yg11<=BallY||yg11<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg11=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y11+h11>=BallY&&x11+w11>=BallX&&x11<=BallX+BallW&&y11<=BallY||y11<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y11=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(ygray10+h10>=BallY&&x10+w10>=BallX&&x10<=BallX+BallW&&ygray10<=BallY||ygray10<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray10=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg10+h10>=BallY&&x10+w10>=BallX&&x10<=BallX+BallW&&yg10<=BallY||yg10<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg10=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y10+h10>=BallY&&x10+w10>=BallX&&x10<=BallX+BallW&&y10<=BallY||y10<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y10=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray9+h9>=BallY&&x9+w9>=BallX&&x9<=BallX+BallW&&ygray9<=BallY||ygray9<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray9=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg9+h9>=BallY&&x9+w9>=BallX&&x9<=BallX+BallW&&yg9<=BallY||yg9<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg9=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y9+h9>=BallY&&x9+w9>=BallX&&x9<=BallX+BallW&&y9<=BallY||y9<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y9=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray8+h8>=BallY&&x8+w8>=BallX&&x8<=BallX+BallW&&ygray8<=BallY||ygray8<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray8=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg8+h8>=BallY&&x8+w8>=BallX&&x8<=BallX+BallW&&yg8<=BallY||yg8<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg8=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y8+h8>=BallY&&x8+w8>=BallX&&x8<=BallX+BallW&&y8<=BallY||y8<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y8=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray7+h7>=BallY&&x7+w7>=BallX&&x7<=BallX+BallW&&ygray7<=BallY||ygray7<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray7=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg7+h7>=BallY&&x7+w7>=BallX&&x7<=BallX+BallW&&yg7<=BallY||yg7<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg7=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y7+h7>=BallY&&x7+w7>=BallX&&x7<=BallX+BallW&&y7<=BallY||y7<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y7=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}		
     
     
    		if(ygray6+h6>=BallY&&x6+w6>=BallX&&x6<=BallX+BallW&&ygray6<=BallY||ygray6<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray6=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg6+h6>=BallY&&x6+w6>=BallX&&x6<=BallX+BallW&&yg6<=BallY||yg6<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg6=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y6+h6>=BallY&&x6+w6>=BallX&&x6<=BallX+BallW&&y6<=BallY||y6<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y6=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray5+h5>=BallY&&x5+w5>=BallX&&x5<=BallX+BallW&&ygray5<=BallY||ygray5<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray5=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg5+h5>=BallY&&x5+w5>=BallX&&x5<=BallX+BallW&&yg5<=BallY||yg5<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg5=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y5+h5>=BallY&&x5+w5>=BallX&&x5<=BallX+BallW&&y5<=BallY||y5<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y5=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray4+h4>=BallY&&x4+w4>=BallX&&x4<=BallX+BallW&&ygray4<=BallY||ygray4<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray4=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg4+h4>=BallY&&x4+w4>=BallX&&x4<=BallX+BallW&&yg4<=BallY||yg4<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg4=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y4+h4>=BallY&&x4+w4>=BallX&&x4<=BallX+BallW&&y4<=BallY||y4<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y4=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray3+h3>=BallY&&x3+w3>=BallX&&x3<=BallX+BallW&&ygray3<=BallY||ygray3<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray3=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg3+h3>=BallY&&x3+w10>=BallX&&x3<=BallX+BallW&&yg3<=BallY||yg3<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg3=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y3+h3>=BallY&&x3+w3>=BallX&&x3<=BallX+BallW&&y3<=BallY||y3<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y3=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray2+h2>=BallY&&x2+w2>=BallX&&x2<=BallX+BallW&&ygray2<=BallY||ygray2<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray2=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg2+h2>=BallY&&x2+w2>=BallX&&x2<=BallX+BallW&&yg2<=BallY||yg2<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg2=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y2+h2>=BallY&&x2+w2>=BallX&&x2<=BallX+BallW&&y2<=BallY||y2<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y2=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray1+h1>=BallY&&x1+w1>=BallX&&x1<=BallX+BallW&&ygray1<=BallY||ygray1<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray1=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg1+h1>=BallY&&x1+w1>=BallX&&x1<=BallX+BallW&&yg1<=BallY||yg1<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg1=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y1+h1>=BallY&&x1+w1>=BallX&&x1<=BallX+BallW&&y1<=BallY||y1<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y1=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(ygray+h>=BallY&&x+w>=BallX&&x<=BallX+BallW&&ygray<=BallY||ygray<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg+h>=BallY&&x+w>=BallX&&x<=BallX+BallW&&yg<=BallY||yg<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y+h>=BallY&&x+w>=BallX&&x<=BallX+BallW&&y<=BallY||y<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(score==96)
    		{
    			JOptionPane.showMessageDialog(null,"Stage 2");
    			BallX=238; BallY=505; BallW=15; BallH=15;
    			BarX=220; BarY=520; BarW=45; BarH=10;
    			ballspeed=10;
    			ygray=350;yg=350;y=350;
    			ygray1=350;yg1=350;y1=350;
    			ygray2=350;yg2=350;y2=350;
    			ygray3=350;yg3=350;y3=350;
    			ygray4=350;yg4=350;y4=350;
    			ygray5=350;yg5=350;y5=350;
    			ygray6=350;yg6=350;y6=350;
    			ygray7=350;yg7=350;y7=350;
    			ygray8=350;yg8=350;y8=350;
    			ygray9=350;yg9=350;y9=350;
    			ygray10=350;yg10=350;y10=350;
    			ygray11=350;yg11=350;y11=350;
     
     
    			score=score+1;
    		}
     
     
    			if(BallY>600){
    			tm.stop();
    			System.exit(0);
    			}
    			repaint();
     
     
    	}
    	}

    Can you run my program and check if it is fine ?
    public class Newbie
    {
      public static void main (String args[])
      { 
     
    	for(int num=0;num<1;num=num+1)
    	{	
    	System.out.println("Dumb");
    	}
     
     
       }
    }

  9. #9
    Junior Member
    Join Date
    Sep 2012
    Location
    Philippines
    Posts
    23
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [Arkanoid]Help

    Quote Originally Posted by jps View Post
    You have to have some way to know where the bricks are, some way to know where the ball is, and compare the locations to see if the ball has hit a brick.

    Suggested reading: Control Flow Statements Specifically the sub-sections regarding loops. Also do some reading on using objects in java.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.Random;
    import java.io.*;
    import java.awt.Color;
    import java.awt.event.ActionEvent;
     
    	public class Arkanoid extends JPanel implements ActionListener, KeyListener {
    	static JFrame frame = new JFrame();
    	static JFrame frame2 = new JFrame();
    	Timer tm = new Timer(25, this);
    	static JButton btnStart = new JButton("Start");
    	static int BallX=238, BallY=505, BallW=15, BallH=15;
    	static int BarX=220, BarY=520, BarW=45, BarH=10;
     
    	static int x=3     ,y=60 ,  w=30 ,  h=15, yg=60, ygray=60;
    	static int x1=35   ,y1=60,  w1=30,  h1=15, yg1=60, ygray1=60;
    	static int x2=67   ,y2=60,  w2=30,  h2=15, yg2=60, ygray2=60;
    	static int x3=99   ,y3=60,  w3=30,  h3=15, yg3=60, ygray3=60;
    	static int x4=131  ,y4=60,  w4=30,  h4=15, yg4=60, ygray4=60;
    	static int x5=163  ,y5=60,  w5=30,  h5=15, yg5=60, ygray5=60;
    	static int x6=195  ,y6=60,  w6=30,  h6=15, yg6=60, ygray6=60;
    	static int x7=227  ,y7=60,  w7=30,  h7=15, yg7=60, ygray7=60;
    	static int x8=259  ,y8=60,  w8=30,  h8=15, yg8=60, ygray8=60;
    	static int x9=291  ,y9=60,  w9=30,  h9=15, yg9=60, ygray9=60;
    	static int x10=323 ,y10=60, w10=30, h10=15, yg10=60, ygray10=60;
    	static int x11=355 ,y11=60, w11=30, h11=15, yg11=60, ygray11=60;
     
    	static int x12=3    ,y12=77,  w12=30,  h12=15;
    	static int x13=35   ,y13=77,  w13=30,  h13=15;
    	static int x14=67   ,y14=77,  w14=30,  h14=15;
    	static int x15=99   ,y15=77,  w15=30,  h15=15;
    	static int x16=131  ,y16=77,  w16=30,  h16=15;
    	static int x17=163  ,y17=77,  w17=30,  h17=15;
    	static int x18=195  ,y18=77,  w18=30,  h18=15;
    	static int x19=227  ,y19=77,  w19=30,  h19=15;
    	static int x20=259  ,y20=77,  w20=30,  h20=15;
    	static int x21=291  ,y21=77,  w21=30,  h21=15;
    	static int x22=323  ,y22=77,  w22=30,  h22=15;
    	static int x23=355  ,y23=77,  w23=30,  h23=15;
     
    	static int x24=3    ,y24=95,  w24=30,  h24=15;
    	static int x25=35   ,y25=95,  w25=30,  h25=15;
    	static int x26=67   ,y26=95,  w26=30,  h26=15;
    	static int x27=99   ,y27=95,  w27=30,  h27=15;
    	static int x28=131  ,y28=95,  w28=30,  h28=15;
    	static int x29=163  ,y29=95,  w29=30,  h29=15;
    	static int x30=195  ,y30=95,  w30=30,  h30=15;
    	static int x31=227  ,y31=95,  w31=30,  h31=15;
    	static int x32=259  ,y32=95,  w32=30,  h32=15;
    	static int x33=291  ,y33=95,  w33=30,  h33=15;
    	static int x34=323  ,y34=95,  w34=30,  h34=15;
    	static int x35=355  ,y35=95,  w35=30,  h35=15;
     
    	static int x36=3    ,y36=113,  w36=30,  h36=15;
    	static int x37=35   ,y37=113,  w37=30,  h37=15;
    	static int x38=67   ,y38=113,  w38=30,  h38=15;
    	static int x39=99   ,y39=113,  w39=30,  h39=15;
    	static int x40=131  ,y40=113,  w40=30,  h40=15;
    	static int x41=163  ,y41=113,  w41=30,  h41=15;
    	static int x42=195  ,y42=113,  w42=30,  h42=15;
    	static int x43=227  ,y43=113,  w43=30,  h43=15;
    	static int x44=259  ,y44=113,  w44=30,  h44=15;
    	static int x45=291  ,y45=113,  w45=30,  h45=15;
    	static int x46=323  ,y46=113,  w46=30,  h46=15;
    	static int x47=355  ,y47=113,  w47=30,  h47=15;
     
    	static int x48=3    ,y48=130,  w48=30,  h48=15;
    	static int x49=35   ,y49=130,  w49=30,  h49=15;
    	static int x50=67   ,y50=130,  w50=30,  h50=15;
    	static int x51=99   ,y51=130,  w51=30,  h51=15;
    	static int x52=131  ,y52=130,  w52=30,  h52=15;
    	static int x53=163  ,y53=130,  w53=30,  h53=15;
    	static int x54=195  ,y54=130,  w54=30,  h54=15;
    	static int x55=227  ,y55=130,  w55=30,  h55=15;
    	static int x56=259  ,y56=130,  w56=30,  h56=15;
    	static int x57=291  ,y57=130,  w57=30,  h57=15;
    	static int x58=323  ,y58=130,  w58=30,  h58=15;
    	static int x59=355  ,y59=130,  w59=30,  h59=15;
     
    	static int x60=3    ,y60=148,  w60=30,  h60=15;
    	static int x61=35   ,y61=148,  w61=30,  h61=15;
    	static int x62=67   ,y62=148,  w62=30,  h62=15;
    	static int x63=99   ,y63=148,  w63=30,  h63=15;
    	static int x64=131  ,y64=148,  w64=30,  h64=15;
    	static int x65=163  ,y65=148,  w65=30,  h65=15;
    	static int x66=195  ,y66=148,  w66=30,  h66=15;
    	static int x67=227  ,y67=148,  w67=30,  h67=15;
    	static int x68=259  ,y68=148,  w68=30,  h68=15;
    	static int x69=291  ,y69=148,  w69=30,  h69=15;
    	static int x70=323  ,y70=148,  w70=30,  h70=15;
    	static int x71=355  ,y71=148,  w71=30,  h71=15;
     
    	static int velx=0;
    	static int vely=6;
    	static int count=0;
    	int ballspeed=10;
    	static int score=0;
    	static int second=0;
    	static JLabel labeltimers;
    	static JLabel lblscore;
    	static JLabel ScoreLabel;
     
    	public Arkanoid()
    	{
    	ScoreLabel = new JLabel ("Score:");
    	ScoreLabel.setBounds(5,545,100,20);
    	add(ScoreLabel);
    	labeltimers = new JLabel("0");
    	labeltimers.setBounds(45,545,100,20);
    	add(labeltimers);
     
    		tm.start();
    		setVisible(true);
    		setLayout(null);
    		this.requestFocus();
    		addKeyListener(this);
            setFocusable(true);
            setFocusTraversalKeysEnabled(false);
    	}
    	public void paintComponent(Graphics g)
    	{
     
    		super.paintComponent(g);
     
    		g.setColor(Color.BLACK);
    		g.fillOval(BallX, BallY, BallW, BallH);
     
    		g.setColor(Color.BLUE);
    		g.fillRect(BarX, BarY, BarW ,BarH);
     
    		//Bricks with 3 hits
    		g.setColor(Color.GRAY);
    		g.fillRect(x, yg, w, h);
    		g.setColor(Color.GRAY);
    		g.fillRect(x, ygray, w, h);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x1, yg1, w1, h1);
    		g.setColor(Color.GRAY);
    		g.fillRect(x1, ygray1, w1, h1);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x2, yg2, w2, h2);
    		g.setColor(Color.GRAY);
    		g.fillRect(x2, ygray2, w2, h2);		
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x3, yg3, w3, h3);
    		g.setColor(Color.GRAY);
    		g.fillRect(x3, ygray3, w3, h3);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x4, yg4, w4, h4);
    		g.setColor(Color.GRAY);
    		g.fillRect(x4, ygray4, w4, h4);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x5, yg5, w5, h5);
    		g.setColor(Color.GRAY);
    		g.fillRect(x5, ygray5, w5, h5);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x6, yg6, w6, h6);
    		g.setColor(Color.GRAY);
    		g.fillRect(x6, ygray6, w6, h6);		
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x7, yg7, w7, h7);
    		g.setColor(Color.GRAY);
    		g.fillRect(x7, ygray7, w7, h7);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x8, yg8, w8, h8);
    		g.setColor(Color.GRAY);
    		g.fillRect(x8, ygray8, w8, h8);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x9, yg9, w9, h9);
    		g.setColor(Color.GRAY);
    		g.fillRect(x9, ygray9, w9, h9);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x10, yg10, w10, h10);
    		g.setColor(Color.GRAY);
    		g.fillRect(x10, ygray10, w10, h10);
     
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x11, yg11, w11, h11);
    		g.setColor(Color.GRAY);
    		g.fillRect(x11, ygray11, w11, h11);
     
     
    		//Bricks
    		g.setColor(Color.GRAY);
    		g.fillRect(x, y, w, h);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x1, y1, w1, h1);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x2, y2, w2, h2);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x3, y3, w3, h3);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x4, y4, w4, h4);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x5, y5, w5, h5);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x6, y6, w6, h6);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x7, y7, w7, h7);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x8, y8, w8, h8);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x9, y9, w9, h9);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x10, y10, w10, h10);
     
    		g.setColor(Color.GRAY);
    		g.fillRect(x11, y11, w11, h11);
     
    		g.setColor(Color.RED);
    		g.fillRect(x12, y12, w12, h12);
     
    		g.setColor(Color.RED);
    		g.fillRect(x13, y13, w13, h13);
     
    		g.setColor(Color.RED);
    		g.fillRect(x14, y14, w14, h14);
     
    		g.setColor(Color.RED);
    		g.fillRect(x15, y15, w15, h15);
     
    		g.setColor(Color.RED);
    		g.fillRect(x16, y16, w16, h16);
     
    		g.setColor(Color.RED);
    		g.fillRect(x17, y17, w17, h17);
     
    		g.setColor(Color.RED);
    		g.fillRect(x18, y18, w18, h18);
     
    		g.setColor(Color.RED);
    		g.fillRect(x19, y19, w19, h19);
     
    		g.setColor(Color.RED);
    		g.fillRect(x20, y20, w20, h20);
     
    		g.setColor(Color.RED);
    		g.fillRect(x21, y21, w21, h21);
     
    		g.setColor(Color.RED);
    		g.fillRect(x22, y22, w22, h22);
     
    		g.setColor(Color.RED);
    		g.fillRect(x23, y23, w23, h23);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x24, y24, w24, h23);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x25, y25, w25, h23);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x26, y26, w26, h26);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x27, y27, w27, h27);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x28, y28, w28, h28);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x29, y29, w29, h29);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x30, y30, w30, h30);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x31, y31, w31, h31);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x32, y32, w32, h32);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x33, y33, w33, h33);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x34, y34, w34, h34);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(x35, y35, w35, h35);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x36, y36, w36, h35);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x37, y37, w37, h35);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x38, y38, w38, h38);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x39, y39, w39, h39);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x40, y40, w40, h40);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x41, y41, w41, h41);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x42, y42, w42, h42);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x43, y43, w43, h43);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x44, y44, w44, h44);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x45, y45, w45, h45);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x46, y46, w46, h46);
     
    		g.setColor(Color.CYAN);
    		g.fillRect(x47, y47, w47, h47);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x48, y48, w47, h47);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x49, y49, w49, h49);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x50, y50, w50, h50);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x51, y51, w51, h51);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x52, y52, w52, h52);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x53, y53, w53, h53);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x54, y54, w54, h54);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x55, y55, w55, h55);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x56, y56, w56, h56);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x57, y57, w57, h57);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x58, y58, w58, h58);
     
    		g.setColor(Color.PINK);
    		g.fillRect(x59, y59, w59, h59);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x60, y60, w60, h60);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x61, y61, w61, h61);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x62, y62, w62, h62);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x63, y63, w63, h63);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x64, y64, w64, h64);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x65, y65, w65, h65);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x66, y66, w66, h66);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x67, y67, w67, h67);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x68, y68, w68, h68);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x69, y69, w69, h69);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x70, y70, w70, h70);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(x71, y71, w71, h71);
     
    	}
    	public void keyPressed(KeyEvent e)
    	{
            int c = e.getKeyCode();
     
            if(c == KeyEvent.VK_LEFT){
                velx=-10;
     
            }
     
            if(c == KeyEvent.VK_RIGHT){
                velx=+10;
     
            }
     
        }
        public void keyTyped(KeyEvent e){}
     
    	public void keyReleased(KeyEvent e){
            velx=0;
     
        }
     
    	public static void main (String args[])
    	{
    		Arkanoid obj = new Arkanoid();
    		frame.setSize(397,600);
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setVisible(true);
    		frame.add(obj);
    	}
    	public void actionPerformed(ActionEvent e)
    	{
    		BarX=BarX+velx;
    		if(BarX<3)
    		{
    			BarX=3;
    			velx=0;
    		}
    		if(BarX>340)
    		{
    			BarX=340;
    			velx=0;
    		}
    	if(((BallY+BallH)==BarY)&&((BallX+BallW)>BarX&&BallX<(BarX+BarW))||(BallY<0)){
    	ballspeed=ballspeed*(-1);
    	}
    	BallY=BallY+ballspeed;
    	BallX=BallX+vely;
    	if(BallX<0||BallX>370)
    	{
    	vely=-vely;
    	}
     
    		if(y71+h71>=BallY&&x71+w71>=BallX&&x71<=BallX+BallW&&y71<=BallY||y71<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y71=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y70+h70>=BallY&&x70+w70>=BallX&&x70<=BallX+BallW&&y70<=BallY||y70<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y70=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y69+h69>=BallY&&x69+w69>=BallX&&x69<=BallX+BallW&&y69<=BallY||y69<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y69=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y68+h68>=BallY&&x68+w68>=BallX&&x68<=BallX+BallW&&y68<=BallY||y68<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y68=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y67+h67>=BallY&&x67+w67>=BallX&&x67<=BallX+BallW&&y67<=BallY||y67<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y67=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y67+h67>=BallY&&x67+w67>=BallX&&x67<=BallX+BallW&&y67<=BallY||y67<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y67=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y66+h66>=BallY&&x66+w66>=BallX&&x66<=BallX+BallW&&y66<=BallY||y66<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y66=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y65+h65>=BallY&&x65+w65>=BallX&&x65<=BallX+BallW&&y65<=BallY||y65<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y65=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y64+h64>=BallY&&x64+w64>=BallX&&x64<=BallX+BallW&&y64<=BallY||y64<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y64=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y63+h63>=BallY&&x63+w63>=BallX&&x63<=BallX+BallW&&y63<=BallY||y63<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y63=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y62+h62>=BallY&&x62+w62>=BallX&&x62<=BallX+BallW&&y62<=BallY||y62<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y62=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y61+h61>=BallY&&x61+w61>=BallX&&x61<=BallX+BallW&&y61<=BallY||y61<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y61=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y60+h60>=BallY&&x60+w60>=BallX&&x60<=BallX+BallW&&y60<=BallY||y60<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y60=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y59+h59>=BallY&&x59+w59>=BallX&&x59<=BallX+BallW&&y59<=BallY||y59<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y59=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y58+h58>=BallY&&x58+w58>=BallX&&x58<=BallX+BallW&&y58<=BallY||y58<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y58=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y57+h57>=BallY&&x57+w57>=BallX&&x57<=BallX+BallW&&y57<=BallY||y57<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y57=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y56+h56>=BallY&&x56+w56>=BallX&&x56<=BallX+BallW&&y56<=BallY||y56<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y56=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y55+h55>=BallY&&x55+w55>=BallX&&x55<=BallX+BallW&&y55<=BallY||y55<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y55=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y54+h54>=BallY&&x54+w54>=BallX&&x54<=BallX+BallW&&y54<=BallY||y54<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y54=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y53+h53>=BallY&&x53+w53>=BallX&&x53<=BallX+BallW&&y53<=BallY||y53<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y53=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y52+h52>=BallY&&x52+w52>=BallX&&x52<=BallX+BallW&&y52<=BallY||y52<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y52=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y51+h51>=BallY&&x51+w51>=BallX&&x51<=BallX+BallW&&y51<=BallY||y51<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y51=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y50+h50>=BallY&&x50+w52>=BallX&&x50<=BallX+BallW&&y50<=BallY||y50<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y50=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y49+h49>=BallY&&x49+w49>=BallX&&x49<=BallX+BallW&&y49<=BallY||y49<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y49=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y48+h48>=BallY&&x48+w48>=BallX&&x48<=BallX+BallW&&y48<=BallY||y48<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y48=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y47+h47>=BallY&&x47+w47>=BallX&&x47<=BallX+BallW&&y47<=BallY||y47<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y47=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y46+h46>=BallY&&x46+w46>=BallX&&x46<=BallX+BallW&&y46<=BallY||y46<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y46=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y45+h45>=BallY&&x45+w45>=BallX&&x45<=BallX+BallW&&y45<=BallY||y45<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y45=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y44+h44>=BallY&&x44+w44>=BallX&&x44<=BallX+BallW&&y44<=BallY||y44<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y44=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y43+h43>=BallY&&x43+w43>=BallX&&x43<=BallX+BallW&&y43<=BallY||y43<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y43=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y42+h42>=BallY&&x42+w42>=BallX&&x42<=BallX+BallW&&y42<=BallY||y42<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y42=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y41+h41>=BallY&&x41+w41>=BallX&&x41<=BallX+BallW&&y41<=BallY||y41<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y41=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y40+h40>=BallY&&x40+w40>=BallX&&x40<=BallX+BallW&&y40<=BallY||y40<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y40=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y39+h39>=BallY&&x39+w39>=BallX&&x39<=BallX+BallW&&y39<=BallY||y39<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y39=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y38+h38>=BallY&&x38+w38>=BallX&&x38<=BallX+BallW&&y38<=BallY||y38<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y38=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y37+h37>=BallY&&x37+w37>=BallX&&x37<=BallX+BallW&&y37<=BallY||y37<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y37=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y36+h36>=BallY&&x36+w36>=BallX&&x36<=BallX+BallW&&y36<=BallY||y36<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y36=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y35+h35>=BallY&&x35+w35>=BallX&&x35<=BallX+BallW&&y35<=BallY||y35<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y35=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y34+h34>=BallY&&x34+w34>=BallX&&x34<=BallX+BallW&&y34<=BallY||y34<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y34=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y33+h33>=BallY&&x33+w33>=BallX&&x33<=BallX+BallW&&y33<=BallY||y33<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y33=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y32+h32>=BallY&&x32+w32>=BallX&&x32<=BallX+BallW&&y32<=BallY||y32<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y32=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y31+h31>=BallY&&x31+w31>=BallX&&x31<=BallX+BallW&&y31<=BallY||y31<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y31=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y30+h30>=BallY&&x30+w30>=BallX&&x30<=BallX+BallW&&y30<=BallY||y30<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y30=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y29+h29>=BallY&&x29+w29>=BallX&&x29<=BallX+BallW&&y29<=BallY||y29<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y29=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y28+h28>=BallY&&x28+w28>=BallX&&x28<=BallX+BallW&&y28<=BallY||y28<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y28=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}		
     
    		if(y27+h27>=BallY&&x27+w27>=BallX&&x27<=BallX+BallW&&y27<=BallY||y27<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y27=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}		
     
    		if(y26+h26>=BallY&&x26+w26>=BallX&&x26<=BallX+BallW&&y26<=BallY||y26<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y26=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y25+h25>=BallY&&x25+w25>=BallX&&x25<=BallX+BallW&&y25<=BallY||y25<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y25=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y24+h24>=BallY&&x24+w24>=BallX&&x24<=BallX+BallW&&y24<=BallY||y24<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y24=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y23+h23>=BallY&&x23+w23>=BallX&&x23<=BallX+BallW&&y23<=BallY||y23<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y23=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y22+h22>=BallY&&x22+w22>=BallX&&x22<=BallX+BallW&&y22<=BallY||y22<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y22=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y21+h21>=BallY&&x21+w21>=BallX&&x21<=BallX+BallW&&y21<=BallY||y21<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y21=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y20+h20>=BallY&&x20+w20>=BallX&&x20<=BallX+BallW&&y20<=BallY||y20<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y20=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y19+h19>=BallY&&x19+w19>=BallX&&x19<=BallX+BallW&&y19<=BallY||y19<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y19=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}	
     
    		if(y18+h18>=BallY&&x18+w18>=BallX&&x18<=BallX+BallW&&y18<=BallY||y18<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y18=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y17+h17>=BallY&&x17+w17>=BallX&&x17<=BallX+BallW&&y17<=BallY||y17<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y17=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}	
     
    		if(y16+h16>=BallY&&x16+w16>=BallX&&x16<=BallX+BallW&&y16<=BallY||y16<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y16=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y15+h15>=BallY&&x15+w15>=BallX&&x15<=BallX+BallW&&y15<=BallY||y15<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y15=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}	
     
    		if(y14+h14>=BallY&&x14+w14>=BallX&&x14<=BallX+BallW&&y14<=BallY||y14<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y14=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}	
     
    		if(y13+h13>=BallY&&x13+w13>=BallX&&x13<=BallX+BallW&&y13<=BallY||y13<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y13=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y12+h12>=BallY&&x12+w12>=BallX&&x12<=BallX+BallW&&y12<=BallY||y12<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y12=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		} 	
     
    		if(ygray11+h11>=BallY&&x11+w11>=BallX&&x11<=BallX+BallW&&ygray11<=BallY||ygray11<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray11=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(yg11+h11>=BallY&&x11+w11>=BallX&&x11<=BallX+BallW&&yg11<=BallY||yg11<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg11=800;
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));
    		}
     
    		if(y11+h11>=BallY&&x11+w11>=BallX&&x11<=BallX+BallW&&y11<=BallY||y11<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y11=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(ygray10+h10>=BallY&&x10+w10>=BallX&&x10<=BallX+BallW&&ygray10<=BallY||ygray10<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray10=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg10+h10>=BallY&&x10+w10>=BallX&&x10<=BallX+BallW&&yg10<=BallY||yg10<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg10=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y10+h10>=BallY&&x10+w10>=BallX&&x10<=BallX+BallW&&y10<=BallY||y10<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y10=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray9+h9>=BallY&&x9+w9>=BallX&&x9<=BallX+BallW&&ygray9<=BallY||ygray9<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray9=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg9+h9>=BallY&&x9+w9>=BallX&&x9<=BallX+BallW&&yg9<=BallY||yg9<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg9=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y9+h9>=BallY&&x9+w9>=BallX&&x9<=BallX+BallW&&y9<=BallY||y9<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y9=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray8+h8>=BallY&&x8+w8>=BallX&&x8<=BallX+BallW&&ygray8<=BallY||ygray8<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray8=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg8+h8>=BallY&&x8+w8>=BallX&&x8<=BallX+BallW&&yg8<=BallY||yg8<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg8=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y8+h8>=BallY&&x8+w8>=BallX&&x8<=BallX+BallW&&y8<=BallY||y8<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y8=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray7+h7>=BallY&&x7+w7>=BallX&&x7<=BallX+BallW&&ygray7<=BallY||ygray7<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray7=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg7+h7>=BallY&&x7+w7>=BallX&&x7<=BallX+BallW&&yg7<=BallY||yg7<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg7=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y7+h7>=BallY&&x7+w7>=BallX&&x7<=BallX+BallW&&y7<=BallY||y7<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y7=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}		
     
     
    		if(ygray6+h6>=BallY&&x6+w6>=BallX&&x6<=BallX+BallW&&ygray6<=BallY||ygray6<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray6=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg6+h6>=BallY&&x6+w6>=BallX&&x6<=BallX+BallW&&yg6<=BallY||yg6<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg6=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y6+h6>=BallY&&x6+w6>=BallX&&x6<=BallX+BallW&&y6<=BallY||y6<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y6=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray5+h5>=BallY&&x5+w5>=BallX&&x5<=BallX+BallW&&ygray5<=BallY||ygray5<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray5=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg5+h5>=BallY&&x5+w5>=BallX&&x5<=BallX+BallW&&yg5<=BallY||yg5<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg5=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y5+h5>=BallY&&x5+w5>=BallX&&x5<=BallX+BallW&&y5<=BallY||y5<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y5=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray4+h4>=BallY&&x4+w4>=BallX&&x4<=BallX+BallW&&ygray4<=BallY||ygray4<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray4=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg4+h4>=BallY&&x4+w4>=BallX&&x4<=BallX+BallW&&yg4<=BallY||yg4<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg4=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y4+h4>=BallY&&x4+w4>=BallX&&x4<=BallX+BallW&&y4<=BallY||y4<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y4=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray3+h3>=BallY&&x3+w3>=BallX&&x3<=BallX+BallW&&ygray3<=BallY||ygray3<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray3=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg3+h3>=BallY&&x3+w10>=BallX&&x3<=BallX+BallW&&yg3<=BallY||yg3<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg3=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y3+h3>=BallY&&x3+w3>=BallX&&x3<=BallX+BallW&&y3<=BallY||y3<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y3=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray2+h2>=BallY&&x2+w2>=BallX&&x2<=BallX+BallW&&ygray2<=BallY||ygray2<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray2=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg2+h2>=BallY&&x2+w2>=BallX&&x2<=BallX+BallW&&yg2<=BallY||yg2<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg2=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y2+h2>=BallY&&x2+w2>=BallX&&x2<=BallX+BallW&&y2<=BallY||y2<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y2=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
     
    		if(ygray1+h1>=BallY&&x1+w1>=BallX&&x1<=BallX+BallW&&ygray1<=BallY||ygray1<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray1=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg1+h1>=BallY&&x1+w1>=BallX&&x1<=BallX+BallW&&yg1<=BallY||yg1<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg1=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y1+h1>=BallY&&x1+w1>=BallX&&x1<=BallX+BallW&&y1<=BallY||y1<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y1=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(ygray+h>=BallY&&x+w>=BallX&&x<=BallX+BallW&&ygray<=BallY||ygray<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		ygray=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(yg+h>=BallY&&x+w>=BallX&&x<=BallX+BallW&&yg<=BallY||yg<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		yg=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(y+h>=BallY&&x+w>=BallX&&x<=BallX+BallW&&y<=BallY||y<=0){
    		ballspeed=ballspeed*(-1);
    		BallY=BallY+ballspeed;
    		y=800;		
    		score = score +1;
    		labeltimers.setText(Integer.toString(score));		
    		}
     
    		if(score==96)
    		{
    			JOptionPane.showMessageDialog(null,"Stage 2");
    			BallX=238; BallY=505; BallW=15; BallH=15;
    			BarX=220; BarY=520; BarW=45; BarH=10;
    			ballspeed=10;
    			ygray=350;yg=350;y=350;
    			ygray1=350;yg1=350;y1=350;
    			ygray2=350;yg2=350;y2=350;
    			ygray3=350;yg3=350;y3=350;
    			ygray4=350;yg4=350;y4=350;
    			ygray5=350;yg5=350;y5=350;
    			ygray6=350;yg6=350;y6=350;
    			ygray7=350;yg7=350;y7=350;
    			ygray8=350;yg8=350;y8=350;
    			ygray9=350;yg9=350;y9=350;
    			ygray10=350;yg10=350;y10=350;
    			ygray11=350;yg11=350;y11=350;
     
     
    			score=score+1;
    		}
     
     
    			if(BallY>600){
    			tm.stop();
    			System.exit(0);
    			}
    			repaint();
     
     
    	}
    	}

    Can you run my program and check if it is fine ?
    public class Newbie
    {
      public static void main (String args[])
      { 
     
    	for(int num=0;num<1;num=num+1)
    	{	
    	System.out.println("Dumb");
    	}
     
     
       }
    }

  10. #10
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: [Arkanoid]Help

    /** FILE: Sample.java */
     
    /**@author jps<br>*/
    public class Sample {
    	/**The number of times the loop in this sample is to run*/
    	public static final int REPS = 10;
     
    	/**This is the entry point for this program.
    	 * @param args Not used
    	 */
    	public static void main(String[] args) {
    		int i = 0;
    		System.out.println("The value of i is " + i);
    		i = i + 1;
    		System.out.println("The value of i is " + i);
    		i++;
    		System.out.println("The value of i is " + i);
    		++i;
    		System.out.println("The value of i is " + i);
    		i += 1;
    		System.out.println("The value of i is " + i);
    		i = i + 1;
    		System.out.println("The value of i is " + i);
    		i++;
    		System.out.println("The value of i is " + i);
    		++i;
    		System.out.println("The value of i is " + i);
    		i = i + 1;
    		System.out.println("The value of i is " + i);
    		i += 1;
    		System.out.println("The value of i is " + i);
    	}
    }
    Compared to:
    /** FILE: Sample.java */
     
    /**@author jps<br>*/
    public class Sample {
    	/**The number of times the loop in this sample is to run*/
    	public static final int REPS = 10;
     
    	/**This is the entry point for this program.
    	 * @param args Not used
    	 */
    	public static void main(String[] args) {
    		for(int i = 0; i < REPS; i++) {
    			System.out.println("The value of i is " + i);
    		}
    	}
    }
    I would like to see your program get much shorter. But in reply to your question, you tell me... Does the program do what it should do? If so, good job. If not, what is wrong with it?

  11. #11
    Junior Member
    Join Date
    Sep 2012
    Location
    Philippines
    Posts
    23
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [Arkanoid]Help

    Quote Originally Posted by jps View Post
    /** FILE: Sample.java */
     
    /**@author jps<br>*/
    public class Sample {
    	/**The number of times the loop in this sample is to run*/
    	public static final int REPS = 10;
     
    	/**This is the entry point for this program.
    	 * @param args Not used
    	 */
    	public static void main(String[] args) {
    		int i = 0;
    		System.out.println("The value of i is " + i);
    		i = i + 1;
    		System.out.println("The value of i is " + i);
    		i++;
    		System.out.println("The value of i is " + i);
    		++i;
    		System.out.println("The value of i is " + i);
    		i += 1;
    		System.out.println("The value of i is " + i);
    		i = i + 1;
    		System.out.println("The value of i is " + i);
    		i++;
    		System.out.println("The value of i is " + i);
    		++i;
    		System.out.println("The value of i is " + i);
    		i = i + 1;
    		System.out.println("The value of i is " + i);
    		i += 1;
    		System.out.println("The value of i is " + i);
    	}
    }
    Compared to:
    /** FILE: Sample.java */
     
    /**@author jps<br>*/
    public class Sample {
    	/**The number of times the loop in this sample is to run*/
    	public static final int REPS = 10;
     
    	/**This is the entry point for this program.
    	 * @param args Not used
    	 */
    	public static void main(String[] args) {
    		for(int i = 0; i < REPS; i++) {
    			System.out.println("The value of i is " + i);
    		}
    	}
    }
    I would like to see your program get much shorter. But in reply to your question, you tell me... Does the program do what it should do? If so, good job. If not, what is wrong with it?
    I get your point my program is not that logical as it is haha anyways I'm just beginner,
    I need to know how to put BG in my Frame can you tell me ?
    public class Newbie
    {
      public static void main (String args[])
      { 
     
    	for(int num=0;num<1;num=num+1)
    	{	
    	System.out.println("Dumb");
    	}
     
     
       }
    }

  12. #12
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: [Arkanoid]Help

    Quote Originally Posted by Totel View Post
    I get your point my program is not that logical as it is haha anyways I'm just beginner,
    That is why we take the time to write sample code. It gives you something to look at, something to think about, and (hopefully) spawns a desire to try things for yourself.




    Quote Originally Posted by Totel View Post
    I need to know how to put BG in my Frame can you tell me ?
    If you have a new question please make a new thread. If the current one is solved please mark the thread as solved. What do you mean by BG?

  13. #13
    Junior Member
    Join Date
    Sep 2012
    Location
    Philippines
    Posts
    23
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [Arkanoid]Help

    Please close the thread I'm already done with it!!!!

    Thanks a lot
    public class Newbie
    {
      public static void main (String args[])
      { 
     
    	for(int num=0;num<1;num=num+1)
    	{	
    	System.out.println("Dumb");
    	}
     
     
       }
    }

  14. #14
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: [Arkanoid]Help

    You can find information on marking the thread as solved on the announcements page.