Project-10-Sonic Story

sketch

//Tim Nelson-Pyne
//tnelsonp@andrew.cmu.edu
//section C
//Assignment-10-Project
//a sound bomb drops from the sky as a zombie rises from the grave
//the sound bomb makes a musical explosion and the zombie dances to the beat

var noteImg
var explosionImg
var danceGifImg
var danceGif
var fall
var explosion
var tam
var beat


var i = 0;


function preload() {
    noteImg = loadImage("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/eighthNote.png");
    explosionImg = loadImage("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/musicExplosion.png");
    danceGifImg = loadImage("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/Mojo_the_zombie.gif");  
    fall = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/falling.wav");
    explosion = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/explosion.wav");
    tam = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/Tam95bpm.wav");
    beat = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/Beat189bpm.wav")
    danceGif = createImg("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/Mojo_the_zombie.gif");
    danceGif.hide();
}

function setup() {
    createCanvas(480, 600);
    useSound();
    background(255);
    frameRate(60);
}

function soundSetup() { 
    
}


function draw() {
    //adds one to i each frame
    i ++;
    background(3, 0, 50);
    imageMode(CENTER);
    //makes the background flash multi colors when the sound bomb drops
    if(i >= 600 & i % 30 < 15) {
        fill(random(100, 255), random(100, 255), random(100,255));
        rect(0,0, 480, 400);
    }
    fill(23, 150, 20);
    noStroke();
    rect(0, 400, 480, 200);
    fill(100);
    rect(250, 325, 100, 150);
    //writes RIP on grave
    fill(0);
    textAlign(CENTER);
    text("RIP", 300, 375);
    //static zombie image rises from the grave
    if (i < 600){
        image(danceGifImg, 300, 700 - map(i, 0, 600, 0, 350), 400, 400);
        fill(23, 150, 20);
        rect(0, 500, 480, 100); 
    }
    //plays the cartoon falling noise and tambourine loop @ start
    if (i == 1) {
        fall.play();
        tam.play();
    }
    //displays the noteImg falling
    if (i < height - 25){
        image(noteImg, 100, i, 50, 50);
    }
    //when the noteImg hits the ground the explosion sound plays
    if (i == height - 25) {
        explosion.play();
    }
    //when the noteImg hits the ground the explosion image flashes
    if (i >= height - 25 & i % 30 < 15 && i < 800) {
        image(explosionImg, 100, height-150, 300, 300);
    }
    //a moment after the noteImg hits the groud the beat starts
    if (i == 600){
        beat.play();
    }
    //and the zombie dances
    if(i >= 600) {
        danceGif.show();
        danceGif.position(0,100);
    }
    //after the beat is over everything goes black
    if (i >= 1800) {
        danceGif.remove();
        fill(0);
        rect(0, 0, 480, 600);
        noLoop();
    }


    
}

Leave a Reply