

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;


import java.awt.Color;



public class Game extends JPanel {

   static long points=-10000;

   Ball ball = new Ball(this);
   Ball ball1 = new Ball(this);

   Box box = new Box(this);
   Box box1 = new Box(this);

   
   Player player = new Player(this);

   public Game() {
   }
	
   private void move() {
   
      ball.move();
      ball1.move();
      box.move();
      box1.move();
   }

   @Override
   public void paint(Graphics g) {
      super.paint(g);
      Graphics2D g2d = (Graphics2D) g;
            
      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
         	RenderingHints.VALUE_ANTIALIAS_ON);
            
      ball.paint(g2d);
      ball1.paint(g2d);
      
      box.paint(g2d);
      box1.paint(g2d);
   
      player.paint(g2d);
      
      
      g2d.setBackground(Color.black);
   
   }
	
   public void gameOver() {
      JOptionPane.showMessageDialog(this, "Your points : "+ points, "Game Over", JOptionPane.YES_NO_OPTION);
      System.exit(ABORT);
   }

   public static void main(String[] args) throws InterruptedException {
      JFrame frame = new JFrame("Dodge Em");
      Game game = new Game();
      frame.add(game);
      frame.setSize(600, 600);
          
      frame.setVisible(true);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   	
      
      //points> 9223372036854775806
      while (true) {
         game.move();
         game.repaint();
         Thread.sleep(2);
         points++;
      }
   }
}