For some reason, the mapTile array seems to be incomplete in my collision code, but working in the map drawing code.
public class MapLoader {
protected int[][] mapTile = new int[100][100];
Textures textures = new Textures();
Window window = new Window();
int offsetX;
int offsetY;
public MapLoader(String map) {
protected boolean getTextureCollidable(int x, int y) {
x += offsetX;
y += offsetY;
if(x >= 0 && y >= 0) {
x /= tileSize;
y /= tileSize;
System.out.println("X: " + x);
System.out.println("Y: " + y);
if(y < mapTile[x].length) {
return textures.textures[mapTile[x][y]].getCollidable();
} else return false;
}
else return false;
}
protected void draw(Graphics2D g2) {
offsetX = GamePanel.getOffsetX() - 30;
offsetY = GamePanel.getOffsetY() - 60;
int tileSize = GamePanel.tileSize;
for (int j = 0; j < mapTile.length; j++) {
for (int i = 0; i < mapTile[j].length; i++) {
if (mapTile[j][i] != 0) {
g2.drawImage(textures.textures[mapTile[j][i]].img, i * tileSize - offsetX, j * tileSize - offsetY, tileSize, tileSize, null);
}
}
}
}
}
the maptile array itself is working perfectly fine, it is just this for some reason.
if you need anything more lemme know, thanks!