How do I set a random number in the global var between 1,10?

0 favourites
  • 4 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • I need some help thinking through this.

    I have 6 germs (sprites).

    On start of layout, I need each germ set to a random number between 1-10 - every tick that number will be displayed on the screen, for each germ.

    Each time a germ is shot - I need to subtract 1 from that original random number, until it reaches 0. When all the germs reach 0 then the game is won.

    How do I get each sprite set to a random number on the start of the layout?

    I tried giving each germ a global var and setting each to: on start of layout > system > set germ1 (2,3 & so on) to random(1,10) But the text on the display gives a number a lot higher than 10.

    Any idea how to do this?


  • Use an instace variable on germ.

    On start of layout:

    For each germ:

    - Set instace variable to round(random(1,10))

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • - Set instace variable to round(random(1,10))

    Round! That's it. I through it was 'floor'. (I have so many languages mixed up in my head)

    Thank you so much - that did it!

  • Actually you want floor. round will skew the results.


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