How do I compare an array to a tilemap?

0 favourites
  • 3 posts
From the Asset Store
This is a black tileset with 2 tilemaps, props, one animated character and more.
  • i want each tile to be mapped from an array.

    the tile map grows when a new square is added. then i want the tiles to be drawn into the tile map from the array.

    i tried to make a function, where the tilemap width is set a local variable then i could just while loop it as long as the local variable is above 0. and -1 on each loop.

    but... construct literally came up with a box telling me "blow me" ...cant set a variable to anything but a number.

    ill get it, but everything i do makes me go back to the drawing board

    *edit* what i want, is a loop to check array for value =1. then set the corresponding tile

  • Try Construct 3

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

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

    width(local variable) <= tilemap.width+96

    width>0

    - value at (array value check local variable) =1

    arrayset value((array value check),0) to 4

    set (array value check) to (array value check)+1

    width(local variable) to width-1

    is my loop. it just freezes

    width=Tilemap.Width/96 at the start of the loop. (96 is a tile size so im getting how many tiles wide the tile map is)

    array value check, is the x coordinate in the array.

    im thinking it should, when a new tile is made; expanding the tileset(that works)

    to set the tiles in the tile map: run the while loop to check for each tile, compare what value the array holds at that position. if 1, then set the tile in the tile map. if 0. reset the tile.

    anyone see what i am doing wrong?

    i want to use an array like this, so if i add a tile to a left place, i can push all Y array values. moving the tile map. and maintaining the room layout.

    hope that explination doesnt make things worse..

  • You’ll have to show a screenshot of the events. If it’s freezing it’s an infinite loop. For a while loop to end you either need a condition in the same event block as the while, or you need to use “stop loop” somewhere elsewhere in the sub-events. Lastly you need to ensure your logic avoids infinite loops. Often a for loop is easier to do right.

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