diff --git a/audio.js b/audio.js index 4baccf3..7251d07 100644 --- a/audio.js +++ b/audio.js @@ -1,10 +1,17 @@ let playing = []; let looping = {}; +let audioContext; +let gainControl; + const audioBaseUrl = "./media/audio/"; let audioDict = {}; +function setVolume(vol) { + gainControl.gain.value = vol; +} + // play some sound function playSfx(name) { @@ -15,7 +22,7 @@ function playSfx(name) { let src = audioContext.createBufferSource(); src.buffer = audioDict[name]; - src.connect(audioContext.destination); + src.connect(gainControl); playing.push(src); @@ -173,6 +180,13 @@ function initAudio(story, state) { if (!audioContext) audioContext = new (window.AudioContext || window.webkitAudioContext)(); + if (!gainControl) { + gainControl = audioContext.createGain(); + gainControl.gain.value = 0.5; + gainControl.connect(audioContext.destination); + } + + createCache(); story.sounds.forEach(sound => { diff --git a/satiate.css b/satiate.css index c74a266..baed264 100644 --- a/satiate.css +++ b/satiate.css @@ -10,6 +10,10 @@ html, body, .scene { display: none; } +.hidden-modal { + display: none; +} + a { color: #8888FF; text-decoration: none; @@ -55,6 +59,7 @@ a:hover { font-size: 48px; color: #eee; } + .modal { position: fixed; z-index: 1; @@ -63,10 +68,59 @@ a:hover { left: 0; top: 0; background-color: rgba(0,0,0,0.5); + text-align: center; + display: flex; + justify-content: center; + align-content: center; + align-items: center; } .modal-content { - margin: 50%; + display: flex; + flex-direction: column; + justify-content: center; + align-content: center; + position: relative; + flex-wrap: nowrap; + text-align: center; + width: 300px; + padding: 100px; + background-color: rgba(0, 0, 0, 0.9); +} + +.menu-header { + width: 100%; + height: 75px; + font-size: 48px; +} + +.menu-button { + width: 100%; + height: 50px; + background-color: #111; + border: 1px solid #333; + font-size: 24px; + color: #eee; +} + +.menu-button:active { + background-color: #222; +} + +.menu-button:focus { + outline: 0px; +} + +.menu-slider { + background: #555; + width: 100%; + height: 50px; +} + +.menu-label { + width: 100%; + height: 25px; + font-size: 36px; } #info-area { @@ -93,12 +147,22 @@ a:hover { font-size: 24px; } -#menu { +#game-menu { margin: 10px; background: #222; flex: 2; } +.game-menu-button { + height: 100%; + width: 50%; + user-select: none; + background-color: #111; + border: 1px solid #333; + font-size: 48px; + color: #eee; +} + #world-info { margin: 10px; background: #222; diff --git a/satiate.html b/satiate.html index ff51b3c..c475bef 100644 --- a/satiate.html +++ b/satiate.html @@ -23,13 +23,13 @@