how to make a grid with no repeats and overlap

0 favourites
  • 5 posts
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • Hello! I'm trying to make a puzzle grid that's 5x5 using 5 different color blocks with two requirements:

    1. Each row must use the 5 color blocks once
    2. Row below cannot have overlap/stack the same color blocks (see below)

    I'm sure there's a more efficient way to do this without making 5 different arrays, open to suggestions. Thank you!!!

    Here's my c3p

  • Brute force method - should be fine for small grids like 5x5.

    Use the advanced random behavior to create a permutation table, 0-5, corresponding to your animation frame.

    Fill the first row with the values from the permutation table.

    Check if any of the colors in that row match the one above it. If there are, repeat with a new permutation table.

    Repeat for following rows.

  • Slightly tricky to implement. Might be cleaner if 0 wasn't used as an animation frame value, then wouldn't need to add an exception to handle the first row (since all values outside of the array's size return 0). Edit: changed it to do so.

    dropbox.com/s/fdhgnpe0fkogds1/neighborawarepermutationsexample.c3p

  • Slightly tricky to implement. Might be cleaner if 0 wasn't used as an animation frame value, then wouldn't need to add an exception to handle the first row (since all values outside of the array's size return 0). Edit: changed it to do so.

    https://www.dropbox.com/s/fdhgnpe0fkogds1/neighborawarepermutationsexample.c3p?dl=0

    Working, thank you so much! One minor issue, when the sprite gets bigger than like 250px it only renders 20 instead of 25 :0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So... change your sprite size? Or change the viewport size.

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