title: SFML Collision with tilemaps
body: <p>My current method of doing it is to check against my array and make cases for each different value I get. It works for small maps with only 1 or 2 collidable tiles but if I have over 100 I'd have to create over 100 cases and if the player enters another map I'd have to create more cases which is very inefficient. Is there a better way I can do tilemap collision with the player? </p>
  
  <p>For example</p>
  
  <pre><code>int x = player.getPlayerPositionX() / map.getTileWidth();
  int y = player.getPlayerPositionY() / map.getTileHeight();
  
  switch (player.getDirection())
  {
  case 3:
      if (map.data[x + y * map.getMapWidth()] == 1)
      {
          player.moveRect(1.0f, 0);
      }
      break;
  case 4:
      x = (player.getPlayerPositionX() + 20) / map.getTileWidth();
      if (map.data[x + y * map.getMapWidth()] == 1)
      {
          player.moveRect(-1.0f, 0);
      }
  
      break;
  }
  </code></pre>