Ok, so I have a text file filled with 0s and 1s. When there are 1s, I want the code to add a block to the block array. For some reason it is not reading it right at all.
World.java:
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.imageio.ImageIO;
import java.io.*;
class World {
Image ground;
Block[] blocks;
int mapWidth = 40;
int mapHeight = 22;
void setWorld(String map) {
try {
BufferedReader br = new BufferedReader(new FileReader(map));
String line;
int enc = -1;
int x = 0;
int y = 0;
while ((line = br.readLine()) != null) {
String values[] = line.split(" ");
for (String str : values) {
int str_int = Integer.parseInt(str);
if (str_int == 1) {
enc++;
System.out.println("x: " + x + ", y: " + y);
//blocks[enc] = new Block(x * 32, y * 32, 32, 32, 1);
}
y++;
}
x++;
}
} catch (Exception e) { e.printStackTrace(); }
System.out.println("hi");
}
}