import java.util.concurrent.TimeUnit;

public class Breakout
{
	public static void main(String[] args) throws InterruptedException
	{
		@SuppressWarnings("unused")
		Window window = new Window();
		
		BrickWall brickwall = new BrickWall();
		Borders borders = new Borders();
	
		Player player = new Player();
		Points points = new Points();
		Ball ball = new Ball();

		Window._dp.setFocusable(true);
		Window._dp.addMouseMotionListener(player);
		
		while (player.life.alive() && !brickwall.destroyed())
		{	
			ball.update();
			points.add(brickwall.update(ball));
			player.update(ball);
			
			if (borders.update(ball))
			{
				ball.reset();
				player.life.decrease();
			}
				
			TimeUnit.MICROSECONDS.sleep(2600 - (30 * points.points()));
		}
		
		if (brickwall.destroyed())
		{
			brickwall.win();
			player.hide();
			ball.hide();
		}
		else
		{
			brickwall.lost();
			player.hide();
			ball.hide();
		}
	}
}
