How do i do probability to Spawn?

0 favourites
  • 3 posts
From the Asset Store
Heads N Tails is an educational Ludo game of probability with visualization and in fun manner.
  • Hi Guys,

    I am thinking about how to do a probability of spawning different sprites.

    I have a set of 6 different sprites to spawn. Currently I am using int(random(5)) to get a random spawn of the sprites.

    What I would like to do is to make the spawning of these sprites based on a probability?

    Example:

    Sprite 1 - 25%

    Sprite 2 - 18%

    Sprite 3 - 25%

    Sprite 4 - 12%

    Sprite 5 - 15%

    Sprite 6 - 5%

    And also I will like to be able to adjust the probability based on the events that happens during runtime.

    A note also, is that currently my sprites are all stored within 1 sprite object with each sprite as a frame in the animation.

    Hope to get advise from the community! Thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • int(random(0,101))

    if less than 25 -> Sprite 1

    if greater than 25 but less than or equal to 43 -> Sprite 2

    etc.

  • Thanks Excal,

    I found this in the FAQs.. should have done it earlier.

    construct.net/en

    This would be more likely I would like to do. Thanks

    Sorry for the post.

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