-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5163 from SanskarSinghiit/main
Adds Drummer Kit game 🥁
- Loading branch information
Showing
18 changed files
with
149 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Drummmer_Kit | ||
|
||
A simple drum kit game made using javascript to understand the concept of event listeners in DOM. | ||
|
||
![image](https://github.com/user-attachments/assets/510acce4-20f9-403e-b665-f68dbfa324ed) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
let allKeys = document.querySelectorAll('li') | ||
|
||
//FUNCTIONS | ||
const play =(audio)=>{ | ||
if(!audio) return; | ||
audio.currentTime=0 | ||
audio.play() | ||
} | ||
const playKey = (event)=>{ | ||
let audio=document.querySelector(`audio[data-key="${event.keyCode}"]`) | ||
play(audio) | ||
let pressed=document.querySelector(`li[data-key="${event.keyCode}"]`) | ||
pressed.classList.add('playing') | ||
} | ||
|
||
const playClick=(event)=>{ | ||
let clickedKey=event.target.getAttribute("data-key") | ||
let audio=document.querySelector(`audio[data-key="${clickedKey}"]`) | ||
play(audio) | ||
let pressed=document.querySelector(`li[data-key="${clickedKey}"]`) | ||
pressed.classList.add('playing') | ||
} | ||
//ACTIONS | ||
allKeys.forEach(key=>key.addEventListener('transitionend',()=>{ | ||
key.classList.remove('playing') | ||
})) | ||
window.addEventListener('keydown',playKey) | ||
|
||
window.addEventListener('click',playClick) | ||
|
||
|
||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>DJ Starter Kit</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
|
||
<body> | ||
<div id="intruments"> | ||
<ul> | ||
<li class="intru" data-key="81">Q</li> | ||
<li class="intru" data-key="76">L</li> | ||
<li class="intru" data-key="70">F</li> | ||
<li class="intru" data-key="66">B</li> | ||
<li class="intru" data-key="75">K</li> | ||
<li class="intru" data-key="84">T</li> | ||
<li class="intru" data-key="89">Y</li> | ||
<li class="intru" data-key="82">R</li> | ||
<li class="intru" data-key="69">E</li> | ||
</ul> | ||
</div> | ||
|
||
<audio data-key="81" src="sounds/clap.wav"></audio> | ||
<audio data-key="76" src="sounds/hihat.wav"></audio> | ||
<audio data-key="70" src="sounds/kick.wav"></audio> | ||
<audio data-key="66" src="sounds/openhat.wav"></audio> | ||
<audio data-key="75" src="sounds/boom.wav"></audio> | ||
<audio data-key="84" src="sounds/ride.wav"></audio> | ||
<audio data-key="89" src="sounds/snare.wav"></audio> | ||
<audio data-key="82" src="sounds/tom.wav"></audio> | ||
<audio data-key="69" src="sounds/tink.wav"></audio> | ||
<script src="app.js "></script> | ||
|
||
</body> | ||
|
||
</html> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap'); | ||
|
||
|
||
|
||
*,::after,::before{ | ||
box-sizing: border-box; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body{ | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
background-image: url(./assets/bg-1.jpg); | ||
background-size: 270%; | ||
background-repeat: no-repeat; | ||
font-family: 'Roboto', sans-serif; | ||
} | ||
|
||
ul{ | ||
list-style: none; | ||
display: grid; | ||
grid-template-columns: 1fr 1fr; | ||
grid-gap: 8vw; | ||
} | ||
|
||
ul li{ | ||
height: 10vh; | ||
width: 20vw; | ||
border: 2px solid white; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
color: white; | ||
font-weight: 800; | ||
background-color: rgb(12, 12, 11); | ||
opacity: 50%; | ||
transition: 0.1s linear; | ||
} | ||
.playing{ | ||
border: rgb(84, 31, 191) solid; | ||
color:rgb(84, 31, 191); | ||
box-shadow: 0 0 8px rgb(84, 31, 191); | ||
transform: scale(1.1); | ||
opacity: 1; | ||
} | ||
|
||
@media (min-width:1025px){ | ||
body{ | ||
background-size: 100%; | ||
} | ||
ul{ | ||
display: flex; | ||
grid-gap:1.5rem | ||
} | ||
ul li{ | ||
width: 6vw; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters