Hello, I have some cards which display a different image for a Pair Matching game. The following code is supposed to shuffle the cards but for some reason the FaceFrameOfInitialCardPicked and FaceFrameOfSecondCardPicked variables seem to stay 0 at all times.
The Card.CardFaceFrame is initialized above and is indeed different than 0. Any ideas what I'm doing wrong?
random(0,gNumberCards) will return a float number, not an integer. If you want to pick between 0 and gNumberCards inclusive, try using int(random(0,gNumberCards+1).
Develop games in your browser. Powerful, performant & highly capable.
Here is a simple way to shuffle a deck of cards:
Demo
If you need to save the order in an instance variable, you can then do "For each Card order by Card.ZIndex -> Card set Order to loopindex"
Here's a pair-matching example using dop2000's shuffle (cheers dop, nice trick :-)), including a method to compare the pair selections without needing to throw around multiple global variables:
dropbox.com/s/0gkk659xby3fwkl/shuffleMatch.c3p
The advanced Random plug has permutation tables that will create a list of non repeating numbers, and even reshuffle them for you.