Skip to content

Commit 63414a3

Browse files
author
Gideon
committed
UPDATE: Some audio adds a entire new dimention to the game.
1 parent e85e0dd commit 63414a3

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/assets/audio/announce.wav

233 KB
Binary file not shown.

src/assets/audio/place.wav

196 KB
Binary file not shown.

src/components/tictactoe.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import '../assets/css/tictactoe.component.css';
2+
import placeAudio from '../assets/audio/place.wav'
3+
import announceAudio from '../assets/audio/announce.wav'
24

35
const gameboardHtml = `
46
<section id="control">
@@ -56,6 +58,7 @@ const announceOutcome = function (message) {
5658
block.style.cursor = 'default';
5759
block.replaceWith(block.cloneNode(true));
5860
});
61+
playSound(announceAudio);
5962
};
6063

6164
const roundsPlayed = function () {
@@ -104,13 +107,18 @@ const gameStateCheck = function () {
104107
}
105108
};
106109

110+
const playSound = function(audioFile) {
111+
new Audio(audioFile).play();
112+
};
113+
107114
const drawOnBlock = function (event) {
108115
let image = document.createElement('img');
109116
image.src = `images/${activePlayer}-100.png`;
110117
image.alt = activePlayer;
111118
event.target.appendChild(image);
112119
event.target.dataset.assignment = activePlayer;
113120
event.target.removeEventListener('click', drawOnBlock);
121+
playSound(placeAudio);
114122
activePlayer = togglePlayer(activePlayer);
115123
toggleMouseCursorStyle(activePlayer);
116124
toggleUserTurnIndicator();

0 commit comments

Comments
 (0)