Project 10-Sonic Story

My sonic story about the election goes as follows:

Biden and Trump meet at the white house. Trump debates biden by saying ‘Wrong’ repeatedly while smiling. Biden then bonks Trump on the head with the great state of Pennsylvania, winning him the election. Trump’s defeat music plays as he frowns and Biden smiles. Trump leaves the white house and Biden dances to his victory music.

Sounds- Wrong, Bonk (hitting on head), Bass(Trump defeat sound), winSound(Biden’s victory song)

sketch

//trump and biden meet, trump debates biden by saying wrong repeatedly while smiling, then biden bonks trump with a democratic pennsylvania, winning the election. Trump then frowns and his panic music plays, he then leaves and biden does a dance to victory music.
//sounds
var bonk;
var winSound;
var bass;
var wrong;

function preload(){
    bonk = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/bonk-1.wav");
    winSound = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/Wide-1.wav");
    bass = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/Bass-1.wav");
    wrong = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/Wrong-1.wav");
}

function setup() {
    createCanvas(400, 400);
    useSound();
    frameRate(1);
    imageMode(CENTER);
    rectMode(CENTER);
    noStroke();
}
function soundSetup() { 
    winSound.setVolume(0.5);
}
var trumpPos=0;
var bidenPos=400;
var armrot=12;
function draw() {
    translate(200,200);
    //biden and trump slide in
    if(frameCount<8){
        drawWH();
        trumpPos+=16;
        bidenPos-=16;
        push();
        translate(trumpPos-200,0);
        drawTrump(true);
        pop();
        push();
        translate(bidenPos-200,0);
        drawBiden(false);
        pop();
    }
    //trump wrong sound
    if(frameCount==7||frameCount==8||frameCount==9){
        wrong.play();
    }
    //biden arm appears and swings
    if(frameCount>=9&frameCount<11){
        armrot-=0.2;
        drawWH();
        push();
        translate(trumpPos-200,0);
        drawTrump(true);
        pop();
        push();
        translate(80,80);
        rotate(armrot);
        drawPenn();
        pop();
        push();
        translate(bidenPos-200,0);
        drawBiden(false);
        pop();
    }
    //bonk sound effect
    if(frameCount==12){
        bonk.play();
    }
    //trump mad
    if(frameCount==13){
        drawWH();
        push();
        translate(trumpPos-200,0);
        drawTrump(false);
        pop();
        push();
        translate(80,80);
        rotate(armrot);
        drawPenn();
        pop();
        push();
        translate(bidenPos-200,0);
        drawBiden(true);
        pop();
    }
    //bass sound
    if(frameCount==14){
        bass.play();
    }
    //trump exit, biden slide
    if(frameCount>14&frameCount<19){
        drawWH();
        trumpPos-=55;
        bidenPos-=27;
        push();
        translate(trumpPos-200,0);
        drawTrump(false);
        pop();
        push();
        translate(bidenPos-200,0);
        drawBiden(true);
        pop();
    }
    //win song plays
    if(frameCount==20){
        winSound.play();
    }
    //biden wiggle
    if(frameCount>20&frameCount<25){
        drawWH();
        push();
        var rot=random(-0.3,0.6);
        rotate(rot);
        translate(bidenPos-200,0);
        drawBiden(true);
        pop();
    }
    if(frameCount==25){
        background(0);
        noLoop();
    }
}

function drawTrump(happy){
    //red suit
    fill(170,27,27);
    rect(0,200,150,400);
    //head and ears
    fill(255,173,101);
    ellipse(0,0,100,90);
    ellipse(50,0,20,40);
    ellipse(-50,0,20,40);
    //hair
    fill(255,220,88);
    ellipse(0,-35,100,50);
    fill(0);
    //smiley face
    if(happy){
        arc(0,10,40,20,0,PI,CHORD);
    }
    //sad face
    else{
        arc(0,10,40,20,PI,0,CHORD);

    }
}

function drawBiden(happy){
    //blue suit
    fill(47,62,140);
    rect(0,230,100,400);
    //hair
    fill(255);
    ellipse(0,-25,70,60);
    //head and ears
    fill(214,169,140);
    ellipse(0,0,80,100);
    ellipse(40,0,10,20);
    ellipse(-40,0,10,20);
    fill(0);
    //smiley face
    if(happy){
        arc(0,10,40,20,0,PI,CHORD);
    }
    //sad face
    else{
        arc(0,10,40,20,PI,0,CHORD);
    }
}

function drawPenn(){
    //arm
    fill(47,62,140);
    rect(0,-45,30,90);
    //hand
    fill(214,169,140);
    ellipse(0,-95,40,40);
    //state
    fill(47,62,140);
    rect(0,-160,60,120);

}

function drawWH(){
    background(82,198,205);
    //grass
    fill(53,123,42);
    rect(0,50,400,300);
    //main house
    fill(255);
    rect(0,-120,100,40);
    //tip
    triangle(0,-150, -20,-140,20,-140);
    //inside
    fill(230);
    rect(0,-118,40,32);
}

Project-10 Sonic Story

Andrew id: heyingw Name: Heying Wang

These are the characters in my sound story: fish, ship, bubbles, small rock, small rock pieces, and big rock.

The sounds in my story include the sound of the ocean waters, ship siren, ship alarm, explosion sound, and bubble popping sound.

This is what the story is about: The ship starts sailing on the sea and the fish is swimming happily in the waters. The ship stops and the siren goes off to warn nearby ships. Nothing dangerous detected. The siren stops and the ship sails again with a faster speed. The ship hits a rock however, and the alarm for collision is triggered. Luckily the rock isn’t too big. Our ship cracks the rock into pieces accompanied by an explosion sound. The ship doesn’t seem to be damaged and it continued its journey. Our fish is making bubbles happily with a poppoing sound. The ships accelerates. It’s now sailing at a very high speed, which can be dangerous for the ship. The ship hits a big tock and the alarm is triggered. The rock is too big to be crashed. The ship sinks to the bottom of the sea. Game over.

sketch

var bgImage;
var boat;
var pieces=[];
function preload() {
    // call loadImage() and loadSound() for all media files here
    bgImageBig=loadImage('https://i.imgur.com/hpw6fpR.jpeg');
    fishImage=loadImage('https://i.imgur.com/zOEWUQ7.png');
    boatImage=loadImage('https://i.imgur.com/MtadjYH.png');
    water=loadSound('https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/water-2.wav');
    siren=loadSound('https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/siren.wav');
    alarm=loadSound('https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/alarm.wav');
    pop=loadSound('https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/pop-1.wav')
    breaking=loadSound('https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/break.wav')
    
}


function setup() {
    createCanvas(400, 400);
    frameRate(10);
    useSound();

    //boat object
    boat=new Object();
    boat.img=boatImage;
    boat.x=280;
    boat.y=15;
    boat.dx=-0.8;
    boat.imgWidth=120;
    boat.imgHeight=120;
    boat.draw=imageDraw;

    //fish object
    fish=new Object();
    fish.img=fishImage;
    fish.x=200;
    fish.y=250;
    fish.dx=-4;
    fish.imgWidth=60;
    fish.imgHeight=60;
    fish.draw=imageDraw;

}


function soundSetup() { 
    water.loop();
    water.setVolume(0.02);
    siren.setVolume(0.05);
    alarm.setVolume(0.2);
    breaking.setVolume(0.2);
    pop.setVolume(0.3);
 
}


function draw() {
    //clip background
    var bgImage=bgImageBig.get(0,100,400,300);
    background(20,60,100);
    image(bgImage,0,100,400,400);

    boat.draw();
    fish.draw();
//The ship starts sailing on the sea and the fish is swimming happily in the waters
    print(frameCount);
    if (frameCount >= 25 & frameCount < 80) { 
        boat.x+=boat.dx;

     }

    fish.x+=fish.dx;
    fish.y+=random(1,-1);
    if(fish.x<=-20){
        fish.x=400;
        fish.y=random(150,350);
    }

//The ship stops and the siren goes off to warn nearby ships
    if(frameCount >=90 & frameCount < 125){
        siren.play();
    }

//Nothing dangerous detected. The siren stops and the ship sails again with a faster speed   
    if(frameCount >125 & frameCount < 219){
        siren.stop();
        boat.dx=-1.5;
        boat.x+=boat.dx;
        
    }

//The ship hits a rock however, and the alarm for collision is triggered 
    if(frameCount>219 & frameCount<240){
        if(frameCount==220){
            alarm.play();
        }
        var ball=new Object();
        ball.x=boat.x+20;
        ball.y=boat.y+90;
        ball.draw=drawBall;
        ball.draw();

    }
//Luckily the rock isn't too big. 
//Our ship cracks the rock into pieces accompanied by an explosion sound 
    if (frameCount>240 & frameCount<250){
        alarm.stop();
        for (i=0;i<50;i++){
            pieces[i]=random(105,130);

        }
        for(i=0;i<pieces.length;i++){
            circle(pieces[i],random(120,380),2,2);
        }
        if(frameCount==241){
            breaking.play();
       

    }}
//The ship doesn't seem to be damaged and it continued its journey
    if(frameCount>235 & frameCount<=399){
        boat.dx=-1.5;
        boat.x+=boat.dx;

    }
//Our fish is making bubbles happily with a poppoing sound
    if(frameCount>280){
        if(frameCount%30==0){
            fill(255)
            circle(fish.x,fish.y,15,15);
            pop.play()
        }
    }



    if(boat.x<=-30){
        boat.x=370;
        boat.y=15;
    }

//The ships accelerates. 
//It's now sailing at a very high speed, which can be dangerous for the ship
    if(frameCount>399 & frameCount<499){
        boat.dx=-5;
        boat.x+=boat.dx;
        if(frameCount%100==0){
            siren.play();
        }}

//The ship hits a big tock and the alarm is triggered
    if(frameCount>499 & frameCount<519){
        if(frameCount==500){
            alarm.play();
        }
            var bigBall=new Object();
            bigBall.x=boat.x;
            bigBall.y=boat.y+90;
            bigBall.draw=drawbigBall;
            bigBall.draw();


    }
//The rock is too big to be crashed. The ship sinks to the bottom of the sea. Game over.
    if(frameCount>519){
        boat.x+=boat.dx;
        boat.y+=20;
        if(boat.y>=390){
            background(0);
            noLoop();
        }
    }
        
        
    
    

    
    
}

function imageDraw(){
    image(this.img,this.x,this.y,this.imgWidth,this.imgHeight);
}

function drawBall(){
    noStroke()
    fill('red');
    circle(this.x,this.y,20,20);
}

function drawbigBall(){
    noStroke()
    fill(40);
    circle(this.x,this.y,40,40);
}


Project 10 – Sonic Story

For my project, I created a story of Santa Clause delivering presents and running into a penguin. Now that Halloween is over, it is Christmas time.

I used Illustrator to create vector drawings correlating to the canvas size.

sketch
//general story
//Santa Clause was delivering presents when he ran into a penguin
let snowflakes = [];
function setup() {
    createCanvas(400, 200);
    useSound();
}

function soundSetup() { 
    osc = new p5.Oscillator();
    osc.amp(0.25);
    osc.setType('square');
    osc.start();
}

// Frequencies in Hz for each of the white and black keys, left to right
var white_freqs = [261.625, 293.665, 329.63, 349.23, 392, 440, 493.88, 523.25];
var black_freqs = [277, 311, 0, 370, 415, 466];   // index 2 not used

function draw() {
    background(0, 0, 68);
       noStroke();
    fill(230, 249, 255);
    rect(0, 180, 400, 200);
    penguin();
    tree();
    santa();
    elf();
    present();
    let t = frameCount / 60; // update time

  // create a random number of snowflakes each frame
  for (let i = 0; i < random(5); i++) {
    snowflakes.push(new snowflake()); // append snowflake object
  }

  // loop through snowflakes with a for..of loop
  for (let flake of snowflakes) {
    flake.update(t); // update snowflake position
    flake.display(); // draw snowflake
  }
}

// snowflake class
function snowflake() {
  // initialize coordinates
  this.posX = 0;
  this.posY = random(-50, 0);
  this.initialangle = random(0, 2 * PI);
  this.size = random(2, 5);

  // radius of snowflake spiral
  // chosen so the snowflakes are uniformly spread out in area
  this.radius = sqrt(random(pow(width / 2, 2)));

  this.update = function(time) {
    // x position follows a circle
    let w = 0.6; // angular speed
    let angle = w * time + this.initialangle;
    this.posX = width / 2 + this.radius * sin(angle);

    // different size snowflakes fall at slightly different y speeds
    this.posY += pow(this.size, 0.5);

    // delete snowflake if past end of screen
    if (this.posY > height) {
      let index = snowflakes.indexOf(this);
      snowflakes.splice(index, 1);
    }
  };

  this.display = function() {
    ellipse(this.posX, this.posY, this.size);
  };
}
 


function mousePressed() {
if(mouseY >= 0 & mouseY < 200 && mouseX >= 25 && mouseX < 325) {
        var keynum = constrain(floor((mouseX - 25) / 50), 0, 5);
        if(keynum != 2) {
        osc.start();
        osc.freq(black_freqs[keynum]);
    }
}
}

function penguin() {
    push();
    noStroke();
    translate(0, 0);
    fill(50);
    rectMode(CENTER);
    //face
    ellipse(49.5, 90.5, 39, 39);
    fill(20);
    //wings
    ellipse(35, 131.5, 8, 55);
    //wings 
    ellipse(64, 131.5, 8, 55);
    fill(50);
    //body
    rect(49.5, 142, 29, 82);
    //belly
    fill(255);
    ellipse(50, 137.5, 16, 55);
    fill(255, 255, 0);
    //foot
    ellipse(35.5, 182.5, 15, 9);
    //foot
    ellipse(64.5, 182.5, 15, 9);
    fill(255, 255, 0);
    //beak
    ellipse(37, 90.5, 22, 3);
    fill(255);
    //eyes
    ellipse(40.5, 83.5, 3, 3);
    //eyes
    ellipse(55.5, 83.5, 3, 3);
    pop();
} 
    function tree() {
        push();
        noStroke();
        translate(0, 0);
        fill(210, 105, 30);
        rectMode(CENTER);
        rect(100, 162, 7, 43);
        //triangle 1
        fill(34, 139, 34);
        beginShape();
        vertex(100, 69.7388);
        vertex(82.5, 130.5);
        vertex(117.8899, 130.5);
        endShape();
        //triangle 2
        beginShape();
        vertex(100, 100.7388);
        vertex(82.5, 161.5);
        vertex(117.8899, 161.5);
        endShape();
        fill(255, 255, 0);
        //star
        ellipse(100, 71, 9 ,9);
        pop();
    }

    function santa() {
        push();
        noStroke();
        translate(0, 0);
        //body
        fill(255, 0, 0);
        ellipse(200, 150.5, 44, 61);
        fill(255);
        ellipse(200, 70, 9, 9);
        //face
        fill(255, 230, 204);
        ellipse(200.5, 110.5, 31, 31);
        //hat
        fill(255, 0, 0);
        beginShape();
        vertex(200.0522, 70);
        vertex(187.2356, 101.5);
        vertex(213.1543, 101.5);
        endShape();
        //boots
        fill(0);
        ellipse(189.5, 179.5, 15, 9);
        ellipse(211.5, 179.5, 15, 9);
        fill(255);
        //buttons
        ellipse(200, 135, 9, 9);
        ellipse(200, 150, 9, 9);
        ellipse(200, 165, 9, 9);
        //eyes
        fill(0);
        ellipse(193, 110, 4, 4);
        ellipse(209, 110, 4, 4);
        pop();
    }

    function elf() {
        push();
        noStroke();
        translate(0, 0);
        rectMode(CENTER);
        //arm
        fill(0, 102, 0);
        rect(242, 155.5, 7, 30);
        rect(258, 155.5, 7, 30);
        //body
        fill(51, 153, 51);
        rect(250, 159, 17, 43);
         //face
        fill(255, 230, 204);
        ellipse(249.5, 130.5, 29, 29);
        //ears
        ellipse(234.5, 131, 3, 14);
        ellipse(264.5, 131, 3, 14);
        //shoes
        fill(255, 0, 0);
        ellipse(241.5, 181, 15, 6);
        ellipse(258.5, 181, 15, 6);
        //hat
        beginShape();
        vertex(249.0522, 94);
        vertex(236.2356, 125.5);
        vertex(263.1543, 125.5);
        endShape();
        //hat top
        fill(255);
        ellipse(249, 92, 9, 9);
        //eyes
         fill(0);
         ellipse(243, 129, 4, 4);
         ellipse(256, 129, 4, 4);
         pop();
    }

    function present() {
        push();
        noStroke();
        translate(0, 0);
        rectMode(CENTER);
        //present
        fill(204, 0, 0);
        rect(299.5, 166.5, 35, 35);
        //ribbon
        fill(255, 204, 0);
        rect(299.5, 166.5, 5, 35);
        rect(299.5, 166.5, 35, 3);
        noFill();
        strokeWeight(2);
        stroke(255, 204, 0);
        ellipse(295, 148, 10, 8);
        ellipse(304, 148, 10, 8);
        pop();
    }
Illustrator Mockup

Project-10-Sonic-Story

For this project, I wanted to create a weird but delightful story with many fun little elements. I spent a lot of time thinking about how to make the transition between each scene smooth and fun. One of the solutions I came up with was creating an unexpected interaction between the background and the water in the fish tank.

Basically, my story goes like this:

Cat girl walked into the frame (walking sound). She blowed up her chewing gum (blowing balloon sound) and gradually shrined(venting balloon sound) it down to a size of a fish tank. As the water in the background flowed into the fish tank hat (filling water sound), a goldfish appeared, bubbling(bubble sound).

sketch new
//jiaqiwa2; Jiaqi Wang; Section C
//Story: a cat girl walked into the frame while chewing a gum. 
//She blowed up the gum and shrinked it down to the size of a fish tank.
//water started filling up the tank and a goldfish appeared.
//She enjoyed the goldfish bubbling infront of her eyes.
var CatGirlImage = [];   // an array to store the images
var fish;
var count=0;
var xC=700;
var yoff=0.0;
var yC=5;
var stepC=40;
var fC=0;


var blowing=false;
var diam=5;
var shrink=0;

var arcS=90;
var arcE=90;

var rise=0;
var filling=false;

var fishSX=175;
var fishSY=455;
var fishXoff=0.0;

var secondHalf=false;

//sound file variable
var walkingSound;
var GrowingSound;
var shrinkingSound;
var fillingSound;
var bubbleSound;

 
function preload(){

    var filenames = [];
    filenames[0] = "https://i.imgur.com/Em6d4RR.png";
    filenames[1] = "https://i.imgur.com/lWdTJLj.png";
    filenames[2] = "https://i.imgur.com/sdhFyfz.png";
    filenames[3] = "https://i.imgur.com/HEiFHNA.png";
    filenames[4] = "https://i.imgur.com/bJF8rmQ.png";
    filenames[5] = "https://i.imgur.com/D8MFSK6.png";
 
    for (var i = 0; i<filenames.length; i++) {
        CatGirlImage[i] = loadImage(filenames[i]);
    }
    fish=loadImage("https://i.imgur.com/UzyMgov.png");

   walkingSound=loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/bubbleSound.wav");
   GrowingSound=loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/bubbleSound.wav");
   shrinkingSound=loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/bubbleSound.wav");
   fillingSound=loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/bubbleSound.wav");
   bubbleSound=loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/bubbleSound.wav");
}

function setup() {
    createCanvas(400,600);
    frameRate(10);
    background(144,181,232);
    useSound();

}

function draw() {
	//scale up to the top left area for the second half of the story
	if(secondHalf){
    	scale(1.75,1.75);
	    translate(-20,-40);
	}
    //start dropping water in the background
	if(filling){
		fill(229,147,147);
		rect(0,0,400,min(115,rise*2));
	}
	else{
        fill(144,181,232);
        rect(0,0,400,600);
    }
	
//---------------------------------catGirl walking into the frame and stopped---------------------

	if(count<20){
		catGirlWalking();
	}
    else if(count<303){
    	 catGirlStopped();
    }
   
	
//---------------------------------the gum grows and shrinks to a fish tank----------------------
	gumGrowing(count);
//---------------------------------water filling+ goldfish appears-------------------------------
	waterFilling(count);      
	        
//-----------------------------------bubble popping----------------------------------------------
	bubble(count);

	if(count>=250){
	   noLoop();
	}



   count++;
   print(count);


}  



function mousePressed(){
	print(count);
	
	noLoop();
}

//update the x&y position of the catGirl walking into the frame
function catGirlWalking(){
		//sound
		if(fC==0||fC%3==0){
			walkingSound.play();
		}
		
		//keep the frame of catGirl animation looping
		if(fC%5==0&fC!=0){
		   fC=0;
	    }
	    //keep moving to the left if catGirl does not reach the stopping point
	    if(xC>=50){
		   xC-=stepC;
	    }

	//keep moving up and down to feel more lively
		yoff=yoff+0.01;
		if(fC%3==0){
        	yC+= noise(yoff);
		}
		else if(yC>0){
			yC-= noise(yoff);
		}
		//draw the catGirl
   		image(CatGirlImage[fC],xC,yC,400,600);
   		fC++;
}
function catGirlStopped(){
	//keep the frame of catGirl animation looping
		if(fC%5==0&fC!=0){
		   fC=0;
	    }
	    //keep moving up and down to feel more lively
		yoff=yoff+0.01;
		if(fC%3==0){
        	yC+= noise(yoff);
		}
		else if(yC>0){
			yC-= noise(yoff);
		}
		image(CatGirlImage[fC],0,yC,400,600);
   		fC++;

}

function gumGrowing(count){
	//gum growing bigger
	if(count>=20&count<45){
	   	fill(229,147,147,170);
	   	noStroke();
	   	diam+=count;
	    ellipse(200,380,diam,diam);
	    if(count%3==0){
	    	GrowingSound.play();
	    }


	}
	
	if(count>=45){
		shrink++;
	    fill(229,147,147,170);
	    if(count==49){
			
			shrinkingSound.play();
		}
		 //if size of gum gets down to 500, stop changing
	    if(diam-shrink*15<510&shrink>10){
	        ellipse(250,240,460,460);
				
	    }
	    else{
	        ellipse(250,240,diam-shrink*15);
	    }
	}

}

function waterFilling(count){
	if(count>=75){
		if(count==75){
	    	fillingSound.play();
	    }

		filling=true;
		rise+=1.08;
		fill(144,181,232,130);
	    arcS-=rise*0.1;
	    arcE+=rise*0.1;
	    
	    //fish appears
	    if(count>100){

	        	image(fish,fishSX-100*(noise(fishXoff)),max(110,fishSY-rise*3),min(100,40+(rise*0.8)),min(150, 60+(rise*1.2)));
	    }
	    if(count<130){
	        	arc(250,240,460,460,radians(arcS),radians(arcE), OPEN);
	    }
	    else{
	        	arc(250,240,460,460,-1.0471975511965976 +random(-0.003,0.0003),4.1887902047863905+random(-0.003,0.0003), OPEN);
	    }
	    fishXoff+=0.04;
	}

}

function bubble(count){
	   if(count>=160){
	   	    secondHalf=true;
	   		
	   	if(count%24==0){
	   		bubbleSound.play();
	   	}
	   	fill(144,219,232,220);
	   	//generating bubbles
	   	for(var i=0;i<5;i++){
	   		ellipse(fishSX-100*(noise(fishXoff))+random(30+i),max(110,fishSY-rise*3)-random(40+i),random(10-i));
	   		ellipse(fishSX-100*(noise(fishXoff))+random(5+i),max(110,fishSY-rise*3)+random(40+i),random(20-i));
	   	}


	   }
}
Sketching characters
Storyboard sketch

Project -10

soundstoryDownload
var cloudX = 0;
var cloudY = 50;
var cloudDx = 5;
var carX = 400;
var carY = 350;
var carDx = 15;
var manX = 200;
var manY = 350;
var manDx = 10;
var cloudLaughing;
var rainSound;
var manGrumble;
var carSound;

function preload() {
    cloudLaughing = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/laugh.wav");
    rainSound = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/rain-1.wav");
    carSound = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/car.wav");
    manGrumble = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/mad.wav");
}


function setup() {
    // you can change the next 2 lines:
    createCanvas(400, 400);
    frameRate(1);
    useSound();
}

function soundSetup(){
    cloudLaughing.setVolume(0.5);
    carSound.setVolume(0.5);
    manGrumble.setVolume(0.4);
}

function cloud(){
    noStroke();
    fill(255);
    //cloud 1
    push();
    scale(1.5);
    circle(cloudX, cloudY, 60);
    circle(cloudX - 30, cloudY + 10, 40);
    circle(cloudX + 30, cloudY +10, 40);
    //face
    stroke(0);
    line(cloudX-15, cloudY - 15, cloudX-5, cloudY - 5);
    line (cloudX - 15, cloudY - 5, cloudX -5, cloudY - 15);
    line(cloudX+15, cloudY - 15, cloudX+5, cloudY - 5);
    line (cloudX + 15, cloudY - 5, cloudX + 5, cloudY - 15);
    fill(0);
    arc(cloudX, cloudY, 30, 30, 0,  PI); //smile
    pop();

    cloudX += cloudDx
    print(frameCount);
    if (frameCount == 25){
        cloudDx = 0
    }
}

function rain(){
    for (var i = 0; i < 12; i++){
        var x = random(125, 275);
        var y = random(100, height);
        fill(93, 146, 245);
        noStroke();
        circle(x - 15, y+3, 5);
        triangle(x - 17.5, y +3, x - 12.5, y+ 3, x - 15, y - 5)
    }
}

function car(){
    fill(255, 0, 0);
    ellipse(carX, carY, 100, 70);
    ellipse(carX, carY + 15, 150, 40);
    fill(60, 140, 255);
    ellipse(carX - 30, carY - 10, 40, 20)
    fill(0)
    //tires
    circle(carX - 35, carY + 30, 30);
    circle(carX + 35, carY + 30, 30);
    carX -= carDx
    if (frameCount == 14){
        carDx = 0;
    }
}

function person(){
    fill(0);
    stroke(0);
    strokeWeight(1);
    circle(manX, manY, 15);
    strokeWeight(5);
    line(manX, manY, manX, manY + 30);
    line(manX, manY + 30, manX -15, manY + 40);
    line(manX, manY + 30, manX + 15, manY + 40);
    line(manX, manY + 20, manX -15, manY+ 5);
    line(manX, manY + 20, manX + 15, manY+ 5);
    if (frameCount >= 27){
        manX -= manDx
    }
}

function draw() {
    background(195, 200, 226);
    fill(190);
    stroke(50);
    rect(0, 350, width, height);
    cloud();
    car();
    if (frameCount <= 5){
        text('Evil Cloud', 190, 200);
    }
    if (frameCount >= 15){
        person();
    }
    strokeWeight(1);
    //sounds
    if (frameCount > 25 & frameCount <= 49) {
        rain();
        rainSound.play();
    }
    if (frameCount >= 27 & frameCount < 49){
        manGrumble.play();
    }
    if (frameCount < 14){
        carSound.play();
    }
    if (frameCount == 25) {
        cloudLaughing.play();
    }
    if (frameCount == 50){
        rainSound.stop();
        manGrumble.stop();
    }
    if (frameCount == 14){
        carSound.stop();
    }
    if (frameCount == 28){
        cloudLaughing.stop();
    }

}

My story is of an evil cloud. A car drives by and parks and the man gets out, seeing this the cloud laughs and the rain starts to fall. The annoyed man grumbles and walks away from the rain.

Project 10

For Project 10, I decided to create a collage based story inspired by the aesthetic of Vaporwave. My process began by creating background collages in Photoshop and displaying them in p5-js. Then, I added in the characters within p5-js so that they could be animated. Due to the surreal nature of the world I ended up creating with the collages, I decided to incorporate Alice from Alice in Wonderland as the main character of the story traveling through this “Vaporwave Land.”

My first sound was a piece of music I found that reminded me of startup sounds from old computers. The next sound I used was the error message sound to coincide with the error message character’s appearance. The third sound I used was an ominous drone sound I found to bring life to the All-Seeing-Eye character. The fourth sound I used was the Windows 95 shutdown sound to coincide with the end of the story and the Windows 95 logo character. The last sound was a piece of “80s” inspired music that I used as credit music.

sketch – CopyDownload

//Story Concept: Alice from Alice in Wonderland wakes up stuck in the glitched out world
//of Vaporwave. First, she wakes up in the MS Paint canvas and sees the marble bust from
//Macintosh Plus's Floral Shoppe album floating above her as startup music plays. Next,
//as she explores this new world trying to find a way out she discovers and incessant error
//message that blocks her path. Then, she visits the All-Seeing-Eye for guidance, but the
//eye just floats around aimlessly making an ominous drone. Finally, she arrives at the 
//original frontier and manages to shut down the Windows 95 logo that runs this world.

var sceneOne;
var sceneTwo;
var sceneThree;
var sceneFour;
var error;
var alice;
var soundOne;
var blink = true; //helps make error message disappear and reappear
var soundError;
var eye;
var eyeDrone;
var windows;
var logoFlip = true;//helps flip and reflip Windows 95 logo
var vaporwave;
var sleepalice;
var sitalice;
var windowSound;
var marbleBust;


function preload() {
    // call loadImage() and loadSound() for all media files here
    sceneOne = loadImage("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/2-scaled.jpgmu.edu/15-104/f2020/wp-content/uploads/2020/11/1-scaled.jpg");
    sceneTwo = loadImage("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/2-scaled.jpg");
    sceneThree = loadImage("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/3-scaled.jpg");
    sceneFour = loadImage("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/4-scaled.jpg");
    //source: https://i.pinimg.com/originals/c8/0b/29/c80b290d6ea187abe624cd42c4b44014.png
    windows = loadImage("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/windows.png")
    //source: https://freshsparks.com/wp/wp-content/uploads/2015/06/generic-error-message-microsoft.jpg
    error = loadImage("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/error.png");
    //source: http://2.bp.blogspot.com/-cM30a7xxeMg/TplisvJ0QYI/AAAAAAAAABk/DUgdfkhhq0c/s320/Alice%2B2.gif
    alice = loadImage("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/alice.gif"); 
    //source: https://freesound.org/people/kjartan_abel/sounds/542453/
    soundOne = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/japansky-1.wav"); 
    //source: https://freesound.org/people/AbdrTar/sounds/519422/
    soundError = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/error-1.wav"); 
    //source: https://freemasoninformation.com/wp-content/uploads/2014/05/all-seeing-eye-of-god-796x1024.jpg
    eye = loadImage("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/eye.png");
    //source: https://freesound.org/people/pointparkcinema/sounds/407241/
    eyeDrone = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/eyedrone-1.wav");
    //source: https://freesound.org/people/Doctor_Dreamchip/sounds/523808/
    vaporwave = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/vaporwave.wav"); 
    //source: https://www.disneyclips.com/images/images/alice1small.gif
    sleepalice = loadImage("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/sleepingalice.gif");
    //source: https://www.disneyclips.com/images/images/alice-small.png
    sitalice = loadImage("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/alicesit.png");
    //source: https://www.myinstants.com/instant/windows-xp-shutdown/
    windowSound = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/preview_4.mp3")
    //source: https://ih0.redbubble.net/image.236642016.7494/ap,550x550,12x16,1,transparent,t.png
    marbleBust = loadImage("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/floralshoppe.png");

}


function setup() {
    createCanvas(400, 400);
    useSound();
    frameRate(1);
}


function soundSetup() { // setup for audio generation
    soundOne.setVolume(.2);
    soundError.setVolume(1);
    eyeDrone.setVolume(.7);
    vaporwave.setVolume(.5);
    windowSound.setVolume(.5);
}

var soundplay = true;
var marbleAngle = 0;

function draw() {
	var eyeX = random(0,3500);
	var eyeY = random(220,500);
    var marbleRadius = 600;
    // you can replace any of this with your own code:
    background(200);
    text("p5.js 15104 fall 2019 v1", 10, 15);
    print(soundplay);
    if (frameCount < 27){
    	soundplay = true;
    	image(sceneOne,0,0,400,400);
    	push();
    	scale(.25,.25);
    	image(sitalice,90,775);
    	pop();
        push();
        imageMode(CENTER);
        scale(.5,.5);
        image(marbleBust,marbleRadius*cos(radians(marbleAngle)),250);
        marbleAngle += 20;
        pop();
    	stroke("black");
    	fill("black");
    	text("Chapter One: Alice Wakes Up in the Internet",5,390);
    	soundOne.play();
    } else if (frameCount >= 27 & frameCount < 50){
    	soundOne.stop();
    	image(sceneTwo,0,0,400,400);
	    push();
	    scale(.1,.1);
	    drawAlice(3000,3000);
	    pop();
	    if (blink == true){ //makes error message appear and disappear
	    	push();
	    	scale(.8,.8);
	   		drawError(0,height/4);
	    	pop();
	    	soundError.play();
	    } else if (blink == false){
	    	soundError.stop();
	    	background(0,0);
	    }
	    blink = !blink;
	    stroke("black");
    	fill("black");
    	text("Chapter Two: Alice Encounters an Error",5,390);
    } else if (frameCount >= 50 & frameCount < 70) {
    	image(sceneThree,0,0,400,400);
		push();
		scale(.4,.4);
		drawAlice(650,300);
		pop();
		push();
		scale(.1,.1);
		drawEye(eyeX,eyeY); //All-Seeing-Eye moves randomly on canvas
		eyeDrone.play();
		pop();
		stroke(255);
    	fill(255);
    	text("Chapter Three: Alice Asks the All-Seeing-Eye for Help",5,390);
    } else if (frameCount >= 70 & frameCount < 90){
    	eyeDrone.stop();
    	image(sceneFour,0,0,400,400);
    	push();
    	scale(.1,.1);
    	drawAlice(3300,3300);
    	pop();
    	push();
    	scale(.5,.5);
    	if (logoFlip == true){
    		drawLogo(width/2,height/2);
    		windowSound.play();
    	} else if (logoFlip == false){
    		windowSound.stop();
    		scale(-1,1);
    		drawLogo(-1.5*width,height/2);
    	}
    	pop();
    	logoFlip = !logoFlip; 
    	stroke(120);
    	fill(120);
    	text("Chapter Four: Alice Faces the Original Frontier",10,390);

    } else {
    	//text(frameCount,0,0);
    	if (soundplay == true){
    		vaporwave.play(); //Cheesy end credit music plays
    		soundplay = !soundplay; //prevents song from restarting each time draw loops
    	}
    	background(0);
    	push();
    	scale(3,3);
    	fill(255,255,0);
    	stroke(255,255,0);
    	text("Alice in Vaporwave Land",1,height/9 + 10);
    	if (frameCount> 95){
    		text("Click to Start Again",1,(height/9)+20);
    	}
    	pop();
    	push();
    	scale(.5,.5);
    	image(sleepalice, 400,400);
    	pop();
    }


}

function mousePressed(){
	if (frameCount > 95){ //restarts story
		vaporwave.stop();
		frameCount = 0;
	}
}


function drawAlice(x,y){
	image(alice,x,y);
}

function drawError(x,y){
	image(error,x,y);
}


function drawEye(x,y){
	image(eye,x,y);
}

function drawLogo(x,y){
	image(windows,x,y);
}

Project 10 Sonic Story

This project is about the life of a Balloon.

It inflates, slightly deflates while floating up, quickly deflates and shoots around the canvas, inflates again, then finally popping.

sketch
// tjchen 
// hand in 10 project 
// life of a balloon 


var vol = 0.75 // set global volume 

function preload() {
    // call loadImage() and loadSound() for all media files here
    deflate = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/shortdeflate.wav");
    inflate = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/inflate.wav");
    bpop = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/pop.wav");
    slowDeflate = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/longdeflate_2.wav");
}

function soundSetup() { // setup for audio generation
        deflate.setVolume(vol);
        inflate.setVolume(vol);
        bpop.setVolume(vol);
        slowDeflate.setVolume(vol);
}

// set up balloon movement 
function balloonStep(){
    this.dx = random(-20,20);
    this.dy = random(-20,20);

    //first inflate

    if (this.age > 0 & this.age <= 200){
        this.size += 1; 
    
    //slow deflate 

    } else if (this.age > 200 & this.age <= 400){
        this.y -= 1; 
        this.size -= 0.3

    // quick deflate and fly around 

    } else if (this.age > 400 & this.age <= 600){
        this.x += this.dx;
        this.y += this.dy;
        if (this.x > width) { // bounce off right wall
            this.x = width - (this.x - width);
            this.dx = -this.dx;
        } else if (this.x < 0) { // bounce off left wall
            this.x = -this.x;
            this.dx = -this.dx;
        }
        if (this.y > height) { // bounce off bottom
            this.y = height - (this.y - height);
            this.dy = -this.dy;
        } else if (this.y < 0) { // bounce off top
            this.y = -this.y;
            this.dy = -this.dy;
        }
        this.size -= 0.4;

    //inflate again 

    }else if (this.age > 600 & this.age <800){
        this.size += 2;
        if(this.size > width){

    // balloon pops

            rect(0,0,width,height);
        } 

    // resets 

    } else if (this.age>800) {
        this.age = 0;
        this.size = 20;
        this.x = width/2;
        this.y = height/2;
    }
    this.age ++; 
}

function balloonDraw(){
    noStroke();
    fill(255,0,0);
    circle(this.x,this.y,this.size);
}

function makeballoon(px,py,pdx,pdy){
    balloon = {x: px, y: py, dx: pdx, dy: pdy, size: 20, stepfunction: balloonStep, drawfunction: balloonDraw, age: 0}
    return balloon; 
}

function setup() {
    createCanvas(400, 400);
    useSound();
    var b = makeballoon(width/2, height/2, random(-10,10), random(-10,10));
}

function draw() {
    background(0);
    balloon.stepfunction();
    balloon.drawfunction();
    // pop! text graphic 
    if (balloon.size > width){
            push();
            textSize(150);
            textAlign(CENTER);
            fill(0);
            text('POP!',width/2,height/2+40);
            pop();
    }
    var bo = false;

    //check balloon age and toggle sound based on it's state 

    if (balloon.age >= 0 & balloon.age <= 1){
       bo = true 
       if (bo == true){
            inflate.play();
       }
    }
    if (balloon.age >= 200 & balloon.age <= 201){
       bo = true 
       if (bo == true){
            slowDeflate.play();
       }
    }
    if (balloon.age >= 400 & balloon.age <= 401){
       bo = true 
       if (bo == true){
            deflate.play();
       }
    }
    if (balloon.age >= 600 & balloon.age <= 601){
       bo = true 
       if (bo == true){
            inflate.play();
       }
    }
    if (balloon.age >= 750 & balloon.age <= 751){
       bo = true 
       if (bo == true){
            bpop.play();
       }
    }
}

Project-10 Sound Story

This is a story about a duck, a duckling, a cloud, and lightning bolt.

sketch
//Robert Rice
//rdrice
//Section C


// sketch.js template for sound and DOM
//
// This is the 15104 Version 1 template for sound and Dom.
// This template prompts the user to click on the web page
// when it is first loaded.
// The function useSound() must be called in setup() if you
// use sound functions.
// The function soundSetup() is called when it is safe
// to call sound functions, so put sound initialization there.
// (But loadSound() should still be called in preload().)

var mama = {filename:'https://i.imgur.com/z44s88k.png', //https://images.dailykos.com/images/214263/story_image/Duck-37.png?1456291242
            x:0,
            y:0,
            playFunc: playOsc,
            stopFunc: stopOsc,
            drawFunc: drawImg}
var duckling = {filename:'https://i.imgur.com/X5iYcio.png', //https://purepng.com/public/uploads/large/91508076238ploll99zx4ifi35p6b1qrontiecfaivclrqbiz0gfg0rru6qtj7qmlw2qmvrthjbk3sj2wgiwa12pz4n00nufufllybyth2akpcx.png
            x:0,
            y:0,
            playFunc: playOsc,
            stopFunc: stopOsc,
            drawFunc: drawImg}
var cloud = {filename:'https://i.imgur.com/igVfind.png', //https://clipground.com/images/clipart-cloud-png-10.png
            x:-50,
            y:100,
            playFunc: playOsc,
            stopFunc: stopOsc,
            drawFunc: drawImg}
var lightning = {filename:'https://i.imgur.com/9RODxMu.png', //https://asr4u.files.wordpress.com/2013/06/lightning-bolt-hi1.png
            x:150,
            y:150,
            playFunc: playOsc,
            stopFunc: stopOsc,
            drawFunc: drawImg}
var tScale = 1; //used later for scaling stuff down. 1 == 100%


function preload() {
    // call loadImage() and loadSound() for all media files here

    mama.image = loadImage(mama.filename);
    duckling.image = loadImage(duckling.filename);
    cloud.image = loadImage(cloud.filename);
    lightning.image = loadImage(lightning.filename);
    //loadSound();
}


function setup() {
    // you can change the next 2 lines:
    createCanvas(300, 300);
    createDiv("p5.dom.js library is loaded.");
    frameRate(30);
    imageMode(CENTER);
    //======== call the following to use sound =========
    useSound();
}


function soundSetup() { // setup for audio generation
    // you can replace any of this with your own audio code:
    mama.osc = new p5.Oscillator();
    mama.trem = new p5.Oscillator();    //mama duck's voice
    mama.trem.freq(10);
    mama.osc.setType('sawtooth');
    mama.osc.freq(midiToFreq(60));
    mama.osc.amp(mama.trem);

    duckling.osc = new p5.Oscillator();
    duckling.trem = new p5.Oscillator();    //baby duck's voice
    duckling.trem.freq(30);
    duckling.osc.setType('sawtooth');
    duckling.osc.freq(midiToFreq(70));
    duckling.osc.amp(mama.trem);

    cloud.osc = new p5.Oscillator();
    cloud.trem = new p5.Oscillator();   //makes cloud go brrrrrrr
    cloud.trem.freq(10);
    cloud.osc.setType('sawtooth');
    cloud.osc.freq(midiToFreq(31));
    cloud.osc.amp(cloud.trem);

    lightning.osc = new p5.Oscillator();    //lightning sound
    lightning.trem = new p5.Oscillator();  //makes it go pew pew
    lightning.trem.freq(10000);
    lightning.osc.setType('square');
    lightning.osc.amp(lightning.trem);
    lightning.osc.freq(midiToFreq(90));
}


function draw() {
    // you can replace any of this with your own code:
    background(200);    
    
    if (frameCount >= 0 & frameCount <= 150) {     //act I the status quo
        mama.x = 50;
        mama.y = 250;
        mama.drawFunc(100, 100);

        duckling.x = 100;
        duckling.y = 275;
        duckling.drawFunc(40, 50);

        if (frameCount == 30) {mama.playFunc();
            mama.drawFunc(200, 200);}
        if (frameCount == 50) {mama.stopFunc();}

        if (frameCount == 60) {duckling.playFunc();
            duckling.drawFunc(80, 100);}
        if (frameCount == 70) {duckling.stopFunc();}

        if (frameCount == 90) {mama.playFunc();
            mama.drawFunc(200, 200);}
        if (frameCount == 150) {mama.stopFunc();}

        if (frameCount == 120) {duckling.playFunc();}
        if (frameCount > 120 & frameCount < 150) {duckling.drawFunc(200, 200);}
        if (frameCount == 150) {duckling.stopFunc();}
    }

    if (frameCount >= 150 & frameCount <= 300) {   //act II a cloud arrives
        mama.drawFunc(100, 100);
        duckling.drawFunc(40, 50);

        var cDX = 2 //the speed at which the cloud will move across the screen


        cloud.drawFunc(100, 50);

        cloud.x += cDX;
        if (cloud.x > 150) {cloud.x = 150;} //will move across the screen, before settling in the middle

        if (frameCount == 250) {cloud.playFunc();}
        if (frameCount > 250 & frameCount < 300) {cloud.drawFunc(300, 150);}
        if (frameCount == 300) {cloud.stopFunc();}
    }

    if (frameCount >= 300 & frameCount <= 450) {   //act III the cloud brings forth lightning
        mama.drawFunc(100, 100);
        duckling.drawFunc(40, 50);
        cloud.drawFunc(300, 150);

        if (frameCount == 325) {lightning.playFunc(); lightning.drawFunc(100, 100);}
        if (frameCount == 330) {lightning.stopFunc(); lightning.drawFunc(50, 50);}

        if (frameCount == 355) {lightning.playFunc(); lightning.drawFunc(100, 100);}
        if (frameCount == 360) {lightning.stopFunc(); lightning.drawFunc(50, 50);}

        if (frameCount == 385) {lightning.playFunc(); lightning.drawFunc(100, 100);}
        if (frameCount == 390) {lightning.stopFunc(); lightning.drawFunc(50, 50);}

        if (frameCount == 415) {lightning.playFunc(); lightning.drawFunc(100, 100);}
        if (frameCount == 420) {lightning.stopFunc(); lightning.drawFunc(50, 50);}
    }

    if (frameCount >= 450 & frameCount <= 600) {   //act IV mama duck defends her child
        mama.drawFunc(100, 100);
        duckling.drawFunc(40, 50);
        cloud.drawFunc(200, 100);

        if (frameCount == 510) {mama.playFunc();}
        if (frameCount > 510 & frameCount < 600){
            mama.drawFunc(300, 300);
            mama.x += random(-10, 10);
            mama.y += random(-10, 10);
        }
        if (frameCount == 600) {mama.stopFunc(); mama.x = 50; mama.y = 250;}
    }

    if (frameCount >= 600 & frameCount <= 750) {   //act V the attackers rejected
        if (frameCount == 600) {
            lightning.x = 250
        }

        mama.drawFunc(100, 100);
        duckling.drawFunc(40, 50);

        push();
        scale(tScale, tScale);
        cloud.drawFunc(200, 100);
        lightning.drawFunc(75, 75);
        pop();

        tScale = tScale * 0.95
    }

    if (frameCount >= 750 & frameCount <= 900) {   //act VI return to status quo
        mama.x = 50;
        mama.y = 250;
        mama.drawFunc(100, 100);

        duckling.x = 100;
        duckling.y = 275;
        duckling.drawFunc(40, 50);

        if (frameCount == 780) {mama.playFunc();
            mama.drawFunc(200, 200);}
        if (frameCount == 800) {mama.stopFunc();}

        if (frameCount == 810) {duckling.playFunc();
            duckling.drawFunc(80, 100);}
        if (frameCount == 820) {duckling.stopFunc();}

        if (frameCount == 840) {mama.playFunc();
            mama.drawFunc(200, 200);}
        if (frameCount == 900) {mama.stopFunc();}

        if (frameCount == 870) {duckling.playFunc();}
        if (frameCount > 870 & frameCount < 900) {duckling.drawFunc(200, 200);}
        if (frameCount == 900) {duckling.stopFunc();}
    }
}

function playOsc() {
    this.trem.start();
    this.osc.start();//plays the sound
}

function stopOsc() {
    this.osc.stop();
    this.trem.stop();//stops the sound
}

function drawImg(w, h) {    //draws the picture at the specified scale
    image(this.image, this.x, this.y, w, h);
}

Project 10 Sonic Story

Story: it rains (rain sound plays), and the sprout grows (grow sound plays) and bloom the flower (bloom sound plays). Then, the cloud clears up and the bird goes by (bird sound plays). At the end, the sun gets bigger (ending sound plays).

sketch

//Jae Son
//Section C
//story: it rains, and the sprout grows and bloom the flower. 
// Then, the cloud clears up and the bird goes by. 
// At the end, the sun gets bigger

var rain;
var grow;
var bloom;
var bird;
var sun;
var sprout;
var flower;
var birdimg;
var sunimg;

function preload() {
  //sounds
  rain = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/rain.wav");
  grow = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/grow.wav");
  bloom = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/bloom.mp3");
  bird = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/bird.wav");
  sun = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/sun.wav");
  //images
  sprout = loadImage("https://i.imgur.com/jhYJcR1.png");
  flower = loadImage("https://i.imgur.com/o6nzV38.png");
  birdimg = loadImage("https://i.imgur.com/amZXis1.png");
  sunimg = loadImage("https://i.imgur.com/2W1rzB0.png");
}

function setup() {
  createCanvas(600, 400);
  useSound();
  frameRate(20); 
}

function soundSetup() { // setup for audio generation
  rain.setVolume(0.6);
}

function draw() {
  //blue background
  background(189,209,255); 
  noStroke();
  imageMode(CENTER);
  
  //animation
    if (frameCount < 5) {
        cloud(200,100);
        image(sprout,width/2,height-20,67,104);
    } else if (frameCount >= 5 & frameCount <10) {
        raindrop(250,150,0);
        cloud(200,100);
        image(sprout,width/2,height-20,67,104);
    } else if (frameCount >= 10 & frameCount <15) {
        raindrop(250,150,100);
        cloud(200,100);
        image(sprout,width/2,height-20,67,104);
    } else if (frameCount >= 15 & frameCount <50) {
        raindrop(250,150+frameCount*3,255);
        cloud(200,100);
        image(sprout,width/2,height-20,67,104);
    } else if (frameCount >= 50 & frameCount < 100) {
        cloud(200,100);
        image(sprout,width/2,height-50-frameCount/3,67,104);
    } else if (frameCount >= 100 & frameCount < 110){
        cloud(200,100);
        image(flower,width/2,height-80,67,104);
    } else if (frameCount >= 110 & frameCount < 270){
        image(sunimg,width/2,100,90,90);
        cloud(400-frameCount*2,100);
        image(flower,width/2,height-80,67,104);
        image(birdimg,-200+frameCount*3,200,84,57);
    } else if (frameCount >=270 & frameCount <300){
        image(sunimg,width/2,100,70+frameCount/5,70+frameCount/5)
        image(flower,width/2,height-80,67,104);
    } else {
        image(sunimg,width/2,100,130,130);
        image(flower,width/2,height-80,67,104);
    }
    
  //brown ground
    fill(165,85,85);
    rect(0,height-40,600,40);
    
  //sound play
    if (frameCount == 2) {
      rain.play();
    } else if (frameCount == 50) {
      grow.play();
    } else if (frameCount == 102) {
      bloom.play();
    } else if (frameCount == 110) {
      bird.play();
    } else if (frameCount == 250) {
      bird.stop();
    } else if (frameCount == 270) {
      sun.play();
    }
    
}

function cloud(x,y) { //cloud shape draw
  push();
  translate(x,y);
  noStroke();
  fill(235,242,255);
  ellipse(0,0,100);
  ellipse(87,0,115);
  ellipse(160,0,95);
  pop();
}

function raindrop(x,y,t) { //rain drops shape draw
  push();
  rectMode(CENTER);
  translate(x,y);
  noStroke();
  fill(100,178,255,t);
  rect(0,10,10,50);
  rect(40,0,10,50);
  rect(80,15,10,50);
  pop();
}


Project-10: Sonic Story (& Media Sound Files)

For my project, I animated a short story about a frog on a lily pad on a lake. The story is simply about a lonely frog who gets excited to eat a fly that comes alone (because it was hungry), and gets sad when a nearby fish swims away. There is thunder and lightning that turns the sky dark, and the frog wishes the fish had stayed with him. This project was pretty difficult because there were many things to account for, like all of the coordinates, movements, sounds, and captions. I had to refresh my canvas multiple times to make sure everything was playing out the way I wanted it to. I was tempted to import images into my code, but wanted to challenge myself, so I decided to create all the images and shapes/objects myself.

My 4 sounds consist of the following: a loud thunder that echoes, a rippling/swishing noise of water, a loud croaking of a frog, and a (very irritating) buzzing of a fly. I used the buzzing sound of the fly to make sure the viewer could understand that the shape I had created was some sort of bug/fly. With the frog, I wanted to make sure its croaking was heard after it ate the fly to show some emotion. With the loud thunder, I used it to make the story more dark and scary, followed by a sudden darkening of the sky. With the water noises, I used that to make the night sounds seem louder and make it more clear that the fish had swam away.

sketch
//Annie Kim
//anniekim@andrew.cmu.edu
//SectionB
//anniekim-10-project

/* 
For my program, this is the general story line:
A lonely frog who is on a lilypad in the middle
of the water, is there with a fish. A fly comes near
the frog, and the frog eats it. Luckily, the frog is 
happy because it was getting hungry, however it is not 
so lucky for the fly. Then suddenly, lightning strikes,
and thunder echoes through the sky, and the sky turns dark.
The fish swims away in fear, and the frog is left alone again.
*/

var fly; //audio file names
var frogcroak;
var thunder;
var water;

var bug = {
    x: 450, y: 180,
    width: 45, height: 25
}
var lily = {
    x: 110, y: 320, 
    width: 200, height: 90
}
var lily1 = {
    x: 110, y: 320,
    width: 200, height: 90
}
var tongue_move = {
    x: 240, y: 220
}
var cloud = {
    x: 50, y: 75
}
var crab = {
    x: 400, y: 370,
}
var fish = {
    x: 225, y: 440,
}


function preload() {
    // call loadImage() and loadSound() for all media files here
    fly = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/fly-1.wav")
    frogcroak = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/frogcroak.wav")
    thunder = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/thunder.wav")
    water = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/water.wav")
}


function setup() {
    // you can change the next 2 lines:
    createCanvas(450, 480);
    useSound();
    frameRate(1);
}


function soundSetup() { // setup for audio generation
    // you can replace any of this with your own audio code:
    fly.setVolume(0.25);
    frogcroak.setVolume(0.75);
    thunder.setVolume(0.75);
    water.setVolume(0.8);
}


function draw() {
    //sky color
    background(217, 243, 245);
    //water
    fill(150, 214, 250);
    noStroke();
    rect(0, 250, 450, 230);
    //calling fish object
    fishy();
    //lilypad1 ~stagnant, doesnt move
    strokeWeight(2);
    stroke(100, 175, 0);
    fill(150, 225, 0);
    ellipse(lily1.x, lily1.y, lily1.width, lily1.height);
    fill(150, 214, 250); //making cut into lily pad
    noStroke();
    triangle(lily1.x, lily1.y, lily1.x - 100, lily1.y + 15, lily1.x - 50, lily1.y + 60);
    //calling cloud object
    clouds();
    //calling froggy object
    froggy();
    //fly & tongue movement + sound
    if (frameCount >= 1 && frameCount <= 7) {
        flying();
        fill(0);
        textSize(17);
        strokeWeight(1);
        textFont('HelveticaBold');
        text("The fly accidentally gets too close to the hungry frog.", 10, 100);
        tongue();
        fly.play();
    }
    if (frameCount == 7) {
        fly.stop(); //stops sound once fly disappears
    }
    if (frameCount >= 9 & frameCount <= 13) {
        frogcroak.play();
    }
    if (frameCount == 13) {
        frogcroak.stop();
    }
    if (frameCount == 25) {
        background(0);
        textSize(40);
        fill(255);
        strokeWeight(1);
        textFont('HelveticaBold');
        text("The End", 150, 240);
        water.stop();
        noLoop();
    }
}

function flying() {
    //creating 1st fly wing
    fill(255);
    stroke(0);
    ellipse(bug.x + 10, bug.y - 12, bug.width - 15, bug.height - 10);
    //creating fly body
    fill(0);
    noStroke();
    ellipse(bug.x, bug.y, bug.width, bug.height);
    //creating 2nd fly wing
    fill(255);
    stroke(0);
    ellipse(bug.x + 12, bug.y - 10, bug.width - 15, bug.height - 10);
    //making fly move
    bug.x = bug.x - 65;
    if (bug.x <=  200) {
        bug.x = 200;
    }
}

function froggy() {
    //light green color
    fill(117, 176, 111);
    //legs
    stroke(0);
    strokeWeight(3);
    ellipse(lily.x - 15, lily.y - 43, 35, 55);
    ellipse(lily.x + 65, lily.y - 43, 35, 55);
    //body
    ellipse(lily.x + 25, lily.y - 50, 80, 90);
    //feet
    fill(117, 176, 111);
    //arc(lily1.x - 3, lily1.y - 5, 40, 25, PI, 0);
    arc(lily.x + 4, lily.y - 5, 40, 30, PI, 0, CHORD);
    arc(lily.x + 46, lily.y - 5, 40, 30, PI, 0, CHORD);
    //head
    stroke(0);
    ellipse(lily.x + 25, lily.y - 105, 100, 80);
    //smile
    fill(100, 0, 0);
    arc(lily.x + 25, lily.y - 100, 70, 40, 0, PI, CHORD);
    //ears
    fill(117, 176, 111);
    circle(lily.x, lily.y - 140, 38);
    circle(lily.x + 47, lily.y - 140, 38);
    noStroke();
    circle(lily.x + 4, lily.y - 132, 36);
    circle(lily.x + 43, lily.y - 132, 36);
    //white part of eyes
    stroke(0);
    strokeWeight(2);
    fill(255);
    circle(lily.x + 47, lily.y - 140, 23);
    circle(lily.x, lily.y - 140, 23);
    //black of eyes
    fill(0);
    circle(lily.x + 47, lily.y - 140, 10);
    circle(lily.x, lily.y - 140, 10);
    //this will make the frog jump
    if (frameCount >= 9 & frameCount <= 10) {
        lily.y -= 150;
        textSize(20);
        strokeWeight(1);
        textFont('HelveticaBold');
        fill(0);
        text("The frog jumps with joy because it was hungry.", 15, 380);
    }
    if (frameCount >= 10 & frameCount <= 11) {
        lily.y += 150;
    }
}

function tongue() {
    strokeWeight(17);
    stroke(100, 0, 0);
    line(tongue_move.x, tongue_move.y - 10, 135, 230);
    //moving tongue to catch fly
    tongue_move.y -= 5;
    tongue_move.x -= 5;
    if (tongue_move.y <= 200) {
        tongue_move.y = 200;
    }
    if (tongue_move.x <= 220) {
        tongue_move.x = 220;
    }
}

function clouds() {
    if (frameCount >= 14 & frameCount <= 18) {
        darksky();
        lightning();
        textSize(28);
        fill(0);
        textFont('HelveticaBold');
        text("The sky shakes with thunder.", 100, 390);
        thunder.play();
    }
    if (frameCount >= 19 & frameCount <= 25) {
        darksky();
        thunder.stop();
        water.play();
    }
    fill(255);
    //left cloud
    circle(cloud.x, cloud.y, 100);
    circle(cloud.x - 45, cloud.y, 70);
    circle(cloud.x + 55, cloud.y, 55);
    //right cloud
    circle(cloud.x + 300, cloud.y - 30, 100);
    circle(cloud.x + 255, cloud.y - 30, 70);
    circle(cloud.x + 355, cloud.y - 30, 55);
    //clouds moving
    cloud.x += 5;
}

function lightning() {
    fill(255, 255, 0);
    quad(cloud.x, cloud.y, cloud.x - 20, cloud.y + 70, cloud.x + 10, cloud.y + 90, cloud.x + 30, cloud.y + 20);
    quad(cloud.x + 2, cloud.y + 75, cloud.x - 10, cloud.y + 145, cloud.x + 12, cloud.y + 165, cloud.x + 32, cloud.y + 95);
}

function darksky() {
    fill(160);
    rect(0, 0, 450, 250);
}

function fishy() {
    //body and tail
    fill(237, 104, 74);
    strokeWeight(1);
    stroke(255, 0, 0);
    ellipse(fish.x - 38, fish.y - 5, 17, 30);
    ellipse(fish.x - 38, fish.y + 5, 17, 30);
    ellipse(fish.x - 8, fish.y - 26, 30, 25);
    ellipse(fish.x, fish.y, 70, 60);
    //face of fish
    fill(255, 122, 92);
    ellipse(fish.x + 10, fish.y, 53, 54);
    //eyes of fish
    fill(255);
    stroke(0);
    circle(fish.x + 9, fish.y - 5, 18, 18);
    circle(fish.x + 27, fish.y - 5, 18, 18);
    fill(0);
    circle(fish.x + 9, fish.y - 5, 6, 6);
    circle(fish.x + 27, fish.y - 5, 6, 6);
    //bottom fin
    fill(237, 104, 74);
    stroke(155, 0, 0);
    triangle(fish.x, fish.y + 22, fish.x - 20, fish.y + 23, fish.x - 4, fish.y + 38);
    //smile
    noFill();
    arc(fish.x + 18, fish.y + 10, 20, 10, 0, PI);
    //fish is moving off of the canvas
    if (frameCount >= 19 & frameCount <= 25) {
        fish.x += 55;
        fish.y -= 36;
        fill(0);
        textFont('HelveticaBold');
        textSize(20);
        text("The frog wishes the fish would stay.", 50, 450);
        text("The frog doesn't want to be alone in the storm.", 50, 400);
    }
}

















This is the image of a frog that I used as reference when drawing the shape on p5js.