Arrow keys to move around, space to shoot.
import sono from 'sono';
import {loaders} from 'pixi.js';
const ext = sono.canPlay.ogg ? 'ogg' : 'mp3';
if (sono.hasWebAudio) {
const {Resource} = loaders;
Resource.setExtensionLoadType(ext, Resource.LOAD_TYPE.XHR);
Resource.setExtensionXhrType(ext, Resource.XHR_RESPONSE_TYPE.BUFFER);
}
const sounds = [{
name: 'music',
url: `audio/space-shooter.${ext}`,
loop: true,
volume: 0.8
}, {
name: 'shoot',
url: `audio/shoot3.${ext}`,
volume: 0.4
}, {
name: 'explode',
url: `audio/explode2.${ext}`,
volume: 0.9
}];
const loader = new loaders.Loader();
loader.add(sounds);
loader.onComplete.once(() => {
sounds.forEach(sound => {
const src = loader.resources[sound.name].data;
const config = Object.assign({}, sound, {src});
sono.create(config);
});
sono.get('shoot').effects.add(reverb();
sono.play('music');
});
loader.load();