XY array of irregular width

0 favourites
  • 6 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Since you can't have a XY array of irregular width.

    How would you do this best:

    Initial width and height is dynamic and calculated at runtime.

    Let's say we have this grid of 20 entries width and 10 entries height.

    We fill the horizontal entries with 0 up to 19 on each row.

    Then a loop for every horizontal row, you pick one cell at random, and then delete it. Making the width of THAT row one cell smaller.

    Repeat for every row until you have no cells left.

    How would you do this?

    Quite confusing.. sorry.

    For this one I would like to ask for capx or at least clear answer. I hope it is not too much.

  • Let's start smaller?

    array:

    0 1 2 3 4

    0 1 2 3 4

    0 1 2 3 4

    Do you want the next stage to be:

    1 2 3 4

    0 2 3 4

    0 1 2 3

    but the final result to be

    [ ]

    [ ]

    [ ]?

  • Since you can't have a XY array of irregular width.

    You said it. So at no point will you have a row smaller than another row. The best you could do is:

    1. Choose your random column (cell)

    2. Re-order that row so that cell's value is at the end of the row

    3. Repeat for each row

    4. Finally, set the array width to it's current width -1

    Now you have an array with width 1 less than before

    Repeat the above steps until you have no more columns (cells).

    Hopefully you will do something meaningful in between the above steps!

    So this is not possible, because it goes against your original assertion. (Although conceptually, it could be thought of this way).

    [quote:2rhmvvdk]Then a loop for every horizontal row, you pick one cell at random, and then delete it. Making the width of THAT row one cell smaller.

    Is this close to what you're asking?

    edit: added a capx, hope it helps (it's 10x10 but it's dynamically set, just change it).

    The array is represented on-screen. Tap on the layout to process each column and observe.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you for this!

    I will return to this later.

  • You could create multiple arrays and think of each array as a row. Then it can be irregular.

  • Oh different instances! Yes. Thanks.

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