/* * Armawebtron - A lightcycle game. * Copyright (C) 2019 Glen Harpring * This file was mostly written by Durf. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ var ctx = new AudioContext(); var bufferLoader = new BufferLoader( ctx, [ "",//0 "",//1 "",//2 "sounds/tr2n_origins/cyclrun.wav",//3 "sounds/gltron/game_engine.ogg",//4 "sounds/arma/cyclrun.wav",//5 "",//0 "",//1 "",//2 "sounds/tr2n_origins/expl.ogg",//3 "sounds/tr2n_origins/expl.ogg",//3 "sounds/tr2n_origins/expl.ogg",//3 //"sounds/gltron/game_crash.ogg",//4 //"sounds/arma/expl.ogg",//5 //other sounds: "sounds/gltron/game_recognizer.wav", "sounds/tr2n_origins/intro.wav", "sounds/tr2n_origins/extro.wav", "sounds/zone_spawn.ogg", ] ); bufferLoader.load(); bufferLoader.other = 12; var playSound = function(buffer, vol, pitch, loop, output) { var src = ctx.createBufferSource(); src.gainNode = ctx.createGain(); src.connect(src.gainNode); src.gainNode.connect(output); src.buffer = buffer; src.gainNode.gain.value = vol; src.playbackRate.value = pitch; src.loop = loop; src.start(ctx.currentTime); return src; }; function toggleSoundType() //safely changes the sound panners in settings, and players (not used anywhere) { if (engine.retroSound == true) { engine.retroSound = false; } else { engine.retroSound = true; } var p = "HRTF"; if (!engine.retroSound) { p = "equalpower" } //assume a change for(var x=0;x 0) engine.camera.position.set(engine.logicalBox.center.x*engine.REAL_ARENA_SIZE_FACTOR,engine.logicalBox.center.y*engine.REAL_ARENA_SIZE_FACTOR,0); return false; } }; function changeSoundPanner(type) { switch(type) { case "EQ": case "HQ": case "equalpower": cycle.audio.panner.panningModel = "equalpower"; break; case "HRTF": case "LQ": cycle.audio.panner.panningModel = "HRTF"; break; default: cycle.audio.panner.panningModel = "equalpower"; break; } } function changeEngineSound(cycle,choice) { cycle.engineType = choice; cycle.engineSound.stop(); cycle.engineSound = playSound(bufferLoader.bufferList[choice], 0.5, 1, true, cycle.audio); } function audioStop() { if(!ctx) return; for(var x=0;x