Should I draw tiles to a canvas?

This forum is currently in read-only mode.
From the Asset Store
Each tile 64 by 64 pixels - Ultimate Tile Set for your awesome games
  • My levels consist of multiple rooms, and are loaded from an array. I've managed to program a sort of 'portal rendering' where the whole map is loaded at each room transition, but everything outside of the current room is destroyed.

    There's still ~300 tiles per room, plus ~100 collision tiles, so I've been thinking at each room transition I should create a canvas the size of the room and paste the tiles to it, then delete the tiles.

    My questions are..

    1) Is it worth it? I'm basically replacing ~300 16x16 tiled background objects for a single, large image with an average size of 1024x224 or vice versa..so I'd say it's worth it..I tend to stay away from giant images though, and as far as VRAM is concerned it could pad out to 1024x1024 or larger, right?

    2) Should I also paste the collision tiles to another canvas? It's either ~100 sprite objects each with their own collisions, or a massive collision mask that is the canvas.

    tl;dr... Which is better? Hundreds of little objects, or a handful of massive objects?

  • From my experience 300 tiles is nothing - I have had projects where a single explosion produced more objects than that. And the whole thing started getting slow around 10000 objects on screen. Meanwhile large textures brought the framerate down a lot faster. So, unless you are doing something really fancy with the tiles (such as baking in shadows or such) you are probably just fine with 300 or even 3000 objects.

  • Thanks for the input. Come to think of it I had ~3800 objects and 60fps before the 'portal rendering', and there's only ~400 now in the largest room so far, so I guess it'll be fine. I'm just worried about the game's performance on older computers, so I've been doing everything I can regarding optimization. Maybe I've gone a bit overboard ^^;

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yeah, a few hundred sprites shouldn't make much of a deference, unless you are moving them around a lot, and even then, the smaller the tile is the better the performance, so at 16x16 you should be doing ok.

    Thing to remember about canvas is it adds a bit of vram on top, then updating the collision mask adds a bit as well.

    Then you can't paste tiles that are off screen, so using it with scroll is pointless.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)