How do I create only even random numbers

Get help using Construct 2

Post » Sun Nov 23, 2014 12:40 am

Hi,

I have just started using Construct 2 and am amazed by the amount of knowledge here. Well done to all you experts.

I have been trying to create a memory match game based on the tutorial by kittiewan (which is excellent) but have a quick question in regards to the way the cards are laid out. As the tutorial stands it will always start it's cardfaceframe to 0, which is okay for random objects, but say when I am trying to use the alphabet or numbers I would like to start further up the list so that the player is not always going to get abcdefgh for example on an 8 card system.

So I thought I would be clever and use the random method as say "set gCardStartNumber to int(random(10))"

Now this does work, however when I get a number which is odd, then the cards do not match as the animation sequence is out of whack. The result will show "say" a D as one card then an E as the other and go yup, they are a match, which in theory they are (based on the layout) but obviously they are not.

Does anyone know how I can always return an even number so that the sequence is never out. I tried to look at arrays but got lost.

Thank you very much.
B
6
S
2
Posts: 38
Reputation: 567

Post » Sun Nov 23, 2014 12:56 am

Just reduce your range in half and multiple the result by two.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Sun Nov 23, 2014 2:17 am

Oh yes. "Doh". That would work very well. Sometimes I assume it must be more complicated than that.

Thank you blackhornet!!!
B
6
S
2
Posts: 38
Reputation: 567


Return to How do I....?

Who is online

Users browsing this forum: dop2000, totoe and 40 guests