Kristine Kim – Project 10-Sonic -Sketch

WORKS PERFECTLY FINE ON LOCAL SERVER!

(please grade based on the local server:))

sketch

// Kristine Kim
// Section D
// younsook@andrew.cmu.edu
// Project -10-Interactive Sonic Sketch


var vacuumnoise;
var fridgenoise;
var dogbarking;
var outsidenoise;
var keynoise;

function preload() {
//load pictures
    var vacuumpicURL = "https://i.imgur.com/qbo0LSB.png[/img]"
    vacuumpic = loadImage(vacuumpicURL);
    var dogpicURL = "https://i.imgur.com/j41YK4G.png[/img]"
    dogpic = loadImage(dogpicURL);
    var keypicURL = "https://i.imgur.com/ozegqNz.png[/img]"
    keypic = loadImage(keypicURL);

//load sounds
    // var vacuumnoise = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/vacuum.wav")
    
    // var fridgenoise =loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/fridge.wav")
    
    // var dogbarking = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/dogbarking.wav")
    
    // var outsidenoise = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/birdsoutside.wav")
    
    
    // var keynoise = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/keys.wav")

//vacuuming noise
    vacuumnoise = loadSound("vacuum.wav");

 //sound of fridge opening and closing   
    fridgenoise =loadSound("fridge.wav");

//sound of dog barking  
    dogbarking = loadSound("dogbarking.wav");

//sound of birds chirping outside    
    outsidenoise = loadSound("birdsoutside.wav");

//sound of key dropping on a table    
    keynoise = loadSound("keys.wav");

}


function setup() {
    createCanvas(500, 400);
    useSound()
}
function soundSetup(){
//controlling the volume
    vacuumnoise.setVolume(1);
    fridgenoise.setVolume(1);
    dogbarking.setVolume(1);
    outsidenoise.setVolume(1);
    keynoise.setVolume(1);

}

function draw() {
    background(255, 247, 135);

//dark brown outline around everything
    stroke(102, 77, 27);
    strokeWeight(5);

//drawing the floor
    fill(199, 154, 58);
    rect(-5,280, 510,400);

//drawing the fridge
    fill(245);
    rect(40,100, 100, 200);
    //fridge shadow
    fill(176, 174, 169);
    rect(40, 170, 100, 10);

    // handle
    fill(0);
    rect(125,120,5,40);
    rect(125,190,5,80);

//drawing the windows
    fill(184, 241, 252);
    rect(170,30,130,100);
    rect(350,30,130,100);

    line(235,30,235,130);
    line(170,80,300,80);
    line(415,30,415,130);
    line(350,80,480,80);

    //table legs
    noStroke();
    fill(102, 77, 27);
    rect(210,240, 12, 70);
    rect(380,240, 12, 70);
    
    fill(71, 54, 20);
    rect(290,190, 12, 100);
    rect(450,190, 12, 100);

//drwing the table   
    fill(102, 77, 27);
    beginShape();
    vertex(280,190);
    vertex(480,190);
    vertex(280,190);
    vertex(200,240);
    vertex(400,240);
    vertex(480,190);
    endShape();

//drawing the vaccum image
    image(vacuumpic, 250, 110, 350,250);

//drawing the dog image
    image(dogpic,5,200,300,200);

//drawing the keys image
    image(keypic,260,195,40,40);
}

function mousePressed(){
//If pressed on keys, play sound and if pressed somewher else, pause the sound
    if (mouseX > 260 & mouseX < 300 && mouseY > 195 && mouseY < 235){
        keynoise.play();
        } else {
            keynoise.pause();
        }
//If pressed on dog, play sound and if pressed somewher else, pause the sound
    if (mouseX > 80 & mouseX < 280 && mouseY > 240 && mouseY < 320){
        dogbarking.play();
        } else {
            dogbarking.pause();
        }
//If pressed on vacuum, play sound and if pressed somewher else, pause the sound
    if (mouseX > 300 & mouseX < 480 && mouseY > 100 && mouseY < 300){
        vacuumnoise.play();
        } else {
            vacuumnoise.pause();
        }
//If pressed on fridge, play sound and if pressed somewher else, pause the sound
    if (mouseX > 40 & mouseX < 140 && mouseY > 100 && mouseY < 300){
        fridgenoise.play();
        } else {
            fridgenoise.pause();
        }
//If pressed on right window, play sound and if pressed somewher else, pause the sound
    if (mouseX > 170 & mouseX < 300 && mouseY > 30 && mouseY < 130){
        outsidenoise.play();
        } else {
            outsidenoise.pause();
        }

}

sounds

sketch

 

I wanted to create an environment and a setting for this project so I decided to create a kitchen/ living room. I was reminded of my childhood when I was working on this project because I used to play a lot of games where I was allowed to decorate my room or my house so I had a lot of fun with this one. The only problem that I had was that the sounds were not playing on WordPress but it works perfectly fine on a local server. I’m still having this problem, but I couldn’t figure it out. I have attached a zip file of my sounds so that it can be played on the local server.

Leave a Reply