diff --git a/package-lock.json b/package-lock.json index 5f5ac55..0673cd6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2535,9 +2535,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.93", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.93.tgz", - "integrity": "sha512-M+29jTcfNNoR9NV7la4SwUqzWAxEwnc7ThA5e1m6LRSotmpfpCpLcIfgtSCVL+MllNLgAyM/5ru86iMRemPzDQ==", + "version": "1.5.94", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.94.tgz", + "integrity": "sha512-v+oaMuy6AgwZ6Hi2u5UgcM3wxzeFscBTsZBQL2FoDTx/T6k1XEQKz++8fe1VlQ3zjXB6hcvy5JPb5ZSkmVtdIQ==", "dev": true, "license": "ISC" }, diff --git a/public/assets/music/click-btn.mp3 b/public/assets/sounds/click-btn.mp3 similarity index 100% rename from public/assets/music/click-btn.mp3 rename to public/assets/sounds/click-btn.mp3 diff --git a/public/assets/sounds/hit.wav b/public/assets/sounds/hit.wav new file mode 100644 index 0000000..5c9e089 Binary files /dev/null and b/public/assets/sounds/hit.wav differ diff --git a/src/App.vue b/src/App.vue index 39e5380..15df037 100644 --- a/src/App.vue +++ b/src/App.vue @@ -47,7 +47,7 @@ addEventListener('click', (event) => { if (!(event.target instanceof HTMLButtonElement)) { return } - const audio = new Audio('/assets/music/click-btn.mp3') + const audio = new Audio('/assets/sounds/click-btn.mp3') audio.play() }) diff --git a/src/components/game/character/Character.vue b/src/components/game/character/Character.vue index c38f109..e841e67 100644 --- a/src/components/game/character/Character.vue +++ b/src/components/game/character/Character.vue @@ -14,6 +14,7 @@ import CharacterHair from '@/components/game/character/partials/CharacterHair.vu import ChatBubble from '@/components/game/character/partials/ChatBubble.vue' import HealthBar from '@/components/game/character/partials/HealthBar.vue' import { useCharacterSpriteComposable } from '@/composables/useCharacterSpriteComposable' +import { useGameComposable } from '@/composables/useGameComposable' import { useGameStore } from '@/stores/gameStore' import { useMapStore } from '@/stores/mapStore' import { Container, Sprite, useScene } from 'phavuer' @@ -29,13 +30,13 @@ const mapStore = useMapStore() const scene = useScene() const { characterContainer, characterSprite, currentPositionX, currentPositionY, isometricDepth, isFlippedX, updatePosition, playAnimation, calcDirection, updateSprite, initializeSprite, cleanup } = useCharacterSpriteComposable(scene, props.tileMap, props.mapCharacter) +const { playSound } = useGameComposable() const handlePositionUpdate = (newValues: any, oldValues: any) => { if (!newValues) return if (!oldValues || newValues.positionX !== oldValues.positionX || newValues.positionY !== oldValues.positionY) { - const direction = !oldValues ? Direction.POSITIVE : calcDirection(oldValues.positionX, oldValues.positionY, newValues.positionX, newValues.positionY) - updatePosition(newValues.positionX, newValues.positionY, direction) + updatePosition(newValues.positionX, newValues.positionY) } if (newValues.isMoving !== oldValues?.isMoving || newValues.rotation !== oldValues?.rotation) { @@ -57,6 +58,8 @@ watch( if (props.mapCharacter.isAttacking) { // Play attack animation playAnimation('attack') + // Play hit sound + playSound('/assets/sounds/hit.wav') // Disable attack immediately after playing the animation mapStore.updateCharacterProperty(props.mapCharacter.character.id, 'isAttacking', false) } diff --git a/src/components/gameMaster/mapEditor/partials/SelectedPlacedMapObject.vue b/src/components/gameMaster/mapEditor/partials/SelectedPlacedMapObject.vue index 98963a7..a2365f5 100644 --- a/src/components/gameMaster/mapEditor/partials/SelectedPlacedMapObject.vue +++ b/src/components/gameMaster/mapEditor/partials/SelectedPlacedMapObject.vue @@ -26,11 +26,11 @@