1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
|
public void generateMap(int level_nr,String filename){
if(level_nr == 1){
tiles_w=273;
tiles_h=76;
}
String stringMap = "";
try {
BufferedReader reader = new BufferedReader(new FileReade(filename));
String line = null;
while ((line = reader.readLine()) != null) {
stringMap += line;
}
} catch (IOException e) {e.printStackTrace();}
if(stringMap != ""){
String[] stringarray = stringMap.split(",");
int[] level = new int[stringarray.length];
for(int i = 0;i<stringarray.length;i++){
level[i] = Integer.parseInt(stringarray[i]);
}
levelMap = new int[tiles_h][tiles_w];
for(int h=0;h<tiles_h;h++){
for(int w=0;w<tiles_w;w++){
if(level_nr==1){
levelMap[h][w]= level[nr];
nr++;
}
}
}
}
} |