Comments (3)
Sorry this isn't easily done without a bit of work. You'd probably need to keep your array of tile IDs around during run time, modify those, then resubmit them to build a new vertex array (if this happens infrequently then there should be very little impact on performance). If you have only a few tiles which change it might be OK to just draw a new sprite over the top of the tile layer. If you do decide to make your own renderer, I'd suggest starting at the basics. There's a tile map example on the sfml site here which you can use to get started. The main difference is that instead of a fixed array of tile IDs you use the tile IDs loaded from the tmx file. Once you get that working with a single tile set you can start to build on it, adding support for more textures, while including the option to update tiles. No smart pointers needed! :) Don't forget you can always hop on the sfml irc or discord server if you want some advice, there's usually someone helpful around to give you a hand
from tmxlite.
It really depends on the playstyle of the player lol. If he decides to burn down the whole forest it would be like 500 tiles of 40.000.
Will it affect performance a lot when I'll just create a new sprite over it, as you mentioned? That seems to be the most efficient solution for me right now
Edit:
And what if I include my own little IF statement that only renders the created sprites when in players field of view? That would allow for unlimited tile overwrites I think...
from tmxlite.
The problem with sprites is that you have a draw()
call for each one, which is one of the mosts expensive parts of rendering. A few sprites is OK, probably a few hundred is OK, but you'll eventually start to notice a slow down in performance. What you could do, now that I think about it, is have your own vertex array to draw tiles over the top. Each time a new damage tile is created, add it to the vertex array. This way you only need to draw one extra vertex array on top of the map, which contains all the damage tiles.
Viewport culling (ie only drawing what's in view) is also a good idea. It gets a bit trickier when using vertex arrays, but they can be broken into smaller parts - which is the idea behind the Chunk
class in the example. I'd say try a vertex array first. If it gets too big or there's noticible performance problems, then look at splitting it into chunks.
from tmxlite.
Related Issues (20)
- CAN SOMEONE JUST EXPLAIN HOW TO USE THIS HOT 9
- Problem with "std::localtime" in Log.hpp line 145 HOT 1
- meson.build version doesn't match git tags HOT 1
- Enough with the unsigned integers
- Find tmxlite on Windows HOT 4
- Feature Request: Allow independent parse of tsx to TileMap. HOT 2
- How hard would it be to adapt the library to render an isometric map? HOT 2
- map.load() not getting any path HOT 10
- Unable to start program. libtmxlite-s-d.lib is not a valid win32 application HOT 6
- When the camera zooms out, the animation speeds up HOT 1
- Not orthogonal and will not be shown HOT 3
- How to use tmxlite on Windows and CLion HOT 3
- Not a valid orthogonal layer, nothing will be drawn. HOT 3
- Failed opening tsx file for tile set
- I can't load every tsx file HOT 1
- test colission HOT 1
- i cant find example for rendering tilemap inSDL2 c++ HOT 1
- Anything against making MapLayer::Chunk public? HOT 3
- I have question HOT 2
- How to use Tmxlite on windows? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tmxlite.