Construct 2 Sprite Shape Comparison?

0 favourites
  • 4 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • So I've been messing around with construct all day trying to get an idea I have to be functional.. but so far I'm failing horribly. What I'm trying is to have sprite shape comparison.. something that is reminiscent of those shape cubes young kids have.

    Example: There is a 50x50 cube sprite. If the player puts another cube down in its location that is also 50x50 ... it changes a variable to be true. But I also want the user to be able to use 2 triangle sprites that also add to a 50x50 cube. So far I can only get it to work for static patterns (I.E. they have to use the 2 triangles.. or the 1 cube.. not either). .. I'm also trying to figure out how to make it return a false value if the shape is wrong or too big. (I.E. 2 triangles that are too big for the bounding box)

    If anyone can help me with this I'd be so happy. Anyway.. thanks in advance!

  • You have noway to know what sprite's shape,suggest you can save sprite's shape at object's var by yourself

    Last...about size,just Comparison two sprite size

  • I think, if you use arrays, and objects made up of tilemaps, you can achieve this.

    I can't tell how to code it but the idea I have in mind is... Lets make it by your example. You will make shapes by using tilemap objects, and you will represent your "hole" with an array. Imagine below


    1 1 1 1 1 1 1 1 1 1

    1 1 0 0 0 0 0 0 1 1

    1 1 0 0 0 0 0 0 1 1

    1 1 0 0 0 0 0 0 1 1

    1 1 0 0 0 0 0 0 1 1

    1 1 0 0 0 0 0 0 1 1

    1 1 1 1 1 1 1 1 1 1

    then you have shapes made up of tilemaps, and also represented by arrays as well. Imagine a triangle shape which is represented by:

    1 1 1 1 1 1

    1 1 1 1 1 0

    1 1 1 1 0 0

    1 1 1 0 0 0

    1 1 0 0 0 0

    1 0 0 0 0 0

    When you place it, you get the coordinates, translate them into array adresses, and add each adress over the first one. If anywhere it becomes a 2, it means the shape is not passing through the hole.

    If not, object is placed. Then you place the second object which is also triangle, but you can rotate it. You will have to go into matrix coding or sth like that to rotate the arrays, probably by writing functions to do so. Same applies for the second object, place it, adress it on the array, chech for 2's. If not, second shape also fits. After all shapes placed, check for any remaining 0's inthe main array to see if the hole was closed completely.

    I don't know if I could describe it, but it just what came on top of my head.

    Hope it helps.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey, thanks for the idea windwalker. It seems a bit difficult to implement but I'm gonna try and figure it out over the next couple of days. If it works out.. I'll definitely let you know and toss you the code as well. If ya want it that is lol

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