Skip to content

Commit

Permalink
Tournament: Add sound when the ball hits a paddle
Browse files Browse the repository at this point in the history
  • Loading branch information
hanmpark committed Nov 14, 2024
1 parent 7e3513c commit 19a1a75
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion frontend/src/components/Game/Tournament/GameTournament.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,14 @@ const GameTournament = () => {
if (data.d.userID !== playerIdRef.current)
setGameState(prevState => ({ ...prevState, opponent: formatUserData(data.d) }));
},
'PADDLE_HIT': () => setHitPos(data.d.ball),
'PADDLE_HIT': () => {
setHitPos(data.d.ball);
if (hasInteractedRef.current) {
const hit1 = new Audio('/sounds/pong-hit1.mp3');
hit1.volume = 0.2;
hit1.play();
}
},
};

const handler = handlers[data.e];
Expand Down

0 comments on commit 19a1a75

Please sign in to comment.