//alcai@andrew.cmu.edu
//AliceCai
//Project 10
//Section E
//load all the sound links and set the volume
function preload() {
a = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/10/217214__goldkelchen__slap-in-the-face-1.wav");
b = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/10/148997__adam-n__slap-2-1.wav");
c = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/10/421876__sventhors__ouch-2.wav");
d = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/10/348244__newagesoup__punch-boxing-01.wav");
a.setVolume(1);
b.setVolume(1);
c.setVolume(1);
d.setVolume(1);
}
function setup() {
createCanvas(400, 400);
background(200, 220, 250);
}
function draw() {
//color change if mouse is pressed
//draw face
if (mouseIsPressed) {
fill('red');
noStroke();
ellipse(width/2,height/2,400,400);
} else {
fill('yellow');
noStroke();
ellipse(width/2,height/2,400,400);
}
fill('black');
ellipse(width/4,height/5 *2 ,30,60);
ellipse(width/4 * 3,height/5 *2 ,30,60);
//change to tears when face is hit
if (mouseIsPressed) {
fill('blue')
ellipse(width/4*3, height/5* 3,20,50);
ellipse(width/4, height/5* 3,20,90);
} else {
fill('pink');
arc(width/2, height/1.8, 200, 200, 0, PI, PI);
}
print(mouseIsPressed);
}
function mousePressed (){
//call different sounds for where the mouse is clicked
if (mouseX < width/2 & mouseY > height/2) {
a.play();
}
if (mouseX > width/2 & mouseY < height/2) {
b.play();
}
if (mouseY > height/2 & mouseX > height/2) {
c.play();
}
if (mouseY < height/2 & mouseX < width/2) {
d.play();
}
}
This is my sound project. It plays four sounds when the mouse clicks (or “hits) the face: big slap, small slap, punch, and OOF!, depending on where the mouse is clicked (four quadrants). When the mouse is clicked the face turns red and starts crying too! I thought it would be funny and simple.