How do I Check for Shape Built?

Not favoritedFavorited Favorited 1 favourites
  • 3 posts
From the Asset Store
5 glow creatures with size, shape and color variations.
  • As part of my being able to attach sprite instances a certain way, which is solved.

    construct.net/en/forum/construct-3/how-do-i-8/attach-sprite-specific-way-183986

    This, however, is just the beginning. With being able to attach the sprites the way I have, certain shapes can be built with them. I was thinking of making an instance boolean with the instruction, "is Shape built?" to check that a certain shape build with the moleks matches the diagrams shown below, but to actually have the game check if the shape is already built with sprite instances or not seems like a daunting task to me.

    What it would be like, then, is the shape that is built advances the player to the next stage, which asks to build a shape over the one already built. For example, from this:

    To this:

    To this:

    Three stages per world.

    I have the Levels Manager plugin in anticipation to this type of build, so if anyone has any experience with it, that would be extremely helpful.

  • First of all, you should have a way to store the information about the neighbours of each sprite onto the sprite itself. For example, each sprite should have 4 booleans (TopLeft, TopRight, BottomLeft, BottomRight), set to true if a sprite is attached at that position, and set to false otherwise.

    Then you coud implement some sort of flood fill algorithm that, starting from the center of the shape, navigates to all sprites in a predefined and fixed order. Each time you visit a sprite, you store its neighbours on some sort of object (even a string). You then have a "code" that represents the shape you have on screen.

    For example, for your first shape, you start from the top-left sprite and proceed in clockwise order. The first sprite has only a neighbour on BottomRight, so you store something like "0001". The following sprite has only a neighbout on BottomLeft, so you store "0010" and so on. The shape will then have code "0001 0010 1000 0100"

    You could then store the codes for your 3 shapes, and check if the code of the player's shape matches one of those.

    This is only a rough idea, but maybe it can help you.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Indeed... I have a marker sprite I use in-game to attach the main sprite (in black) to the others. Perhaps by counting the instances of the marker sprites I can confirm the shape? I noticed that each shape has its own corresponding marker number. Going back to the example, that the first shape has 8, the second has 16, and the third has 12.

    Perhaps by storing this marker info as well as the number of attached sprites to match it maybe I can confirm the shape that way?

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