Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Digot

Pages: [1]
1
General / Re: Problems rendering TileMaps
« on: August 03, 2014, 11:28:29 am »
Heyyy

I'm using a lib now that parses my map format and renders it with Vertices to the screen.

Thanks for your help tho :)

2
General / Re: Problems rendering TileMaps
« on: August 02, 2014, 10:19:31 am »
Yeah that was only a small test map.

Also each map has layers. And the tiles are 64 x 64 not 5x5.

5x5 was the Map Size (*64) i took to test the framerates.

3
General / Re: Problems rendering TileMaps
« on: August 02, 2014, 12:16:25 am »
Hi!

Thanks for your answer.

I think it's because I'm doing those loops on each Draw call instead of just doing it once and saving it to a costum class so i only have to call it through one loop.

But instead of that i'll do it like the tutorial (http://www.sfml-dev.org/tutorials/2.0/graphics-vertex-array.php) showed.

I think it will perform much better.

Thanks!

4
General / Problems rendering TileMaps
« on: August 01, 2014, 08:23:12 pm »
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 :)


Pages: [1]