Hey, i have this code
it work fine
void Map::Draw( sf::RenderWindow &wnd)
{
if(isDraw)
{
for(int i=0; i<TileList.size();i++)
{
for(int j=0; j<TileList[i].size();j++)
{
if(TileList[i][j]->SpriteX==-1&&TileList[i][j]->SpriteY==-1)
{
rect.setPosition( (TileList[i][j]->X*tilesize)+(Pos.x*tilesize), (TileList[i][j]->Y*tilesize)+(Pos.y*tilesize));
wnd.draw(rect);
}
else
{
TileSet.setPosition( (TileList[i][j]->X*tilesize)+(Pos.x*tilesize), (TileList[i][j]->Y*tilesize)+(Pos.y*tilesize));
TileSet.setTextureRect( sf::IntRect(TileList[i][j]->SpriteX*tilesize, TileList[i][j]->SpriteY*tilesize,tilesize, tilesize) );
wnd.draw(TileSet);
}
}
}
}
}
but when i do something like this, the app will crash, why?
void Map::Draw( sf::RenderWindow &wnd)
{
if(isDraw)
{
for(int i=0; i<Pos.x+10;i++)
{
for(int j=0; j<Pos.y+10;j++)
{
if(TileList[i][j]->SpriteX==-1&&TileList[i][j]->SpriteY==-1)
{
rect.setPosition( (TileList[i][j]->X*tilesize)+(Pos.x*tilesize), (TileList[i][j]->Y*tilesize)+(Pos.y*tilesize));
wnd.draw(rect);
}
else
{
TileSet.setPosition( (TileList[i][j]->X*tilesize)+(Pos.x*tilesize), (TileList[i][j]->Y*tilesize)+(Pos.y*tilesize));
TileSet.setTextureRect( sf::IntRect(TileList[i][j]->SpriteX*tilesize, TileList[i][j]->SpriteY*tilesize,tilesize, tilesize) );
wnd.draw(TileSet);
}
}
}
}
}