A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: excluding random numbers

  1. #1
    Junior Member
    Join Date
    Mar 2000
    Posts
    6
    talofa, I'm making this game where you have to click on this button which randomly chooses a number between 1 and 20. That works fine but I want to make it so that when a number is chosen once it won't be chosen again. So in theory you would only have to click on the button 20 times to get all 20 numbers. Randomly.
    cheers
    Peter

  2. #2
    Angkor-What? Gekke_Hollander's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    234

    Lightbulb

    After the button is clicked store the random number into a variable for instance var click1 = 17, var click2 = 9 and so on. So after the button is clicked check if the random number is the same as click1 or click2 and if so go thru the loop again...

    Gekke_Hollander


    On (Release)
    Set Variable: "varnumber" = Random (19)+1
    Set Variable: "howmanyclicks" = howmanyclicks+1
    Comment: or is it how many licks?
    Set Variable: "x" = "1"
    Loop While (x <= howmanyclicks)
    If (varnumber = "click"&howmanyclicks)
    Set Variable: "varnumber" = Random (19)+1
    Set Variable: "x" = "0"
    Else
    Set Variable: "click"&howmanyclicks = varnumber
    End If
    Set Variable: "x" = x + 1
    End Loop
    End On

    DO NOT BET YOUR LIFE ON THIS CODE AS I HAVE NOT TESTED IT!!!

    but let me know if it worked...
    Gekke

  3. #3
    Junior Member
    Join Date
    Mar 2000
    Posts
    6
    thanks Gekke,
    I'll give it a spin and let you know how it went
    cheers
    Peter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center