1
\$\begingroup\$

So I made a map using the TILED application and I have it as a .tmx for reasons, but whenever I use the TildMap class in the Slick2D library to render the map on the screen, it gives me an error. Here are the files:

Class file:

public TiledMap testMap = null;

//TILE-READER
public static TileReader tileReader;

public Game (int stateID) {}

@Override
public int getID() {
    return Main.game; //GAMESTATE = 1
}

@Override
public void init(GameContainer gameContainer, StateBasedGame stateBasedGame) throws SlickException {
    worldMap = new Image ("res/in_game_map.png");
    player = new Player(playerX, playerY, mapX, mapY);
    tileReader = new TileReader();
    player.init(gameContainer, stateBasedGame);
    tileReader.init(gameContainer, stateBasedGame);

    testMap = new TiledMap("res/worldMap.tmx");
}

@Override
public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int delta) throws SlickException {
    player.update(gameContainer, stateBasedGame, delta);
    tileReader.update(gameContainer, stateBasedGame, delta);
}

@Override
public void render(GameContainer gameContainer, StateBasedGame stateBasedGame, Graphics graphics) throws SlickException {
    graphics.scale(1.05f, 1.05f);

    graphics.translate(player.camera.getCamX(), player.camera.getCamY());
    gameMap.draw(mapX - mapLength, mapY - mapWidth);
    testMap.render(0, 0);
    tileReader.render(gameContainer, stateBasedGame, graphics);
    player.render(gameContainer, stateBasedGame, graphics);
    graphics.translate(-player.camera.getCamX(), -player.camera.getCamY());

    if (inputHandler.keyMAP) {
        worldMap.draw(0, 0);
    }

    graphics.drawString("Player X: " + player.getxPos(), 400, 400);
    graphics.drawString("Player Y: " + player.getyPos(), 400, 415);
}

And here is the error message that it provided me:

Caused by: org.newdawn.slick.SlickException: Unsupport tiled map type: base64,zlib (only gzip base64 supported)

Is there an issue with the way I formatted the .tmx file or is it that I am using the latest version of Tiled and that slick2D is no longer compatible with the newer version?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

I managed to figure out the answer whilst looking through the Tiled application. Basically, you go to Map --> Map Properties and under "Tiled Layer Format" you can change it to a gzip base64 compression method. Also, you can change the compression method when you create a new Tiled map.

\$\endgroup\$
1
  • \$\begingroup\$ I have to warn though, that "gzip" will be deprecated in Tiled 0.15, since there is no advantage over "zlib" so the additional option is mostly just confusing. It would be good to convince the Slick2D maintainers to add support for "zlib" as well, which should be an easy change. \$\endgroup\$ Commented Dec 23, 2015 at 9:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .