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

Particles Slowing Game Down

A

AdinMilo

Guest
Hey ya'll

I went a bit crazy with particles and have my Rocket Ship streaming smoke when it moves, asteroids with little pixels coming off them as they roll around space, a black hole that sparkles etc etc.

One thing I noticed is that when I play the game for about 1 minute it all of a sudden slows down so drastically, its unplayable. We put two and two together and thought it could be particles. After looking online I saw that quite often people will say you have to "Destroy" or "Clear" them after you die or the game ends.

I was messing around with this code (located in obj_asteroid > step event > code)

if (global.life > 0)
{
global.life -= 1;
global.myTime = 30;
instance_create(1696,1200,obj_player);
part_system_destroy(obj_player.part1_sys);
part_system_destroy(obj_asteroid_l.part2_sys);
part_emitter_destroy(obj_asteroid_l.part2_sys,obj_asteroid_l.part2_emit);
part_system_destroy(obj_asteroid.part2_sys);
part_emitter_destroy(obj_asteroid.part2_sys,obj_asteroid.part2_emit);
part_system_destroy(obj_blackholering.part2_sys);
part_emitter_destroy(obj_blackholering.part2_sys,obj_blackholering.part2_emit);

}

and here is an example of the some particle code I have attached to an object (obj_blackholering > step event > code)

//Particle System
part2_sys = part_system_create();
part_system_depth(part2_sys,0);
//colPurple = make_colour_rgb(91, 82, 69);
//Particle
part2 = part_type_create();
part_type_shape(part2,pt_shape_pixel);
part_type_scale(part2,5,5);
part_type_size(part2,1,1,-0.005,0);
part_type_colour1(part2,c_purple);
part_type_alpha2(part2,0.5,-5);
part_type_speed(part2,0.5,0.5,-1,0);
part_type_direction(part2,360,0,0,0);
part_type_gravity(part2,0,90);
part_type_life(part2,room_speed,room_speed-50);
part_type_blend(part2,0);
//Particle Emitter
part2_emit = part_emitter_create(part2_sys);
part_emitter_region(part2_sys,part2_emit,x-120,x+120,y-120,y+120,ps_shape_ellipse,ps_distr_invgaussian);
part_emitter_burst(part2_sys,part2_emit,part2,irandom(-5));


But with no success. I was wondering where I would tell the game to wipe the Particles after the player loses a life or respawns, and where I could put the code so its not just floating around my obj_asteroid.

p.s
Sorry about the mass of code, still a noob to it all.

-A
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Before going any further, can I suggest that you read this article I wrote a while back? http://www.yoyogames.com/blog/50

Read that and see if you can't work out for yourself what the issue is then get back to us (hint: particle systems created in one instance need to be destroyed in that same instance, or be GLOBAL in scope). :)
 
A

AdinMilo

Guest
Thanks Nocturne.

I'll have a look now and get back to you.

-A
 
A

AdinMilo

Guest
Hey Nocturne.

I've read through your article and started to make them all "Global" variables, but I'm still having this problem of slowing down. Here is the code I'm currently using for the smoke on the back for the Players Rocket Ship

STEP EVENT
//Particle System
if keyboard_check(vk_up)
{
global.part1_sys = part_system_create();
part_system_depth(global.part1_sys,0);

//Particle
global.part1 = part_type_create();
part_type_shape(global.part1,pt_shape_square);
part_type_scale(global.part1,0.5,0.5);
part_type_size(global.part11,0.5,0.7,-0.005,0);
part_type_colour2(global.part1,c_ltgray,c_white);
part_type_alpha2(global.part1,1,0);
part_type_speed(global.part1,0.1,0.5,0,0);
part_type_direction(global.part1,0,359,0,0);
part_type_gravity(global.part1,0.01,90);
part_type_life(global.part1,room_speed,room_speed*2);
part_type_blend(global.part1,0);

//Particle Emitter
var xpos = x + lengthdir_x(47, image_angle - 180);
var ypos = y + lengthdir_y(47, image_angle - 180);
part_particles_create(global.part1_sys, xpos - 5 + random(10), ypos - 5 + random(10), part1, irandom(50));
}

//Engine Sound
if keyboard_check_pressed (vk_up)
{
audio_play_sound (snd_engine, 1, true);
}
if keyboard_check_released (vk_up)
{
audio_stop_sound (snd_engine);
part_type_destroy(global.part1);
part_system_destroy(global.part1_sys);
}


Wondering if i'm taking the right approach.

Regards

-A
 
Top