Skip to content

Commit

Permalink
Merge pull request #4501 from AdityaP700/resolve-readme-conflict
Browse files Browse the repository at this point in the history
Added KeySymphony Game
  • Loading branch information
kunjgit authored Jun 21, 2024
2 parents d883bde + a3caa8d commit 30b35d7
Show file tree
Hide file tree
Showing 23 changed files with 276 additions and 7 deletions.
46 changes: 46 additions & 0 deletions Games/keySymphony/index1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>KeySymphony</title>
<link rel="stylesheet" href="style1.css">
<script src="index1.js" defer></script>
</head>
<body>
<div class="wrapper">
<header>
<h2>
KeySymphony
</h2>
<div class="column sound">
<span>Sound</span><input type="range">
</div>

<div class="column keys-checkbox">
<span>Show Keys</span><input type="checkbox" checked>
</div>
</header>
<ul class="Piano">
<li class="key white" data-key="a"><span>a</span></li>
<li class="key black" data-key="w"><span>w</span></li>
<li class="key white" data-key="s"><span>s</span></li>
<li class="key black" data-key="e"><span>e</span></li>
<li class="key white" data-key="d"><span>d</span></li>
<li class="key white" data-key="f"><span>f</span></li>
<li class="key black" data-key="t"><span>t</span></li>
<li class="key white" data-key="g"><span>g</span></li>
<li class="key black" data-key="y"><span>y</span></li>
<li class="key white" data-key="h"><span>h</span></li>
<li class="key black" data-key="u"><span>u</span></li>
<li class="key white" data-key="j"><span>j</span></li>
<li class="key white" data-key="k"><span>k</span></li>
<li class="key black" data-key="o"><span>o</span></li>
<li class="key white" data-key="l"><span>l</span></li>
<li class="key black" data-key="p"><span>p</span></li>
<li class="key white" data-key=";"><span>;</span></li>
<!-- <li class="key black"data-key="c"><span>c</span></li> -->
</ul>
</div>
</body>
</html>
43 changes: 43 additions & 0 deletions Games/keySymphony/index1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
document.addEventListener("DOMContentLoaded", () => {
const pianoKeys = document.querySelectorAll(".Piano .key"),
volumeSlider = document.querySelector(".sound input"),
keyCheckbox = document.querySelector(".keys-checkbox input");

let allKeys = [],
audio = new Audio();

const playTune = (key) => {
audio.src = `tunes/${key}.wav`;
audio.play();

const clickedKey = document.querySelector(`[data-key="${key}"]`);
if (clickedKey) {
clickedKey.classList.add("active");
setTimeout(() => {
clickedKey.classList.remove("active");
}, 160);
}
};

const handleVolume = (e) => {
audio.volume = e.target.value / 100;
};

const showHideKeys = () => {
pianoKeys.forEach(key => key.classList.toggle("hide"));
};

pianoKeys.forEach(key => {
allKeys.push(key.dataset.key);
// Calling playTune function with passing data-key value as an argument
key.addEventListener("click", () => playTune(key.dataset.key));
});

const pressedKey = (e) => {
if (allKeys.includes(e.key)) playTune(e.key);
};

keyCheckbox.addEventListener("click", showHideKeys);
volumeSlider.addEventListener("input", handleVolume);
document.addEventListener("keydown", pressedKey);
});
186 changes: 186 additions & 0 deletions Games/keySymphony/style1.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@

@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');

*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family:'Poppins',sans-serif;
}
body{
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background-color: rgb(207, 232, 255);
}
.wrapper{
border-radius: 20px;
width:795px;
background-color: black;
padding: 32px 40px;

}
.wrapper header{
color: rgb(255, 255, 222);
display: flex;
align-items: center;
justify-content: center;
justify-content: space-between;
}
header h2{
font-size:35px;
}
header .column{
display: flex;
justify-content: center;
align-items: center;
}
header .column span{
font-weight: 420;
font-size: 18px;
margin-right:15px;
}
.sound input{
accent-color: #c3c018;
}
.keys-checkbox input{
height:35px ;
width:65px;
cursor:pointer;
border-radius:30px ;
background: #118df3;
appearance: none;
outline:none;
position: relative;
}
.keys-checkbox input::before{
content: "";
border-radius: inherit;
position: absolute;
background-color: rgb(137, 239, 217);
width: 25px;
height: 25px;
top:50%;
left: 5px;
transform: translateY(-50%);
transition: all 0.2s ease;
}
.keys-checkbox input:checked::before{
left:35px;
background-color: antiquewhite;
}
.Piano{
display: flex;
margin-top: 40px;
/* padding: 20px 10px; */
justify-content: center;
list-style: none;
}
.Piano .key{
list-style:none;
/* color: rgb(143, 130, 112); */
text-transform: uppercase;
cursor: pointer;
user-select: none;
position: relative;
}
.Piano .white{
width:80px;
height:230px;
border: 1px solid black;
background: linear-gradient(#fff 96%,#eee 4%);
border-radius: 9px;

}
.Piano .white:active{
box-shadow:inset -5px 5px 20px rgba(0,0,0,0.2);
background-color: linear-gradient(to bottom, #fff 0%, #eee 100%);
}
.Piano .black{
width:44px;
height:140px;
/* border: 1px solid black; */
background: linear-gradient(#333 ,#000 );
border-radius: 0 0 5px 5px;
z-index: 2;
margin: 0 -22px 0 -22px;
}
.Piano .black:active{
box-shadow:inset -5px -10px 10px rgba(255,255,255,0.2);
background-color: linear-gradient(to bottom, #000 , #434343);
}
.Piano span{
position: absolute;
bottom: 20px;
width: 100%;
font-size: 1.15rem;
text-align: center;
}
.Piano .key span {
position: absolute;
bottom: 20px;
width: 100%;
color: #A2A2A2;
font-size: 1.13rem;
text-align: center;
}
.Piano .key.hide span {
display: none;
}
.Piano .black span {
bottom: 13px;
color: #888888;
}
.Piano .key{
list-style: none;
color: rgba(174, 174, 174, 0.856);
}
.Piano .key.hide span {
display: none;
}
.Piano .black span {
bottom: 13px;
color: #888888;
}
@media screen and (max-width: 815px) {
.wrapper {
padding: 25px;
}
header {
flex-direction: column;
}
header :where(h2, .column) {
margin-bottom: 13px;
}
.sound input {
max-width: 100px;
}
.Piano {
margin-top: 20px;
}
.Piano .key:where(:nth-child(9), :nth-child(10)) {
display: none;
}
.Piano .black {
height: 100px;
width: 40px;
margin: 0 -20px 0 -20px;
}
.Piano .white {
height: 180px;
width: 60px;
}
}
@media screen and (max-width: 615px) {
.Piano .key:nth-child(13),
.Piano .key:nth-child(14),
.Piano .key:nth-child(15),
.Piano .key:nth-child(16),
.Piano .key :nth-child(17) {
display: none;
}
.Piano .white {
width: 50px;
}
}
Binary file added Games/keySymphony/tunes/;.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/a.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/d.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/e.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/f.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/g.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/h.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/j.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/k.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/l.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/o.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/p.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/s.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/t.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/u.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/w.wav
Binary file not shown.
Binary file added Games/keySymphony/tunes/y.wav
Binary file not shown.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ This repository also provides one such platforms where contributers come over an
| [Helicopter_Game](https://github.com/kinjgit/GameZone/tree/main/Games/Helicopter_Game) |
| [Bouncing Ball Game](https://github.com/kunjgit/GameZone/tree/main/Games/Bouncing_Ball_Game) |
|[Harmony_Mixer](https://github.com/kunjgit/GameZone/tree/main/Games/Harmony_Mixer)|
|[KeySymphony](https://github.com/kunjgit/GameZone/tree/main/Games/KeySymphony)|
|[Math_Race_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Math_Race_Game)|
| [Bunny is Lost](https://github.com/kunjgit/GameZone/tree/main/Games/Bunny_is_Lost)|
|[Steam_Punk](https://github.com/kunjgit/GameZone/tree/main/Games/Steam_Punk)|
Expand All @@ -809,18 +810,11 @@ This repository also provides one such platforms where contributers come over an
|[Dot_Box_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Dot_Box_Game)|
| [Cosmic_Blast](https://github.com/kunjgit/GameZone/tree/main/Games/Cosmic_Blast) |
|[Mole](https://github.com/taneeshaa15/GameZone/tree/main/Games/Mole)|
=======
=======
| [Go-fish-master](https://github.com/kunjgit/GameZone/tree/main/Games/Go-fish-master) |
|[Pottery-Game](https://github.com/kunjgit/GameZone/tree/main/Games/Pottery-Game)|
| [Ganesh QR Maker](https://github.com/kunjgit/GameZone/tree/main/Games/Ganesh_QR_Maker) |

| [Ganesh_QR_Maker](https://github.com/kunjgit/GameZone/tree/main/Games/Ganesh_QR_Maker) |

|[Wheel_of_Fortunes](https://github.com/Saipradyumnagoud/GameZone/tree/main/Games/Wheel_of_Fortunes)|
|[Tic-tac-toe](https://github.com/Saipradyumnagoud/GameZone/tree/main/Games/Tic-tac-toe)|

=======
|[Quest_For_Riches](https://github.com/kunjgit/GameZone/tree/main/Games/Quest_For_Riches)|

| [IKnowYou-Mind-Reading-Game](https://github.com/kunjgit/GameZone/tree/main/Games/IKnowYou-Mind-Reading-Game) |
Expand Down
Binary file added assets/images/KeySymphony.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 assets/images/KeySymphony2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 30b35d7

Please sign in to comment.