New answers tagged

3

Some style points first. Always wrap statement and loop blocks in {} eg you wrote for (let j = 0; j < x2; j++) someFunction(j) to avoid maintenance headaches use the curlies for (let j = 0; j < x2; j++) { someFunction(j) } Don't declare the same variable over and over. There is no advantage to locally scoping variables to code blocks unless you are ...


3

Bug #1 Your code does not follow pattern (x - a < y + b) && (x + b + a > y) but (x - a < y + b1) || (x + b2 + a > y) instead. So our refactored formula is moot! obsolete Bug #2 A collision is detected when any of the guards trigger, not when all. Proposed Solution Solving both bugs, we could refactor Nikko Khresna's method: function ...


Top 50 recent answers are included