I wanna make a DICE ROLL!!

0 favourites
  • 8 posts
From the Asset Store
Let’s improve your match skill in a fun competition!
  • How do i do a dice roll??

    For example: i wanna dice to roll from 1-110

    if it rolls 1-49 -Action 1 happens

    If it rolls 50-99 -Action 2 happens

    and if it rolls 100-110 -Action 3 happens!

  • When you say "dice roll," I am guessing you mean you want the computer to choose a random value. Take a look in the manual at the random() system expression:

    https://www.scirra.com/manual/126/system-expressions

    Since random returns a float (or floating point number), the return will be a decimal. You will want to get the integer value from it.

    Something like this would get what you want:

    int(random(1,111))

    *note: random returns the a number below the high value so to get 110, the high needs to be 111.

  • To add to above. To get actions to happen when you do your dice role you will want to make a function.

    When action calls for the dice to be thrown do function "dice roll"

    Then in another event you will have On function "roll dice" set a var to int(random(1-111) then in sub events you will want the use the compare value event. in the first one you will want to compare var dice roll = range(1-49) then do action 1. the same for the other sub events but make sure they are on the same level as the first one

    Function

    event

    event

    event

    not

    Function

    event

    event

  • That helped a lot. Thank you !

  • I'm a noob and I dont understand how do make a random dice roll still....Any more help would be appreciated

  • If you could first explain what you expect with a dice roll, it might be easier to tell you how to do it..

    The above comments explain how to get a random number.

    Once you get the random number you can compare it and attach the actions you'd like to set.

    What part are you having trouble with or was your initial question misunderstood?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • My question was understood perfectly, but I have trouble executing it in construct.

    I want every random 1-3 seconds that program throws a dice and a random number between 1-110.

    and for numbers between :

    1-49 executes animation 1

    50-99 executes animation 2

    100-110 animation 3

    Step by step instructions would be great

  • Should be something like this:

    Create a global variable DiceRoll

    Add the function object to your game

    triggered event (on sprite clicked?)

    • system set variable DiceRoll = int(random(1,111))
    • Function call "DiceAction" with parameter0 DiceRoll

    on function "DiceAction"

    • Function if parameter0 is < 50

    > (add the action you'd like)

    • Function if parameter0 > 49
    • Function if parameter0 < 100

    > (add the action you'd like)

    • Function if parameter0 > 100

    > (add the action you'd like)

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