Does anyone know how to make a Tetris-style inventory in Construct 3

Not favoritedFavorited Favorited 0 favourites
  • 5 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • Does anyone know how to make a Tetris-style inventory in Construct 3

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could use an Array with a width of 7. Fill it with values from 1 to 7 (or 0 to 6), where each represents a different piece type. Arrays have an action that lets you shuffle them.

  • I already tried that and it worked. The problem is that I don't know how to detect how many squares an object needs and whether it fits when there's an edge or not enough space; in other words, how to calculate the surrounding squares.

  • I'm not too sure what approach you're doing to understand properly.

    There's some example templates of Tetris in the store you could learn from, if you don't mind paying:

    construct.net/en/game-assets/search

  • I already tried that and it worked. The problem is that I don't know how to detect how many squares an object needs and whether it fits when there's an edge or not enough space; in other words, how to calculate the surrounding squares.

    You don't need to detect how many squares an object needs, you should define the width and height ahead of time for the object, and use those values to check available space.

    For your inventory array, cells outside the array bounds are always 0. So for empty spaces inside your array, use something like -1 while filled spaces could be set to 1. Then when checking array coordinates based on the width and height of whatever you're trying to fit, you'll be able to see if each target space an empty space (-1), filled space (1), or out of bounds (0). Only allow placement/confirmation if all checked spaces are empty.

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