Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a new drumKit project #8

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added DrumKit/.DS_Store
Binary file not shown.
Binary file added DrumKit/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 DrumKit/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 DrumKit/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 DrumKit/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 DrumKit/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 DrumKit/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 DrumKit/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 DrumKit/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>Make your own music ❤️ </footer>
<script src="index.js" charset="utf-8"></script>
</body>
</html>
57 changes: 57 additions & 0 deletions DrumKit/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
var numberOfDrumButtons = document.querySelectorAll(".drum").length;
for (var i = 0; i < numberOfDrumButtons; i++) {
document
.querySelectorAll(".drum")
[i].addEventListener("click", function playSound() {
var buttonInnerHtml = this.innerHTML;
makeSound(buttonInnerHtml);
buttonAnimation(buttonInnerHtml);
});
}
document.addEventListener("keydown", function (event) {
makeSound(event.key);
buttonAnimation(event.key);
});
//Read mdn docs for more on EventListerner.
function makeSound(key) {
switch (key) {
case "w":
var audio = new Audio("sounds/tom-1.mp3");
audio.play();
break;
case "a":
var audio = new Audio("sounds/tom-2.mp3");
audio.play();
break;
case "s":
var audio = new Audio("sounds/tom-3.mp3");
audio.play();
break;
case "d":
var audio = new Audio("sounds/tom-4.mp3");
audio.play();
break;
case "j":
var audio = new Audio("sounds/snare.mp3");
audio.play();
break;
case "k":
var audio = new Audio("sounds/crash.mp3");
audio.play();
break;
case "l":
var audio = new Audio("sounds/kick-bass.mp3");
audio.play();
break;

default:
break;
}
}
function buttonAnimation(currentKey) {
var activeButton = document.querySelector("." + currentKey);
activeButton.classList.add("pressed");
setTimeout(function () {
activeButton.classList.remove("pressed");
}, 100);
}
Binary file added DrumKit/sounds/crash.mp3
Binary file not shown.
Binary file added DrumKit/sounds/kick-bass.mp3
Binary file not shown.
Binary file added DrumKit/sounds/snare.mp3
Binary file not shown.
Binary file added DrumKit/sounds/tom-1.mp3
Binary file not shown.
Binary file added DrumKit/sounds/tom-2.mp3
Binary file not shown.
Binary file added DrumKit/sounds/tom-3.mp3
Binary file not shown.
Binary file added DrumKit/sounds/tom-4.mp3
Binary file not shown.
80 changes: 80 additions & 0 deletions DrumKit/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/tom1.png");
}

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

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

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

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

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

.l {
background-image: url("images/kick.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;
}
Loading