hobune Channels Contact About Donate

GameMaker - Particles: Rain

Description YT

PLEASE LIKE, COMMENT & SUBSCRIBE!
Continuing our look into particles in Game Maker: Studio. We use a particle destoyer (part_type_death) to change one particle into another and use part_system_update to create 'in progress' particle systems.

OBJECT CREATE:
//Rain System
partRain_sys = part_system_create();

//Rain Particle
partRain = part_type_create();
part_type_shape(partRain,pt_shape_line);
part_type_size(partRain,0.2,0.3,0,0);
part_type_color2(partRain,c_teal, c_white);
part_type_alpha2(partRain,.5,.1);
part_type_gravity(partRain,0.1,290);
part_type_speed(partRain,0.5,0.5,0,0);
part_type_direction(partRain,250,330,0,1);
part_type_orientation(partRain,290,290,0,0,0);
part_type_life(partRain,20,180);

//Puddle Particle
partPuddle = part_type_create();
part_type_shape(partPuddle,pt_shape_circle);
part_type_size(partPuddle,0.5,0.8,.01,0);
part_type_scale(partPuddle,.5,.1);
part_type_color1(partPuddle,c_silver);
part_type_alpha2(partPuddle,.4,0);
part_type_speed(partPuddle,0,0,0,0);
part_type_direction(partPuddle,0,0,0,0);
part_type_gravity(partPuddle,0,270);
part_type_life(partPuddle,50,60);

//Set Sequence
part_type_death(partRain,1,partPuddle);

//Create Emitter
partRain_emit = part_emitter_create(partRain_sys);
part_emitter_region(partRain_sys,partRain_emit,view_xview[0]-400,view_wview[0],view_yview[0]-100, view_yview[0]-100,ps_shape_line,ps_distr_linear);
part_emitter_stream(partRain_sys,partRain_emit,partRain,30);

//Advance System
repeat (room_speed * 3){
part_system_update(partRain_sys);
}

*NOTE:* If you want this system to work with a moving view, you have to update it's location each step... remove the *part_emitter_region* and *part_emitter_stream* codes from the creat event and instead, add the following to the step event:

//Update Emitter
part_emitter_region(partRain_sys,partRain_emit,view_xview[0]-400,view_xview[0]+view_wview[0],view_yview[0]-100, view_yview[0]-100,ps_shape_line,ps_distr_linear);
part_emitter_burst(partRain_sys,partRain_emit,partRain,30);

For our complete game tutorial series, click here: http://bit.ly/1yK6XtF

This channel is part of the Geekism Network, for more information on this and other channels visit http://www.geekism-network.com

--- GameMaker: Studio
GameMaker: Studio by YoYo Games is a fantastic free software (with premium paid options) for creating video games in an easy to use workspace. Get it here: https://www.yoyogames.com/studio

--- Music Credits:
"Jazzy Frenchy", "Little Idea" - Bensound.com

Licensed under Creative Commons: By Attribution 3.0
http://creativecommons.org/licenses/by/3.0/