mercredi 19 avril 2017

Limitation on irandom() of game maker?

I have three objects. All of them in the create event contain an action each (execute a piece of code):

obj_r01 => r01=0;

obj_r02 => r02=0;

obj_r03 => r03=0;

Image (to clarify what I have tried to explain):

enter image description here

So far so good, but I have one more object that modifies the variables of these other three: obj_control

The obj_control contains two events: create and draw.

enter image description here

crete event (obj_control):

obj_r01.r01=irandom(9);
obj_r02.r02=irandom(9);
obj_r03.r03=irandom(9);

draw event (obj_control):

This event contains three actions, precisely three "execute a piece of code":

enter image description here

piece one:

draw_text(x,y,obj_r01.r01); => applies to obj_r01

piece two:

draw_text(x,y,obj_r02.r02); => applies to obj_r02

piece three:

draw_text(x,y,obj_r03.r03); => applies to obj_r03

The objects are arranged as follows in the room:

enter image description here

In execution this is what happens:

enter image description here

The value of r01 is randomized, but that of r02 and r03 is not. I also tried to modify the obj_control creation event code to:

randomize();
obj_r01.r01=irandom(9);
randomize();
obj_r02.r02=irandom(9);
randomize();
obj_r03.r03=irandom(9);

However the result does not change. With this I could only suspect that the irandom () function can only create a storable random value, would it solve such a problem?


I tried putting randomize() only at the beginning of the code:

randomize();
obj_r01.r01=irandom(9);
obj_r02.r02=irandom(9);
obj_r03.r03=irandom(9);

But there was no change in the result.

I also did a test to be sure if the value was not even being randomized or if the values ​​of r02 and r03 were being randomized to 0 and for that I modified their values ​​in the creation of each object:

In obj_r02:

r02=10

In obj_r03:

r03=100

The result:

enter image description here

The first value (not surprisingly) was randomized, but the second and third values ​​were not. Thus it is clear that the randomization is not being made or that the draw event is occurring before the radomization of r02 and r03.




Aucun commentaire:

Enregistrer un commentaire