Jina Lee – Project 10

sketch

// Jina Lee
// jinal2@andrew.cmu.edu
// Section E
// Project 10
var x = 0;
var cloudmove = 1;
var boathorn;
var seagulls;
var wave;
var help;

function preload() {
    help = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/help.wav");
    boathorn = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/boathorn.wav");
    seagulls = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/seagulls.wav");
    waves = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/waves.wav");
}


function setup() {
    createCanvas(480, 480);
    background(173, 216, 230);
}

function draw() {

    cloudDraw();
    //person
    noStroke();
    fill(226, 63, 41);
    ellipse(300, 200, 15, 40);
    fill(229, 194, 152);
    ellipse(300, 170, 20, 20);
    //flag
    fill(255);
    triangle(200, 100, 200, 130, 250, 115);
    stroke(0);
    strokeWeight(5);
    line(200, 100, 200, 300);
    //boat
    noStroke();
    fill(101, 67, 33);
    arc(250, 200, 350, 400, 0, PI, TWO_PI);
    fill(150);
    rect(150, 170, 30, 30);
    arc(165, 160, 50, 50, 0, PI, TWO_PI);
    //waterwaves
    fill(0, 143, 198);
    rect(0, 320, width, 160);
    for (var i = 0; i < 700; i += 30) {
        push();
        translate(-200 * 1, 0);
        fill(0, 143, 198);
        triangle(i, 320, i + 20, 290, i + 40, 320);
        pop();
    }
}

function cloudDraw() {
    noStroke();
    //sky color
    fill(173, 216, 230);
    rect(0, 0, width, height/2);
    //cloud color
    fill(230);
    //cloud move
    x = x + cloudmove;
    if(x >= width + 10){
        x = 0;
    }
    //cloud parts and drawing multiple clouds in sky section
    for (i = 0; i <= 10; i++) {
        push();
        translate(-200 * i, 0);
        ellipse(x + 10, height / 4, 50, 50);
        ellipse(x + 50, height / 4 + 5, 50, 50);
        ellipse(x + 90, height / 4, 50, 40);
        ellipse(x + 30, height / 4 - 20, 40, 40);
        ellipse(x + 70, height / 4 - 20, 40, 35);
        pop();
    }
}


function mousePressed(){
    // when you press the grey horn
    // then a boat horn will start playing
    var b = dist(mouseX, mouseY, 150, 170);
    if (b < 50) {
        boathorn.play();
    }
    // when you press the person
    // the person shouts for help
    var d = dist(mouseX, mouseY, 300, 170);
    if (d < 20) {
        help.play();
    }
    // when you press the ocean
    // the waves start playing
    if (mouseX > 0 & mouseX < width && mouseY > 320 && mouseY < height) {
        waves.play();
    }
    // when you press the sky
    // seagulls will start chirpping
    if (mouseX > 0 & mouseX < width && mouseY > 0 && mouseY < 320) {
        seagulls.play();
    }
}

For this week, I wanted to create a person lost at sea. When you press the sky, you will hear seagulls everywhere. When you click on the person’s head, you can hear him saying “help, help.” When you press the water, you will hear the ocean waves. When you press the grey horn, you will hear a boat horn go off.

Leave a Reply