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


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


2

This is really not that bad. Despite the variable names not being in English, I'm able to get the gist of it. Here are some useful things that I think would improve the situation. Avoid Globals Your first header is mainly a list of global variables. Globals are difficult to work with because they can be changed by any code anywhere in your app. So when a ...


1

Quite a lot of context is missing, so I'm guessing some things. e.g.: What's BV? What's BV::Type? (apparently it's a size, but for some reason it's stored outside the BV itself? Seems a bit odd if we have our own copy of the BV.) What is maximize? (I'd guess a = std::max(a, b), but that can't be right because maximize(getSize(primitive), *node->...


1

first, accessing those properties all over again is really confusing let bgI = background.allPixels[i] let locI = bgI.location let line = drawLineBetweenPixelRange let bgJ = background.allPixels[j] let locJ = bgJ.location if (locI.x - line < locJ.x + bgJ.width && locI.x + bgI.width + line > locJ.x && locI.y - line < locJ.y +...


1

Something I would immediately recommend from looking at your code is that you should not put random whitespace in your code. Whenever you space out random parts, you should ensure you do so with good reason - such as splitting up various logical parts of your codebase. Also, you want to avoid writing code like this for (CollideableObject object : objects) ...


Only top voted, non community-wiki answers of a minimum length are eligible