Optimized collision checks. Like wtf why didn't I do it this way before?

This commit is contained in:
Robbie Antenesse 2016-04-14 08:31:01 -06:00
parent e87f4433d1
commit 74b7eb885d
1 changed files with 4 additions and 10 deletions

View File

@ -995,16 +995,10 @@ Oversimplified.GameObjectsAtPoint = function (x, y) {
var objectsAtPoint = [];
for (var obj in Oversimplified.O) {
var object = Oversimplified.O[obj];
for (var i = 0; i < 2 * object.xBound; i++) {
for (var j = 0; j < 2 * object.yBound; j++) {
var xToCheck = (object.x - object.xBound) + i;
var yToCheck = (object.y - object.yBound) + j;
if (xToCheck == x && yToCheck == y)
{
objectsAtPoint.push(object);
}
}
if (x <= object.x + object.xBound && x >= object.x - object.xBound &&
y <= object.y + object.yBound && y >= object.y - object.yBound)
{
objectsAtPoint.push(object);
}
}