Discord
Login
Community
DARK THEME

How to set variable to random number

I'm making a project that requires a sprite to be put in a random place, but I am having trouble generating a random number. Does anyone know how I would get a random number?

that should help

rand = function(min,max)
  return floor(random.next()*(max - min) + min)
end
randFloat = function(min,max)
  return random.next() * (max-min) + min
end

Thanks!

i usually just use

var = (random.nextInt(max*2))-max

i dont know if Romero's can go negative or not, but this just gives you a up to max and as low as -max since microstudio uses centered draw anchor

Yes, you can use negative numbers in both functions

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community