Skip to content

Commit

Permalink
Merge pull request kennethnym#7 from DMZTdhruv/main
Browse files Browse the repository at this point in the history
feat: add meow sound when clicking on the cat :3
  • Loading branch information
kennethnym authored Jul 26, 2024
2 parents 9869c35 + 406513e commit eae55ae
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,3 @@ $RECYCLE.BIN/

# End of https://www.toptal.com/developers/gitignore/api/python,windows,macos,linux

*.mp3
Binary file added web/audio/cat-meow.mp3
Binary file not shown.
10 changes: 6 additions & 4 deletions web/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">

<title>infinifi</title>

<link rel="preload" href="./style.css" as="style">
Expand All @@ -12,12 +13,12 @@
<link rel="stylesheet" href="./style.css">

<meta name="viewport" content="width=device-width, initial-scale=1">

<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@kennethnym">
<meta name="twitter:title" content="infinifi">
<meta name="twitter:description" content="infinite lo-fi beats in the background">
</head>

<body>
<div class="container">
<main>
Expand All @@ -28,7 +29,7 @@ <h2>infinite lo-fi music in the background</h2>
</div>
<div class="volume-slider-container">
<output id="current-volume-label" for="volume-slider">100%</output>
<input id="volume-slider" type="range" min="0" max="100" step="1" />
<input id="volume-slider" type="range" min="0" max="100" step="1">
</div>
</main>
<img class="cat" src="./images/cat-0.png">
Expand All @@ -37,13 +38,14 @@ <h2>infinite lo-fi music in the background</h2>

<footer>
<span>made by kennethnym &lt;3 ·&nbsp;</span>
<a target="_blank" href="https://github.com/kennethnym/infinifi">github</a>
<a target="_blank" rel="noopener noreferrer" href="https://github.com/kennethnym/infinifi">github</a>
</footer>

<canvas id="bg"></canvas>

<audio id="click-audio" preload="auto" src="./audio/click.wav"></audio>
<audio id="click-release-audio" preload="auto" src="./audio/click-release.wav"></audio>
<audio id="meow-audio" preload="auto" src="./audio/cat-meow.mp3"></audio>

<script type="module" src="./bg.js"></script>
<script type="module" src="./script.js"></script>
Expand Down
7 changes: 7 additions & 0 deletions web/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const volumeSlider = document.getElementById("volume-slider");
const currentVolumeLabel = document.getElementById("current-volume-label");
const clickAudio = document.getElementById("click-audio");
const clickReleaseAudio = document.getElementById("click-release-audio");
const meowAudio = document.getElementById("meow-audio");

const CROSSFADE_DURATION_MS = 5000;
const CROSSFADE_INTERVAL_MS = 20;
Expand Down Expand Up @@ -132,6 +133,11 @@ playBtn.onmousedown = () => {
);
};

// Cat audio sound function
catImg.onmousedown = () => {
meowAudio.play();
};

playBtn.onclick = () => {
if (isPlaying) {
pauseAudio();
Expand All @@ -149,6 +155,7 @@ volumeSlider.oninput = () => {
}
clickAudio.volume = volumeSlider.value / 100;
clickReleaseAudio.volume = volumeSlider.value / 100;
meowAudio.volume = volumeSlider.value / 100;
};

volumeSlider.value = 100;
Expand Down
2 changes: 1 addition & 1 deletion web/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,4 @@ input[type="range"]::-ms-fill-upper {
.button:after {
opacity: 0.5;
}
}
}

0 comments on commit eae55ae

Please sign in to comment.