Hundreds of features to explore
Games made in Construct
Your questions answered
Trusted by schools and universities worldwide
Free education resources to use in the classroom
Students do not need accounts with us
What we believe
We are in this together
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
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?
Develop games in your browser. Powerful, performant & highly capable.
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).
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.