2022-06-03 17:22:05 +01:00
|
|
|
import java.io.*;
|
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-03 18:08:59 +01:00
|
|
|
//Input game map
|
2022-06-03 17:22:05 +01:00
|
|
|
public static void inputMap(ArrayList<Tile> map, String filePath) throws IOException {
|
2022-06-03 18:08:59 +01:00
|
|
|
String file = FileManager.readFile(filePath);
|
2022-06-03 17:22:05 +01:00
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
for(int i=0; i<file.length(); i++){
|
|
|
|
if(file.charAt(i)=='\n'){
|
|
|
|
y+=Tile.length;
|
|
|
|
x=0;
|
|
|
|
}
|
|
|
|
else if(file.charAt(i)=='1'){
|
|
|
|
map.add(new Tile(x,y));
|
|
|
|
}
|
|
|
|
x+=Tile.length;
|
|
|
|
}
|
2022-06-02 18:21:29 +01:00
|
|
|
}
|
|
|
|
}
|