Different sound effect when punching Ryan.
This commit is contained in:
parent
f12f0fc4bb
commit
730c7e3e52
1
dist/index.html
vendored
1
dist/index.html
vendored
@ -13,6 +13,7 @@
|
|||||||
<div id="hand">👋🏿</div>
|
<div id="hand">👋🏿</div>
|
||||||
<div id="fist">✊🏾</div>
|
<div id="fist">✊🏾</div>
|
||||||
<audio id="slap-sound" src="slap.mp3" preload="auto"></audio>
|
<audio id="slap-sound" src="slap.mp3" preload="auto"></audio>
|
||||||
|
<audio id="punch-sound" src="punch.mp3" preload="auto"></audio>
|
||||||
<script src="script.js"></script>
|
<script src="script.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
10
dist/script.js
vendored
10
dist/script.js
vendored
@ -2,6 +2,7 @@ const slapImage = document.getElementById('slap-image');
|
|||||||
const hand = document.getElementById('hand');
|
const hand = document.getElementById('hand');
|
||||||
const fist = document.getElementById('fist');
|
const fist = document.getElementById('fist');
|
||||||
const slapSound = document.getElementById('slap-sound');
|
const slapSound = document.getElementById('slap-sound');
|
||||||
|
const punchSound = document.getElementById('punch-sound');
|
||||||
|
|
||||||
const initialHandRight = 20;
|
const initialHandRight = 20;
|
||||||
const initialFistRight = 20;
|
const initialFistRight = 20;
|
||||||
@ -19,8 +20,13 @@ function doAction(emoji, x, y) {
|
|||||||
emoji.style.left = `${x - emoji.offsetWidth / 2}px`;
|
emoji.style.left = `${x - emoji.offsetWidth / 2}px`;
|
||||||
emoji.style.top = `${y - emoji.offsetHeight / 2}px`;
|
emoji.style.top = `${y - emoji.offsetHeight / 2}px`;
|
||||||
|
|
||||||
slapSound.currentTime = 0;
|
if (emoji === hand) {
|
||||||
slapSound.play();
|
slapSound.currentTime = 0;
|
||||||
|
slapSound.play();
|
||||||
|
} else {
|
||||||
|
punchSound.currentTime = 0;
|
||||||
|
punchSound.play();
|
||||||
|
}
|
||||||
|
|
||||||
/* Move the emoji back to a ready position. */
|
/* Move the emoji back to a ready position. */
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user