Playing with 0.9.93 - How to Shuffle a Deck of Cards + Project File
Hi,
Someone asked me if it is possible to shuffle a deck of cards in Game Salad. So since we have writable tables now, I guess the answer is why not?
This project file is nothing fancy, it displays 52 cards (empty at first) and when you click on 'Shuffle' it will shuffle the deck. The cards are marked as , so:
1. A, 1, 2, 3, .... 10, J, Q, K for the card numbers
2. d (diamond), h (heart), s and c for the symbol
The performance is very slow, but I'm sure it can be improved quite a bit (did this one in 10min so don't expect much).
It also demonstrates a loop within a loop, or sort of...
https://www.dropbox.com/s/aygrfzx0sinzwet/Shuffle.gameproj.zip
Hope you'll find it useful. Needless to say, you will need 93 for this one.
Cheers,
GR
Someone asked me if it is possible to shuffle a deck of cards in Game Salad. So since we have writable tables now, I guess the answer is why not?
This project file is nothing fancy, it displays 52 cards (empty at first) and when you click on 'Shuffle' it will shuffle the deck. The cards are marked as , so:
1. A, 1, 2, 3, .... 10, J, Q, K for the card numbers
2. d (diamond), h (heart), s and c for the symbol
The performance is very slow, but I'm sure it can be improved quite a bit (did this one in 10min so don't expect much).
It also demonstrates a loop within a loop, or sort of...
https://www.dropbox.com/s/aygrfzx0sinzwet/Shuffle.gameproj.zip
Hope you'll find it useful. Needless to say, you will need 93 for this one.
Cheers,
GR
Comments
also updated the one on top. Thanks, but actually, tshirtbooth posted quite a few of those recently including a full end to end tutorial on how to build a word game, I'm sure there were others.
It's actually was not for a game, just a quick test. But now that you made it instant maybe it should be a game.
I was thinking of optimizing it by moving the logic to the individual cards, but I didn't thought/forgot about the remove row as keeping the selection unique. Very cool solution.
Update: LOL, just started watching your videos... I guess I should have started with that
http://www.crypes.com/work/ShuffleTableTest1.gameproj
This is actually a 2 part-er.
1) is the automatic creation and placement of your cards, and assignment of values.
2) is the Green button on the bottom left. Shuffle button
the gray boxes show the values in the first row of the Table.
I'm only using 10 cards to test it, but it's super clean.
I suggest you create 1000 rows, and keep them empty, because you can now CHANGE values in Tables, not CREATE new rows.
What I am doing is choosing the first card (row 1), and storing it's value (Column 1), then choosing a Random Row, and storing IT's value(Column 1). Then swapping the two Values (Column 1).
Then move to the next Row (row 2), and doing the same. I swap each row with a random row.
This shuffles the numbers pretty good.
If you really want them shuffled Super-dooper, you can run this loop 3 times. It's super fast.
No repeating numbers, no missing spaces.
Remember: Col 1 is the card placement in the deck.
You can use Col 2,3,4,5,etc for card value, color, Wild/Not, etc.
The only thing that should change is Col 1 (placement).
I did not do a Rule for moving the card around on the screen. that's too easy. I just wanted to show shuffling.
Hope this helps..
Love the New writable tables. Thanks GS!
Next time you might want to post it to a new thread to get some more exposure.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS