• 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!

GameMaker failed to rotate particle System

J

jaber

Guest
hi,
very straight, I have created an object and added the code:
create_event
GML:
// Setup:
sys_particle = part_system_create()
part_system_layer(sys_particle, layer)
part_particle = part_type_create()
part_type_shape(part_particle, pt_shape_explosion)
part_type_size(part_particle, 0, 1.35, 0, 0)
part_type_scale(part_particle, 1, 1)
part_type_color3(part_particle, 6480853, 7763629, 2500351)
part_type_alpha3(part_particle, 0, 0.25, 0.16)
part_type_speed(part_particle, 0, 1.48, 0, 0)

part_type_direction(part_particle, 0, 360, 0, 0)

part_type_gravity(part_particle, 0, 270)
part_type_orientation(part_particle, 315, 315, 1, 0, 1)
part_type_blend(part_particle, 1)
part_type_life(part_particle, 0, 34)
emit_particle = part_emitter_create(sys_particle)
step_event

Code:
// To Use Particle:
part_emitter_region(sys_particle, emit_particle, x - 150, x + 150, y - 0, y + 0, ps_shape_rectangle, ps_distr_invgaussian)
part_emitter_burst(sys_particle, emit_particle, part_particle, 10)
I am trying to rotate the emitter, I tried rotating the object using
image_angle = something also with direction = something but that is not working! any one knows why?

How can I rotate the emitter then?

Thanks in advance
cheers!
 

rytan451

Member
image_angle only changes the angle the object instance's sprite is drawn in the draw event, either by default, or through using the draw_self() method. direction defines the direction of the velocity vector of an object instance. Neither affect particles; nor should they.

With this in mind, what do you mean by "rotate" the emitter? Are you attempting to create particles within a rotated rectangle? If that is the case, it may be easier to define the rectangle in code, including the orientation, and use random and part_particles_create to create particles within the desired region.
 
J

jaber

Guest
image_angle only changes the angle the object instance's sprite is drawn in the draw event, either by default, or through using the draw_self() method. direction defines the direction of the velocity vector of an object instance. Neither affect particles; nor should they.

With this in mind, what do you mean by "rotate" the emitter? Are you attempting to create particles within a rotated rectangle? If that is the case, it may be easier to define the rectangle in code, including the orientation, and use random and part_particles_create to create particles within the desired region.
thanks for the reply,
yes, thats exactely what I wanted... I want to create particles within a define rotated rectangle.
I am still confused, what do u mean with defining rectangle in code?? do u mean draw_rectangle ()? this is still to be placed inside an object and again depends on Image angel!
 
J

jaber

Guest
Update...
I found that people are suggesting drawing the particles to a surface and then rotating the surface
I have red the dokumentation from here https://docs.yoyogames.com/source/dadiospice/002_reference/particles/particle systems/part_system_drawit.html
and I experminted that myself... I can see the new surfece is created and tested successfully to draw on it random sprites... unfortunately it is not showing particles inside it, please advice if I skipped something here

I have created a surface opject
create event:
Surf_fire = surface_create(300,300);

draw event:
GML:
if (surface_exists(Surf_fire )) {
    draw_surface(Surf_fire , obj_heli_chopper.x + 200,obj_heli_chopper.y);    // jut to desplay the surface near the chopper
} else {  
    Surf_fire  = surface_create(300, 300);
}
then I have created another Obj for Particle system
create event:
Code:
// Setup:
sys_particle = part_system_create()
part_system_layer(sys_particle, layer)
part_particle = part_type_create()
part_type_shape(part_particle, pt_shape_explosion)
part_type_size(part_particle, 0, 1.35, 0, 0)
part_type_scale(part_particle, 1, 1)
part_type_color3(part_particle, 6480853, 7763629, 2500351)
part_type_alpha3(part_particle, 0, 0.25, 0.16)
part_type_speed(part_particle, 0, 1.48, 0, 0)

part_type_direction(part_particle, 0, 360, 0, 0)

part_type_gravity(part_particle, 0, 270)
part_type_orientation(part_particle, 315, 315, 1, 0, 1)

part_type_blend(part_particle, 1)
part_type_life(part_particle, 0, 34)
emit_particle = part_emitter_create(sys_particle)

part_system_automatic_draw(sys_particle, false); // no automatic drawing
and in the step event:
Code:
part_type_orientation(part_particle, 0,359,10,0,true);
part_emitter_region(sys_particle, emit_particle, x - 150, x + 150, y - 0, y + 0, ps_shape_rectangle, ps_distr_invgaussian);
part_emitter_burst(sys_particle, emit_particle, part_particle, 10);
and in the draw event:
Code:
if (instance_exists(obj_surf_tank_fire)) {
   
surface_set_target(obj_surf_tank_fire.Surf_fire);

//draw_sprite(spr_AK_gui,0,10,10);
//draw_clear_alpha(c_white,1);
part_system_drawit(sys_particle);  
surface_reset_target();
   
}
as you see... I could draw the spr_AK_gui Sprite,, but I could not bring the particles inside my surface!! 0.O
ak.JPG

any Ideas would be much appreciated
thnx
J
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
You are creating the particles in room space, not the surface space. The fix is probably something as simple as changing the "x + 150" / "x - 150" parts to simply 0 and 300.
 
J

jaber

Guest
You are creating the particles in room space, not the surface space. The fix is probably something as simple as changing the "x + 150" / "x - 150" parts to simply 0 and 300.
Thanks a LOT.... you nailed it... i fixed it and it works now : )
 
Top