Hello, I'm trying to set a random number from a range of 1-4 when you collide with a power-up. How do I do this? (as far as I know, all random ranges must start from zero?) But i know there must be a way.
random starts from what you want it to and ends where you want it to. What you want is "random(1, 4)". This will give you a number in between 1 and 4.
Develop games in your browser. Powerful, performant & highly capable.
Actually, if you want integers, you want: int(random(1,5)), or you can use choose(1,2,3,4). The manual explains the subtleties of the two random() commands.
https://www.scirra.com/manual/126/system-expressions
thank you guys! i'll try this stuff out.
Actually, if you want integers, you want: int(random(1,5)), or you can use choose(1,2,3,4). The manual explains the subtleties of the two random() commands. https://www.scirra.com/manual/126/system-expressions
Oh, and you can always use round(random(1,4)) as well. I had no idea there was a choose() function though, thank you!
round() won't give you an even distribution of numbers. It's better to use int() or floor() (same thing).