RANDOM : Please help once and for all! PLEASE PLEASE PLEASE

TechnoDaveTechnoDave Member Posts: 103
edited November -1 in Working with GS (Mac)
Ok I have being trying to use the random behavior for ever now and it just does not work! I have searched and searched on this forum for a simple work around and all I get are complicated explanations that don't seem to work.

CAN SOMEONE PLEASE JUST GIVE ME A SIMPLE SOLUTIONS TO THE FOLLOWING!!!

I want a player to press a button, and when that button is pressed a random image will be spawned every time. That's it! Spawn a random image on touch.... Why can't I do this!!! lol

Comments

  • sebmacflysebmacfly Member Posts: 1,018
    Exemple for 10 images...

    ON YOUR BUTTON ACTOR :

    when actor receive touch is pressed :
    Change Attribute game.randomimage to Random(1,10)

    ON YOUR IMAGE ACTOR :
    When Attribute game.randomimage=1
    Change image to : Image1.png

    When Attribute game.randomimage=2
    Change image to : Image2.png
    ......
    When Attribute game.randomimage=10
    Change image to : Image10.png

    PS : "randomimage" its an integer attribute.
  • TechnoDaveTechnoDave Member Posts: 103
    Thank you for the reply "sebmacfly" but that only works the first time around. But every single time a player launches the game they will get the same order of images over and over. That's the problem!! Random may generate a random set the first time around, but then it will generate the same random set over and over making in not random at all!
  • TechnoDaveTechnoDave Member Posts: 103
    No one? Nothing? Nothing from the Pros out there?!?!
  • dotsonj23dotsonj23 Member Posts: 316
    I think you first need to use random on the title screen to randomly produce, once the title screen is loaded, random numbers every .01 seconds for an attribute that you don't actually use at all, say 1-100. Then when you push play to play the game the random generation stops. Naturally play will be pushed by the player at "random" intervals (i.e., sooner or later in terms of time) and that will seed the random generator for your next use of random with a different sequence almost every time (unless the player happens to hit play at the exact same time interval each time). This should give you a better result for the second random that creates the characters you actually want to see. They key to making it random is to have the random seed number based on variable user input.
  • netdzynrnetdzynr Member Posts: 296
    It's been mentioned in the forums dozens of times -- random is not random, unfortunately.

    Depending on the number of images you have, you might be able to employ the time attribute to create the limits of the random number, since the time will always be changing when the user presses the button.
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    Got here a little late... ;-)
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    you really need to seed the random generator, because as it's been said countless times before, it's not really random.
Sign In or Register to comment.