hey guys i started working on a class that would take an image and turn it into a map and im progressing i have converted all the pixels into hex color codes and stored them in array and everything is working fine
except when im trying to all the createMap method to actually create the tiles
its throwing me a nullPointerException and i can’t seem to find the reason
any suggestions ?
code:
public class Level {
public static BufferedImage createDataArray(BufferedImage level) {
String[] pixels = new String[level.getHeight() * level.getWidth()];
BufferedImage out = level;
for(int x = 0;x < level.getHeight(); x++) {
for(int y = 0; y < level.getWidth();y++) {
int rgb = level.getRGB(x, y);
String hex = Integer.toHexString(rgb & 0x00ffffff);
pixels[x+y] = hex;
}
}
createMap(pixels);
return out;
}
public static void createMap(String[] pixels) {
for(String s : pixels) {
if(s.equals("000000")) {
System.out.println("wall");
}
if(s.equals("06941a")) {
System.out.println("grass");
}
}
}
}