diff options
Diffstat (limited to 'src/index.html.in')
-rw-r--r-- | src/index.html.in | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/index.html.in b/src/index.html.in index 8d0ccea..aca8b6d 100644 --- a/src/index.html.in +++ b/src/index.html.in @@ -36,6 +36,9 @@ const INPUT_PAUSE_PLAY = 3; const WASM = #include "../build/main.wasm.b64" +const MUSIC = +#include "../build/music.mp3.b64" + async function main() { let bytes = Uint8Array.from(atob(WASM), function(c) { return c.charCodeAt(0); @@ -48,6 +51,12 @@ async function main() { let ctx = canvas.getContext("2d"); let memory = exports.memory; + const audio = new Audio(); + audio.src = MUSIC; + audio.volume = 0.2; + audio.loop = true; + let musicPlaying = false; + const start = Date.now(); function now() { return Date.now() - start; @@ -94,6 +103,10 @@ async function main() { e.preventDefault(); exports.game_update(INPUT_RCLICK, mousex, mousey, now()); } + if (!musicPlaying) { + musicPlaying = true; + audio.play(); + } }); canvas.addEventListener("contextmenu", function (e) { |