Skip to content

Commit f7fb41e

Browse files
authored
Merge pull request #708 from aditya7302/master
added drum kit project
2 parents 2cf6c62 + cb7498f commit f7fb41e

File tree

13 files changed

+97
-0
lines changed

13 files changed

+97
-0
lines changed

Drum/aditya7302/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is a simple drum kit project using html, css and js to implement drum kit sound.
2+
It is very simple to implement and use just click on the html file and it will work.
3+
![ScreenShot](image.png)

Drum/aditya7302/css/styles.css

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
body{
2+
margin: 0;
3+
display: flex;
4+
flex-direction: column;
5+
align-items: center;
6+
height: 100vh;
7+
justify-content: center;
8+
background-color: pink;
9+
}
10+
11+
h1{
12+
font-size: 50px;
13+
font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
14+
letter-spacing: 4px;
15+
color: white;
16+
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
17+
white-space: nowrap;
18+
}
19+
20+
.container{
21+
text-align: center;
22+
}
23+
24+
.btn{
25+
padding: 30px 50px;
26+
background-color: white;
27+
border: none;
28+
margin: 10px;
29+
font-size: 30px;
30+
min-width: 200px;
31+
border-radius: 10px;
32+
box-shadow: 0 4px 8px rgba(0,0,0,0.3);
33+
background-image: url("/javascript_projects/drum_kits/img/tom.png");
34+
background-size: cover;
35+
color: white;
36+
font-family: cursive;
37+
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
38+
cursor: pointer;
39+
text-transform: capitalize;
40+
}
41+
42+
.btn:hover{
43+
color: pink;
44+
}
45+
46+
.btn:active{
47+
background-size: 105%;
48+
}

Drum/aditya7302/image.png

124 KB
Loading

Drum/aditya7302/img/crash.png

19.1 KB
Loading

Drum/aditya7302/img/kick.png

51.9 KB
Loading

Drum/aditya7302/img/snare.png

16.8 KB
Loading

Drum/aditya7302/img/tom.png

23.5 KB
Loading

Drum/aditya7302/index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<link rel="stylesheet" href="css/styles.css">
8+
<script src="index.js" defer></script>
9+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
10+
<title>Drum Kits</title>
11+
</head>
12+
<body>
13+
<h1>Drum Kits
14+
<i class="fa-solid fa-drum"></i>
15+
</h1>
16+
<div class="container">
17+
18+
19+
</div>
20+
</body>
21+
</html>

Drum/aditya7302/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const kits = ["crash" , "kick", "snare", "tom"];
2+
const containerEl = document.querySelector(".container");
3+
4+
kits.forEach((kit)=>{
5+
const btnEl = document.createElement("button");
6+
btnEl.classList.add("btn");
7+
btnEl.innerText = kit;
8+
btnEl.style.backgroundImage = "url(img/"+kit+".png)";
9+
containerEl.appendChild(btnEl);
10+
const audioEl = document.createElement("audio");
11+
audioEl.src = "sound/"+kit+".mp3";
12+
containerEl.appendChild(audioEl);
13+
btnEl.addEventListener("click",()=>{
14+
audioEl.play();
15+
});
16+
window.addEventListener("keydown",(event)=>{
17+
if(event.key === kit.slice(0,1)){
18+
audioEl.play();
19+
btnEl.style.transform = "scale(0.9)";
20+
setTimeout(()=>{
21+
btnEl.style.transform = "scale(1)";
22+
},100)
23+
}
24+
})
25+
});

Drum/aditya7302/sound/crash.mp3

33.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)