"Auto Tile" help.

Get help using Construct 2

Post » Fri Jan 27, 2017 3:00 am

I've been trying to see what I could do with a sandbox style game, and this has lead me to making better looking tiles. I've tested a method of making a tile automatically change based on the surrounding tiles (the tiles are sprites, not tilemap tiles) and it's worked pretty good up until a certain point. I've been using "Is overlapping at offset" to determine if a tile should change. So instead of a grass tile staying a grass tile when a grass tile is placed on top of it, it will become a dirt tile (via animation frames). However, it stopped working correctly when I tried to make side tiles. The side tiles turn into edge tiles. As this may sound confusing as hell. Here's the capx: https://www.mediafire.com/?7x5qhs5au706slq

As you would have guessed, I need help here. I've tried several times to get frames 3-8 to work, but nothing seems to fix it. I'm sure it has to do with how C2 attempts to detect overlapping objects, I need to find a solution.

Thanks in advance.
Oh, okay.
B
21
S
5
Posts: 34
Reputation: 1,189

Post » Fri Jan 27, 2017 4:26 am

Your capx seems to work exactly as your events describe. Can you try describing what you see vs what you expect to see again more clearly?

Edit: I'm guessing this is an earlier version with only horizontal checking. Did you have a later version where you tried to check above and below each tile as well?

(Also recommend going back and using tilemap rather than sprites. Bitwise neighbor aware tile selection is completely feasible using the tilemap object.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Fri Jan 27, 2017 6:59 am

Message: Ben Wilson can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
The reason I think it's not working is how "Is overlapping another object" works.
Quote from Sprite Manual
For example, testing for an overlap at an offset of (100, 0) will temporarily move the object to the right 100 pixels, test for the overlap, then move it back again.


And as your sprites are all touching each other the Y at 0 will all ways get triggered to anything below it.

To fix it your going to have to make a small gap around each sprite (1 pixel gap) then when it 0 on the Y it won't find anything and then you have to change all the X's from 1 to 2.

https://www.scirra.com/ forum / what-is-the-overlap-offset-coordinate-based-on_t72860
This is the location where I found that out from @Kyatric
Kyatric wrote:Try to have crates 1 pixel smaller (15X15) than the grid's cells size.


Hope you can understand it.
B
8
S
2
Posts: 22
Reputation: 606

Post » Fri Jan 27, 2017 12:54 pm

That is easily to overcome.

Set the scale of the sprite to 0.9 (original size must match layout size)
Test overlaps with offsets = grid size. (16 in this case)
Set the scale of the sprite to 1.0

But that is not the main problem.
Besides that the check happens every tick in the provided capx, i see checks only a look left/right & up/down.
That way the rules can never be exclusive. Several situations will be true for several rules.

I think this is the right way to do such a task.
https://www.dropbox.com/s/sr4kpio8k3ih2 ... .capx?dl=0

I did not account for all combinations, got have some work left eh.
B
33
S
18
G
28
Posts: 2,455
Reputation: 20,874

Post » Fri Jan 27, 2017 1:50 pm

@99Instances2Go

What version of Construct 2 are you using as it says to update my program to the newest version ( I have r239) but on the website it says its still r239. You using the beta?
B
8
S
2
Posts: 22
Reputation: 606

Post » Fri Jan 27, 2017 2:20 pm

I think most in here use beta/ or both (i do).
Same in non beta:

https://www.dropbox.com/s/h4kvaudc91008 ... .capx?dl=0
B
33
S
18
G
28
Posts: 2,455
Reputation: 20,874

Post » Fri Jan 27, 2017 2:28 pm

Dam I'm mind blown on that code.
Nice work tho
B
8
S
2
Posts: 22
Reputation: 606

Post » Fri Jan 27, 2017 5:21 pm

oosyrag wrote:(Also recommend going back and using tilemap rather than sprites. Bitwise neighbor aware tile selection is completely feasible using the tilemap object.


You have my attention.
Oh, okay.
B
21
S
5
Posts: 34
Reputation: 1,189

Post » Fri Jan 27, 2017 8:51 pm

http://www.saltgames.com/article/awareTiles/

Here is a good description of the bitwise method. I can put together a sample later today probably.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Fri Jan 27, 2017 9:08 pm

@oosyrag Thanks.
Oh, okay.
B
21
S
5
Posts: 34
Reputation: 1,189

Next

Return to How do I....?

Who is online

Users browsing this forum: ketramtu18 and 9 guests