"Auto Tile" help.

0 favourites
  • 12 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • 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.

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

  • The reason I think it's not working is how "Is overlapping another object" works.

    Quote from Sprite Manual

    [quote:3ih6i5rs] 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.

    scirra.com forum / what-is-the-overlap-offset-coordinate-based-on_t72860

    This is the location where I found that out from Kyatric

    Try to have crates 1 pixel smaller (15X15) than the grid's cells size.

    Hope you can understand it.

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

  • 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?

  • I think most in here use beta/ or both (i do).

    Same in non beta:

    https://www.dropbox.com/s/h4kvaudc91008 ... .capx?dl=0

  • Dam I'm mind blown on that code.

    Nice work tho

  • (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.

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

    Here is a good description of the bitwise method. I can put together a sample later today probably.

  • oosyrag Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Funny !

  • Got home, took a look at 99's capx and that is pretty much the technique I mentioned.

    Here is a bare bones version, using the tilemap object. https://www.dropbox.com/s/xz4dqd4ov8h0p ... .capx?dl=0

    Note that with your 9 tiles (10, if you include a blank one), you cannot properly utilize a bitwise tilemap, as you can see from the example. The minimum number of tiles is 16 - one for each configuration of adjacent spaces. You are missing the ones for when a tile has only one neighbor for each direction (4), and also when the neighbors are across from each other (2). Also, by utilizing half tiles you'll additionally have to account for interior corners (4), and diagonals (2). Those last 6 tiles are all variations of when a tile is bordered by 4 other tiles, so you'll need some more events to specify those as well.

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