Creating objects problem.

AlfMandoor

Member
Hi everyone, I have an object that I would like it to spawn into the room anytime I click any area of the room, I got it working, so if I click the object it destroys, but I would like that instead of always only creating one object, If I click, it can create randomly eather one or two Objects.

I attach a gif so you can understand it more better.

You are so kind for helping me.
 

Attachments

TheouAegis

Member
if irandom(1) { create 2 objects }
else { create 1 object }


If you need more help than that, you'll need to be specific about where and how these objects would be created. Obviously you don't want both objects at the exact point the mouse is clicked.
 

AlfMandoor

Member
Hello my friend TheouAegis thank you so much for answering me, my room is 880 width and a height of 600, so I was thinking that the y position for all would be 400 and x position would be eather 300 or 500 if it´s only one object it should choose any of those numbers and if it´s two objects well it should be both numbers...

Thank you again for your help
 

TheouAegis

Member
Code:
if irandom(1) {
    instance_create_layer(choose(300,500),400,"Instances",object);
}
else {
    instance_create_layer(300,400,"Instances",object);
    instance_create_layer(500,400,"Instances",object);
}
 
Top