Skip to content

Commit

Permalink
feat(sound): absorption sound
Browse files Browse the repository at this point in the history
  • Loading branch information
pathes committed Mar 19, 2016
1 parent 19d56d3 commit be33335
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 2 deletions.
7 changes: 6 additions & 1 deletion js/particles.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ class ParticleAnimation {
.remove();

this.measurementTextGroup.datum(measurement)
.each((d) => (d.measured && d.tile != null) ? d.tile.absorbAnimation() : null);
.each((d) => {
if (d.measured && d.tile != null) {
d.tile.absorbSound();
d.tile.absorbAnimation();
}
});
});

}
Expand Down
16 changes: 16 additions & 0 deletions js/sound_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ const SOUND_DEFS = {
file: 'error.mp3',
throttleMs: 250,
},
detector: {
file: 'detector.mp3',
throttleMs: 100,
},
mine: {
file: 'mine.mp3',
throttleMs: 1000,
},
rock: {
file: 'rock.mp3',
throttleMs: 1000,
},
absorber: {
file: 'absorber.mp3',
throttleMs: 1000,
},
};


Expand Down
18 changes: 17 additions & 1 deletion js/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import changeCase from 'change-case';

import * as config from './config';
import * as full from './tensor/full';
import {SoundService} from './sound_service';

export const Vacuum = {
svgName: 'vacuum',
Expand Down Expand Up @@ -235,6 +236,9 @@ export const Mine = {
maxRotation: 1, // []
rotationAngle: 360,
transition: () => full.zero,
absorbSound: () => {
SoundService.play('mine');
},
absorbAnimation: (that) => {

const gDom = that.g[0][0];
Expand Down Expand Up @@ -270,6 +274,9 @@ export const Rock = {
maxRotation: 1, // []
rotationAngle: 360,
transition: () => full.zero,
absorbSound: () => {
SoundService.play('rock');
},
};

export const Glass = {
Expand Down Expand Up @@ -306,6 +313,9 @@ export const Absorber = {
maxRotation: 1, // []
rotationAngle: 360,
transition: () => full.absorber,
absorbSound: () => {
SoundService.play('absorber');
},
};

export const Detector = {
Expand All @@ -318,6 +328,9 @@ export const Detector = {
maxRotation: 4, // > ^ < v
rotationAngle: 90,
transition: () => full.zero,
absorbSound: () => {
SoundService.play('detector');
},
absorbAnimation: (that) => {

that.g.append('use')
Expand All @@ -328,7 +341,6 @@ export const Detector = {
.duration(config.absorptionDuration)
.style('opacity', 0)
.remove();

},
};

Expand Down Expand Up @@ -386,6 +398,10 @@ export class Tile {

}

absorbSound() {
(this.type.absorbSound || _.noop)();
}

absorbAnimation() {

// NOTE or maybe just class inheritance?
Expand Down
Binary file added sounds/absorber.mp3
Binary file not shown.
Binary file added sounds/detector.mp3
Binary file not shown.
Binary file added sounds/mine.mp3
Binary file not shown.
Binary file added sounds/rock.mp3
Binary file not shown.

0 comments on commit be33335

Please sign in to comment.