Skip to content

Commit

Permalink
added sound for each object, makes decent(ish) cresendo
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Irving authored and Will Irving committed May 25, 2021
1 parent 8dab8fa commit dfa1921
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 11 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Browser game built using HTML, CSS and JS

create switch statement for different objects (depending on input integer)

3. Add ideas class (with sound)

4. Configure mechanics so that collision increases feedback

++) Add background soundscape
Expand All @@ -28,9 +26,11 @@ create switch statement for different objects (depending on input integer)

++ random speed of objects (1-10);

++ change object path (via. touchdesigner)

5. Add more objects

6. Change direction of avatar on click
6. Change choice of avatar (on load)

++) refine sound track/sound components

Expand All @@ -40,12 +40,15 @@ increase density of objects depending on screen size

8. Add sound fx over time - reverb, delay etc.

scale objects and player for smaller browser

++ add font scaling function // seperate canvas for score
?? change path of objects (sometimes arising from horizontal direction)?

// rules

density > over time

feedback ++ when you hit objects

++ create imports/exports for functions and write a test for some of them
// write some function tests
32 changes: 25 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
let score = 0;
let gameFrame = 0;

let densityModulo = 50;
let feedbackModulo = 1;
let densityModulo = 1;
let feedbackModulo = 5000;

// GLOBAL FUNCTIONS

Expand Down Expand Up @@ -203,7 +203,7 @@ const objectArray = [];

let shuffledArray = shuffleArr(objectLoader);

function handleObjects() {
const handleObjects = () => {
if (gameFrame % densityModulo == 0) {
//every 50 frames..

Expand Down Expand Up @@ -396,12 +396,12 @@ function handleObjects() {
}

for (let i = 0; i < objectArray.length; i++) {
// call update and draw methods for each bubbles in the array
// call update and draw methods for each object in the array
objectArray[i].update();
objectArray[i].draw();
}

// when y position > 0 then delete bubbles. 0 - this.radius * 2 ensures full bubbles has passed
// when y position > 0 then delete object. 0 - this.radius * 2 ensures full bubbles has passed

for (let i = 0; i < objectArray.length; i++) {
if (objectArray[i].y < 0 - objectArray[i].radius * 2) {
Expand All @@ -412,7 +412,7 @@ function handleObjects() {
if (objectArray[i].distance < objectArray[i].radius + player.radius) {
// this line allows us to set the score only once per bubble, even though multiple collisions will continue to be registered
if (!objectArray[i].counted) {
if (objectArray[i].sound == "milk") {
if (objectArray[i].sound == "yakyu") {
soundArray[0].play();
} else if (objectArray[i].sound == "folder") {
soundArray[1].play();
Expand All @@ -424,6 +424,24 @@ function handleObjects() {
soundArray[4].play();
} else if (objectArray[i].sound == "humberg") {
soundArray[5].play();
} else if (objectArray[i].sound == "kamakiri") {
soundArray[6].play();
} else if (objectArray[i].sound == "master") {
soundArray[7].play();
} else if (objectArray[i].sound == "milk") {
soundArray[8].play();
} else if (objectArray[i].sound == "pencil") {
soundArray[9].play();
} else if (objectArray[i].sound == "ramensoup") {
soundArray[10].play();
} else if (objectArray[i].sound == "shows") {
soundArray[11].play();
} else if (objectArray[i].sound == "tomato") {
soundArray[12].play();
} else if (objectArray[i].sound == "tyun") {
soundArray[13].play();
} else if (objectArray[i].sound == "usagi") {
soundArray[14].play();
}
score++;
objectArray[i].counted = true;
Expand All @@ -433,7 +451,7 @@ function handleObjects() {
}
// collision detection, using distance of each bubble agaisnt player radius
}
}
};

// ANIMATION LOOP

Expand Down
Binary file modified sounds/0.mp3
Binary file not shown.
Binary file modified sounds/1.mp3
Binary file not shown.
Binary file modified sounds/10.mp3
Binary file not shown.
Binary file modified sounds/11.mp3
Binary file not shown.
Binary file modified sounds/12.mp3
Binary file not shown.
Binary file modified sounds/13.mp3
Binary file not shown.
Binary file modified sounds/14.mp3
Binary file not shown.
Binary file modified sounds/2.mp3
Binary file not shown.
Binary file modified sounds/3.mp3
Binary file not shown.
Binary file modified sounds/4.mp3
Binary file not shown.
Binary file modified sounds/5.mp3
Binary file not shown.
Binary file modified sounds/6.mp3
Binary file not shown.
Binary file modified sounds/7.mp3
Binary file not shown.
Binary file modified sounds/8.mp3
Binary file not shown.
Binary file modified sounds/9.mp3
Binary file not shown.

0 comments on commit dfa1921

Please sign in to comment.