xxxxxxxxxx
87
var sepSlider,aliSlider,cohSlider,runSlider,chaseSlider;
var particles = [];
var xoff = 0;
function setup() {
wid = floor(windowWidth);
hit = floor(windowHeight);
createCanvas(wid, hit);
//Sliders
//sepSlider = createSlider(0,10,1,0.5);
//sepSlider.position(200,height-35);
//aliSlider = createSlider(0,10,1,0.5);
//aliSlider.position(400,height-35);
//cohSlider = createSlider(0,10,1,0.5);
//cohSlider.position(600,height-35);
//runSlider = createSlider(0,10,1,0.5);
//runSlider.position(800,height-35);
//chaseSlider = createSlider(0,10,1,0.5);
//chaseSlider.position(1000,height-35);
//Creating
var team = 0;
for(var i = 0; i < 20; i++){
append(particles, new Particle(0,random(hit),team));
}
team = 1;
for(var j = 0; j < 10; j++){
append(particles, new Particle(400,random(hit),team));
}
}
function draw() {
background(255);
strokeWeight(1);
//Slider
//var sep = sepSlider.value();
//var ali = aliSlider.value();
//var coh = cohSlider.value();
//var run = runSlider.value();
//var chase = chaseSlider.value();
//text('Sep: '+sep, 200 + sepSlider.width + 2, height-20 );
//text('Ali: '+ali, 400 + aliSlider.width + 2, height- 20 );
//text('Coh: '+coh, 600 + cohSlider.width + 2, height-20 );
//text('Run: '+run, 800 + runSlider.width + 2, height-20 );
//text('Chase: '+sep, 1000 + chaseSlider.width + 2, height-20 );
//noise
var n = noise(xoff) * 3.5;
//movements
for(i=0;i<particles.length;i++){
particle = particles[i];
particle.flock(particles,n);
particle.update();
particle.show();
hit = particle.checkHit(particles);
var hit = false;
var gate = false;
if (gate == false){
if (hit){
particles.splice(particle,1);
gate = true;
}
}
if(hit == false){
gate = false
}
}
xoff += 0.1;
//Stats
let fps = frameRate();
fill(0);
stroke(0);
text("FPS: " + fps.toFixed(2) + " | Particles: " + particles.length, 10, height - 20);
}