Jonalogy / puttyPoodle

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

Code holds true only if bridge is drawn from right to left. #3

Open Jonalogy opened 8 years ago

Jonalogy commented 8 years ago

screen shot 2016-09-01 at 10 57 19 am

A scenario of another ball passing through the bridge was found and this time the path was drawn from left to right. The following line of code only holds true if the bridge is drawn from left to right because it is programmed to always first compare ballX with xStart(x-cords on mouseDown ), then ballX with xEnd (x-cords on mouseUp).

screen shot 2016-09-01 at 10 54 53 am

Need to amend code to:

  1. Calculate xRange between xStart and xEnd of line and Math.abs() it.
  2. Add either xStart or xEnd whichever is smaller to xRange,
  3. (In the case where path is drawn from left to right, xEnd <xStart ) Then compare the ballX first to xEnd, then later( xEnd+xRange).
Jonalogy commented 8 years ago

screen shot 2016-09-01 at 11 50 54 am Problem Solved