Eliminate last frame used

Get help using Construct 2

Post » Wed Jan 01, 2014 11:07 am

Hi I have a problem at a card game.At dealing i made set animation frame at Random(0,Card.AnimationFrameCount),but the frames are repeating idk why.
Its like I draw the 1st 5 cards and some are copies like 2Q or 2Ace that are exactly the same heart or leaf ..... and I don't wanna have that in my hand coz the deck has no copies idk how to eliminate frame after the card with that frame its drawn pls help or tell me a way to draw cards without duplicates.

Happy New Year 2014!!!!!!!!!!!!!!lo7s2014-01-01 11:24:33
B
6
S
2
Posts: 28
Reputation: 758

Post » Wed Jan 01, 2014 11:23 am

Hi,
i haven't worked with array in construct yet, but how about pushing the drawn cards frame number into an array and in your condition Random(0,Card.AnimationFrameCount) add a second condition for "not - array contains value"

happy new year5Type2014-01-01 11:24:41
B
22
S
7
G
4
Posts: 154
Reputation: 3,699

Post » Wed Jan 01, 2014 11:34 am

Seems that my game its messed up .I'm newbie I tried to make the deck and so with array but idk how to place a frame into an array and so.Seems like array can help me as it has a pop option to eliminate one element .I think i can use that like random placing frames or sprites in the array the draw the from card from array with pop fron after that.

I need some help with the array, if some1 can explain how to make that I would be really GRATEFUL.
B
6
S
2
Posts: 28
Reputation: 758

Post » Wed Jan 01, 2014 11:40 am

You may want to use choose system expression instead.

choose(1,2,4,5) picks a random number from the list, excluding the 3. You just need to fill the parameters by listing animation frames excluding the current one.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,170

Post » Wed Jan 01, 2014 11:54 am

still waiting for tips! Expression choose(1,2,4) excluding current frame doesn't work it still duplicates 1,2 or 4 .I'm trying to do something to exclude frame 1,2,4 after its chosen, drawn.It choose one of those numbers,but it can choose the same number many times I want the same number to be chosen only once so it can't duplicate.lo7s2014-01-01 12:01:01
B
6
S
2
Posts: 28
Reputation: 758

Post » Wed Jan 01, 2014 11:55 am

Anyway Thx for tips Mipey and 5Type.lo7s2014-01-01 11:56:07
B
6
S
2
Posts: 28
Reputation: 758

Post » Wed Jan 01, 2014 12:10 pm

Ah, right, you want a set of unique numbers. Here is a tutorial for that:
Generating Random Numbers Without Duplicates

Not very elegant solution in my taste, but it should do you well. What I normally use is a Fischer-Yates shuffle method (google it), as demonstrated here:


I just iterate through the function results and draw the frames in supplied order.Mipey2014-01-01 12:12:36
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,170

Post » Wed Jan 01, 2014 12:17 pm

THX A LOT MIPEY !!!!!!!!!!!!
B
6
S
2
Posts: 28
Reputation: 758

Post » Wed Jan 01, 2014 12:18 pm

Happy new year :)
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,170


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests