function particle_mover(speed) {
    for (var i = 0; i <= particle_array.length - 1; i++) {
        //code decides which particle we are currently moving
        current_particle = particle_array[i];

        //if the magnet flag is true, the x and y directions of the particle is altered to travel towards the mouse cursor position
        switch (magnet_flag){
            case true:
                x_dir = mouse_x - current_particle.x_pos;
                y_dir = mouse_y - current_particle.y_pos;

                grav_radius = Math.sqrt(Math.pow(x_dir,2) + Math.pow(y_dir,2));

                current_particle.x_pos += x_dir * speed;
                current_particle.y_pos += y_dir * speed;
            
            case false: 
                //if there is no magnetism, the particle will simply be propogated by adding its original direction to the particles current
                //x and y positions each frame
                current_particle.x_pos += current_particle.init_x_dir * speed;
                current_particle.y_pos += current_particle.init_y_dir * speed;
        }

        ctx.beginPath();
        ctx.strokeStyle = "white";
        
        //particle is passed to this function every frame to check for out of bounds particles
        generate_posdir(current_particle, i);

        ctx.closePath();
        ctx.stroke();

        draw_line(current_particle);
    }
}
//function responsible for moving the particles
function responsible for moving the particles
function responsible for moving the particles
function particle_mover(speed) {
    for (var i = 0; i <= particle_array.length - 1; i++) {
        current_particle = particle_array[i];
        switch (magnet_flag){
            case true:
                x_dir = mouse_x - current_particle.x_pos;
                y_dir = mouse_y - current_particle.y_pos;
                grav_radius = Math.sqrt(Math.pow(x_dir,2) + Math.pow(y_dir,2));
                current_particle.x_pos += x_dir * speed;
                current_particle.y_pos += y_dir * speed;
            case false: 
                current_particle.x_pos += current_particle.init_x_dir * speed;
                current_particle.y_pos += current_particle.init_y_dir * speed;
        }
        ctx.beginPath();
        ctx.strokeStyle = "white";
        generate_posdir(current_particle, i);
        ctx.closePath();
        ctx.stroke();
        draw_line(current_particle);
    }
}
function particle_mover ( speed ) { for ( var i = 0 ; i <= particle_array . length - 1 ; i ++ ) { current_particle = particle_array [ i ] ; switch ( magnet_flag ) { case true : x_dir = mouse_x - current_particle . x_pos ; y_dir = mouse_y - current_particle . y_pos ; grav_radius = Math . sqrt ( Math . pow ( x_dir , 2 ) + Math . pow ( y_dir , 2 ) ) ; current_particle . x_pos += x_dir * speed ; current_particle . y_pos += y_dir * speed ; case false : current_particle . x_pos += current_particle . init_x_dir * speed ; current_particle . y_pos += current_particle . init_y_dir * speed ; } ctx . beginPath ( ) ; ctx . strokeStyle = "white" ; generate_posdir ( current_particle , i ) ; ctx . closePath ( ) ; ctx . stroke ( ) ; draw_line ( current_particle ) ; } }
function responsible for moving the particles
function responsible for moving the particles
//code decides which particle we are currently moving //if the magnet flag is true, the x and y directions of the particle is altered to travel towards the mouse cursor position //if there is no magnetism, the particle will simply be propogated by adding its original direction to the particles current //x and y positions each frame //particle is passed to this function every frame to check for out of bounds particles