Randomized an array for a deck of cards

Get help using Construct 2

Post » Wed Sep 23, 2015 9:52 pm

i made a card game... well so far its just one player...

i made all cards separate and had them in a family "Deck". have a boolean on the card "picked".
on draw (or on click) pick a random instance of a card where "picked" is false,
add it to the hand and set it to picked=true

for the face value, either have a variable (1-13) for each card. just add it to the family, and add it as you go.

heres my capx https://www.dropbox.com/s/oonwtbo0ajprx ... .capx?dl=0

as an addendum, your shuffle animation looks sick (pardon the game name, if you kno it you'll forgive me)
Posts: 102
Reputation: 987

Post » Sat Feb 20, 2016 10:48 am

Sorry to bump a super old thread. But this came up as a top result when I was searching for information regarding card deck in Construct so I should point out.

The initial capx in the OP does not do a random shuffle of the deck. It's easy to see, mathematically that it's not doing so.

That event group has a comment at the top explaining two algorithms that are mathematically sound. But the execution does not implement either of them.

The indexes need to reference "shuffle" for one thing.

Shuffle a few times and you will notice that many if not most of the cards are in their original spots.

Overall I found it to be a nice program and as a beginner to construct, found it educational. But the shuffle was not random or mathematically fair.

Again sorry to bump an old thread, but it needed to be done and was right to do.
Posts: 33
Reputation: 345

Post » Wed Oct 26, 2016 8:49 pm

im trying to make this work for a small 6 card deck for a children's game... so far I've been unsuccessfull... :(
Freefall Bird
Posts: 280
Reputation: 5,781


Return to How do I....?

Who is online

Users browsing this forum: morti and 10 guests