I have a problem with the following Game-Maps:
I want to save all the land area (near yellow) in an array, so that the computer later knows whether a click by the user is on the water (x / y coordinate of the mouse pointer not in the array) or in the country (x / y coordinate the cursor not in the array) . I've already made (basic visual representation):
As can be seen, the land area is covered with equally large rectangles, which are stored as follows in the array:
{x:upper left corner - X-postion, y: upper left corner - Ypostion, x1:width of the rect, y1: height of the rect}
example: {x:0, y:0, x1:3, y2: 2}
These obejcts are all stored in one big array. But it takes too long to determine if a point in the array (land area) or not in the array (water area) is. (Takes 45 milliseconds) I would now like to merge these small individual rectangles, so larger rectangles formed, which can be compared with the mouse postion faster. Like this handmade example:
If its possible these little rectangle-objects should be add to one big rect (like the green or brown one).
Til yet I couldn't find anything to do this, so that I hope you can help me. There is one more problem: The array, where I saved all the small rects is very big (over 100.000 Elements). They all are stored like this:
[{x:0, y: 0, x1:3, y1:2},{x:0, y: 2, x1:3, y1:2},{x:0, y: 4, x1:3, y1:2}]
It's not a problem if a solution takes more than 10 Minutes or something like that.