#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Random Generate a card

Posts: 3Member
Hi

I'm very new to GS and trying to get my head around designing a high low card game based on a standard 52 card deck. A player picks a random card and the computer picks a random card and then the app simply compares to see who wins the trump.

Ive split my project into:
Pick a card scene
Resolve the trump scene

In the pick a card scene I have created a card actor and I have a button that spawns a card, but I'm confused as to how to spawn a random card from a selection of 52 each with different values? Do I need to create 52 individual card actors? Or can I have a card prototype and just assign a random value on each instance that is created?

• Posts: 2,807Member, Sous Chef
You can make one Card actor, and behavior: game.Card (integer).
If player takes the first card, change game.Card to 1, etc.
In your card actor put a rule:
If game.Card is 1, change image to: Card1.png

And similar with the rest 51 cards
• Posts: 3Member
HI Souschef,
thanks for the pointers. So I'm clear, I create a card actor and add a new attribute of Game.Card (integer).
It's the second part I'm not sure of, how do I make the game.Card receive a random value? Create Rule - Attribute game.Card random(1,52)?
• Posts: 3Member
I think in the main rule for the card actor I essentially need to say:
When an instance of that actor is spawned assign a random number to that instance's game.Card attribute between 1 and 52.
• Posts: 2,807Member, Sous Chef
Yes, if you use: Change attribute game.Card to random(1,52) it will randomly choose the card from 1 to 52
• Posts: 1,803Head Chef, Member, PRO
• Posts: 256Member
I made a game based on this sort of that's on the app store.. Blind Man's Bluff.
My first basic game... didn't use tables since it was like 2years ago.. Would definitely use tables if i had to do it over.
This discussion has been closed.