What I have currently is basically what you’re describing as a While Loop; every time you generate a card, it randomizes, it’s supposed to check to see if the card exists, and if it has it creates a new one. The trouble is stemming from the fact that the cards it’s checking are multiple instances of the same object, each displaying different animations between 1 and 52. Here’s what the code looks like:
1. The number of NewCard is =1 | Do =”Yes” to the text of global variable Gambling.Shuffling
2. The text of global variable Gambling.Shuffling is =”Yes” | Do =Random(4) to the number of current animation of NewCard
3. If the number of the current animation of NewCard is !=0 | Do =”No” to the text of global variable Gambling.Shuffling
4. The text of the global variable Gambling.Shuffling is =”No” | Create object DealtCard at position Newcard.X(); NewCard.Y(), Do =NewCard.Animation() to the number of current animation of DealtCard; Delete object NewCard; Do =”Standby” to the text of global variable Gambling.Shuffling
I’m currently using 4 card to test out if this is working, so the NewCard and the DealtCard objects have 5 animations, 0 being a card back and 1-4 being actual cards. When the NewCard is created, it’s on animation 0; the game checks the NewCard object to see if it’s at animation 0, and if it is it shuffles a random animation.
The shuffling state is currently set to be based on a variable with three states; Standby (initial variable), Yes, and No. When the NewCard object is found to be at animation 0, the Gambling.Shuffling variable changes from Standby to Yes; the game randomly changes NewCard’s animation; the game checks to see if the animation is either 0 (a card back) or the same animation as the DealtCard object already in play, if it isn’t it sets the variable Gambling.Shuffling to “No”; when the variable Gambling.Shuffling is on “No”, it creates a DealtCard object in place of the NewCard object, changes the DealtCard object’s animation to the same animation as NewCard, and deletes the NewCard.
All of this is working fine except for when it checks current animation of the object DealtCard; the way this is set up, there are multiple DealtCard objects on the screen, each displaying a different animation. It’s only checking the first one, but it’s ignoring any of the additional DealtCard objects.
All that said, I think I have an idea, based on ddabrahim’s suggestion of hidden cards used to display the dealt cards. If I keep a number of cards for each player hidden, then set them to copy the NewCard object’s chosen animation and become visible when the NewCard object randomized its animation, then set the NewCard to not copy the animation of any visible DealtCard objects (which would each be separate objects in this case), I think it will work.
EDIT: Yep, that’s the solution. I put in a variable that counts how many cards are on the table (the variable goes up by 1 every time the Deal/Hit button is pressed), and at each stage the game will check existing DealtCards’ animations and rule them out, randomly pick a new number for NewCard, then assign the animation of NewCard to a hidden DealtCard object and make it visible. Because there’s only four animations currently available, once all four are used up, the NewCard object just shuffled infinitely, but never lands on an existing one. Once I have all 52 cards in there, it will be all set up.