Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void Load() throws FileNotFoundException, IOException, JSONException {
  2.     BufferedReader reader = new BufferedReader(new FileReader("MAP1.MAP"));
  3.     String jsondata = reader.readLine();
  4.        
  5.     JSONArray jsonarray = new JSONArray(jsondata);
  6.     JSONArray array = jsonarray.getJSONArray(jsonarray.length()-1);
  7.        
  8.     for (int i = 0; i < array.length(); i++) {
  9.         JSONObject obj = array.getJSONObject(i);
  10.            
  11.         float _x = (float) obj.getDouble("x");
  12.         float _y = (float) obj.getDouble("y");
  13.         float _w = (float) obj.getDouble("w");
  14.         float _h = (float) obj.getDouble("h");
  15.         float _rot = (float) obj.getDouble("rot");
  16.         float _rad = (float) obj.getDouble("rad");
  17.            
  18.         if ("SQUARE".equals(obj.getString("type"))) {
  19.             objects.add(new SquareObject(_x, _y, _w, _h, _rot));
  20.         } else if ("CIRCLE".equals(obj.getString("type"))) {
  21.             objects.add(new CircleObject(_x, _y, _rad, _rot));
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement