// // ballX: is the X position of the ball // ballY: is the Y position of the ball // ballSize: is the size of the ball // paddleX/Y: is the X/Y position of the paddle // paddleWidth/Height: are the width/Height of the paddle // // This function returns the condition if the ball and the // paddle has collided. // boolean ballPaddleCollide(float ballX, float ballY, float ballSize, float paddleX, float paddleY, float paddleWidth, float paddleHeight) { float paddleMaxX = paddleX + paddleWidth; if (ballX < paddleMaxX) { float ballMaxX = ballX + ballSize; if (paddleX < ballMaxX) { float paddleMaxY = paddleY + paddleHeight; if (ballY < paddleMaxY) { return (paddleY < (ballY + ballSize)); } } } return false; }