xxxxxxxxxx
169
let flock = [];
let c = 0.5;
let s = 1;
let fg;
let currentState = 0;
function preload(){
fontBold = loadFont('helvetica-bold.otf')
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(51);
bg = createGraphics(width, height);
bg.background(0,20);
bg.noStroke();
for (let i = 0; i < 30000; i++) {
let x = random(width);
let y = random(height);
let s = noise(x*0.01, y*0.01)*2;
bg.fill(0, 10);
bg.rect(x, y, s, s);
}
colors = [];
colors.push(color(255, 190, 11));
colors.push(color(251, 86, 7));
colors.push(color(255, 0, 110));
colors.push(color(131, 56, 236));
colors.push(color(58, 134, 255));
fg=random(colors);
for (let i = 0; i <150; i++){
flock.push(new Boid());
}
}
function draw() {
image(bg,0,0)
//drawing of the basic orbs
for (let boid of flock) {
boid.edges();
boid.flock(flock, c, s);
boid.update();
boid.show(fg);
}
if (currentState == 1){
push();
textFont(fontBold);
textSize(60)
// textAlign(CENTER);
fill(255);
text('BONDS', 45, 100);
pop();
textSize(12)
// textAlign(CENTER);
fill(255);
text("With each gathering we have fun, share our stories and each of us coming \ntogether to uplift and support one another and having a good time...", 50, height - 50);
push();
textSize(15)
// textAlign(CENTER);
fill(255);
text(
"Press 2 on your keyboard to release and see what happens!", 50, 150);
pop()
}
else if (currentState == 2){
push();
textFont(fontBold);
textSize(60)
// textAlign(CENTER);
fill(255);
text('BONDS', 45, 100);
pop();
push();
textSize(12)
// textAlign(CENTER);
fill(255);
text("And this happiness is multiplied, like an explosion of happiness to keep us going. \nSo stay hopeful in these tough times that we may weather it out to get together normally again.", 50, height - 50);
pop();
push();
textSize(15)
// textAlign(CENTER);
fill(255);
text(
"Press 1 on your keyboard to gather the orbs again \nPress 3 on your keyboard to return home", 50, 150);
pop()
} else {
push();
textFont(fontBold);
textSize(60)
// textAlign(CENTER);
fill(255);
text('BONDS', 45, 100);
pop();
push();
textSize(12)
// textAlign(CENTER);
fill(255);
text(
"Happiness is when we meet up with people who matter to us. \nMeeting up with friends and family has always been a fun activity. However, \n2020 has not been easy for us to gather together to celebrate moments with \none another. This sketch is an attempt to recall the times we got together \nand the excitement we felt after each get together. Feeling hopeful that one day \nwe might be able to have normal gatherings again.", 50, height - 110);
pop()
push();
textSize(15)
// textAlign(CENTER);
fill(255);
text(
"Press 1 on your keyboard to gather the orbs \n(In cases where it does not work, click the sketch once and try again) ", 50, 150);
pop()
fill(255)
}
console.log(currentState)
}
function keyPressed(){
if (key == '1'){
currentState = 1;
c = 100;
s = 1;
fg = random(colors);
} else if (key == '2'){
currentState = 2;
c = 0;
s = 1;
fg = random(colors);
} else {
currentState = 0;
c = 1;
s = 2;
fg = random(colors);
}
}
function mousePressed(){
fg = random(colors);
}