I'm trying to make a 2D matrix dynamic system which identifies whether there is an "object" at X,Y coordinates (true), or not (false).
Simplified example code:
var coords = [[]]; // Matrix is over 10,000 x 10,000
var objectX = 76;
var objectY = 54;
coords[objectX][objectY] = true;
//Check to see if there is an object @ coordinates
if(coords[100][65] == false || coords[100][65] === undefined)
{
//There is no object @ 100 x 65
}
else
{
//Object detected @ 100 x 65
}
But it seems I can't do it this way, since I think I have to start from [0][0], [0][1], [0][2], ... , ect; or something..
Also, matrix is too large to define via putting it in a loop. I can't have it loading for hours.
I won't mind keeping an array segment 'undefined', as I treat it as false in my code.
How can I accomplish this?
[[]]just creates a nested empty array. You need to create other arrays manually. And then usecoords[inLimit1][inLimit2] = Anything;