function particle_generator(start, end) {
    for (var i = start; i <= end; i++) {
        //randomizing the x and y positions of the particles and the directions the particles will be traveling
        rand_x = Math.floor(Math.random() * win_width);
        rand_y = Math.floor(Math.random() * win_height);
        x_dir = rand_range[Math.floor(Math.random() * 2)];
        y_dir = rand_range[Math.floor(Math.random() * 2)];

        //we don't want any stationary particles, so if the x velocity is 0 this code makes sure the y velocity wont be zero as well
        switch (x_dir) {
            case 0:
                y_dir = second_range[Math.floor(Math.random() * 2)];
                break;
        }
        switch (y_dir) {
            case 0:
                x_dir = second_range[Math.floor(Math.random() * 2)];
                break;
        }

        ctx.beginPath();
        ctx.strokeStyle = "black";
        ctx.arc(rand_x, rand_y, 2, 0, Math.PI*2, true);
        ctx.closePath();
        ctx.stroke();

        //constructs a particle with the new randomized values
        new_particle = new Particle(rand_x, rand_y, x_dir, y_dir);

        //passes the constructed particles to an array of particles
        particle_array.push(new_particle);
    }
}
//function responsible for generating the particles
function responsible for generating the particles
function responsible for generating the particles
function particle_generator(start, end) {
    for (var i = start; i <= end; i++) {
        rand_x = Math.floor(Math.random() * win_width);
        rand_y = Math.floor(Math.random() * win_height);
        x_dir = rand_range[Math.floor(Math.random() * 2)];
        y_dir = rand_range[Math.floor(Math.random() * 2)];
        switch (x_dir) {
            case 0:
                y_dir = second_range[Math.floor(Math.random() * 2)];
                break;
        }
        switch (y_dir) {
            case 0:
                x_dir = second_range[Math.floor(Math.random() * 2)];
                break;
        }
        ctx.beginPath();
        ctx.strokeStyle = "black";
        ctx.arc(rand_x, rand_y, 2, 0, Math.PI*2, true);
        ctx.closePath();
        ctx.stroke();
        new_particle = new Particle(rand_x, rand_y, x_dir, y_dir);
        particle_array.push(new_particle);
    }
}
function particle_generator ( start , end ) { for ( var i = start ; i <= end ; i ++ ) { rand_x = Math . floor ( Math . random ( ) * win_width ) ; rand_y = Math . floor ( Math . random ( ) * win_height ) ; x_dir = rand_range [ Math . floor ( Math . random ( ) * 2 ) ] ; y_dir = rand_range [ Math . floor ( Math . random ( ) * 2 ) ] ; switch ( x_dir ) { case 0 : y_dir = second_range [ Math . floor ( Math . random ( ) * 2 ) ] ; break ; } switch ( y_dir ) { case 0 : x_dir = second_range [ Math . floor ( Math . random ( ) * 2 ) ] ; break ; } ctx . beginPath ( ) ; ctx . strokeStyle = "black" ; ctx . arc ( rand_x , rand_y , 2 , 0 , Math . PI * 2 , true ) ; ctx . closePath ( ) ; ctx . stroke ( ) ; new_particle = new Particle ( rand_x , rand_y , x_dir , y_dir ) ; particle_array . push ( new_particle ) ; } }
function responsible for generating the particles
function responsible for generating the particles
//randomizing the x and y positions of the particles and the directions the particles will be traveling //we don't want any stationary particles, so if the x velocity is 0 this code makes sure the y velocity wont be zero as well //constructs a particle with the new randomized values //passes the constructed particles to an array of particles