# How do I simulating the launch of dice

0 favourites
• 5 posts
From the Asset Store
Let’s improve your match skill in a fun competition!
• HI to all

I am trying Construct 2, I am a begginner

I need to create a game same chess but i need to simulating the launch of dice and I should have one, two or three dice according to the ontest of the play.

Can someone help me?

Thank's

Mimmo

• ## Try Construct 3

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

Construct 3 users don't see these ads
• Hey mgsoftwaring!

You can simulate dice (with any number of sides) using the random() expression.

From Construct 2 Manual:

"Random(N) - Returns a random number between 0 and N, not including N. The result includes fractions, so random(3) can return 2.5. Use floor(random(n)) to generate a random whole number up to but not including N, e.g. floor(random(3))* will return either 0, 1 or 2. Random(A, B) can also be used to generate a random number between A and B."

To simulate 6 sided dice use: floor(random(6)) + 1

If you need the sum of dice values, I'd suggest you make a function like the one below:

When you call the function you say how many dice you need to roll and it will roll all dice and return the sum.

eg. roll(3) to roll 3 dice and get the sum of the results or roll(1000000) to roll one million dice and get the sum of the results.

Hope this helps. Cheers!

• Thank's

Mimmo

• I can propose another simple way:

on whatever condition

choose(1,2,3,4,5,6)

This chooses one of the 6 numbers

• 5 posts