chg: usr: add sound when the game start #10
This commit is contained in:
@@ -49,6 +49,7 @@ export const GameProvider = ({ children }) => {
|
|||||||
mine: new Howl({ src: ['/sound/mine.mp3'] }),
|
mine: new Howl({ src: ['/sound/mine.mp3'] }),
|
||||||
warning: new Howl({ src: ['/sound/warning.mp3'] }),
|
warning: new Howl({ src: ['/sound/warning.mp3'] }),
|
||||||
won: new Howl({ src: ['/sound/won.mp3'] }),
|
won: new Howl({ src: ['/sound/won.mp3'] }),
|
||||||
|
starting: new Howl({ src: ['/sound/starting.mp3'] }),
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Sync helpers (keep ref + state in lockstep) */
|
/** Sync helpers (keep ref + state in lockstep) */
|
||||||
@@ -269,6 +270,8 @@ export const GameProvider = ({ children }) => {
|
|||||||
makeGameEndIfItEnds, resignProcess,
|
makeGameEndIfItEnds, resignProcess,
|
||||||
/** UI action */
|
/** UI action */
|
||||||
onBombToggle,
|
onBombToggle,
|
||||||
|
/** Sounds */
|
||||||
|
sounds,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const useServerCommunication = (gameAssoc, gameInherited, opponentName, isEnvDev
|
|||||||
/** Sync helpers */
|
/** Sync helpers */
|
||||||
syncWebPlayer, syncActivePlayer, syncBombSelected, syncConnLost, syncRed, syncBlue,
|
syncWebPlayer, syncActivePlayer, syncBombSelected, syncConnLost, syncRed, syncBlue,
|
||||||
/** Game logic */
|
/** Game logic */
|
||||||
showOverlay, hideOverlay, applyStep, makeGameEndIfItEnds, resignProcess,
|
showOverlay, hideOverlay, applyStep, makeGameEndIfItEnds, resignProcess, sounds,
|
||||||
/** Current cells snapshot (for active-check in onClick) */
|
/** Current cells snapshot (for active-check in onClick) */
|
||||||
cells,
|
cells,
|
||||||
} = useGame();
|
} = useGame();
|
||||||
@@ -212,6 +212,7 @@ const useServerCommunication = (gameAssoc, gameInherited, opponentName, isEnvDev
|
|||||||
*/
|
*/
|
||||||
if (!endRef.current && (!isTrueRestoredRef.current || 0 !== opponentLastSeenRef.current)) {
|
if (!endRef.current && (!isTrueRestoredRef.current || 0 !== opponentLastSeenRef.current)) {
|
||||||
hideOverlay();
|
hideOverlay();
|
||||||
|
sounds.current.starting.play();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
BIN
public/sound/starting.mp3
Normal file
BIN
public/sound/starting.mp3
Normal file
Binary file not shown.
Reference in New Issue
Block a user