• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Particle emitters situation

Le Slo

Member
Hello!

I'm trying to create only the number of local particles emitters I need for each object (squared blocks that can shoot laser in four directions maximum)
upload_2017-7-8_15-3-10.png

Each block has a value between 0 (no lasers) and 15 (all lasers), built my summing 1,2,4 or 8, if the laser can shoot left, down, right or up, respectively.

How I'm trying to create the emitters in obj_laser eventCreate:

Code:
if(type % 2 ==1 ){
    emitter[0]=part_emitter_create(global.particle);
}
else{
    emitter[0]=-1;
}
if(type % 4 > 1){
    emitter[1]=part_emitter_create(global.particle);
}
else{
    emitter[1]=-1;
}if(type % 8 > 3){
    emitter[2]=part_emitter_create(global.particle);
}
else{
    emitter[2]=-1;
}
if(type > 7){
    emitter[3]=part_emitter_create(global.particle);
}
else{
    emitter[3]=-1;
}
I'm 99% sure the math is done correctly as it has been a pillar in all my code.
This is how I draw and set the emitter regions

Code:
var pos=[];
if(type % 2 ==1 ){
    pos=takeMaxLaser(dir.left);
    //draw_line_width_color(bbox_left,y,pos[0],pos[1],5,color,make_color_rgb(0,0,0));
    part_emitter_region(global.particle, emitter[0], bbox_left-20,pos[0],y-1,y+1, ps_shape_rectangle, ps_distr_linear);
    part_emitter_burst(global.particle,emitter[0],part1,distance_to_point(pos[0],y)/5);
}
if(type % 4 > 1){
    pos=takeMaxLaser(dir.down);
    //draw_line_width_color(x,bbox_bottom,pos[0],pos[1],5,color,make_color_rgb(0,0,0));
    part_emitter_region(global.particle, emitter[1], x-1,x+1,bbox_bottom+20,pos[1], ps_shape_rectangle, ps_distr_linear);
    part_emitter_burst(global.particle,emitter[1],part1,distance_to_point(x,pos[1])/5);
}
if(type % 8 > 3){
    pos=takeMaxLaser(dir.right);
    //draw_line_width_color(bbox_right,y,pos[0],pos[1],5,color,make_color_rgb(0,0,0));
    part_emitter_region(global.particle, emitter[2], bbox_right+20,pos[0],y-1,y+1, ps_shape_rectangle, ps_distr_linear);
    part_emitter_burst(global.particle,emitter[2],part1,distance_to_point(pos[0],y)/5);
}
if(type > 7){
    pos=takeMaxLaser(dir.up);
    //draw_line_width_color(x,bbox_top,pos[0],pos[1],5,color,make_color_rgb(0,0,0));
    part_emitter_region(global.particle, emitter[3], x-10,x+10,bbox_top-20,pos[1], ps_shape_rectangle, ps_distr_linear);
    part_emitter_burst(global.particle,emitter[3],part1,distance_to_point(x,pos[1])/5);
}
When I do this, not all laser are being drawn, and not always the same lasers. Here is the same block before and after restarting the room.

upload_2017-7-8_15-11-31.pngupload_2017-7-8_15-12-19.png

But if I create all four emitters I have no problem:

Code:
for(var i=0; i<4; i++){
    emitter[i]=part_emitter_create(global.particle);
}
What am I not seeing here?

Bonus question: I'm working on a big room (around 1000 objects laser, plus other objects), is it the best way to draw the lasers with up to four local emitters? At least, should I destroy the emitters while my objects are unactive, and create them as soon as the get activated again?
 
Top