Project 10-Sonic Story

project-10-sonicStory
/*
Lauren Kenny
lkenny@andrew.cmu.edu
Section A

This program creates a sonic story that shows a short food chain.

*/

var chew;

function preload() {
    beetleimg = loadImage("https://i.imgur.com/shXn6SX.png");
    quailimg = loadImage("https://i.imgur.com/Zd4T90e.png");
    coyoteimg = loadImage("https://i.imgur.com/W7IHE01.png");
    chew = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/chew.wav");
}

function setup() {
    createCanvas(300, 100);
    frameRate(10);
    useSound();
}

function soundSetup() { 
    chew.setVolume(0.5);
}

function draw() {
    background(217, 233, 250);
    drawBerries();
    drawBeetle();
    if (frameCount==69 || frameCount==125 || frameCount==190) {
        chew.play();
    }
}


function drawBerries() {
    var size=10;
    var xpos=20;
    for (var i=0; i<3; i++) {
        var ypos=70;
        fill(15, 30, 110);
        noStroke();
        push();
        if (i==1) {
            ypos=ypos-5;
        }
        circle(xpos, ypos, size);
        xpos+=5;
    }
}

var beetleX=300;
var beetleY=40;
function drawBeetle() {
    var beetleW = 51.1;
    var beetleH = 41.7;
    image(beetleimg, beetleX, beetleY, (beetleW), (beetleH));
    if (beetleX!=10) {
        beetleX-=5;
    }
    else if (beetleX==10) {
        chew.play();
        drawQuail();
    }
}

var quailX=300;
var quailY=40;
function drawQuail() {
    chew.stop();
    var quailH = 60;
    var quailW = 61.9;
    image(quailimg, quailX, quailY, (quailW), (quailH));
    if (quailX!=10) {
        quailX-=5;
    }
    else if (quailX==10) {
        drawCoyote();
    }
}

var coyoteX=300;
var coyoteY=30;
function drawCoyote() {
    var coyoteW = 153.2;
    var coyoteH = 90.2;
    image(coyoteimg, coyoteX, coyoteY, (coyoteW), (coyoteH));
    if (coyoteX!=5) {
        coyoteX-=5;
    }
    else if (coyoteX==5) {
        drawText();
    }
}

function drawText() {
    textSize(12);
    fill(15, 30, 110)
    text('the circle of life', 200, 20);
}






I was watching a show where a guy had a mouse in his apartment and to get rid of it, he brought in a snake. Then he realized he had a snake running loose, so he brought in a hawk. This inspired me to make this short animation showing a simple food chain. First there are some innocent berries which get eaten by a blister beetle which gets eaten by a quail which gets eaten by a coyote.

Leave a Reply