for my javascript game project, I'd like to make a 2 dimensional array that checks a PNG image for the color red and then saves tile-wise "true" or "false".
So I made something like this:
var array = new Array(100);
for(i = 0; i < 100; i++)
{
array[i] = new Array(100);
}
First I only found a lot of canvas use cases, but because I am working in app.js (aka my node.js server application), I don't have access to the canvas (well I can use canvas on client side, but that brings a lot of cheating possibilites with it!) So I looked into node modules I could use, and I found jimp which I tried using. There are some issues though. First I encountered a similar error to this, but for some reason it fixed itself after changing the code.
I feel like JIMP isn't the 100% correct solution for my problem though, does node maybe have some default file reading system I can use?
All I really need is a function like
function getPixel(x, y){
return pixelColor('./client/img/map.png', x, y).red;
}
Which I can then use to iterate through my arrays and save the RGB value of red into the array. I feel like I did a really poor job on phrasing what I want to achieve and where my problems are, I hope somebody might be able to help me anyways if not, please ask me for more information if you feel like this is an easy task.
Edit 1: My title says "a lot of images" because my game is split into chunks, and every chunk = "background"-picture of the map, which equates to 1 896x896 file of "tile collisions". My application will need to read like 900 images to get the complete collision data into the array.