Random, but not more than once?

0 favourites
  • 4 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Hello everyone,

    I have a problem with a game I am trying to make. I want to deal cards to 4 players, but every card may only appear once and in random order.

    The random order is not a problem, but the game deals the same card more than once.

    I have added a Boolean (Gespeeld) that is set on True if the card is played.

    But when I add a condition that if the Boolean is "True", then the game won't deal cards.

    I hope somebody can help me with this.

    Thanks in advance,

    Greetz

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • One idea might be to give every card type its own ID and creating an Array object with the width the same size as the amount of cards you've got. Once you've played a card, set Array.At(cardIndex) to 1... checking if its already 1 before playing the card.

    Clear / Reset the array between deals

  • Hello Captaincatnip,

    Thank you for the quick response. I've tried another way, instead of using an Array, because it was the same problem. I've tried again with your information (Thx again). But I still have the same problem.

    Maybe I'll go over step by step:

    Created A Family with 32 different sprites (cards)

    When Clicked on "Kaarten Schudden" (Button) The Array picks a random number to start dealing from.

    When Clicked on "Kaarten Delen" (Button) Then the game should deal 3 cards to 4 four places, then 2 cards to 4 places and then again 3 cards to 4 places. Card placing for 4 players is ok.

    Random start card is also no problem, but dealing all the different cards is a problem.

    I've tried with the array, without the array, with boolean, without boolean. It won't work.

    When I add a condition that has to do with the cards, the game won't deal.

    Would it be possible to upload an example of what you mean? Because I don't completely understand what you are saying.

    Thx in advance

    Greetz

  • Okay, so what I think you might want to do is create an Array and call it "Deck."

    In your Family with your 32 different cards, add an Instance Variable to the Family called "CardID"

    On each of your cards, set the ID to a unique number (0 - 31 works great)

    Set Array's Width to "32"

    When you're dealing, you want to pick a Random number between 0 - 31. Using this number, check if Deck.At(Number) is 0, if it is, deal the card represented by the ID, and then set Deck.At(Number) to 1.

    Since you're marking the card ID as Used, you shouldn't get doubles.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)