Hopefully this should be a simple one; I want to restrict the points that instances enter the screen from so they don't come in at the edges.
In Game Maker I'm using the following code instance_create(random(room_width), random(-100) - 50, obj_enemy1);
to create the instance off screen (create(x, y, ...))
At the moment I'm just using the room_width to define the max width for the random on x, but ideally I want to find a way of defining a max AND min width for the random. I can't figure out how to restrict the range on the x axis to between say 100 and 350.
Any help would be appreciated.
Cheers
minrand = 150; maxrand = room_width - 150; randnumber = random(room_width); realrand = 0; if randnumber < minrand {realrand = 150} else {realrand = room_width - 150}; instance_create(realrand, random(-100) - 50, obj_enemy1); timer -= 10; alarm[0] = timer; randnumber = 0;
still no luck :( \$\endgroup\$a
andb
, you should just do:number = a + random(b - a)
. \$\endgroup\$