feat : add sounds
This commit is contained in:
@@ -2,6 +2,7 @@ import { Button, CircularProgress, Grid, Typography } from "@mui/material";
|
||||
import { useAtom, useAtomValue } from "jotai";
|
||||
import { gameAtom, isGameInProgressAtom } from "./states";
|
||||
import { useEffect } from "react";
|
||||
import { playGameEndSound } from "@/lib/sounds";
|
||||
|
||||
export default function GameInProgress() {
|
||||
const game = useAtomValue(gameAtom);
|
||||
@@ -11,6 +12,11 @@ export default function GameInProgress() {
|
||||
if (game.isGameOver()) setIsGameInProgress(false);
|
||||
}, [game, setIsGameInProgress]);
|
||||
|
||||
const handleResign = () => {
|
||||
playGameEndSound();
|
||||
setIsGameInProgress(false);
|
||||
};
|
||||
|
||||
if (!isGameInProgress) return null;
|
||||
|
||||
return (
|
||||
@@ -42,7 +48,7 @@ export default function GameInProgress() {
|
||||
xs={12}
|
||||
gap={2}
|
||||
>
|
||||
<Button variant="outlined" onClick={() => setIsGameInProgress(false)}>
|
||||
<Button variant="outlined" onClick={handleResign}>
|
||||
Resign
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user