I know making a random number divisible by 10 means it isn’t so random after all, but stick with me. Imagine a game grid of tiles that are 10×10 pixels. I want to place a 10×10 sprite randomly on the game grid.
I’ve got everything working other than getting my random number function to return random numbers that are divisible by 10. If I give it a range of 10 and 50, I want it to only return 10, 20, 30, 40, 50. You know what I mean.
Here’s my function:
public function randomNumber(low:Number = 0, high:Number = 1):Number
{
return Math.floor(Math.random() * (1 + high - low)) + low;
}
How can I make that happen?
Thanks!
generate a random number from 1 to 5 and multiply by 10.