How do I auto-tile with tilemap?

  • I know the basics, but was hoping there was something already done to make this an easier process. It's driving me nuts trying to do it alone, but what I'm trying to accomplish is for a character to "farm" land, and the border of the land to auto-fill with the proper border. The closest thing I can think of to this is the way RPG Maker handles putting land on water or vice versa. What is this called?

    BTW: This is the current "farming" tiles I'm using. Is this the proper format (enough images, that is) to "auto-tile" the borders?

  • I know the basics, but was hoping there was something already done to make this an easier process. It's driving me nuts trying to do it alone, but what I'm trying to accomplish is for a character to "farm" land, and the border of the land to auto-fill with the proper border. The closest thing I can think of to this is the way RPG Maker handles putting land on water or vice versa. What is this called?

    BTW: This is the current "farming" tiles I'm using. Is this the proper format (enough images, that is) to "auto-tile" the borders?

    Think I mentioned this in the other post, as soon as you have stuff that are bigger than the tile size then it starts to get a bit complicated

    I don't think there are any other way than to make it so you check the surrounding tiles and correct them. I used a similar method in my Random dungeon generator tutorial - https://www.scirra.com/tutorials/999/random-dungeon-generator-node-based#h2a13 - Step 9, this is ofc a bit different as I work with hallways, where there are certain limits to how they can be arranged, where I guess the player in your game could make the farming area whatever shape they like. So in your case you would need 8 corrections I think, where as I needed 4 because of there being no directional corrections needed.

    However what you can do is start by placing a square farm plot on the map using those tiles that are just dirt. And then you add functionality that corrects these, so it create a border around that. When that is done you should now have the ability to correct Left, Right, Top, Bottom tiles. So you create a new shape maybe one that is in the shape of a horseshoe and again you try to see how you can correct the borders on that one. And you just keep doing that until you have all the stuff you need to make any shape. Doing it like that will make it a bit easier to see where bugs occur and what tiles still need to be corrected as you work.

    But it seems that you have most types that you need, might lack 4 tiles for turning but if you do it like above and just build the shape in design view it should quickly show whether that's the case or not.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You wouldn't want to take a look, huh? I end up with way more than 8 corrections, but maybe I'm over complicating it. I start to "get it" but then it stops making sense when I get around to implementing it.

  • [quote:344c85pd]You wouldn't want to take a look, huh? I end up with way more than 8 corrections, but maybe I'm over complicating it. I start to "get it" but then it stops making sense when I get around to implementing it.

    After doing an example I think you need 12 in total to make it work. Here is how I would approach it.

    If we do an internal correction of the tiles, meaning that we replace the actual farming tiles with the correct ones, it could be like this:

    Which will work fine if the farming area is a minimum of 9 tiles. But that is not going to be very flexible and it doesn't work well with different shapes.

    In this case all single tiles will cause some problems and would create some weird spikes in the farming plot. So instead we can do an external correction. Indicated by the blue dots. So if we start making all the horizontal and vertical corrections (Top, Bottom, Left, Right). We would end up with something like this.

    Next we do it for the outer corners which again requires 4 corrections. (Top left, Top right, Bottom left, Bottom right) and then we would end up with something like this:

    So last we need the inner corners, in the screenshot there are only 3 dots, but obviously you need 4, but its just not in this shape. But again it requires 4 corrections (Inner top left, inner top right, inner bottom left, inner bottom right) and then you would be able to make any shape needed.

    So I would approach it like that, split each correction up into these categories. And just focus on 1 of them at the time, and don't worry that it doesn't look correct until all of them are made. And just work on one shape all the time until it looks correct to avoid confusion. And when that shape is working, then try to make some other random shapes. Because even though I say that these 12 correction will allow you to make any shape, it actually not true

    The moment you get a shape like this, then it wont work anymore.

    So you need to find some way to handle situations like that as well. But if you focus on all the problems at once, I think it will be very confusing.

  • Tiled supports auto-tiling and can be imported to C2. So you can design maps in that and import them to Construct 2.

  • https://www.scirra.com/tutorials/1128/auto-tiling-with-autotilegen-and-tilemaps

    And there's a lot more examples on the forum.

  • Tiled supports auto-tiling and can be imported to C2. So you can design maps in that and import them to Construct 2.

    https://www.scirra.com/tutorials/1128/auto-tiling-with-autotilegen-and-tilemaps

    And there's a lot more examples on the forum.

    Well I will definitely check that out later, had no clue that something like that existed

  • https://www.scirra.com/tutorials/1128/auto-tiling-with-autotilegen-and-tilemaps

    And there's a lot more examples on the forum.

    And all this can be done real-time in gameplay? I intend on the tiles reverting back to the background color after prolonged disuse/planting grass seeds.

  • Yes

  • Maybe I misunderstood the program, but I don't see how that relates to this issue, besides that its generate the tilemap for you a bit easier.

    But the tilemap that it creates will as far as I can see not be able to handle this situation either, if you use what I refer to as an external correction method, that you couldn't solve yourself, by adding some more tile options?

    The program seems to use an internal correction, but again it doesn't change the fact that you still need to add a lot of code to make it work. But maybe i misunderstood the purpose of it or do you mean that if you use that program and just hook it up to C2 then you wouldn't have to make any checks, it would just handle it for you automatically?

    Because I tried to download the demo capx in the link that was posted, and i see no particular benefits in the code that would suggest that it does such thing. The code seems to just be another way of working with tilemaps, but whether you made it like that or some other way, doesn't really change anything you still have to do it yourself one way or another.

  • It makes it much easier if you are tracking your tiles using an array.

    Here is a nicer example of "Bitwise Numbers" to automatically tile what you draw for you.

    HTML5 Demo

    Just left click to place a tile. Ignore the tilemap it was something I had laying around from an old prototype just imagine the sea/blue is the grass and the sand is your dirt.

    Here is more info on Bitwise Numbers definitely worth reading it's a great explanation of bitwise numbers.

    [attachment=0:2d2gf0v3][/attachment:2d2gf0v3]

  • It makes it much easier if you are tracking your tiles using an array.

    Here is a nicer example of "Bitwise Numbers" to automatically tile what you draw for you.

    HTML5 Demo

    Just left click to place a tile. Ignore the tilemap it was something I had laying around from an old prototype just imagine the sea/blue is the grass and the sand is your dirt.

    Here is more info on Bitwise Numbers definitely worth reading it's a great explanation of bitwise numbers.

    [attachment=0:1wv0765z][/attachment:1wv0765z]

    Ahh ok I see what you mean that's pretty clever to be honest. Ill have to try that out some time. thanks

  • I carried on playing around after making the bitwise number example so I'll just post them here in case they are of use to anyone.

    An expanded version of the first example. Use left click to place a tile, right click to remove, hold shift and left mouse button to drag an rectangular area to tile.

    HTML5 Demo

    [attachment=1:1hpv90co][/attachment:1hpv90co]

    And a version that is probably closer to what roracle originally wanted with dirt & grass tiles.

    HTML5 Demo

    [attachment=0:1hpv90co][/attachment:1hpv90co]

    The improvement with this version is more tiles for the grass area and also stores the original grass tile when removing dirt.

    Hope someone finds them useful

  • If you should take a look at this, I ended up deleting all the work I did. The layout is different than what you're describing I would like more information about storing information about tiles, though. If anyone wants to take a look and maybe implement something useful for me, go ahead. I have a tilemap for it and a sprite object in case I found a different way of doing it. Any help would be greatly appreciated.

    https://dl.dropboxusercontent.com/u/111 ... thing.capx

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