Need help in very complicated random

0 favourites
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I have a Sprite "Dino" and copied 3 times in layout

    "Dino" has instance variable "Color"

    I have another Sprite "Choose" and copied 10 times.

    Now I want to set all three Dino's "Color" variable a Random number between 1 to 10. But all three should be different numbers.

    1) I want to pick one random Dino and set "Color" variable Manually (By click "Choose" and set Choose's Index to "Color")

    2) Remaining 2 Dino's "Color" variable should be Random between 1-10 (Excluding previously picked number)

    Tagged:

  • Here you go:

    dropbox.com/s/ziihp5gkie6h78o/VeryComplicatedRandom.capx

    Run the project in debug mode to see color variable.

  • Actually, here is a shorter version:

    dropbox.com/s/9tmz47wm4b8nj89/VeryComplicatedRandom2.capx

  • Thanks for this

    It works but not perfectly

    on click chooser only Single Random Dino variable Changing others are not changing.

    and Sometime Repeated number showing

    dropbox.com/s/7pw9aigr2gpbiht/VeryComplicatedRandom.capx

  • Did you try my second version? Both my files work. You probably made some mistake when transferring code to your project.

  • Yes I also tried second version

    On Very first click all 3 Dino gets random number but after that only Single Random Dino gets random and other 2 remain same as previous. and sometime they become same number, sometime 2 number same and sometime all three same because only one Dino changing on click

  • I didn't transfer code to my project

    I just did check your code in text and in debug. But result was same.

    Only first click generates random.

    May be I didn't explained it well.

    I want 3 Random numbers on Single Click. I mean when click on Chooser all three Dino's Color will be change But 1 Dino's Color will be same no of Choose IID and other Dino's Color will be random and all three Dino's Color should be different.

  • Yes, it only works one time. If you want to be able to click again and fill different random numbers, first you need to reset all color variables to 0 for all Dino sprite. Simply add "Dino set color=0" at the start of the event and it should help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks it worked

    you helped me again

    each time when i need help you were there always

    I'll never forget it.

    Thanks again

  • dop2000

    one more thing i want to do here , I though i could do it myself but I'm not getting any way.

    we click Chooser and a Random Dino gets a Number and other two Dino get another different random number.

    Now i want to repeat that cycle 5 times but this time we never click on chooser and we will use the same number (last picked number from chooser) and apply to a random dino again for remaining 2 dinos I want new random numbers(not repeated number).

    is this Complicated ? for me its very complicated.

  • Complicated, but not impossible.

    dropbox.com/s/9tmz47wm4b8nj89/VeryComplicatedRandom2.capx

  • your help worked but i didn't understand the logic from 5th Line

    First we picked all chooser

    then we picked all chooser and extract previously picked one

    (One Question here why we use both here pick all chooser will pick all Chooser instances and pick by evaluate picked all except that one which we already picked, As this one pick by evaluate is doing what we want then why we also used pick all?)

    after that we used Sub Event For each (Ordered), why we use this I didn't understand. and for Random Expression I always thought Random always needs a Range and i always give 2 values in random expression.

    please can you explain to help me understand.

  • "Pick all" is left from previous version, it's not needed here, you can remove it.

    "For each chooser order by random(1)" is to pick two random chooser sprites (excluding the one we removed in event 5). It doesn't matter what number you put in random() expression in this case, it's just used to sort the list of instances randomly. Then "loopindex=1" condition is used to stop the loop after two chooser instances are processed. Again, this is not really needed, the loop can continue for the remaining chooser sprites, but Dino sprites will not be changed after that.

    random() doesn't always need a range, random(1) means the same as random(0,1)

  • again here

    i have given LiteTween (move_in and move_out) behavior to Dino

    they all move_in together but they move_out separately.

    I want to detect when all thee dino move_out

    I means Do Not Detect when only one or two Dino are move_out. I want to detect when all three dino are move_out

    How to know this

    I tried to use pick all but it didn't worked.

  • I'm not sure I understand your question.

    Try to pick Dino instances that "move_out". And use Dino.PickedCount expression to check how many are picked.

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