Giter Club home page Giter Club logo

Comments (3)

fallahn avatar fallahn commented on June 27, 2024

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.

Luke004 avatar Luke004 commented on June 27, 2024

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.

fallahn avatar fallahn commented on June 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.