Example usage for com.badlogic.gdx.utils IntArray contains

List of usage examples for com.badlogic.gdx.utils IntArray contains

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils IntArray contains.

Prototype

public boolean contains(int value) 

Source Link

Usage

From source file:com.kotcrab.vis.editor.proxy.EntityProxy.java

License:Apache License

public void addGroup(int groupId, int parentGroupId) {
    IntArray groupIds = getGroupComponent().groupIds;
    if (groupIds.contains(groupId) == false) {
        if (parentGroupId != -1)
            groupIds.insert(groupIds.indexOf(parentGroupId), groupId);
        else/*from w w  w .j av  a2 s  .  c  o  m*/
            groupIds.add(groupId);
    }
}

From source file:com.kotcrab.vis.editor.proxy.EntityProxy.java

License:Apache License

public void removeGroup(int groupId) {
    IntArray groupIds = getGroupComponent().groupIds;
    if (groupIds.contains(groupId))
        groupIds.removeValue(groupId);//  w w  w.  j  a  v  a2s  .com
}

From source file:com.weimingtom.iteye.simplerpg.tiled.TiledMapPacker.java

License:Apache License

private void packTileSet(TileSet set, IntArray usedIds, FileHandle inputDirHandle, File outputDir,
        Settings settings) throws IOException {
    BufferedImage tile;//from ww w . ja v a2  s .c  o m
    Vector2 tileLocation;
    TileSetLayout packerTileSet;
    Graphics g;

    packer = new TexturePacker(settings);

    TileSetLayout layout = new TileSetLayout(set, inputDirHandle);

    for (int gid = layout.firstgid, i = 0; i < layout.numTiles; gid++, i++) {
        if (usedIds != null && !usedIds.contains(gid)) {
            System.out.println("Stripped Id: " + gid);
            continue;
        }

        tileLocation = layout.getLocation(gid);
        tile = new BufferedImage(layout.tileWidth, layout.tileHeight, BufferedImage.TYPE_4BYTE_ABGR);

        g = tile.createGraphics();
        g.drawImage(layout.image, 0, 0, layout.tileWidth, layout.tileHeight, (int) tileLocation.x,
                (int) tileLocation.y, (int) tileLocation.x + layout.tileWidth,
                (int) tileLocation.y + layout.tileHeight, null);

        if (isBlended(tile))
            setBlended(gid);

        packer.addImage(tile, removeExtension(removePath(set.imageName)) + "_" + i);
    }

    File outputFile = getRelativeFile(outputDir, removeExtension(set.imageName) + " packfile");
    outputFile.getParentFile().mkdirs();
    packer.process(outputFile.getParentFile(), outputFile, removeExtension(removePath(set.imageName)));
}

From source file:de.bitowl.advent.game2.MyTiledMapPacker.java

License:Apache License

/** Traverse the specified tilesets, optionally lookup the used ids and pass every tile image to the {@link TexturePacker2},
 * optionally ignoring unused tile ids */
private void packTilesets(ObjectMap<String, TiledMapTileSet> sets, FileHandle inputDirHandle, File outputDir,
        Settings texturePackerSettings) throws IOException {
    BufferedImage tile;/*from w  w w. ja v a 2 s  .  c  o m*/
    Vector2 tileLocation;
    TileSetLayout packerTileSet;
    Graphics g;

    packer = new TexturePacker2(texturePackerSettings);

    int tileidx = 0;
    for (TiledMapTileSet set : sets.values()) {
        String tilesetName = set.getName();
        System.out.println("Processing tileset " + tilesetName);
        IntArray usedIds = this.settings.stripUnusedTiles ? getUsedIdsBucket(tilesetName, -1) : null;

        int tileWidth = set.getProperties().get("tilewidth", Integer.class);
        int tileHeight = set.getProperties().get("tileheight", Integer.class);
        int firstgid = set.getProperties().get("firstgid", Integer.class);
        String imageName = set.getProperties().get("imagesource", String.class);

        TileSetLayout layout = new TileSetLayout(firstgid, set, inputDirHandle);
        tileidx = 0;
        for (int gid = layout.firstgid, i = 0; i < layout.numTiles; gid++, i++, tileidx++) {
            if (usedIds != null && !usedIds.contains(gid)) {
                System.out.println("Stripped id #" + gid + " from tileset \"" + tilesetName + "\"");
                continue;
            }

            tileLocation = layout.getLocation(gid);
            tile = new BufferedImage(tileWidth, tileHeight, BufferedImage.TYPE_4BYTE_ABGR);

            g = tile.createGraphics();
            g.drawImage(layout.image, 0, 0, tileWidth, tileHeight, (int) tileLocation.x, (int) tileLocation.y,
                    (int) tileLocation.x + tileWidth, (int) tileLocation.y + tileHeight, null);

            if (isBlended(tile))
                setBlended(gid);
            System.out.println("Adding " + tileWidth + "x" + tileHeight + " (" + (int) tileLocation.x + ", "
                    + (int) tileLocation.y + ")" + tileidx);
            packer.addImage(tile, tilesetName + "_" + tileidx);
        }
    }

    File outputDirTilesets = getRelativeFile(outputDir, this.settings.tilesetOutputDirectory);
    outputDirTilesets.mkdirs();
    packer.pack(outputDirTilesets, this.settings.atlasOutputName + ".atlas");
}

From source file:se.toxbee.sleepfighter.challenge.sort.PermutatingListGenerator.java

License:Open Source License

@Override
public int[] generateList(Random rng, int size) {
    IntArray arr = new IntArray(size);

    // Put an initial number in the list
    arr.add(this.generateNumber(rng));

    while (arr.size < size) {
        /*/* w w w.j a  va  2  s  .c  o m*/
         * Randomly choose a number from the list, manipulate it, and put
         * the result back if it is not already present.
         */
        int number = this.manipulateNumber(arr.get(rng.nextInt(arr.size)), rng);

        if (!arr.contains(number)) {
            arr.add(number);
        }
    }

    PrimitiveArrays.shuffle(arr.items, rng);

    return arr.items;
}