How do I loopinex, and tiletoposition?

0 favourites
  • 5 posts
  • i want to be able to tell how big a room is, which can be built on a tile map.

    i thought flood fill would be an easy copy paste job... it may be.. but im looking at it without a clue what the terms are.

    loopindex("X")

    tiletopositionX(loopindex)

    for sure ill have a day on reading about it tomorrow. but if anyone can give me a brief introduction. not only would it be a huge step in the right direction, i could probably use it in multiple situations if it does what i think it does (how, i have no idea)

    howtoconstructdemos.com/flooding-a-dungeon-tilemap-capx-construct2-construct3

    is the flood fill example i am looking at

  • loopindex gets the value of a currently running loop. For loopindex("X") it's getting the index of the loop named "X".

    tiletopositionX() converts a tile X index to a X co-coordinate. So the position of the tile using layout coordinates.

    For tiletopositionX(loopindex) it is doing exactly that but the x index you are converting is based on the index of the loop. This is very helpful if you want to run through all the tiles.

    In this example I've created 2 loops.

    The first one is named "X" and runs from 0 to the tilemap display width. Which is how many tiles it can display across its width.

    The second one is named "Y" and runs from 0 to the tilemap display height. Which is how many tiles it can display across its height.

    Here I'm setting the tile at the position in the loop. So loopindex("X") is for the X index and loopindex("Y") is the Y index. Since the loop will run through every single tile on the tilemap this will set them all to whatever tile I choose.

    Going through all the tiles like this is great for flood fill because you can check every tile and the tiles around that tile to see where the walls are.

  • BaconSwagg Good example! But since tile index is zero-based, the loops should end at Tilemap.MapDisplayWidht-1 and Tilemap.MapDisplayHeight-1

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Theres also a floodfill extension as well, but i've never used it.

  • first, huge thanks to everyones advice! i went from no knowledge, to being able to recreate this effect.

    m00npunk, ill have a look at the extentions! it does seem reasonably straight forward (cant believe im saying that..)

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