Example #1
0
void L_ShootingEffect::howto_emit_particle(void)
{
	static L_REAL radian_t;
	static L_REAL current_speed_dis;

	static L_REAL width_t;
	static L_REAL x_shift;
	static L_REAL y_shift;

	static int j;

	shooting_angle_cache = shooting_vector.get_angle();

	for(j=0;j<particle_per_period;j++)
	{
		// === shooting interval(angle) ===
		if(angle_interval == 0)
			radian_t =0;

		else
			radian_t = ( L_RAND_REAL_1() - 0.5f ) * angle_interval;
		// === end ===


		// === speed distortion ===
		if(speed_dis == 0)
			current_speed_dis = 0;

		else
			current_speed_dis = ( L_RAND_REAL_1()*2.0f - 1.0f ) * speed_dis;
		// === end ===


		// === shooting interval(width) ===
		if(width_interval == 0)
		{
			x_shift = 0;
			y_shift = 0;
		}

		else
		{
			width_t = ( L_RAND_REAL_1() - 0.5f ) * width_interval;

			x_shift = width_t * L_SIN(shooting_angle_cache);
			y_shift = width_t * L_COS(shooting_angle_cache);
		}
		// === end ===

		L_Vector v_t = shooting_vector;
		v_t.set2(shooting_magnitude_cache+current_speed_dis, shooting_angle_cache+radian_t);

		create_particle(x_pos+x_shift, y_pos+y_shift, &v_t);
	}
}
void L_ExplosionEffect::howto_emit_particle(void)
{
	static L_REAL radian;
	static int num_particles;
	static int j;

	num_particles = min_particles + rand() % (max_particles - min_particles + 1);

	for( j=0; j<num_particles; j++ )
	{
		radian = L_RAND_REAL_2()*L_2PI;

		static L_REAL current_speed_dis;

		if(speed_dis == 0)
			current_speed_dis = 0;

		else
			current_speed_dis = ( L_RAND_REAL_1()*2.0f - 1.0f ) * speed_dis;

		CL_Vec2f v_t;
		linear_set2(v_t,  explosion_level+current_speed_dis, radian );

		create_particle(x_pos,y_pos,&v_t);
	}
}
Example #3
0
void L_ParticleEffect::create_particle(L_REAL in_x, L_REAL in_y, L_Vector* vec_t)
{
	int chosen = choose_particle();

	L_Particle* par_new;
	L_NEW_PAR( par_new, *fl_particle[chosen] );

	L_Vector vec_t2;
	if(addit_vector_enabled == true)
	{
		if(vec_t != NULL)
			vec_t2 = addit_vector + *vec_t;

		else
			vec_t2 = addit_vector;
	}

	else
	{
		if(vec_t != NULL)
			vec_t2 = *vec_t;
	}

	par_new->set_velocity(vec_t2);


	if(follow_shooting)
	{
		par_new->set_rotation(vec_t->get_angle());
	}

	else if(rotation_distortion != 0)
	{
		par_new->set_rotation2((L_RAND_REAL_1()-0.5f)*rotation_distortion);
	}

	if(size_distortion != 0)
	{
		par_new->set_size( par_new->get_ref_size()+rand_size() );
	}

	if(life_distortion != 0)
	{
		int distort = rand() % life_distortion + 1;

		if(rand() % 2 == 0)
			distort = -distort;

		par_new->set_life(par_new->get_remaininig_life()+distort);
	}

	par_new->x_pos = in_x;
	par_new->y_pos = in_y;

	par_new->initialize();

	//add to list
	particle_list.push_back(par_new);
}
Example #4
0
L_REAL L_ParticleEffect::rand_size(void)
{
	L_REAL current_size_dis = L_RAND_REAL_1() * size_distortion;
	if( rand()%2 == 0 )
		current_size_dis = -current_size_dis;

	return current_size_dis;
}
Example #5
0
int L_ParticleEffect::choose_particle(void)
{
	L_REAL dice = L_RAND_REAL_1();
	L_REAL slider = 0;
	int i;
	for( i=0; i<num_particle_type; i++ )
	{
		slider += particle_prob[i];

		if( dice <= slider )
			break;
	}

	return i;
}