Random Generate a card

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:
Menu Scene
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?

Comments

  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    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 :)
  • wibbsywibbsy Member Posts: 3
    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)?
  • wibbsywibbsy Member Posts: 3
    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.
  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    Yes, if you use: Change attribute game.Card to random(1,52) it will randomly choose the card from 1 to 52 :)
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
  • StormtrixStormtrix Member Posts: 256
    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.
Sign In or Register to comment.