Hey i want to create a Game in Processing and i need a random command wich Pics a random Numbers of 1 to 5 …
If i use the normal random Code then IT could happened that a number bigger than 5 …
I need a special command please send me the command thanks
(int) random(1,6);
should do it. Although there used to be a bug in Processing that you’d occasionally get 6 there, due to use of float
over double
. This might now be fixed.
1 Like
Now that I see that with 6, might this work:
floor(random(1, 5.99));
?
Just wondering…
The conversion to int
will already floor it. Looks like the bug I mentioned was fixed some time ago anyway - https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java#L5110