# GMS 2Randomize position by multiples of 24

#### Nathan

##### Member
I have a very simple spawning object which randomly spawns an object every 2 seconds. What I would like it to do the spawner creates the objects in the same y position of the spawner, but the x position I want to be randomized multiples of 24 (ie. x, x+24, x+48, x+72, x, x-24, x-48, x-72 etc) so each object spawns in a different x position. How would I make a randomize like this? Thanks!

#### Nathan

##### Member
Get an irandom_range number and multiply it by 24.
Does irandom return an integer?

#### RichHopefulComposer

##### Member
Does irandom return an integer?
The manual might know!
Middle click on any function in your code, and it'll take you to the manual page for it! =)

#### TheouAegis

##### Member
x + random_range(-72,72) div 24 * 24

Or

x + round(random(6) - 3) * 24

Or

x + irandom_range(-3,3)*24

Or

x + (irandom(6)-3)*24

Or

x + 24 * irandom(3) * choose(1,-1)

Or

x + 24 * choose(0,1,2,3) * choose(-1,1)

Or

x + 24 * choose(-3,-2,-1,0,1,2,3)

Or

x + choose(-72,-48,-24,0,24,48,72)

Or

x + sin(random(pi*2)) * 72 div 24 * 24

#### Nidoking

##### Member
x + 24 * choose(0,1,2,3) * choose(-1,1)
This will generate 0 twice as often as any other value. Not quite equivalent to the other suggestions.

#### TheouAegis

##### Member
The pi formula i think might yield 0 more frequently as well. At least the *choose(-1,1) methods yield 8 outcomes. The Power of Twos!

I know it wasn't obvious to everybody, but I was just throwing out random crap to make a point. LOL

#### Nathan

##### Member
The manual might know!
Middle click on any function in your code, and it'll take you to the manual page for it! =)
Oh awesome! I didn't know they added that functionality! Much appreciated

#### Nathan

##### Member
Oh awesome! I didn't know they added that functionality! Much appreciated
Actually I'm using a mac laptop with a touch pad so I don't have a middle click haha Any idea what the alternative way to make that happen might be?

#### JackTurbo

##### Member
Put the cursor in the function and press f1

#### RefresherTowel

##### Member
Or alternatively, just open the manual and type in the function name in the search tab.