@Override
	public void update(float pDeltaTime) {
		mGame.getInput().getMouseEvents();
		mGame.getInput().getKeyEvents();
		
		int len = mBalls.size();
		for (int i=0; i<len; i++) {
			Ball firstBall = mBalls.get(i);
			
			for (int j=0; j<len; j++) {
				Ball secondBall = mBalls.get(i);
				if (secondBall == firstBall || !OverlapTester.overlapCircles(firstBall.bounds, secondBall.bounds)) {
					continue;
				}
				System.out.println("overlap");
				float newVelocityX1 = (firstBall.velocity.x * (firstBall.mass - secondBall.mass) + (2 * secondBall.velocity.x * secondBall.mass))
						/ (firstBall.mass + secondBall.mass);
				float newVelocityY1 = (firstBall.velocity.y * (firstBall.mass - secondBall.mass) + (2 * secondBall.velocity.y * secondBall.mass))
						/ (firstBall.mass + secondBall.mass);
				float newVelocityX2 = (secondBall.velocity.x * (secondBall.mass - firstBall.mass) + (2 * firstBall.velocity.x * firstBall.mass))
						/ (firstBall.mass + secondBall.mass);
				float newVelocityY2 = (secondBall.velocity.y * (secondBall.mass - firstBall.mass) + (2 * firstBall.velocity.y * firstBall.mass))
						/ (firstBall.mass + secondBall.mass);
				
				firstBall.velocity.add(newVelocityX1, newVelocityY1);
				secondBall.velocity.add(newVelocityX2, newVelocityY2);
			}
			
			
			//firstBall.velocity.add(mGravity.x * pDeltaTime, mGravity.y * pDeltaTime);
			
			firstBall.update(pDeltaTime);
			if (firstBall.getX() < firstBall.getWidth() / 2) {
				firstBall.setX(firstBall.getWidth() / 2);
				firstBall.velocity.x *= -1;
			}
			if (firstBall.getX() > mWidth - firstBall.getWidth() / 2) {
				firstBall.setX(mWidth - firstBall.getWidth() / 2);
				firstBall.velocity.x *= -1;
			}
			if (firstBall.getY() < firstBall.getWidth() / 2) {
				firstBall.setY(firstBall.getWidth() / 2);
				firstBall.velocity.y *= -1;
			}
			if (firstBall.getY() > mHeight - firstBall.getHeight() / 2) {
				firstBall.setY(mHeight - firstBall.getHeight() / 2);
				firstBall.velocity.y *= -1;
			}
		}
	}