Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardpepa committed Jan 13, 2021
1 parent 001f06d commit eed8790
Show file tree
Hide file tree
Showing 18 changed files with 158 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added images/crash.png
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 images/kick.png
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 images/snare.png
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 images/tom1.png
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 images/tom2.png
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 images/tom3.png
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 images/tom4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<title>Drum Kit</title>
<link rel="stylesheet" href="styles.css" />
<link
href="https://fonts.googleapis.com/css?family=Arvo"
rel="stylesheet"
/>
</head>

<body>
<h1 id="title">Drum 🥁 Kit</h1>
<div class="set">
<button class="w drum">w</button>
<button class="a drum">a</button>
<button class="s drum">s</button>
<button class="d drum">d</button>
<button class="j drum">j</button>
<button class="k drum">k</button>
<button class="l drum">l</button>
</div>

<footer>Made from Leonard Pepa | Udemy Course| 🎹</footer>
<script src="index.js"></script>
</body>
</html>
50 changes: 50 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const allButtons = document.querySelectorAll(".drum");

allButtons.forEach((btn) => {
btn.addEventListener("click", () => {
const audio = selectedSound(btn.classList[0]);
btnAnimation(btn.classList[0]);
audio.play();
});
});

document.addEventListener("keydown", (e) => {
btnAnimation(e.key);
const audio = selectedSound(e.key);
audio.play();
});

const selectedSound = (btn) => {
switch (btn) {
case "w":
return new Audio("sounds/crash.mp3");
break;
case "a":
return new Audio("sounds/kick-bass.mp3");
break;
case "s":
return new Audio("sounds/snare.mp3");
break;
case "d":
return new Audio("sounds/tom-1.mp3");
break;
case "j":
return new Audio("sounds/tom-2.mp3");
break;
case "k":
return new Audio("sounds/tom-3.mp3");
break;
case "l":
return new Audio("sounds/tom-4.mp3");
break;
}
};

function btnAnimation(currentKey) {
const activeBtn = document.querySelector(`.${currentKey}`);
activeBtn.classList.toggle("pressed");

setTimeout(() => {
activeBtn.classList.toggle("pressed");
}, 300);
}
Binary file added sounds/crash.mp3
Binary file not shown.
Binary file added sounds/kick-bass.mp3
Binary file not shown.
Binary file added sounds/snare.mp3
Binary file not shown.
Binary file added sounds/tom-1.mp3
Binary file not shown.
Binary file added sounds/tom-2.mp3
Binary file not shown.
Binary file added sounds/tom-3.mp3
Binary file not shown.
Binary file added sounds/tom-4.mp3
Binary file not shown.
80 changes: 80 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
body {
text-align: center;
background-color: #283149;
}

h1 {
font-size: 5rem;
color: #dbedf3;
font-family: "Arvo", cursive;
text-shadow: 3px 0 #da0463;
}

footer {
color: #dbedf3;
font-family: sans-serif;
}

.w {
background-image: url("images/crash.png");
}

.a {
background-image: url("images/kick.png");
}

.s {
background-image: url("images/snare.png");
}

.d {
background-image: url("images/tom1.png");
}

.j {
background-image: url("images/tom2.png");
}

.k {
background-image: url("images/tom3.png");
}

.l {
background-image: url("images/tom4.png");
}

.set {
margin: 10% auto;
}

.game-over {
background-color: red;
opacity: 0.8;
}

.pressed {
box-shadow: 0 3px 4px 0 #dbedf3;
opacity: 0.5;
}

.red {
color: red;
}

.drum {
outline: none;
border: 10px solid #404b69;
font-size: 5rem;
font-family: "Arvo", cursive;
line-height: 2;
font-weight: 900;
color: #da0463;
text-shadow: 3px 0 #dbedf3;
border-radius: 15px;
display: inline-block;
width: 150px;
height: 150px;
text-align: center;
margin: 10px;
background-color: white;
}

0 comments on commit eed8790

Please sign in to comment.