Random Number Picker in GameMaker

Forum Listing » Coding Forum » View Topic


  • i will start out by saying that i do know how to do this, but want to see if there is a better way to go about doing it.

    so what i need is a way to have a random number generator that will pick say a number between one - ten. this is for gamemaker. but that's what i need it to do, but i need it to have the ability to have mulitple generators generating stats.

  • x = irandom_range(1,10);

  • Or you can be a noob and do this:

    x = choose( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 );

    Or...

    x = round( random_range( 1 , 10 ) );

  • orrrrrrrrrrrrrrrr

     

    n = 10;

    while n > 0

       {

       if floor(random(n)) = 0

          {

          x = n;

          break;

          }

       else

       n -= 1;

       }

    Last edited on May 22, 2013 - 01:55 PM by Nik

  • how would I go about getting it to draw that out than ?

  • If by drawing out, you mean drawing it to the screen, you can use the draw_text function:

    //Create event

    randomnumber = irandom(10);

    //Draw event

    draw_text(2, 2, randomnumber);

Friends {{client.onlineFriendsCount}}/{{client.offlineFriendsCount}}

People Online:

Room Users {{client.usersOnline.length}}

: