# Random Function

Is there some sort of random function in MicroStudio? If so, how do you use it?

Discord

Login

DARK THEME

- Help
- All
- Off Topic
- Project Sharing
- Suggestions
- Bugs
- Questions
- Articles
- Roadmap
- News
- Game Engines
- Tips
- Resources
- 3D

Is there some sort of random function in MicroStudio? If so, how do you use it?

Here's whats written in the docs

```
// random number in the range [0 .. 1]
random.next()
// random integer in the range [0 .. 99]
random.nextInt(100)
// reseed the random number generator
random.seed(1234)
// clone the random number generator
r = random.clone()
// reseeded clone of a random number generator
r = random.clone(1234)
// use the clone as the original random object
r.next()
```

thank you so much

what does "reseed" mean?

what is "rangle" mean?

how do you use this in terms of x and y coordinates of a sprite?

https://en.wikipedia.org/wiki/Random_seed

And rangle is a typo of myself, excuse me.

how do you use this in terms of x and y coordinates of a sprite?

like, this sprite should be in a random position on the screen?

Example. You want the characters x to be between: -20 and 80.

So you go:
`x = random.next() * 100 - 20`

OR

Example. You want the characters x to be between: 40 and 45.

So you go:
`x = random.next() * 5 + 40`

```
random.next() * ( The difference between the 2 ranges ) + ( The minimum pos if minus - * + is - )
```

thank you so much @MurdexStudio and @Soool1244

can I write

x = random.next(99)

for example?

To get a number in between 1 and 99, you would call `x = random.nextInt(99)`

which is slightly different (since it is guaranteed to return a whole number), or call `x = random.next()*99`

if you truly wanted a random value between the two.

Validate your e-mail address to participate in the community