diff --git a/src/App.svelte b/src/App.svelte
index 90e5473..4250a8d 100644
--- a/src/App.svelte
+++ b/src/App.svelte
@@ -7,7 +7,8 @@
import { gameActive, menuActive, page } from "./stores/gameActive";
import Menu from "./pages/menu.svelte";
import CrashHandler from "./pages/crashHandler.svelte";
- import { startPlaying } from "./stores/music";
+ import { startPlaying, isPlaying } from "./stores/music";
+ import { fade } from "svelte/transition";
var preloads = new Map;
function preload(url) {
@@ -69,6 +70,12 @@
{/if}
+{#if !$isPlaying}
+
+ Click anywhere for sound.
+
+{/if}
+
{#if dialog[$page].map}
{/if}
@@ -99,4 +106,14 @@
vertical-align: middle;
line-height: normal;
}
+ .play-notif {
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100vw;
+ text-align: center;
+ background-image: linear-gradient(to bottom, rgba(0,0,0,0.7), rgba(0,0,0,0.0));
+ z-index: 98;
+ font-size: x-large;
+ }
\ No newline at end of file
diff --git a/src/stores/music.js b/src/stores/music.js
index 0cf36a3..3b55cdc 100644
--- a/src/stores/music.js
+++ b/src/stores/music.js
@@ -1,4 +1,5 @@
import { Howl } from "howler";
+import { writable } from "svelte/store";
export const musicStore = {
departure: {
@@ -13,6 +14,8 @@ export const musicStore = {
export class Music {
static current = musicStore.departure;
+ static isPlaying = writable(false);
+
/**
* @param {keyof musicStore} key
*/
@@ -21,6 +24,11 @@ export class Music {
this.current = musicStore[key];
if(!this.current.howl) this.prepare();
this.current.howl.play();
+ if(this.current.howl.playing()) {
+ this.isPlaying.set(true);
+ }
+ this.current.howl.on("play", () => this.isPlaying.set(true));
+ this.current.howl.on("pause", () => this.isPlaying.set(false));
}
static prepare() {
@@ -32,13 +40,17 @@ export class Music {
}
static startPlaying() {
- if(!this.current.howl.playing())
+ if(!this.current.howl.playing()) {
this.current.howl.play();
+ this.isPlaying.set(true);
+ }
}
}
Music.prepare();
Music.startPlaying();
+export const isPlaying = Music.isPlaying;
+
export function startPlaying(e) {
Music.startPlaying();
}
\ No newline at end of file