memory game randomizing card faces

Get help using Construct 2

Post » Mon Jul 23, 2012 5:23 pm

Hello all! First, let me say that I love this website. This has got to be one of the most helpful/friendly sources of information on the internet. You people are geniuses.

So I recently went through and did kittiewan's memory matching tutorial.memory match tutorial
This thing helped me understand so much more about Construct. I'm no programmer but i loove video games so i apologize for the lack of programming etiquette here, but ill try to explain my problem as best as i can.
The way that game is set up, it has 2 frames for each cardface that is put onto the field. So when you have 6 cards to match in the game, the first 6 frames of the card object are used. This ensures that there will always be 2 of every face.
My problem is that if i make my card deck have more cards (frames) than will ever appear on the field, the cards that use the later frames in the animation will never see the light of day. Those first 6 cards will always be the first 6 frames. I'm having trouble wrapping my head around how to get the game to randomly choose card faces from the entire animation AND THEN make sure that each randomly selected frame has its partner frame (either the frame before it or after it) put onto the field as well.
For example, if i was using the entire alphabet as a matching game and i wanted to only have a 6 card game. how could i ensure that Q, W, Z, etc. have a chance to be used and not just have A, B, and C every time.
I hope that was easy to understand... Thanks in advance!
B
2
Posts: 9
Reputation: 268

Post » Mon Jul 23, 2012 6:42 pm

B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Post » Tue Jul 24, 2012 4:06 pm

thanks R0J0! now ill see if i can figure out how to implement that in her tutorial
B
2
Posts: 9
Reputation: 268

Post » Tue Jul 24, 2012 5:57 pm

ok so ive gotten it... kind of working lol

using kittiewan's tutorial still, ive gotten the cards to be randomly selected from all of the available frames

i have 2 problems i cant seem to figure out

1. if i have only 6 cards appear on the field, the pairs aren't really shuffled, each card's partner is underneat/above it. kittiewan had a shuffle function but once i added all this jazz it makes all the cards the same if enabled, at the moment ive disabled that function so if anyone can figure out why they cant be shuffled that way, i would love it

2. every once in a while it will give me 2 of the same pairs, so 4 frames that are the same, like 4 fires or 4 stick men

heres the capx if anyone can figure it out. thanks again!

https://dl.dropbox.com/s/25qhvc6ny5thgev/MemMatchTutComplete_random.capx?dl=1Vaidd2012-07-24 17:59:50
B
2
Posts: 9
Reputation: 268

Post » Wed Jul 25, 2012 3:58 pm

ok i think i fixed my first problem, the cards arent always positioned above and below each other.

i still kind of have the 2nd problem, but slightly different/worse.

every couple games it will give me 2 pairs and then 2 different cards that cant be matched together, like ill get 2 stick men 3 hands and a fire, or 2 fire, 2 leaves, 1 rabbit and 1 stick man.

been working at this for hours and i cant figure it out

heres another capx https://dl.dropbox.com/s/25qhvc6ny5thgev/MemMatchTutComplete_random.capx?dl=1

thanks!
B
2
Posts: 9
Reputation: 268

Post » Wed Jul 25, 2012 5:55 pm

Make event 8 so that it is not a sub-event of event 5 and that should fix most of it. You can still get two pairs of the same card so just delete the duplicate frames.
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Post » Wed Jul 25, 2012 8:44 pm

unfortunatly taking event 8 out of event 5 and just making it a sub event of on start of layout, and even a stand alone event did not fix the problem of getting unmatchable pairs, although it didnt seem to make anything worse either haha

and when you say delete the duplicate frames, do you mean the duplicated frames inside the card sprite itself? cause i tried that and it didnt work
B
2
Posts: 9
Reputation: 268

Post » Wed Jul 25, 2012 9:29 pm

Add a card:destroy action to start of layout. The off screen card is what is giving the unmatchable cards.
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Post » Wed Jul 25, 2012 9:58 pm

poop that didn't work either

the card is definitely being destroyed but i still sometimes get 2 cards i cant match or double of 1 pair. i've somehow even gotten 2 cards that weren't the same to "match". ive probably destroyed the hell out of this tutorial with all of my changes lol

here's the newest capx with all suggested changes if anyone still wants to give it a shot https://dl.dropbox.com/s/25qhvc6ny5thgev/MemMatchTutComplete_random.capx?dl=1

R0J0, thanks for wasting your time with me haha... im sure you have nothing better to do Vaidd2012-07-25 21:58:55
B
2
Posts: 9
Reputation: 268

Post » Thu Jul 26, 2012 6:15 pm

Ok, add a new event:
System:compare tickcount=1

And move event 9 (the for each ordered) to be a sub event of that new event.

What was happening was destroyed objects still exist until the end of the frame. So there was still an odd number of cards when the for each was run.


As for being able to match different cards I suspect your condition that checks for a win may be the cause.
Try changing the expressions to just gFirstCardFrame=gSecondCardFrame
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Next

Return to How do I....?

Who is online

Users browsing this forum: Colorfish and 26 guests