For those who've made tile engines...

0 favourites
  • 7 posts
From the Asset Store
slide the tiles to fill the board.60 awesome levels.
  • My design for the map: A 64x64 grid of tiles, each represented by 32x32 pixel tiles that are all sprites. The map data will be held in a 2D array, and there will be a function that runs whenever something changes that will update the sprite-tiles to reflect the data in the array. The player's view window of the map will be only 10-15 tiles in size and will follow the player, generally, wherever they go on a particular map.

    When the player goes from one 64x64 map area to another, the array will be filled with the new data, and the tiles will be updated.

    Now that you (hopefully) have an idea of how this is supposed to work, I am wondering if there is an easier way to place each of those tile sprites (all 64x64=4096 of them) in the editor? Or will I have to script it in runtime to set the grid up?

    Also, do you think having 4096 relatively inactive sprites will run slow or cause other problems? Any suggestions for a better method of having dynamic tiles?

  • I personaly use rexrainbow's plugin : TMXimporter, and prepare my tile maps in TMX. Look at this thread, there are a lot of examples.

    Hope it helps !

  • Wow, that's a cool plugin!

    Unfortunately, It won't help me. In my initial post, I should have mentioned this game is a roguelike, where maps are generated dynamically, not premade.

    I did have some more thoughts about the engine design, though. I'm worried FPS will suffer with 4096 sprite tiles. I am already using R0J0hound's canvas plugin for something else in this project. I think I could have a big canvas object, 4096x4096 pixels, and then have the update function read my map data array, then rubber stamp the correct tile image onto the canvas at the right place. Any part of the map that can be collided or otherwise interacted with will have to be layered on top of this canvas, however. More complicated, but should perform much quicker I think.

  • Yttermayn

    The tile count could be a problem yes. Not storing it in arrays, arrays are fast, but 4k instances can be laggy, depending on the system.

    If it was me, I would prepare my tile types and store it into the arrays, then build only a screen and a half (tiles covering the screen +50% of its size). As your movement are tilebased (or can be assimilated to), you can update your layout every movement, with something like this :

    • when move right, get the left column, move it to the right of the layout, change the frame of every of its tiles to what is said in the array (and maybe more than just changing frames, like spawning monsters, ...)
    • same for the other directions

    With a loading system like this, you could virtually have billions of tiles without lagging, as the object count won't go up and you would recycle most of the objects.

  • That is an intriguing idea. I think I did something like that years ago in C++, I will have to think on this. Thank you!

  • Here's one such way to implement it:

    With 32x32 sized tiles then a total of 336 objects would be used.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • wow amazing, and you can probably still use the tmximporter for populating the array..

    ps: hm after rechecking, im not sure how you should make the array with grounddata

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