diff --git a/public/audio/thwomp.ogg b/public/audio/thwomp.ogg new file mode 100644 index 00000000..51e5973e Binary files /dev/null and b/public/audio/thwomp.ogg differ diff --git a/public/js/entities.js b/public/js/entities.js index 555c6029..5a1f6174 100644 --- a/public/js/entities.js +++ b/public/js/entities.js @@ -18,7 +18,7 @@ export async function loadEntities(audioContext) { loadBulletBill(audioContext).then(addAs('bulletBill')), ]); - entityFactories['cannon'] = loadCannon(entityFactories); + await loadCannon(entityFactories, audioContext).then(addAs('cannon')); return entityFactories; } diff --git a/public/js/entities/Cannon.js b/public/js/entities/Cannon.js index 999cc444..bbf6e823 100644 --- a/public/js/entities/Cannon.js +++ b/public/js/entities/Cannon.js @@ -1,12 +1,16 @@ import {findPlayers} from '../player.js'; import Entity, {Trait} from '../Entity.js'; import Emitter from '../traits/Emitter.js'; +import {loadAudioBoard} from '../loaders/audio.js'; -export function loadCannon(entityFactory) { - return createCannonFactory(entityFactory); +export function loadCannon(entityFactory, audioContext) { + return loadAudioBoard('cannon', audioContext) + .then(audio => { + return createCannonFactory(entityFactory, audio); + }); } -function createCannonFactory(entityFactory) { +function createCannonFactory(entityFactory, audio) { const createBullet = entityFactory.bulletBill; const bulletEmitter = (entity, level) => { @@ -24,6 +28,7 @@ function createCannonFactory(entityFactory) { return function createCannon() { const cannon = new Entity(); + cannon.audio = audio; const emitter = new Emitter(); emitter.interval = 4; diff --git a/public/sounds/cannon.json b/public/sounds/cannon.json new file mode 100644 index 00000000..058f433d --- /dev/null +++ b/public/sounds/cannon.json @@ -0,0 +1,7 @@ +{ + "fx": { + "shoot": { + "url": "/audio/thwomp.ogg" + } + } +}