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

Author Topic: sf::Rendertexture Collision Detection  (Read 1240 times)

0 Members and 1 Guest are viewing this topic.

Qluxzz

  • Guest
sf::Rendertexture Collision Detection
« on: April 04, 2013, 09:40:35 pm »
Hi there, I'm working on a little project in which i render a large tilemap. To save performance and don't having to draw 100x100 tiles each draw update, so instead i rendered the whole tilemap to a separate texture so i only have to draw one thing.

The problem I have is that I don't really know how to do collision detection with a large texture.

for (int x = 0; x < worldMap.size(); x++) {
                        for (int y = 0; y < worldMap[x].size(); y++) {
                int tileId = worldMap[y][x];
               // Get the width and height of the image
                int width = 64;
                int height = 64;
                // Adjust the offset by using the width and height of the image used      
                                caveTiles[tileId].setPosition(x * width, y * height);
                // Draw the tiles
                cave.draw(caveTiles[tileId]);
            }
        }
 
This code is for drawing all tiles to the texture.

Thanks in Advance.
 

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: sf::Rendertexture Collision Detection
« Reply #1 on: April 04, 2013, 09:47:37 pm »
You still have your tile data in memory. So what prevent you from doing you collision detection on these tiles? ;)

Wnt2bsleepin

  • Guest
Re: sf::Rendertexture Collision Detection
« Reply #2 on: April 05, 2013, 02:03:13 am »
I am actually rendering each and every tile each iteration of the game loop. How did you store it and only have it display one?

 

anything