How do I auto-tile with tilemap?

Get help using Construct 2

Post » Thu Oct 09, 2014 6:07 am

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?

Image
B
25
S
6
G
6
Posts: 265
Reputation: 3,696

Post » Thu Oct 09, 2014 10:41 am

roracle wrote: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.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Oct 09, 2014 10:56 am

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.
B
25
S
6
G
6
Posts: 265
Reputation: 3,696

Post » Thu Oct 09, 2014 12:21 pm

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:
Image
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.

Image
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.

Image
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:

Image
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.

Image
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 :D

The moment you get a shape like this, then it wont work anymore.
Image
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.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Oct 09, 2014 12:51 pm

Tiled supports auto-tiling and can be imported to C2. So you can design maps in that and import them to Construct 2.
Scirra Founder
B
398
S
236
G
88
Posts: 24,441
Reputation: 194,671

Post » Thu Oct 09, 2014 12:55 pm

ImageImageImageImage
B
157
S
66
G
42
Posts: 2,603
Reputation: 35,343

Post » Thu Oct 09, 2014 12:59 pm

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

shinkan wrote: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 :shock:
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Oct 09, 2014 2:02 pm

shinkan wrote: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.
B
25
S
6
G
6
Posts: 265
Reputation: 3,696

Post » Thu Oct 09, 2014 2:09 pm

Yes
ImageImageImageImage
B
157
S
66
G
42
Posts: 2,603
Reputation: 35,343

Post » Thu Oct 09, 2014 3:32 pm

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?
Image
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.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Next

Return to How do I....?

Who is online

Users browsing this forum: Instrex and 20 guests