As shown in the screenshot, the ball is on touching the bridge. Based on the ball's position, it is calculated based on the line equation bounce off at y= 203.593 (calY). But it seems ball's center is already at y = 296 (ballY).
The condition to check the ball's height when this post was created was:
if((ballY+ballR) >= (calY-5) && (ballY+ballR)<=(calY+ 17)){
... /code to manipulate the ball's movement/...
}
Note:
bridges[] array is a 2-dim array to store details of each drawn path. For example:
bridges[i] = [xStart, yStart, xEnd, yEnd, gradient, y-intercept]; Gradient and y-intercept are
calculated with straight line equation y=mx + c.
The second snapshot has a bridge with significantly smaller gradient. Difference between ballY and calY do is much and within range thus the ball bounces off properly (ballY :288.984, calY : 298.984).
As shown in the screenshot, the ball is on touching the bridge. Based on the ball's position, it is calculated based on the line equation bounce off at y= 203.593 (calY). But it seems ball's center is already at y = 296 (ballY).
The condition to check the ball's height when this post was created was: if((ballY+ballR) >= (calY-5) && (ballY+ballR)<=(calY+ 17)){ ... /code to manipulate the ball's movement/... }
Note: bridges[] array is a 2-dim array to store details of each drawn path. For example: bridges[i] = [xStart, yStart, xEnd, yEnd, gradient, y-intercept]; Gradient and y-intercept are calculated with straight line equation y=mx + c.
The second snapshot has a bridge with significantly smaller gradient. Difference between ballY and calY do is much and within range thus the ball bounces off properly (ballY :288.984, calY : 298.984).