Jonalogy / puttyPoodle

GA-WDI5 Project 1b: Custom build a game
1 stars 0 forks source link

Ball glitches through bridge with large gradients #2

Open Jonalogy opened 8 years ago

Jonalogy commented 8 years ago

screen shot 2016-09-01 at 9 27 28 am

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.

screen shot 2016-09-01 at 9 40 58 am

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).

Jonalogy commented 8 years ago

Problem solved, see issue #3