Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Load() throws FileNotFoundException, IOException, JSONException {
- BufferedReader reader = new BufferedReader(new FileReader("MAP1.MAP"));
- String jsondata = reader.readLine();
- JSONArray jsonarray = new JSONArray(jsondata);
- JSONArray array = jsonarray.getJSONArray(jsonarray.length()-1);
- for (int i = 0; i < array.length(); i++) {
- JSONObject obj = array.getJSONObject(i);
- float _x = (float) obj.getDouble("x");
- float _y = (float) obj.getDouble("y");
- float _w = (float) obj.getDouble("w");
- float _h = (float) obj.getDouble("h");
- float _rot = (float) obj.getDouble("rot");
- float _rad = (float) obj.getDouble("rad");
- if ("SQUARE".equals(obj.getString("type"))) {
- objects.add(new SquareObject(_x, _y, _w, _h, _rot));
- } else if ("CIRCLE".equals(obj.getString("type"))) {
- objects.add(new CircleObject(_x, _y, _rad, _rot));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement