I'm rather new at SFML and I've been playing around with a basic tile engine that I found online. In the tile engine was a camera that did not work all that well and so I took it out with the intent to replace it with my own later. Directly prior to this, the engine would draw only the tiles which were on screen and for some reason was incapable of adding additional tiles to the list of the tiles which need to be drawn. At the current time, I am attempting to draw every tile possible but receiving a vector subscript error after the first row - 1.
Here is the code that seems to be causing the error:
int levelHeight = currentLevel->getHeight();
int levelWidth = currentLevel->getWidth();
for(int tileY = 1; tileY < levelHeight; tileY++)
{
for(int tileX = 1; tileY < levelWidth; tileX++)
{
tile = currentLevel->getTile(tileX, tileY);
std::cout << "Adding Tile X: " << tileX << ", Y: " << tileY << " to buffer." << std::endl;
if(tile)
tile->draw((tileX * tileSize), (tileY * tileSize), display);
}
}
If there is anything else that it would be useful if I provide feel free to ask
I think the inner for
loop terminating condition is incorrect:
for(int tileX = 1; tileY < levelWidth; tileX++)
should be:
for(int tileX = 1; tileX < levelWidth; tileX++)
//^