-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (27 loc) · 1.14 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Defining all variables
let playBtn = document.querySelector("#play-button span");
let instructionBtn = document.querySelector(".instructions-button span");
let marioImage = document.getElementById("mario");
let scoreCorrect = sessionStorage.setItem("wins", 0)
let scoreIncorrect = sessionStorage.setItem("wrong", 0)
let bgmAudio = new Audio("./assets/background-music.mp3")
bgmAudio.volume = 0.6;
bgmAudio.play()
bgmAudio.loop = true
// Updates marioImage source to marioWalkLarge and adjusts paddingTop for bouncy effect
setInterval(()=>{
setTimeout(()=>{
marioImage.setAttribute("src","./assets/Mario Walk - Fall/MarioStandLarge.png");
marioImage.style.paddingTop="8px";
},300)
marioImage.setAttribute("src","./assets/Mario Walk - Fall/MarioWalkLarge.png");
marioImage.style.paddingTop="12px";
},600)
// when instruction button is clicked it will redirect to instructions.html
instructionBtn.addEventListener("click",() => {
window.open("./instructions.html", "_self")
})
// when play button is clicked it will redirect to theme.html
playBtn.addEventListener("click",() => {
window.open("./theme.html", "_self")
})