Optimized collision checks. Like wtf why didn't I do it this way before?
This commit is contained in:
parent
e87f4433d1
commit
74b7eb885d
|
@ -995,16 +995,10 @@ Oversimplified.GameObjectsAtPoint = function (x, y) {
|
||||||
var objectsAtPoint = [];
|
var objectsAtPoint = [];
|
||||||
for (var obj in Oversimplified.O) {
|
for (var obj in Oversimplified.O) {
|
||||||
var object = Oversimplified.O[obj];
|
var object = Oversimplified.O[obj];
|
||||||
for (var i = 0; i < 2 * object.xBound; i++) {
|
if (x <= object.x + object.xBound && x >= object.x - object.xBound &&
|
||||||
for (var j = 0; j < 2 * object.yBound; j++) {
|
y <= object.y + object.yBound && y >= object.y - object.yBound)
|
||||||
var xToCheck = (object.x - object.xBound) + i;
|
{
|
||||||
var yToCheck = (object.y - object.yBound) + j;
|
objectsAtPoint.push(object);
|
||||||
|
|
||||||
if (xToCheck == x && yToCheck == y)
|
|
||||||
{
|
|
||||||
objectsAtPoint.push(object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue