Hello!
I have a Tilemap that is 5 by 5 big and has 64 by 64 big Tiles!
I'm using .tmx maps with tmxparser lib and i have only 2 FPS.
Also at when the map ends there are still buggy grass tiles. What's the problem there? . Btw that's the only thing I'm rendering right now.
Image:
http://imgur.com/NoIUBbi (2 is the FPS counted by Fraps)
void DrawMap(){
IntRect cropRect;
for (int i = 0; i < testmap->map.layerCollection.size(); ++i)
{
tmxparser::TmxLayer layer = testmap->map.layerCollection[i];
int currTile = 0;
for (int y = 0; y < layer.width; y++)
{
for (int x = 0; x < layer.height; x++)
{
if (layer.tiles[currTile].gid > 0){
tmxparser::TmxTileset currTileset = testmap->map.tilesetCollection[layer.tiles[currTile].tilesetIndex];
int tileIndex = layer.tiles[currTile].gid - currTileset.firstgid;
cropRect.left = (tileIndex % (currTileset.image.width / 64)) * 64;
cropRect.top = (tileIndex / (currTileset.image.width / 64)) * 64;
cropRect.width = currTileset.tileWidth;
cropRect.height = currTileset.tileHeight;
VertexArray v(sf::Quads,4);
v[0].position = Vector2f(x * 64, y * 64);
v[1].position = Vector2f((x + 64) * 64, y * 64);
v[2].position = Vector2f((x + 64) * 64, (y + 64) * 64);
v[3].position = Vector2f(x * 64, (y + 64) * 64);
v[0].texCoords = Vector2f(cropRect.left * 64, cropRect.top * 64);
v[1].texCoords = Vector2f((64 + cropRect.left) * 64, cropRect.top * 64);
v[2].texCoords = Vector2f((64 + cropRect.left) * 64, (64 + cropRect.top) * 64);
v[3].texCoords = Vector2f(cropRect.left * 64, (64 + cropRect.top) * 64);
window->draw(v, &currTileset.image.texture);
}
currTile++;
printf("Tile %i \n", currTile);
}
}
currTile = 0;
}
}
Please help