final/src/MapReader.java

28 lines
837 B
Java
Raw Normal View History

2022-06-02 19:48:16 +01:00
import java.io.BufferedReader;
2022-06-02 18:21:29 +01:00
import java.io.File;
2022-06-02 19:48:16 +01:00
import java.io.FileNotFoundException;
import java.io.FileReader;
2022-06-02 18:21:29 +01:00
import java.util.ArrayList;
2022-06-02 19:48:16 +01:00
import java.util.Scanner;
2022-06-02 18:21:29 +01:00
public class MapReader {
2022-06-02 19:48:16 +01:00
public static void inputMap(ArrayList<Tile> map, File file) throws FileNotFoundException {
2022-06-02 18:33:04 +01:00
int x = 0;
int y = 0;
2022-06-02 19:48:16 +01:00
Scanner sc = new Scanner(new BufferedReader(new FileReader("src/Level1.txt")));
int rows = 7;
int columns = 7;
while(sc.hasNextLine()) {
for (int i=0; i<7; i++) {
String[] line = sc.nextLine().trim().split(" ");
for (int j=0; j<line.length; j++) {
map.add(new Tile(x,y));
x+=Tile.length;
}
x=0;
y+=Tile.length;
}
}
2022-06-02 18:21:29 +01:00
}
}