File tree Expand file tree Collapse file tree 3 files changed +8
-0
lines changed Expand file tree Collapse file tree 3 files changed +8
-0
lines changed Original file line number Diff line number Diff line change 11import '../assets/css/tictactoe.component.css' ;
2+ import placeAudio from '../assets/audio/place.wav'
3+ import announceAudio from '../assets/audio/announce.wav'
24
35const 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
6164const roundsPlayed = function ( ) {
@@ -104,13 +107,18 @@ const gameStateCheck = function () {
104107 }
105108} ;
106109
110+ const playSound = function ( audioFile ) {
111+ new Audio ( audioFile ) . play ( ) ;
112+ } ;
113+
107114const 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 ( ) ;
You can’t perform that action at this time.
0 commit comments