Search in sources :

Example 1 with Key

use of test.StaticGeneratedDungeon.Key in project ultimate-java by pantinor.

the class GeneratedMapTmxConvert method main.

public static void main(String[] args) throws Exception {
    int TILE_SIZE = 16;
    FileHandle f = new FileHandle("assets/tilemaps/tiles-vga-atlas.txt");
    TextureAtlasData atlas = new TextureAtlasData(f, f.parent(), false);
    String[] mapTileIds = new String[atlas.getRegions().size + 1];
    for (Region r : atlas.getRegions()) {
        int x = r.left / r.width;
        int y = r.top / r.height;
        int i = y * TILE_SIZE + x + 1;
        mapTileIds[i] = r.name;
    }
    List<StaticGeneratedDungeon> dungeons = new ArrayList<StaticGeneratedDungeon>();
    dungeons.add(new StaticGeneratedDungeon("The Dark Pit of Emes the Fallen 01 (tsv).txt"));
    dungeons.add(new StaticGeneratedDungeon("The Dark Pit of Emes the Fallen 10 (tsv).txt"));
    dungeons.add(new StaticGeneratedDungeon("The Dark Pit of Emes the Fallen 20 (tsv).txt"));
    List<String> layers = new ArrayList<String>();
    for (StaticGeneratedDungeon sd : dungeons) {
        StringBuffer data = new StringBuffer();
        for (int y = 0; y < StaticGeneratedDungeon.DIM; y++) {
            for (int x = 0; x < StaticGeneratedDungeon.DIM; x++) {
                Key val = sd.getCell(x, y);
                if (val == null) {
                    val = StaticGeneratedDungeon.Key.NULL;
                }
                data.append(findTileId(mapTileIds, val.getName()) + ",");
            }
            data.append("\n");
        }
        String dl = data.toString();
        dl = dl.substring(0, dl.length() - 2);
        layers.add(dl);
    }
    GeneratedMapTmxConvert c = new GeneratedMapTmxConvert("delve", "tiles-vga.png", StaticGeneratedDungeon.DIM, StaticGeneratedDungeon.DIM, TILE_SIZE, TILE_SIZE, layers.get(0), layers.get(1), layers.get(2), "", "", "");
    FileUtils.writeStringToFile(new File("assets/tilemaps/generatedDungeon.tmx"), c.toString());
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle) ArrayList(java.util.ArrayList) TextureAtlasData(com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData) Region(com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region) File(java.io.File) Key(test.StaticGeneratedDungeon.Key)

Aggregations

FileHandle (com.badlogic.gdx.files.FileHandle)1 TextureAtlasData (com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData)1 Region (com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Key (test.StaticGeneratedDungeon.Key)1