Skip to content

Commit 927e287

Browse files
committed
Merge branch 'main' into thunder
2 parents 9217556 + 9fcea1e commit 927e287

File tree

3 files changed

+54
-35
lines changed

3 files changed

+54
-35
lines changed

fart-paulstretched.flac

532 KB
Binary file not shown.

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html>
33
<head>
44
<meta charset="UTF-8"/>
5+
<meta name="viewport" content="width=device-width" />
56

67
<title>Click me!</title>
78
<link rel="stylesheet" type="text/css" href="main.css">

index.js

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
1-
const regularFart = new Audio("fart-83471-fixed-regular.flac");
2-
const critFart = new Audio("fart-4-228244-fixed-crit.flac");
1+
const farts = [];
32

4-
const farts = [
5-
regularFart,
6-
critFart,
7-
];
8-
9-
function playFart(fart) {
10-
fart.currentTime = 0;
11-
fart.playbackRate = randomPlaybackRate();
3+
function newFart(url) {
4+
const fart = new Audio(url);
125
fart.preservesPitch = false;
6+
fart.onended = () => {
7+
shaking = false;
8+
clickMe.disabled = false;
9+
};
10+
farts.push(fart);
11+
return fart;
12+
}
13+
14+
const regularFart = newFart("fart-83471-fixed-regular.flac");
15+
const critFart = newFart("fart-4-228244-fixed-crit.flac");
16+
const bigoneFart = newFart("fart-paulstretched.flac");
17+
18+
function randomPlaybackRate(min = 0.97, max = 1.03) {
19+
return Math.random() * (max - min) + min;
20+
}
21+
22+
function playFart(fart, randomPitch) {
23+
for (const f of farts) {
24+
f.pause();
25+
f.currentTime = 0;
26+
}
27+
28+
fart.playbackRate = randomPitch ? randomPlaybackRate() : 1;
1329
fart.play();
1430
shaking = true;
1531
}
1632

17-
function randomPlaybackRate(min = 0.98, max = 1.02) {
18-
return Math.random() * (max - min) + min;
33+
const regularAction = () => {
34+
clickMeText.innerText = `Congrats! You clicked it ${counter} times!`;
35+
playFart(regularFart, true);
1936
}
2037

2138
const eventsTable = [
@@ -29,27 +46,28 @@ const eventsTable = [
2946
onCount: 1,
3047
action: () => {
3148
clickMeText.innerText = "Gotchu!!";
32-
playFart(regularFart);
49+
playFart(regularFart, true);
3350
}
3451
},
3552
{
3653
onCount: 4,
3754
action: () => {
3855
clickMeText.innerText = "Oh, you're into that...";
39-
playFart(regularFart);
56+
playFart(regularFart, true);
4057
},
4158
},
4259
{
4360
onCount: 6,
4461
action: () => {
4562
clickMeText.innerText = `Oh, you're into that...`;
4663
popupText.style.visibility = "visible";
47-
playFart(regularFart);
64+
playFart(regularFart, true);
4865
},
4966
},
5067
{
5168
onCount: 10,
5269
action: () => {
70+
clickMe.disabled = true;
5371
clickMeText.innerText = `You broke it`;
5472
playFart(critFart);
5573
critImg.animate([
@@ -66,7 +84,7 @@ const eventsTable = [
6684
onCount: 11,
6785
action: () => {
6886
clickMeText.innerText = `jk keep going`;
69-
playFart(regularFart);
87+
playFart(regularFart, true);
7088
}
7189
},
7290
{
@@ -75,51 +93,59 @@ const eventsTable = [
7593
clickMeText.innerText = `having fun?`;
7694
clickMeWrapper.classList.add("customCursor");
7795
clickMe.classList.add("customCursor");
78-
playFart(regularFart);
96+
playFart(regularFart, true);
7997
}
8098
},
8199
{
82100
onCount: 20,
83101
action: () => {
84102
clickMeText.innerText = `dude this is just a fart button`;
85-
playFart(regularFart);
103+
playFart(regularFart, true);
86104
}
87105
},
88106
{
89107
onCount: 30,
90108
action: () => {
91109
clickMeText.innerText = `it doesn't do anything, but farts`;
92-
playFart(regularFart);
110+
playFart(regularFart, true);
93111
}
94112
},
95113
{
96114
onCount: 40,
97115
action: () => {
98116
clickMeText.innerText = `you are not getting anything for clicking it`;
99-
playFart(regularFart);
117+
playFart(regularFart, true);
100118
}
101119
},
102120
{
103121
onCount: 50,
104-
action: () => {
105-
clickMeText.innerText = `Congrats! You clicked it ${counter} times!`;
106-
playFart(regularFart);
107-
}
122+
action: regularAction,
108123
},
109124
{
110125
onCount: 69,
111126
action: () => {
127+
clickMe.disabled = true;
112128
clickMeText.innerText = `Nice!`;
113-
playFart(regularFart);
129+
playFart(critFart);
114130
}
115131
},
116132
{
117133
onCount: 70,
134+
action: regularAction,
135+
},
136+
{
137+
onCount: 100,
118138
action: () => {
119-
clickMeText.innerText = `Congrats! You clicked it ${counter} times!`;
120-
playFart(regularFart);
139+
clickMe.disabled = true;
140+
setTimeout(() => clickMe.disabled = false, 3000);
141+
clickMeText.innerText = `HERE COMES THE BIG ONE`;
142+
playFart(bigoneFart);
121143
}
122144
},
145+
{
146+
onCount: 101,
147+
action: regularAction,
148+
}
123149
];
124150

125151
eventsTable.sort((a, b) => b.onCount - a.onCount);
@@ -136,14 +162,6 @@ function fireEvents() {
136162
let shaking = false;
137163
let counter = 0; // TODO: DONT FORGET TO SET TO 0 ON RELEASE!!!
138164

139-
function finishFart() {
140-
shaking = false;
141-
}
142-
143-
for (let fart of farts) {
144-
fart.onended = finishFart;
145-
}
146-
147165
// TODO: change it to onmousedown (it stopped working after separating button and label)
148166
clickMe.onclick = () => {
149167
counter += 1;

0 commit comments

Comments
 (0)