Looping through tiles by columns instead of rows

How can I revise the following code to loop through the tile by its columns (top to bottom from left to right) instead of by its rows (left to right from top to bottom)?

const frame = new Tile(new Rectangle(125,55, [white], black), 10, 10, 50).center(firstHundred).mov(165,74).sca(.8);

const listOne = ["1) the","2) of","3) and","4) a","5) to","6) in","7) is", "8) you", "9) that", "10) it", "11) he", "12) was", ]

let index = 0;

loop(frame, rectangle=>{ 
        let word = new Label (listOne[index++], 30, "verdana", black).addTo(rectangle).mov(0,15);
        let currentTile = rectangle.tileNum+1;


Welcome, @Jac - the Tile has an items property that is an array of all items in order. Then there is an items2D which is a 2D array with each row and inside that each col. Then there is am items2DCols which is a 2D array with each col and inside that each row. That is what you want!

loop(tile.items2DCols, col=>{
  loop(col, item=>{
    zog(item.tileCol, item.tileRow); 
    // 0,0... 0,1... 0,2... 1,0... 1,1... 1,2

Thank you!

1 Like