Generate an object by using percentage

0 favourites
  • 3 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hi everybody. I need your help. ^^

    I made a game with an object grid. When the user taps on an object, he destroys it. When this object disappears a new one replaces it.

    So I need to create a new one using percentage. Because it's possible to have one from those four: wood, stone, gold, diamond.

    I would the new one will be a wood one at 70%, stone at 24%, Gold at 5% and diamond at 1%.

    But I don't know how to do it.

    So I made this

    Tagged:

  • So what you currently have is 25% chance of each right? All you need to do is set the setCreate variable to floor(random(100)) which gives you 100 numbers from 0-99. Then on the conditions you use ranges so setCreate is between 0 and 69 for the wood, 70 and 93 or stone, 94 and 98 for gold and if it is 99 then diamond.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • , thanks for your help, it works perfectly. I share a screenshot for others wh'll have the same difficulties.

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