Sewon Park – Project 10

sketch

//Sewon Park
//sewonp@andrew.cmu.edu
//Section B
//Project 10

var sound1;
var sound2;
var sound3;
var sound4;

function preload() {
    sound1 = loadSound('https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/378641__13fpanska-kolar-jan__fire-stick-shake-2.wav');
    sound2 = loadSound('https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/476202__djmistressm__rain-drips.mp3');
    sound3 = loadSound('https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/85602__jankoehl__walk-forest02.wav');
    sound4 = loadSound('https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/459977__florianreichelt__soft-wind.mp3'); //saving sounds
}

//I have no clue why the sounds are not loading 


function setup() {
    createCanvas(400, 400);
    background(220);
    useSound(); 
}

function soundSetup() {
    sound1.setVolume(1); 
    sound2.setVolume(1);
    sound3.setVolume(1);
    sound4.setVolume(1);
}

function draw() {
fill(0,0,0);
rect(0,0,200,200); //black square

fill(255,0,0);
noStroke();
ellipse(100,150,50,50);
noStroke();
triangle(78,140,100,100,122,140)
fill(255,255,0);
ellipse(100,160,30,30); //fire


fill(0,255,0);
rect(0,200,200,200);
fill(220,180,130); //green square
  
rect(100,350,10,40);
fill(0,100,0);
triangle(90,360,105,300,120,360) //tree

fill(0,0,255);
rect(200,0,200,200); //Blue Square
  
for (var x=210; x<600; x=x+20) {
   for(var y=10; y<190; y= y+20) {
   stroke(135,206,235);
   fill(135,206,235);
   rect(x,y,1,10); //rain on background
        }

fill(255);
rect(200,200,200,200); //White Square
  
fill(130,200,230);
rect(270,350,70,5);
arc(280, 325, 60, 60, HALF_PI, PI); //wind symbol
}
}


function mousePressed() {
    // When mouse is pressed, appropriate sounds play

    if (mouseX < 200 & mouseY < 200) {
        sound1.play();
    } else {
        sound1.pause();
    } //Makes sound 1 for black square

    if (mouseX > 200 & mouseY < 200) {
        sound2.play();
    } else {
        sound2.pause();
    } //Makes sound 2 for blue square)

    if (mouseX < 200 & mouseY > 200) {
        sound3.play();
    } else {
        sound3.pause();
    } //Makes sound 3 for green square)

    if (mouseX > 200 & mouseY > 200) {
        sound4.play();
    } else {
        sound4.pause();
    } //Makes sound 4 for white square

}

For this project I used “The Last Airbender” as the theme. I drew the four elements and had sounds that correlated to the element playing when the mouse is clicked.

(Grace Day Used)

Leave a Reply