File Parser WIP: see comments
Signed-off-by: Anthony Debucquoy <debucquoy.anthony@gmail.com>
This commit is contained in:
parent
a1e36ccbc7
commit
1cd017f8ca
@ -27,9 +27,16 @@ public class MapParser {
|
||||
}
|
||||
}
|
||||
|
||||
byte[] map_data = Arrays.copyOfRange(bytes, start_position, end_position); //TODO tonitch cursor
|
||||
byte[] level_data = Arrays.copyOfRange(bytes, start_position, end_position);
|
||||
int width_map = level_data[0], height_map = level_data[1];
|
||||
byte[] map_data = Arrays.copyOfRange(level_data, 2, 2 + width_map * height_map / 8 + (height_map * width_map % 8 != 0 ? 1 : 0));
|
||||
byte piece_count = level_data[3 + width_map * height_map / 8 + (height_map * width_map % 8 != 0 ? 1 : 0)];
|
||||
byte[] pieces_datas = Arrays.copyOfRange(level_data, 4 + width_map * height_map / 8 + (height_map * width_map % 8 != 0 ? 1 : 0), level_data.length-1);
|
||||
for (int piece_index = 0; piece_index < piece_count; piece_index++) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
fileStream.close();
|
||||
return new Map(); //TODO: Send the parsed map
|
||||
}
|
||||
@ -37,6 +44,12 @@ public class MapParser {
|
||||
// public static void SaveMapFile(File file){
|
||||
// }
|
||||
|
||||
|
||||
private static boolean[][] BuildMatrixFromBytes(int map_width, int map_height, byte[] map_data){
|
||||
boolean[][] ret = new boolean[map_height][map_width];
|
||||
//TODO tonitch: cursor 2
|
||||
|
||||
}
|
||||
public static void main(String[] args) throws IOException, IllegalAccessException {
|
||||
ParseMapFile(new File("test.smap"));
|
||||
}
|
||||
|
@ -37,4 +37,17 @@ public class Shape {
|
||||
public boolean[][] getShape() {
|
||||
return matrix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String ret = "";
|
||||
for (boolean[] row : matrix) {
|
||||
for (boolean el : row) {
|
||||
if(el) ret = ret.concat("⬛");
|
||||
else ret = ret.concat("⬜");
|
||||
}
|
||||
ret = ret.concat("\n");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user