So I'm working on a 2D game and right now I have a problem with drawing out my tiles. It laggs terribly and I don't really know what to do about it.
I got a set of tiles: Tile * tiles[32][32];
for(int i = 0; i < 32; i++)
{
for(int j = 0; j < 32; j++)
{
if(tile[j][i]->getPosition().x > (cameraCenter.x-cx-tss) &&
tile[j][i]->getPosition().x < (cameraCenter.x+cx+tss) &&
tile[j][i]->getPosition().y > (cameraCenter.y-cy-tss) &&
tile[j][i]->getPosition().y < (cameraCenter.y+cy+tss)){
renderWindow.draw(tile[j][i]->sprite);
}
}
}
This is my code when I draw it.
Now I tried drawing when my Tiles wasn't pointer and I had no lagg.
Is there a reason why this is ?
And is there someone who can give some pointers to one that is new in both c++ and SFML.
If you need more of anything, just ask.
Thanks