How do I spawn a grid of Squares with different sizes? (for example 1x1, 2x2, 4x4)

  • I'm trying to spawn a area full of squares, and these are of different sizes.

    16x16px, and 32x32px for example, and I don't want any overlapping sprites or empty spots.

    Now, I am trying to do go about it by 'Pick overlapping point' and checking if there are any other sprites of that family there, and then doing sprites.PickedCount = 0, but it does not work at all.

    Anyone have a idea?

  • You can fill the whole area with 16x16 squares first. Then "Wait 0" for objects to be created. Then pick a random group of 4 squares and replace them with 32x32 square, repeat this several times.

    Another option is to create several 32x32 squares without overlapping (search the forum, there are lots of examples how to do this). And then fill the gaps with 16x16 squares.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can spawn all available spots with smaller squares, then randomly spawn non overlapping larger squares and delete the covered small squares after.

  • A few good suggestions here, kinda depends on what sort of pattern you want. The easiest solution I can think of is recursive subdivision. Basically everything starts as the largest size tile, then you split each tile into 4 smaller tiles, and repeat for as many divisions as you want.

    This algorithm is basically "quadtrees", which can be used for many things. Here's a cool quadtree art thing by Michael Fogleman, it's worth checking out his stuff because he has some very awesome projects!

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