How do I destroy a group of sprites? Math Based

0 favourites
  • 7 posts
From the Asset Store
Advanced inventory mechanics for your RPG game (Array-based). Take Items, split them, pick up them, read the description
  • Hey everyone!

    Having troubles with the last main mechanic of my game. I need to be able to destroy a group of sprites once they are selected but only if the correct ones or the correct values assigned to them equate to the operation being used on them.

    Example: Using a grid filled with 12 blocks, 4 being answer blocks and 8 being numbers you use to equate to the answer block I need them to destroy once you select the proper 3. This happens through +-*/ designated to color coded answer blocks respectively.

    Values to these blocks are randomly generated for the greys and then two greys are assigned (using an operator +-*/) to a color block giving it that value. This is all done and stored within two arrays:

    -BrickStorage[stores the number bricks[RNG stores randomly generated numbers]]

    If any more details are needed feel free to ask! Thank you for any help in advance! Cheers.

  • Should be something like this in pseudo code:

    if selected = 3

    -- operator = +

    -- system compare two values : block1.value+block2.value = answer

    ----- pick all blocks selected

    destroy blocks

    -- operator = -

    -- system compare two values : block1.value-block2.value = answer

    ----- pick all blocks selected

    destroy blocks

    -- operator = *

    -- system compare two values : block1.value*block2.value = answer

    ----- pick all blocks selected

    destroy blocks

    -- operator = /

    -- system compare two values : block1.value/block2.value = answer

    ----- pick all blocks selected

    destroy blocks

  • Ok, I will try to implement the pseudo. Just for clarification, each level of "dash" is a sub event? And "greater than" denotes action correct?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes..

  • LittleStain Hey, sorry for a late reply. This code is kind of working for me, my implementation may be incorrect, though. I think there may have been some misunderstanding because it's actually not possible for me to implement the --operator = + step in my code, unless i just don't know how. But there aren't any variables that justify a + operation, there is only a value that is created from a + operation and etc for each other operation.

    The point I have it at using your pseudo code is that three bricks will be deleted BUT it can be any grey brick to a color even if the numbers don't equate properly. I know for a fact its the way i'm trying to access values. And with the way I have it set up I'm finding hard to actually find the two values that are getting assigned to each brick. This is so because its random every time.

    If you are up for it I can actually post the project for you to scan over, if not feel free to ask some more questions I can try to clarify with what is going on.

    Thank you again for your help!

  • I think you are really close..

    I would have a look at your capx, but I'm not sure when I'll have the time..

  • That's OK haha. My friend and I may have come up with another solution.....much more code...but we think it will accomplish what we need done. I appreciate your time again. I'm sure I'll be back here at some point hehe.

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