package uk.org.floop.epq3d; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.Objects; public class Texture { protected final String name; private final String type; public int[][] img; public Color color; public Texture(String _name, Color _color){ name = _name; type = "solid"; color = _color; } public Texture(String _name, String _imgPath){ name = _name; type = "image"; // grab file and pack it into a list[][] int (gives better performance than a BufferedImage by a _lot_ File imgFile = new File(_imgPath); try { BufferedImage _img = ImageIO.read(imgFile); for(int x = 0; x < _img.getWidth(); x +=1) { for (int y = 0; y < _img.getHeight(); y += 1) { img[x][y] = _img.getRGB(x, y); } } } catch (IOException e) { throw new RuntimeException(e); } } public boolean isSolid(){ if (Objects.equals(type, "solid")){ return true; } else{ return false; } } }