How do I create only even random numbers

0 favourites
  • 3 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Just reduce your range in half and multiple the result by two.

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

    Thank you blackhornet!!!

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