Java Code Examples for com.badlogic.gdx.utils.Array#add()

The following examples show how to use com.badlogic.gdx.utils.Array#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GwtDatabaseQueryTest.java    From gdx-fireapp with Apache License 2.0 6 votes vote down vote up
@Test
public void terminate() {
    // Given
    Database database = Mockito.mock(Database.class);
    GwtDatabaseQuery gwtDatabaseQuery = new TestQuery(database, "/test");
    Array<Filter> filters = new Array<>();
    OrderByClause orderByClause = new OrderByClause(OrderByMode.ORDER_BY_KEY, null);
    filters.add(new Filter(FilterType.LIMIT_FIRST, 2));
    gwtDatabaseQuery.with(filters);
    gwtDatabaseQuery.with(orderByClause);

    // When
    gwtDatabaseQuery.prepare();
    gwtDatabaseQuery.run();
    gwtDatabaseQuery.terminate();

    // Then
    Mockito.verify(database, VerificationModeFactory.times(1)).terminateOperation();
    Assert.assertNull(Whitebox.getInternalState(gwtDatabaseQuery, "filtersToApply"));
    Assert.assertNull(Whitebox.getInternalState(gwtDatabaseQuery, "orderByToApply"));
    Assert.assertNull(Whitebox.getInternalState(gwtDatabaseQuery, "databaseReference"));
}
 
Example 2
Source File: PackDialogController.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
private Array<PackProcessingNode> prepareProcessingNodes(ProjectModel project, Array<PackModel> packs) {
    Array<PackProcessingNode> result = new Array<>();
    for (PackModel pack : packs) {
        for (ScaleFactorModel scaleFactor : pack.getScaleFactors()) {
            PackModel newPack = new PackModel(pack);
            newPack.setScaleFactors(Array.with(scaleFactor));
            TexturePacker.Settings settings = newPack.getSettings();
            settings.scaleSuffix[0] = "";
            settings.scale[0] = scaleFactor.getFactor();
            settings.scaleResampling[0] = scaleFactor.getResampling();

            PackProcessingNode processingNode = new PackProcessingNode(project, newPack);
            processingNode.setOrigPack(pack);

            result.add(processingNode);
        }
    }
    return result;
}
 
Example 3
Source File: Assets.java    From ud406 with MIT License 6 votes vote down vote up
public GigaGalAssets(TextureAtlas atlas) {
    standingLeft = atlas.findRegion(Constants.STANDING_LEFT);
    standingRight = atlas.findRegion(Constants.STANDING_RIGHT);
    walkingLeft = atlas.findRegion(Constants.WALKING_LEFT_2);
    walkingRight = atlas.findRegion(Constants.WALKING_RIGHT_2);

    jumpingLeft = atlas.findRegion(Constants.JUMPING_LEFT);
    jumpingRight = atlas.findRegion(Constants.JUMPING_RIGHT);

    Array<AtlasRegion> walkingLeftFrames = new Array<AtlasRegion>();
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_1));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_3));
    walkingLeftAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingLeftFrames, PlayMode.LOOP);

    Array<AtlasRegion> walkingRightFrames = new Array<AtlasRegion>();
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_1));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_3));
    walkingRightAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingRightFrames, PlayMode.LOOP);
}
 
Example 4
Source File: Assets.java    From ud406 with MIT License 6 votes vote down vote up
public GigaGalAssets(TextureAtlas atlas) {
    standingLeft = atlas.findRegion(Constants.STANDING_LEFT);
    standingRight = atlas.findRegion(Constants.STANDING_RIGHT);
    walkingLeft = atlas.findRegion(Constants.WALKING_LEFT_2);
    walkingRight = atlas.findRegion(Constants.WALKING_RIGHT_2);

    jumpingLeft = atlas.findRegion(Constants.JUMPING_LEFT);
    jumpingRight = atlas.findRegion(Constants.JUMPING_RIGHT);

    Array<AtlasRegion> walkingLeftFrames = new Array<AtlasRegion>();
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_1));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_3));
    walkingLeftAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingLeftFrames, PlayMode.LOOP);

    Array<AtlasRegion> walkingRightFrames = new Array<AtlasRegion>();
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_1));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_3));
    walkingRightAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingRightFrames, PlayMode.LOOP);
}
 
Example 5
Source File: Assets.java    From ud406 with MIT License 6 votes vote down vote up
public GigaGalAssets(TextureAtlas atlas) {
    standingLeft = atlas.findRegion(Constants.STANDING_LEFT);
    standingRight = atlas.findRegion(Constants.STANDING_RIGHT);
    walkingLeft = atlas.findRegion(Constants.WALKING_LEFT_2);
    walkingRight = atlas.findRegion(Constants.WALKING_RIGHT_2);

    jumpingLeft = atlas.findRegion(Constants.JUMPING_LEFT);
    jumpingRight = atlas.findRegion(Constants.JUMPING_RIGHT);

    Array<AtlasRegion> walkingLeftFrames = new Array<AtlasRegion>();
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_1));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_3));
    walkingLeftAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingLeftFrames, PlayMode.LOOP);

    Array<AtlasRegion> walkingRightFrames = new Array<AtlasRegion>();
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_1));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_3));
    walkingRightAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingRightFrames, PlayMode.LOOP);
}
 
Example 6
Source File: Assets.java    From ud406 with MIT License 6 votes vote down vote up
public GigaGalAssets(TextureAtlas atlas) {
    standingLeft = atlas.findRegion(Constants.STANDING_LEFT);
    standingRight = atlas.findRegion(Constants.STANDING_RIGHT);
    walkingLeft = atlas.findRegion(Constants.WALKING_LEFT_2);
    walkingRight = atlas.findRegion(Constants.WALKING_RIGHT_2);

    jumpingLeft = atlas.findRegion(Constants.JUMPING_LEFT);
    jumpingRight = atlas.findRegion(Constants.JUMPING_RIGHT);

    Array<AtlasRegion> walkingLeftFrames = new Array<AtlasRegion>();
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_1));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_3));
    walkingLeftAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingLeftFrames, PlayMode.LOOP);

    Array<AtlasRegion> walkingRightFrames = new Array<AtlasRegion>();
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_1));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_3));
    walkingRightAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingRightFrames, PlayMode.LOOP);
}
 
Example 7
Source File: Assets.java    From ud406 with MIT License 6 votes vote down vote up
public GigaGalAssets(TextureAtlas atlas) {
    standingLeft = atlas.findRegion(Constants.STANDING_LEFT);
    standingRight = atlas.findRegion(Constants.STANDING_RIGHT);
    walkingLeft = atlas.findRegion(Constants.WALKING_LEFT_2);
    walkingRight = atlas.findRegion(Constants.WALKING_RIGHT_2);

    jumpingLeft = atlas.findRegion(Constants.JUMPING_LEFT);
    jumpingRight = atlas.findRegion(Constants.JUMPING_RIGHT);

    Array<AtlasRegion> walkingLeftFrames = new Array<AtlasRegion>();
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_1));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_3));
    walkingLeftAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingLeftFrames, PlayMode.LOOP);

    Array<AtlasRegion> walkingRightFrames = new Array<AtlasRegion>();
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_1));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_3));
    walkingRightAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingRightFrames, PlayMode.LOOP);
}
 
Example 8
Source File: WordHighlightRule.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
public void process (HighlightTextArea textArea, Array<Highlight> highlights) {
	String text = textArea.getText();
	int index = text.indexOf(word);
	while (index >= 0) {
		highlights.add(new Highlight(color, index, index += word.length()));
		index = text.indexOf(word, index);
	}
}
 
Example 9
Source File: Assets.java    From ud406 with MIT License 5 votes vote down vote up
public ExplosionAssets(TextureAtlas atlas) {

            Array<AtlasRegion> explosionRegions = new Array<AtlasRegion>();
            explosionRegions.add(atlas.findRegion(Constants.EXPLOSION_LARGE));
            explosionRegions.add(atlas.findRegion(Constants.EXPLOSION_MEDIUM));
            explosionRegions.add(atlas.findRegion(Constants.EXPLOSION_SMALL));

            explosion = new Animation(Constants.EXPLOSION_DURATION / explosionRegions.size,
                    explosionRegions, PlayMode.NORMAL);
        }
 
Example 10
Source File: LevelLoader.java    From ud406 with MIT License 5 votes vote down vote up
private static void loadPlatforms(JSONArray array, Level level) {

        Array<Platform> platformArray = new Array<Platform>();

        for (Object object : array) {
            final JSONObject platformObject = (JSONObject) object;

            final float x = safeGetFloat(platformObject, Constants.LEVEL_X_KEY);
            final float y = safeGetFloat(platformObject, Constants.LEVEL_Y_KEY);
            final float width = ((Number) platformObject.get(Constants.LEVEL_WIDTH_KEY)).floatValue();
            final float height = ((Number) platformObject.get(Constants.LEVEL_HEIGHT_KEY)).floatValue();

            Gdx.app.log(TAG,
                    "Loaded a platform at x = " + x + " y = " + (y + height) + " w = " + width + " h = " + height);

            final Platform platform = new Platform(x, y + height, width, height);
            platformArray.add(platform);

            final String identifier = (String) platformObject.get(Constants.LEVEL_IDENTIFIER_KEY);
            if (identifier != null && identifier.equals(Constants.LEVEL_ENEMY_TAG)) {
                Gdx.app.log(TAG, "Loaded an enemy on that platform");
                final Enemy enemy = new Enemy(platform);
                level.getEnemies().add(enemy);
            }
        }

        platformArray.sort(new Comparator<Platform>() {
            @Override
            public int compare(Platform o1, Platform o2) {
                if (o1.top < o2.top) {
                    return 1;
                } else if (o1.top > o2.top) {
                    return -1;
                }
                return 0;
            }
        });

        level.getPlatforms().addAll(platformArray);
    }
 
Example 11
Source File: Firestorm.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
private IActionResult calcResult(Creature creature, Grid2D.Coordinate cell) {
    Vector2 position = tmp.set(cell.x(), cell.y());
    Array<Creature> underAttack = new Array<Creature>();
    Array<Creature> killed = new Array<Creature>();
    ObjectIntMap<Creature> expResults = new ObjectIntMap<Creature>();
    for (int i = cell.x() - MathUtils.ceil(radius); i <= cell.x() + radius; i++) {
        for (int j = cell.y() - MathUtils.ceil(radius); j <= cell.y() + radius; j++) {
            if (position.dst(i, j) <= radius) {
                WorldObject object = creature.world.get(i, j);
                if (object instanceof Creature && ((Creature) object).get(Attribute.canBeSelected)) {
                    underAttack.add((Creature) object);
                }
            }
        }
    }
    for (Creature c : underAttack) {
        int attackLevel = (c.getX() == cell.x() && c.getY() == cell.y()) ? this.epicenterAttackLevel : this.attackLevel;
        int defenceLevel = c.get(Attribute.defenceFor(attackType));
        if (attackLevel > defenceLevel) {
            killed.add(c);
            if (creature.inRelation(Creature.CreatureRelation.enemy, c)) {
                expResults.getAndIncrement(creature, 0, ExpHelper.expForKill(creature, c));
            }
        } else {
            if (creature.inRelation(Creature.CreatureRelation.enemy, c)) {
                expResults.put(c, ExpHelper.expForDefence(creature, c));
            } else {
                expResults.put(c, ExpHelper.MIN_EXP);
            }
        }
    }
    return new FirestormResult(creature, owner, underAttack, killed, expResults, cell);
}
 
Example 12
Source File: Roll.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public Array<RangeItemCount> roll() {
    if (range == null) {
        return dropped;
    }
    Array<RangeItemCount> res = new Array<RangeItemCount>();
    int value = range.getRandomInRange();
    for (RangeItemCount rangeItemCount : dropped) {
        Range r = rangeItemCount.range;
        if (r == null || r.inRange(value)) {
            res.add(rangeItemCount);
        }
    }
    return res;
}
 
Example 13
Source File: OperationTree.java    From artemis-odb-orion with Apache License 2.0 5 votes vote down vote up
private void clear(OperationTree ot, Array<Operation> toRemove) {
	toRemove.add(ot.operation);
	ot.operation = null;
	ot.parent = null;
	ot.executor = null;

	if (ot.children.size > 0) {
		for (OperationTree node : ot.children) {
			clear(node, toRemove);
		}
		ot.children.clear();
	}

	pool.free(ot);
}
 
Example 14
Source File: Assets.java    From ud406 with MIT License 5 votes vote down vote up
public ExplosionAssets(TextureAtlas atlas) {

            Array<AtlasRegion> explosionRegions = new Array<AtlasRegion>();
            explosionRegions.add(atlas.findRegion(Constants.EXPLOSION_LARGE));
            explosionRegions.add(atlas.findRegion(Constants.EXPLOSION_MEDIUM));
            explosionRegions.add(atlas.findRegion(Constants.EXPLOSION_SMALL));

            explosion = new Animation(Constants.EXPLOSION_DURATION / explosionRegions.size,
                    explosionRegions, PlayMode.NORMAL);
        }
 
Example 15
Source File: TXT.java    From riiablo with Apache License 2.0 4 votes vote down vote up
@Deprecated
public static TXT loadFromStream2(InputStream in) {
  BufferedReader reader = null;
  try {
    reader = IOUtils.buffer(new InputStreamReader(in, "US-ASCII"));
    ObjectIntMap<String> columns = new ObjectIntMap<>();
    String[] columnNames = reader.readLine().split("\t");
    for (int i = 0; i < columnNames.length; i++) {
      String key = columnNames[i].toLowerCase();
      if (!columns.containsKey(key)) columns.put(key, i);
    }
    if (DEBUG_COLS) {
      ObjectSet<String> duplicates = new ObjectSet<>();
      String[] colNames = new String[columns.size];
      for (int i = 0, j = 0; i < columnNames.length; i++) {
        String columnName = columnNames[i];
        if (!duplicates.add(columnName)) {
          continue;
        }

        colNames[j++] = columnName;
      }
      Gdx.app.debug(TAG, "cols=" + Arrays.toString(colNames));
    }

    Array<String[]> data = new Array<>(String[].class);
    for (String line; (line = reader.readLine()) != null;) {
      String[] tmp = line.split("\t", -1);
      if (tmp.length != columnNames.length) {
        if (DEBUG_ROWS) Gdx.app.debug(TAG, "Skipping row " + Arrays.toString(tmp));
        continue;
      }

      data.add(tmp);
      if (DEBUG_ROWS) Gdx.app.debug(TAG, data.size - 1 + ": " + Arrays.toString(tmp));
    }

    return new TXT(columns, data);
  } catch (Throwable t) {
    throw new GdxRuntimeException("Couldn't read TXT", t);
  } finally {
    IOUtils.closeQuietly(reader);
  }
}
 
Example 16
Source File: LegacyImporter.java    From talos with Apache License 2.0 4 votes vote down vote up
ModuleWrapper readScaledNumbericalValue(BufferedReader reader, ModuleWrapper toModule, int toSlot, String varName, boolean skip, boolean independant) {
    ModuleWrapper wrapper = null;
    DynamicRangeModuleWrapper dynamic;
    RandomRangeModuleWrapper randomRange;
    try {
        if(isActive(reader, varName)) {
            float lowMin = readFloat(reader, "lowMin");
            float lowMax = readFloat(reader, "lowMax");
            float highMin = readFloat(reader, "highMin");
            float highMax = readFloat(reader, "highMax");

            if(scaleTimes.contains(varName, false)) {
                lowMin /= 1000f;
                lowMax /= 1000f;
                highMin /= 1000f;
                highMax /= 1000f;
            }

            if(varName.equals("emission")) {
                //1 value hack
                if(lowMin == 1) lowMin = 2;
                if(lowMax == 1) lowMax = 2;
                if(highMin == 1) highMin = 2;
                if(highMax == 1) highMax = 2;
            }

            boolean relative = readBoolean(reader, "relative");
            float[] scaling = new float[readInt(reader, "scalingCount")];
            for (int i = 0; i < scaling.length; i++) {
                scaling[i] = readFloat(reader, "scaling" + i);
            }
            float[] timeline = new float[readInt(reader, "timelineCount")];
            for (int i = 0; i < timeline.length; i++) {
                timeline[i] = readFloat(reader, "timeline" + i);
            }

            Array<Vector2> points = new Array<>();
            for(int i = 0; i < scaling.length; i++) {
                points.add(new Vector2(timeline[i], scaling[i]));
            }

            if(!skip) {
                if(varName.equals("xOffset") || varName.equals("yOffset")) { // special shitty case
                    randomRange = (RandomRangeModuleWrapper) stage.moduleBoardWidget.createModule(RandomRangeModule.class, leftX, getNextY());
                    randomRange.setData(lowMin, lowMax);
                    if(toModule != null) {
                        stage.moduleBoardWidget.makeConnection(randomRange, toModule, RandomRangeModule.OUTPUT, toSlot);
                    }
                    wrapper = randomRange;
                } else {
                    dynamic = (DynamicRangeModuleWrapper) stage.moduleBoardWidget.createModule(DynamicRangeModule.class, leftX, getNextY());
                    dynamic.setData(lowMin, lowMax, highMin, highMax, points);
                    if(toModule != null) {
                        stage.moduleBoardWidget.makeConnection(dynamic, toModule, DynamicRangeModule.OUTPUT, toSlot);
                    }
                    wrapper = dynamic;
                }
            }
        }

        if(independant) {
            String line = reader.readLine();
            if (line != null && line.contains("independent")) {
                boolean independent = Boolean.parseBoolean(readString(line));
            } else {
                reader.reset();
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    return wrapper;
}
 
Example 17
Source File: FamilyManager.java    From ashley with Apache License 2.0 4 votes vote down vote up
public void updateFamilyMembership (Entity entity) {
	// Find families that the entity was added to/removed from, and fill
	// the bitmasks with corresponding listener bits.
	Bits addListenerBits = bitsPool.obtain();
	Bits removeListenerBits = bitsPool.obtain();

	for (Family family : entityListenerMasks.keys()) {
		final int familyIndex = family.getIndex();
		final Bits entityFamilyBits = entity.getFamilyBits();

		boolean belongsToFamily = entityFamilyBits.get(familyIndex);
		boolean matches = family.matches(entity) && !entity.removing;

		if (belongsToFamily != matches) {
			final Bits listenersMask = entityListenerMasks.get(family);
			final Array<Entity> familyEntities = families.get(family);
			if (matches) {
				addListenerBits.or(listenersMask);
				familyEntities.add(entity);
				entityFamilyBits.set(familyIndex);
			} else {
				removeListenerBits.or(listenersMask);
				familyEntities.removeValue(entity, true);
				entityFamilyBits.clear(familyIndex);
			}
		}
	}

	// Notify listeners; set bits match indices of listeners
	notifying = true;
	Object[] items = entityListeners.begin();

	try {
		for (int i = removeListenerBits.nextSetBit(0); i >= 0; i = removeListenerBits.nextSetBit(i + 1)) {
			((EntityListenerData)items[i]).listener.entityRemoved(entity);
		}

		for (int i = addListenerBits.nextSetBit(0); i >= 0; i = addListenerBits.nextSetBit(i + 1)) {
			((EntityListenerData)items[i]).listener.entityAdded(entity);
		}
	}
	finally {
		addListenerBits.clear();
		removeListenerBits.clear();
		bitsPool.free(addListenerBits);
		bitsPool.free(removeListenerBits);
		entityListeners.end();
		notifying = false;	
	}
}
 
Example 18
Source File: Event.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
public void addListener (Listener<T, O> listener, T type, O order) {
	Array<Listener<T, O>> ls = listeners[type.ordinal()][order.ordinal()];
	if (!ls.contains(listener, true)) {
		ls.add(listener);
	}
}
 
Example 19
Source File: FilteredTree.java    From talos with Apache License 2.0 4 votes vote down vote up
public void findExpandedObjects (Array<T> objects) {
    if (expanded && !FilteredTree.findExpandedObjects(children, objects))
        objects.add(object);
}
 
Example 20
Source File: LevelLoader.java    From ud406 with MIT License 2 votes vote down vote up
private static void loadPlatforms(JSONArray array, Level level) {

        Array<Platform> platformArray = new Array<Platform>();

        for (Object object : array) {
            final JSONObject platformObject = (JSONObject) object;

            Vector2 bottomLeft = extractXY(platformObject);

            final float width = ((Number) platformObject.get(Constants.LEVEL_WIDTH_KEY)).floatValue();
            final float height = ((Number) platformObject.get(Constants.LEVEL_HEIGHT_KEY)).floatValue();


            final Platform platform = new Platform(bottomLeft.x, bottomLeft.y + height, width, height);

            platformArray.add(platform);


            final String identifier = (String) platformObject.get(Constants.LEVEL_IDENTIFIER_KEY);


            if (identifier != null && identifier.equals(Constants.LEVEL_ENEMY_TAG)) {
                final Enemy enemy = new Enemy(platform);
                level.getEnemies().add(enemy);
            }


        }


        platformArray.sort(new Comparator<Platform>() {
            @Override
            public int compare(Platform o1, Platform o2) {
                if (o1.top < o2.top) {
                    return 1;
                } else if (o1.top > o2.top) {
                    return -1;
                }
                return 0;
            }
        });

        level.getPlatforms().addAll(platformArray);

    }