sketchDownload
//Carson Michaelis
//Section B
var frameCount = 0;
var rackTime = 0;
var pinsTime = 0;
var ballTime = 0;
var ballColor = 0;
var knockedTime = 0;
var pinsX = [100, 77, 100, 55, 32, 77, 133, 145, 158, 133];
var pinsY = [40, 30, 18, 18, 6, 6, 30, 18, 6, 6];
var pinsAngles = [];
var rollSound;
var strikeSound;
var backgroundSound;
var cheerSound;
function preload() {
// NAME OF SOUND = loadSound("web address");
rollSound = loadSound("http://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/CarsonRoll.wav");
strikeSound = loadSound("http://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/CarsonStrike.wav");
backgroundSound = loadSound("http://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/CarsonBackground.wav");
cheerSound = loadSound("http://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/CarsonCheer.wav");
//image loading
bowlingLane = loadImage("https://i.imgur.com/58QdPGi.jpg");
}
function setup() {
createCanvas(200, 400);
frameRate(20);
background(220);
ballColor = color(random(100,200),75,75);
for (let i = 0; i < 10; i ++) {
pinsAngles[i] = random(360);
}
useSound();
}
function soundSetup() {
rollSound.setVolume(1);
strikeSound.setVolume(.5);
backgroundSound.setVolume(.25);
cheerSound.setVolume(.25);
}
function draw() {
background(220);
bowlingLane.resize(160,400);
image(bowlingLane,20,0);
rack(rackTime);
bowlingPins(pinsTime);
bowlingBall(ballTime);
pinsKnocked(knockedTime);
frameCount++;
if (frameCount > 50 & frameCount < 175) {rackTime++; pinsTime++;}
if (frameCount > 225) {rackTime = 0;}
if (frameCount > 250) {ballTime -= 1;}
if (frameCount > 330 & frameCount < 350) {knockedTime++; pinsTime = -100;}
backgroundSound.play();
if (frameCount > 250 & frameCount < 330) {rollSound.play();}
if (frameCount > 330 & frameCount < 360) {strikeSound.play();}
if (frameCount > 360 & frameCount < 500) {cheerSound.play();}
}
function rack(t) {
push();
noStroke();
fill(100);
rect(15,0+t,170,-10);
fill(50);
rect(15,-10+t,5,-100);
rect(180,-10+t,5,-100);
pop();
}
function bowlingBall (t) {
push();
noStroke();
fill(ballColor);
circle(100,height+20+(t*9),30);
pop();
}
function bowlingPins(t) {
push();
fill(255);
noStroke();
circle(100,40-64+t,15);
circle(77,30-64+t,15);
circle(100,18-64+t,15);
circle(55,18-64+t,15);
circle(32,6-64+t,15);
circle(77,6-64+t,15);
circle(100+(100-77),30-64+t,15);
circle(100+(100-100),18-64+t,15);
circle(100+(100-55),18-64+t,15);
circle(100+(100-32),6-64+t,15);
circle(100+(100-77),6-64+t,15);
strokeWeight(1);
stroke(255,0,0);
circle(100,40-64+t,9);
circle(77,30-64+t,9);
circle(100,18-64+t,9);
circle(55,18-64+t,9);
circle(32,6-64+t,9);
circle(77,6-64+t,9);
circle(100+(100-77),30-64+t,9);
circle(100+(100-100),18-64+t,9);
circle(100+(100-55),18-64+t,9);
circle(100+(100-32),6-64+t,9);
circle(100+(100-77),6-64+t,9);
pop();
}
function bowlingGutter() {
push();
noStroke();
fill();
rect(0,0,20,height);
rect(width-20,0,20,height);
}
function pinsKnocked(t) {
if (t > 1) {
for (let i = 0; i < 10; i++) {
push();
translate(pinsX[i],pinsY[i]);
if (frameCount < 350) {
rotate(radians(random(360)));
} else if (frameCount >= 350) {
rotate(radians(pinsAngles[i]));
}
pinSide();
pop();
}
}
}
function pinSide() {
push();
noStroke();
fill(255);
ellipse(0,0,5,15);
circle(0,-7,9);
strokeWeight(3);
stroke(255,0,0);
line(-4,-7,4,-7);
pop();
}
In my short story I decided to create a sonic scene of a bowling alley, since this week I watched The Big Lebowski to relieve some election stress.