0

I'm creating a game and I would like to load levels in the game using a tile map. this is the TileMap class code:

        for(int row = 0; row < mapHeight; row++){
            for(int col = 0; col < mapWidth; col++){

                if(tile[col][row] == "1"){
                    handler.addObject(new Block(col * tileSize, row * tileSize, ID.Block, ss, 1, handler));
                }

                if(tile[col][row] == "&"){
                    handler.addObject(new Player(col*tileSize, row*tileSize, ID.Player, handler, game, ss, 2));
                }
            }
        }

With this code I just get a blank screen. How do I fix this? Is there a better way? Thanks!

yasko kai
  • 5
  • 4
  • Don't compare Strings using `==` or `!=`. Use the `equals(...)` or the `equalsIgnoreCase(...)` method instead. Understand that `==` checks if the two *object references* are the same which is not what you're interested in. The methods on the other hand check if the two Strings have the same characters in the same order, and that's what matters here. – Hovercraft Full Of Eels Apr 09 '18 at 01:46
  • I changed it to .equals(), but I'm still getting a blank screen. – yasko kai Apr 10 '18 at 01:01

0 Answers0