So I used the following post to help me render my isometric map in Slick2D:

Slick2D Isometric TiledMap Rendering Problem

Big thanks and credit to arminb for the code supplied and for the fix to be able to use it.

My question is, how would I go about getting the properties of the isometric tiles. I have a little character that can walk around on the map, but he can walk on the blocked tiles. I have no code to be able to detect the properties.

This is the code I am using. The map is generated correctly, and the character is generated correctly.

How would I get the properties of a tile that I walk on?

import org.newdawn.slick.Animation;
import org.newdawn.slick.AppGameContainer; 
import org.newdawn.slick.BasicGame; 
import org.newdawn.slick.GameContainer; 
import org.newdawn.slick.Graphics; 
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException; 
import org.newdawn.slick.tiled.TiledMap;  

public class Game extends BasicGame {

    private TiledMap map;
    private Animation sprite, up, down, left, right;
    private float x = 350f, y = 250f;
    public static void main(String[] args) throws SlickException {
        AppGameContainer app = new AppGameContainer(new Game());

        app.setDisplayMode(800, 600, false);

    public Game() {

    public void render(GameContainer arg0, Graphics arg1) throws SlickException {
        map.render(350, 250);
        sprite.draw((int)x, (int)y);

    public void init(GameContainer arg0) throws SlickException {
        Image [] movementUp = {new Image("data/wiz_up_one.jpg"), 
                new Image("data/wiz_up_two.jpg")};

        Image [] movementDown = {new Image("data/wiz_down_one.jpg"),
                          new Image("data/wiz_down_two.jpg")};

        Image [] movementLeft = {new Image("data/wiz_left_one.jpg"), 
                          new Image("data/wiz_left_two.jpg")};

        Image [] movementRight = {new Image("data/wiz_right_one.jpg"), 
                           new Image("data/wiz_right_two.jpg")};
        int [] duration = {300, 300}; 

        up = new Animation(movementUp, duration, false);
        down = new Animation(movementDown, duration, false);
        left = new Animation(movementLeft, duration, false);
        right = new Animation(movementRight, duration, false);

        // Original orientation of the sprite. It will look right.
        sprite = right;
        map = new TiledMap("data/iso.tmx"); //path is valid!

    public void update(GameContainer gc, int delta) throws SlickException {
        Input input = gc.getInput();
        if (input.isKeyDown(Input.KEY_UP))
            sprite = up;

            // The lower the delta the slowest the sprite will animate.
            y -= delta * 0.1f;

        else if (input.isKeyDown(Input.KEY_DOWN))
            sprite = down;

            y += delta * 0.1f;

        else if (input.isKeyDown(Input.KEY_LEFT))
            sprite = left;

            x -= delta * 0.1f;

        else if (input.isKeyDown(Input.KEY_RIGHT))
            sprite = right;

            x += delta * 0.1f;



enter code here
  • \$\begingroup\$ You haven't told us what you've tried and how it's not working. Asking us how to modify your code to implement the feature you want is too localized in my opinion. I'm voting to close this question for that reason. \$\endgroup\$ – MichaelHouse Jan 20 '13 at 20:13
  • \$\begingroup\$ The questions is how do I go about doing it? "How would I get the properties of a tile that I walk on?" I know how to do it for a regular map, but I don't see how it would work. I really just want a push in the right. \$\endgroup\$ – n0774k3n Jan 20 '13 at 20:14

Read the documentation for the TiledMap class. You'll find a method called getTileID(). It takes a x and y position and a layer ID. Pass in the position and layer ID of the player. This will give you the ID of the tile the player is at. Use that ID to retrieve information about the tile.

  • \$\begingroup\$ Are the positions read the same as a Orthogonal map? The very top being 0,0 then down and right is 0,1? Or just the x,y position of my character? \$\endgroup\$ – n0774k3n Jan 20 '13 at 20:30
  • \$\begingroup\$ x,y position of the character as far as I know. I've never used the TiledMap before. This would be easy to implement and test to see if it's working correctly. \$\endgroup\$ – MichaelHouse Jan 20 '13 at 20:46
  • \$\begingroup\$ I did what you said and it works to a point. I can't use the location of the character, only the location of the actual tile in the map. I will keep playing around with it to see if I can get it to work right. Thanks a lot for your help. \$\endgroup\$ – n0774k3n Jan 20 '13 at 22:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.