diff --git a/public/assets/sounds/connect.wav b/public/assets/sounds/connect.wav new file mode 100644 index 0000000..4f28a69 Binary files /dev/null and b/public/assets/sounds/connect.wav differ diff --git a/src/App.vue b/src/App.vue index 46787aa..d2b4a03 100644 --- a/src/App.vue +++ b/src/App.vue @@ -20,9 +20,12 @@ import { useMapEditorComposable } from '@/composables/useMapEditorComposable' import { useGameStore } from '@/stores/gameStore' import { useMapEditorStore } from '@/stores/mapEditorStore' import { computed, ref, useTemplateRef, watch } from 'vue' +import { useGameComposable } from '@/composables/useGameComposable' const gameStore = useGameStore() + const mapEditor = useMapEditorComposable() +const { playSound } = useGameComposable() const currentScreen = computed(() => { if (!gameStore.game.isLoaded) return Loading @@ -45,8 +48,7 @@ watch( // @TODO: Not all button-like elements will actually be a button, so we need to find a better way to do this addEventListener('click', (event) => { if (!(event.target instanceof HTMLButtonElement)) return - const audio = new Audio('/assets/sounds/button-click.wav') - audio.play() + playSound('/assets/sounds/button-click.wav') }) // Watch for "G" key press and toggle the gm panel diff --git a/src/components/screens/Game.vue b/src/components/screens/Game.vue index b099b87..95183a8 100644 --- a/src/components/screens/Game.vue +++ b/src/components/screens/Game.vue @@ -29,8 +29,10 @@ import Menu from '@/components/game/gui/Menu.vue' import Map from '@/components/game/map/Map.vue' import { useGameStore } from '@/stores/gameStore' import { Game, Scene } from 'phavuer' +import { useGameComposable } from '@/composables/useGameComposable' const gameStore = useGameStore() +const { playSound } = useGameComposable() const gameConfig = { name: config.name, @@ -57,6 +59,8 @@ const createGame = (game: Phaser.Game) => { }) gameStore.disconnectSocket() } + + playSound('/assets/sounds/connect.wav') } function preloadScene(scene: Phaser.Scene) {