How do I randomize between 2 interger within a variable

0 favourites
  • 6 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • this is what i currently have and it's obviously wrong

  • Not sure I understand you correct. But a variable can only have one value at the time. But if what you mean is that you want this to be either 1 or 2. Then you have to use int(random(2)+1) or you can do choose(1,2) I think, I normally use the first one, due to old habit.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not sure I understand you correct. But a variable can only have one value at the time. But if what you mean is that you want this to be either 1 or 2. Then you have to use int(random(2)+1) or you can do choose(1,2) I think, I normally use the first one, due to old habit.

    both work quite well thanks =]

  • Just a heads up for informatino.

    Random generates a float number between X and Y. This includes x.x and y.y. The number always creates a decimal value. So

    Random 1,2

    1.000000 to 1.9999999

    What nimos does is generate a float value of 0.0 to 1.9, then adds + 1 for a solid 1.0 to 2.9.. then uses the int to truncate the decimal value off.

  • I was advised to use choose() in preference to random() as the choose() is slightly quicker -obviously this depends on the circumstances. In this case I would use "Choose(1,2)".

  • Just a heads up for informatino.

    Random generates a float number between X and Y. This includes x.x and y.y. The number always creates a decimal value. So

    Random 1,2

    1.000000 to 1.9999999

    What nimos does is generate a float value of 0.0 to 1.9, then adds + 1 for a solid 1.0 to 2.9.. then uses the int to truncate the decimal value off.

    thanks for the extra info. learnt something new

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