Skip to content

Commit

Permalink
Merge pull request #5163 from SanskarSinghiit/main
Browse files Browse the repository at this point in the history
Adds Drummer Kit game 🥁
  • Loading branch information
kunjgit authored Aug 10, 2024
2 parents 7648cac + 8a7e53e commit 3c7f558
Show file tree
Hide file tree
Showing 18 changed files with 149 additions and 9 deletions.
6 changes: 6 additions & 0 deletions Games/Drummer_Kit/README.md
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)

34 changes: 34 additions & 0 deletions Games/Drummer_Kit/app.js
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)





Binary file added Games/Drummer_Kit/assets/bg-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Drummer_Kit/assets/dj.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions Games/Drummer_Kit/index.html
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 added Games/Drummer_Kit/sounds/boom.wav
Binary file not shown.
Binary file added Games/Drummer_Kit/sounds/clap.wav
Binary file not shown.
Binary file added Games/Drummer_Kit/sounds/hihat.wav
Binary file not shown.
Binary file added Games/Drummer_Kit/sounds/kick.wav
Binary file not shown.
Binary file added Games/Drummer_Kit/sounds/openhat.wav
Binary file not shown.
Binary file added Games/Drummer_Kit/sounds/ride.wav
Binary file not shown.
Binary file added Games/Drummer_Kit/sounds/snare.wav
Binary file not shown.
Binary file added Games/Drummer_Kit/sounds/tink.wav
Binary file not shown.
Binary file added Games/Drummer_Kit/sounds/tom.wav
Binary file not shown.
61 changes: 61 additions & 0 deletions Games/Drummer_Kit/style.css
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;
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ Terms and conditions for use, reproduction and distribution are under the [Apach
| [Sky_Lift_Dash](https://github.com/kunjgit/GameZone/tree/main/Games/Sky_Lift_Dash) |
| [Block_Vault](https://github.com/kunjgit/GameZone/tree/main/Games/Block_Vault) |
| [Random_Choice_Picker](https://github.com/kunjgit/GameZone/tree/main/Games/Random_Choice_Picker) |
| [Drummer_Kit](https://github.com/kunjgit/GameZone/tree/main/Games/Drummer_Kit) |

</center>
<br>
Expand Down
Binary file added assets/images/Drummer_Kit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 7 additions & 9 deletions assets/js/gamesData.json
Original file line number Diff line number Diff line change
Expand Up @@ -3229,17 +3229,11 @@
"gameUrl": "Block_Vault",
"thumbnailUrl": "Block_Vault.png"
},




"646":{
"gameTitle" : "Harry Potter Wizard Quiz",
"gameUrl": "Harry_Potter_Wizard_Quiz/start.html",
"thumbnailUrl": "Harry_Potter_Wizard_Quiz.png"
}


},
"647":{
"gameTitle" : "Droop Dash Game",
"gameUrl": "Drop_Dash_Game",
Expand All @@ -3250,11 +3244,15 @@
"gameTitle" : "Gravity Switch Game",
"gameUrl": "Gravity_Switch_Game",
"thumbnailUrl": "Gravity_Switch_Game.png"

},
"649":{
"gameTitle" : "Random Choice Picker",
"gameUrl": "Random_Choice_Picker",
"thumbnailUrl": "Drop_Dash_Game.png"

},
"648":{
"gameTitle" : "Drummer Kit",
"gameUrl": "Drummer_Kit",
"thumbnailUrl": "Drummer_Kit.png"
}
}

0 comments on commit 3c7f558

Please sign in to comment.