How do I destroy a group of sprites? Math Based

Get help using Construct 2

» Fri May 15, 2015 11:06 pm

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.
B
4
Posts: 16
Reputation: 230

» Fri May 15, 2015 11:24 pm

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
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

» Fri May 15, 2015 11:34 pm

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?
B
4
Posts: 16
Reputation: 230

» Fri May 15, 2015 11:36 pm

Yes..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

» Sat May 16, 2015 10:13 pm

@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!
B
4
Posts: 16
Reputation: 230

» Sat May 16, 2015 10:36 pm

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

» Sat May 16, 2015 10:57 pm

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.
B
4
Posts: 16
Reputation: 230