GameMaker: Studio

GameMaker: Studio

Statistiken ansehen:
irandom(59)=1
The randomness of 60 positions, right? from 0 to 59 .... why there is the position of "X", which I do not have? Why are only the values 0,1,2,3,4,5,6,7,8,9,19,29,39,49,59 .... Why do not participate during the randomness other values that I also pointing
-------------------------------------------------------------------------------------------------------------------------
В рандоме 60 позиций, верно? от 0 до 59.... почему существует позиция "Икс", которой я не указал? Почему используются только значения 0,1,2,3,4,5,6,7,8,9,19,29,39,49,59.... Почему в ходе рандома не участвуют прочие значения, которые я так же указываю..............
Zuletzt bearbeitet von .M.Y.W.; 11. Dez. 2016 um 3:51
< >
Beiträge 115 von 28
Thew 10. Dez. 2016 um 18:43 
randomize();
Why? What it performs?
I need all the participants from 0 to 59, 38 and 22 switches on and so on ....
And now I have just mentioned by me above ....
-----------------------------------------------------------------------------
Зачем? Что он выполняет?
Мне нужны все участники от 0 до 59, влючая 38 и 22.... и т.д.
А сейчас у меня лишь указанные мной выше....
They told you "randomize();" to encourage you to look it up in the manual.

Without using "randomize();" at some point in your program prior to using the random function you aren't truly getting random results. The reason is that by default Gamemaker uses a preset random seed unless you tell it to "randomize();". They do it so that you can debug easier by always having your random functions play out in a predictable and repeatable way.

In other words... you'll only ever got those same results from random functions until you include randomize();
Thank you. But even so, a random number does not fall out.
Very often, the action does not work (in action "random" concluded the creation of an object by coordinates).
Thew 11. Dez. 2016 um 8:40 
Ursprünglich geschrieben von Firm .M.Y.W.:
Thank you. But even so, a random number does not fall out.
Whoops! I'm sorry, my Russian is really poor and I assumed you were having issues with random values being consistent each time. (You should still use randomize() though)

As for making random numbers unique each time, a relatively easy way to do this would be to create a ds_list and store all the numbers in it.
number_list = ds_list_create(); for (var n = 0; n < 60; n++){ ds_list_add(number_list, n); }

Now whenever you want to draw a random number, shuffle the list and then delete that value so it can never be drawn again.
ds_list_shuffle(number_list); random_number = ds_list_find_value(number_list, 0); ds_list_delete(number_list, 0);
Zuletzt bearbeitet von Thew; 11. Dez. 2016 um 8:41
randomize();
if irandom(9)=0
{
position_destroy(352,96);
}
else if irandom(9)=1
{
position_destroy(384,96);
}
else if irandom(9)=2
{
position_destroy(416,96);
}
else if irandom(9)=3
{
position_destroy(448,96);
}
else if irandom(9)=4
{
position_destroy(480,96);
}
else if irandom(9)=5
{
position_destroy(512,96);
}
else if irandom(9)=6
{
position_destroy(544,96);
}
else if irandom(9)=7
{
position_destroy(576,96);
}
else if irandom(9)=8
{
position_destroy(608,96);
}
else if irandom(9)=9
{
position_destroy(640,96);
}
And not always it works. And this is very great need! Otherwise the game does not work out ...
---------------------------------------------------------------------------------------
И не всегда это срабатывает. А в этом очень огромная необходимость! Иначе игра не сложится...
Thew 11. Dez. 2016 um 11:10 
Your code usually won't work because you're re-randomizing on each If statement. You can simplify this very easily.
randomize(); var random_number = irandom(9); position_destroy(352 + (random_number * 32), 96);
the random number generator is just a SET of numbers. If you don't randomize the game at the start, then you will get the same series of numbers in a row evry time you run your game. To change this you would (at the beginning of the game) randomize() the game, shuffling up that SET of numbers. You only have to do it once at the start of the game and no other time.

See Random Number Generation[www.whitewoodencryption.com] to understand the major problems with using randomness in computer programming.
.M.Y.W. 11. Dez. 2016 um 14:11 
Ursprünglich geschrieben von Thew:
Your code usually won't work because you're re-randomizing on each If statement. You can simplify this very easily.
randomize(); var random_number = irandom(9); position_destroy(352 + (random_number * 32), 96);
Oh oh oh!!! This magnificent ..... paid homage on 99 products randomness, but you stung all in 2 lines))) That's it !!! education
-----------------------------------------------------------------------------------
Ой, ой ой!!! ЭТО ВЕЛИКОЛЕПНО..... На воздавал 99 позиций рандома, а ты ужал всё в 2 строчки))) Вот оно образование!!!

Listen? And what about the music? I want it to play from the list. Shuffle and obsession
-----------------------------------------------------------------------------------
Послушай? А как быть с музыкой? Я хочу, чтоб она воспроизводилась из папки. В случайном порядке и зацикленно...

Is my code:

if irandom(1)=0
{
sound_replace(sound0,"sounds\s0.mp3",1,1)
sound_play(sound0)
}
else if irandom(1)=1
{
sound_replace(sound0,"sounds\s1.mp3",1,1)
sound_play(sound0)
}

if not sound_isplaying(sound0)
{
if irandom(1)=0
{
sound_replace(sound0,"sounds\s0.mp3",1,1)
sound_play(sound0)
}
else if irandom(1)=1
{
sound_replace(sound0,"sounds\s1.mp3",1,1)
sound_play(sound0)
}
}
Thew 11. Dez. 2016 um 19:42 
sound_replace() is a deprecated function and should not be used.

If you want to play a random sound file, you can just use the choose() function.
choose(sound0, sound1, sound2);
.M.Y.W. 11. Dez. 2016 um 21:09 
I have a very old version of GameMaker (free) ...
I play a little melody randomly. I need this to happen after it ends (looped event)
the new gamemaker is free
In any case, I use the 7.9 version, since Yo Yo Games...
Thew 12. Dez. 2016 um 6:50 
Does GM7 have the choose() function? If it does, this should still be a very good solution for your problem.
< >
Beiträge 115 von 28
Pro Seite: 1530 50

Geschrieben am: 10. Dez. 2016 um 14:52
Beiträge: 28