Skip to content

Commit

Permalink
add audio and images
Browse files Browse the repository at this point in the history
  • Loading branch information
Sami Oldham committed Nov 22, 2023
1 parent b7fbab2 commit fc403fd
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 8 deletions.
Binary file added assets/audio/audio10.mp3
Binary file not shown.
Binary file added assets/audio/audio11.mp3
Binary file not shown.
Binary file added assets/audio/audio7.mp3
Binary file not shown.
Binary file added assets/audio/audio8.mp3
Binary file not shown.
Binary file added assets/audio/audio9.mp3
Binary file not shown.
Binary file modified assets/images/img10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/img11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/img13.jpg
Binary file not shown.
Binary file removed assets/images/img14.jpg
Binary file not shown.
Binary file removed assets/images/img15.jpg
Binary file not shown.
Binary file modified assets/images/img8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/img9.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 32 additions & 8 deletions assets/js/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class obj {

setUp(imgPosX, imgPosY, imgSize) {
this.imgSize = imgSize;
this.imgSizeCpy = imgSize;
this.imgPosX = imgPosX;
this.imgPosY = imgPosY;
this.sound.loop();
Expand All @@ -29,7 +30,7 @@ class obj {
}

draw() {
let distanceFromImage = (1 - dist(mouseX, mouseY, this.imgPosX, this.imgPosY) / (this.imgSize * 4));
let distanceFromImage = (1 - dist(mouseX, mouseY, this.imgPosX, this.imgPosY) / (this.imgSize * 3.75));
if(distanceFromImage < 0){
distanceFromImage = 0.01;
}
Expand All @@ -40,7 +41,7 @@ class obj {
let rms = this.analyzer.getLevel();
this.sound.amp(distanceFromImage);

this.finalSize = this.imgSize + rms * 750;
this.finalSize = this.imgSize + rms * 650;

imageMode(CENTER);
image(this.img, this.imgPosX, this.imgPosY, this.finalSize, this.finalSize);
Expand All @@ -65,6 +66,7 @@ class obj {
this.isDragging = true;
this.imgPosX = mouseX;
this.imgPosY = mouseY;
this.imgSize = this.imgSizeCpy*4;
}
}

Expand All @@ -78,6 +80,7 @@ class obj {

mouseReleased() {
// Stop dragging when the mouse is released
this.imgSize = this.imgSizeCpy;
this.isDragging = false;
}

Expand All @@ -103,7 +106,7 @@ function backroundShape(){

angle += 0.02;
}
let num = 6;
let num = 12;
// to load all of mt images and sounds we can put it in an array, then loop through the dir until there are none left, the naming should be img1, sound1, ext...
function preload() {
soundFormats('mp3', 'ogg');
Expand All @@ -129,11 +132,17 @@ function setup() {

audioCtx = getAudioContext();
audioCtx.suspend();

let imgWidth;
if(width > height){
imgWidth = height/8;
}
else{
imgWidth = width/8;
}
for(let i = 0; i < imageObjects.length -1; i++){
//add a function to get a suiteble random size and position for each image
let crnt = imageObjects[i];
crnt.setUp(random(width), random(height), width/8);
crnt.setUp(random(width), random(height), imgWidth);
}
ccStartUp();

Expand All @@ -157,7 +166,8 @@ function draw() {
}
textSize(30);
if(!started){
strokeWeight(5);
noStroke();
fill(75)
text('Click to start!', 0, 30);
}
}
Expand Down Expand Up @@ -189,13 +199,27 @@ function mouseReleased() {
}
}


function windowResized() {
resizeCanvas(windowWidth, windowHeight);
background(25);
for(let i = 0; i < imageObjects.length -1; i++){
//add a function to get a suiteble random size and position for each image
let crnt = imageObjects[i];
crnt.imgPosX = random(width);
crnt.imgPosY = random(height);
}
}


function windowResized() {
resizeCanvas(windowWidth, windowHeight);
background(25);
for(let i = 0; i < imageObjects.length -1; i++){
//add a function to get a suiteble random size and position for each image
let crnt = imageObjects[i];
crnt.imgPosX = random(width);
crnt.imgPosY = random(height);
}
}


///////////////////////////////////////////////////
Expand Down

0 comments on commit fc403fd

Please sign in to comment.