In my constructor I have my TileMap object definition. But other functions of the class cant use the map. I tried defining map in the header but it really dosent work like that. I have a render function that does all my rendering like window.clear and window.draw(map). I also have a processEvents that processes all the events. I cant pass it to the function as a parameter either.
window.create(sf::VideoMode(528, 256), "Tilemap");
// define the level with an array of tile indices
const int level[] =
{
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
};
//create the tilemap from the level definition
TileMap map;
if (!map.load("tileset.png", sf::Vector2u(33, 33), level, 16, 8))
std::cout << "Cant upload map" << std::endl;
}