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 - Nex

Pages: [1]
1
Graphics / How to render a tile based game efficiently?
« on: June 17, 2014, 09:27:35 pm »
Hi!

I'm currently trying to create a small, tile-based adventure game implemented in C++ and SFML and need a way to render my tiles efficiently. Right now I use a vector of sprites (std::vector<Sprite>) in which I fill in the Sprites created in the map generation algorithm (I created 3 Sprites whose textures are set to be soil, grass and water, then, while generating the map, I change their position and put the moved Sprite into the vector before changing the position again). This vector is passed to the main class in which I render every Sprite with a for-loop that calls the window.draw() function for every individual Sprite.

Drawing all of those Sprites every time in the main loop and moving them around via the sf::View class is incredibly exhausting for my computer - so there has to be a more efficient way. I probably need to reduce the draw calls. I thought about only re-drawing my tiles everytime there's a change to the map and using the View class to hover over a mostly static image - I also read that I should send my draw calls in a batch or draw a big image via the window.draw() call instead of calling this function for every tile, but I'm still not sure about what the most efficient way to do this is.

I hope someone can give me advice on how to render my map resource-friendly - sadly I'm not that experienced with this library.

Pages: [1]
anything