xxxxxxxxxx
var song_1;
var song_2;
var song_3;
var amplitude;
var level;
//the pictures
var meet;
var love;
var scene_slides = 1;
//scene 2 library and heart(https://editor.p5js.org/marlontenorio/sketches/M_BGUpfKL)
var scribble;
const R = 150;
const xh = (angle) => (R / 15.0) * 16 * Math.pow(Math.sin(angle), 3);
const yh = (p) =>
(R / 15.0) *
(-13 * Math.cos(p) +
5 * Math.cos(2 * p) +
2 * Math.cos(3 * p) +
Math.cos(4 * p));
//scene 3 search (capture)
var capture;
function preload() {
song_1 = loadSound("meet2.mp3");
meet = loadImage("meeting.png");
song_2 = loadSound("myl.mp3");
song_3 = loadSound("We cry.mp3");
}
function setup() {
createCanvas(800, 600);
//scene 1
imageMode(CENTER);
song_1.play();
amplitude = new p5.Amplitude();
noSmooth();
//scene 2
song_2.play();
scribble = new Scribble()
//scene 3
capture = createCapture(VIDEO);
capture.hide();
song_3.play();
}
function draw() {
if (scene_slides == 1) {
scene1();
} else if (scene_slides == 2) {
scene2();
} else if (scene_slides == 3) {
scene3();
}
function scene1() {
background(100, 20, 250);
level = amplitude.getLevel();
print(level);
size = map(level, 0, 0.25, 100, 50);
image(meet, 400, 500);
textSize(13);
text("Welcome to the start of a journey, Press 1.", 310, 300);
//sun
noStroke();
fill(200, 200, 0);
ellipse(50, 50, size);
//tree #1
fill(0);
triangle(0, 350, 69, 237, 150, 350);
triangle(0, 450, 69, 337, 150, 450);
triangle(0, 550, 69, 437, 150, 550);
rect(60, 550, 25, 100);
//tree #2
triangle(650, 350, 720, 237, 800, 350);
triangle(650, 450, 720, 337, 800, 450);
triangle(650, 550, 720, 437, 800, 550);
rect(710, 550, 25, 100);
//ground
rect(0, 591, 900, 300);
song_2.stop();
song_3.stop();
}
function scene2() {
background(55, 90, 89);
//heart
noFill();
stroke(255);
strokeWeight(3);
beginShape();
let n = 200;
for (let i = 0; i < n; i++) {
let x = width / 2 + xh((TAU * i) / n);
let y = height / 2 + yh((TAU * i) / n);
vertex(x, y);
}
endShape();
//rectangle
scribble.scribbleRect(410,315,450,400)
//text
strokeWeight(1);
textSize(13);
text("Press 2 to hear their love blossom", 310, 170);
//person #1
noStroke()
fill(0)
ellipse(50,100,260)
rect(0,200,50,100)
rect(0,300,100,550)
fill(255)
arc(130, 150, 80, 80, 0, PI + QUARTER_PI, OPEN);
//person #2
fill(0)
ellipse(750,100,260)
rect(750,200,50,100)
rect(705,300,200,550)
fill(255)
arc(690, 150, 80, 80, 0, PI + QUARTER_PI, OPEN);
song_1.stop();
song_3.stop();
}
function scene3() {
background(254, 25, 18);
level = amplitude.getLevel();
print(level);
size = map(level, 0, 0.25, 100, 50);
image(capture, 400, 450, 200, (200 * capture.height) / capture.width);
//1st head
noStroke();
fill(150, 75, 0);
ellipse(150, 200, size * 3);
fill(0);
ellipse(267, 175, 27);
stroke(0);
strokeWeight(6);
line(250, 140, 293, 185);
noStroke();
ellipse(235, 259, size);
//2nd head
fill(150, 75, 0);
ellipse(650, 200, size * 3);
fill(0);
ellipse(527, 175, 27);
stroke(0);
strokeWeight(6);
line(507, 170, 557, 135);
ellipse(559, 259, size);
song_1.stop();
song_2.stop();
//text
noStroke();
fill(0);
textSize(13);
text("Press 3 to hear the bickering.", 320, 250);
}
}
function mousePressed() {
scene_slides = scene_slides + 1;
if (scene_slides > 3) {
scene_slides = 1;
}
}
function keyTyped() {
if (key == "1"){
song_1.play()
song_2.stop()
song_3.stop()
} else if (key == "2") {
song_1.stop();
song_2.play();
song_3.stop();
} else if (key == "3") {
song_1.stop();
song_2.stop();
song_3.play();
}
}