Random, but not more than once?

Get help using Construct 2

Post » Tue Feb 09, 2016 8:43 pm

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
B
2
Posts: 3
Reputation: 158

Post » Tue Feb 09, 2016 9:25 pm

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
B
15
S
3
G
1
Posts: 15
Reputation: 839

Post » Wed Feb 10, 2016 10:26 am

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
B
2
Posts: 3
Reputation: 158

Post » Wed Feb 10, 2016 4:56 pm

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.
B
15
S
3
G
1
Posts: 15
Reputation: 839


Return to How do I....?

Who is online

Users browsing this forum: Congrats2u, jhjconstruct, tarek2 and 6 guests