Compare two arrays and subtract identical values

Get help using Construct 2

Post » Tue May 23, 2017 6:25 pm

Hi all. I've been working on a simple memory palace/recall game to practice using arrays. Problem is, I'm stuck and can't seem to figure out how to get unstuck. As always I'm probably overlooking something basic, but I could use a nudge in the right direction.

Here's the basic flow of the game:

1. Tap the screen and a random icon appears. Repeat several times.
2. When a certain number of icons have been seen, go to the quiz screen.
3. Quiz screen shows a grid of all the icons. User must tap to select the icons he or she saw in the previous screen.
4. After the quiz screen, correct guesses will be added to an array for permanent storage.
5. Next round is the same as the first, only now the icons that are shown do not repeat icons the user has correctly guessed.

(.capx file to see the in-progress example. Ignore the incomplete sections, just stay on main-sheet)

I've been using two arrays in my attempt to accomplish the last task:

- Array1 (aIconPool) holds randomized numbers used to spawn icons.
- Array2 (aSaved) holds a record of the correctly guessed icons.

The idea is to subtract the contents of the second array from the contents of the first. My problem is I can't find a way to do this. The events pictured below do something similar, but incorrect:

So, what's wrong with the above setup? I've tried various permutations of event ordering and nesting, but they're just as broken.

Also, if my entire approach is too convoluted, feel free to tell me as such.

Posts: 10
Reputation: 799

Post » Wed May 24, 2017 8:04 am

I updated your checking event, that should work as intended now (at least I think)

Not sure about the rest of the events, they will require some "work" :D

Who dares wins
Posts: 1,878
Reputation: 19,572

Post » Thu May 25, 2017 7:20 pm

Heh, yeah, most of the other stuff in the file is scaffolding so I can test things. Long ways to go.

I ran the updated capx and checked the debugger. The new method is pulling out a handful of entries, but not the ones I'm looking for. Here's what shows up in the debugger (array - index:value):

aSaved - 0:0, 1:1, 2:2, 3:3, 4:4
aIconPool: 0:1, 1:7, 2:9, 3:10, 4:11

Right now, aSaved is loaded with dummy data 0-4 and aIconPool is loaded with dummy data 0-11. The output I'm looking for is to subtract aSaved from aIconPool, leaving aIconPool with the values 5-11.

I'm going to keep experimenting/hitting my head against the wall until I figure out what's going on.

Thanks for taking the time to check this out!
Posts: 10
Reputation: 799

Return to How do I....?

Who is online

Users browsing this forum: Artcadev and 49 guests