First of all, the Draw Event is suppose to contain only graphical rendering functions and statements, you are strongly recommended to separate logic from rendering.
Being the Draw Event executed room_speed
times per second, it keeps generating random numbers continuously over the time, and that's another reason to move the variable assignment outside from the Draw Event.
I suggest you to edit your obj_Boss
having a Create Event and a Draw Event as follow:
// Create Event
randomize();
ratio = irandom_range(1, 6);
u7 = power(ratio, 6);
and:
// Draw Event
draw_text(obj_Boss.x, obj_Boss.y,u7);
This way, your random number ratio
and its power u7
will be assigned only once, and you will be displaying the value assigned to them. Also, ratio
and u7
aren't local variables anymore but instance variables, thus they are accessible by other instances.
You can even save memory space by removing your variable ratio
and perform the computation on one line only:
// Create Event
u7 = power(irandom_range(1, 6),6);
That's a legal statement as first irandom_range()
is executed, and its return value is used as argument for function power()
.