-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
281 lines (246 loc) Β· 10.8 KB
/
Copy pathscript.js
File metadata and controls
281 lines (246 loc) Β· 10.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
const noBtn = document.getElementById('noBtn');
const yesBtn = document.getElementById('yesBtn');
const screen1 = document.getElementById('screen1');
const screen2 = document.getElementById('screen2');
const loaderScreen = document.getElementById('loader-screen');
const loaderText = document.getElementById('loader-text');
const loaderFill = document.getElementById('loaderFill');
const mainEmoji = document.getElementById('mainEmoji');
const audio = document.getElementById('myAudio');
const trollMsg = document.getElementById('trollMsg');
const trollBox = document.getElementById('trollBox');
const canvas = document.getElementById('trailCanvas');
const ctx = canvas.getContext('2d');
// --- Sound System ---
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
function playSound(type) {
if (audioCtx.state === 'suspended') audioCtx.resume();
const osc = audioCtx.createOscillator();
const gain = audioCtx.createGain();
osc.connect(gain); gain.connect(audioCtx.destination);
if (type === 'whoosh') {
osc.frequency.setValueAtTime(100, audioCtx.currentTime);
osc.frequency.exponentialRampToValueAtTime(600, audioCtx.currentTime + 0.1);
gain.gain.setValueAtTime(0.1, audioCtx.currentTime);
gain.gain.exponentialRampToValueAtTime(0.01, audioCtx.currentTime + 0.1);
osc.start(); osc.stop(audioCtx.currentTime + 0.1);
} else if (type === 'pop') {
osc.type = 'triangle';
osc.frequency.setValueAtTime(400, audioCtx.currentTime);
osc.frequency.exponentialRampToValueAtTime(10, audioCtx.currentTime + 0.1);
gain.gain.setValueAtTime(0.2, audioCtx.currentTime);
gain.gain.linearRampToValueAtTime(0, audioCtx.currentTime + 0.1);
osc.start(); osc.stop(audioCtx.currentTime + 0.1);
} else if (type === 'success') {
osc.frequency.setValueAtTime(500, audioCtx.currentTime);
osc.frequency.exponentialRampToValueAtTime(800, audioCtx.currentTime + 0.2);
gain.gain.setValueAtTime(0.1, audioCtx.currentTime);
gain.gain.linearRampToValueAtTime(0, audioCtx.currentTime + 0.3);
osc.start(); osc.stop(audioCtx.currentTime + 0.3);
}
}
// --- Cursor Trail ---
let particles = [];
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
class Particle {
constructor(x, y) {
this.x = x; this.y = y;
this.size = Math.random() * 5 + 2;
this.speedX = Math.random() * 2 - 1;
this.speedY = Math.random() * 2 - 1;
this.color = `hsl(${Math.random() * 60 + 280}, 100%, 70%)`;
this.alpha = 1;
}
update() {
this.x += this.speedX; this.y += this.speedY;
if (this.size > 0.1) this.size -= 0.1;
this.alpha -= 0.02;
}
draw() {
ctx.save(); ctx.globalAlpha = this.alpha;
ctx.fillStyle = this.color; ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fill(); ctx.restore();
}
}
window.addEventListener('mousemove', (e) => {
for (let i = 0; i < 2; i++) particles.push(new Particle(e.x, e.y));
});
function animateParticles() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
for (let i = 0; i < particles.length; i++) {
particles[i].update(); particles[i].draw();
if (particles[i].alpha <= 0) { particles.splice(i, 1); i--; }
}
requestAnimationFrame(animateParticles);
}
animateParticles();
// --- Main UI Logic ---
const trollPhrases = ["Pakad ke dikhao! πββοΈ", "Itna slow? π’", "Try again ji! π", "Nahi milega! π«"];
function moveButton() {
playSound('whoosh');
const maxX = window.innerWidth - yesBtn.offsetWidth - 20;
const maxY = window.innerHeight - yesBtn.offsetHeight - 20;
const newX = Math.max(10, Math.floor(Math.random() * maxX));
const newY = Math.max(10, Math.floor(Math.random() * maxY));
yesBtn.style.left = newX + "px";
yesBtn.style.top = newY + "px";
yesBtn.style.transform = "none";
yesBtn.innerText = trollPhrases[Math.floor(Math.random() * trollPhrases.length)];
}
yesBtn.addEventListener('mouseover', moveButton);
yesBtn.addEventListener('touchstart', (e) => { e.preventDefault(); moveButton(); });
// --- Feature 4: Mood Slider Logic ---
const moodScreen = document.getElementById('mood-screen');
const moodSlider = document.getElementById('moodSlider');
const moodEmoji = document.getElementById('moodEmoji');
const moodLabel = document.getElementById('moodLabel');
noBtn.addEventListener('click', () => {
playSound('pop');
yesBtn.style.display = 'none';
confetti({ particleCount: 100, spread: 60 });
screen1.style.display = 'none';
moodScreen.classList.remove('hidden'); // Opens the mood slider screen
});
moodSlider.addEventListener('input', (e) => {
const val = parseInt(e.target.value);
if (val <= 25) {
moodEmoji.innerText = "π€";
moodLabel.innerText = "Current Mood: Very Angry! π€¬";
moodLabel.style.color = "#ff416c";
} else if (val <= 50) {
moodEmoji.innerText = "π";
moodLabel.innerText = "Current Mood: Still Annoyed... π«€";
moodLabel.style.color = "#fd79a8";
} else if (val <= 75) {
moodEmoji.innerText = "π";
moodLabel.innerText = "Current Mood: Okay, slightly better. π";
moodLabel.style.color = "#7950f2";
} else if (val < 95) {
moodEmoji.innerText = "π";
moodLabel.innerText = "Current Mood: Smiling? Almost there! π";
moodLabel.style.color = "#2ed573";
} else if (val >= 95) {
moodEmoji.innerText = "π₯°";
moodLabel.innerText = "Current Mood: Genuine Smile Detected! β€οΈ";
moodLabel.style.color = "#00b894";
moodSlider.disabled = true; // Avoids multiple triggers
setTimeout(() => {
confetti({ particleCount: 150, spread: 70, origin: { y: 0.6 } });
moodScreen.style.display = 'none';
loaderScreen.classList.remove('hidden');
setTimeout(() => {
loaderFill.classList.add('success-green');
loaderText.innerText = "{name}'s Genuine Smile Detected! π";
loaderText.classList.add('text-success-green');
playSound('success');
confetti({ particleCount: 40, spread: 50 });
}, 1800);
setTimeout(() => {
loaderScreen.style.display = 'none';
screen2.classList.remove('hidden');
screen2.classList.add('zoom-in-entrance');
document.body.classList.add('show-magic');
document.body.classList.add('magic-theme');
setInterval(createSparkle, 500);
audio.play().catch(e => {});
}, 3500);
}, 800);
}
});
// --- Feature 2: Audio Visualizer Logic ---
let visInitialized = false;
function initVisualizer() {
if (visInitialized) return;
visInitialized = true;
if (audioCtx.state === 'suspended') audioCtx.resume();
const src = audioCtx.createMediaElementSource(audio);
const analyser = audioCtx.createAnalyser();
src.connect(analyser);
analyser.connect(audioCtx.destination);
analyser.fftSize = 64;
const bufferLength = analyser.frequencyBinCount;
const dataArray = new Uint8Array(bufferLength);
const canvasElement = document.getElementById('visualizerCanvas');
const canvasCtx = canvasElement.getContext('2d');
canvasElement.width = canvasElement.clientWidth;
canvasElement.height = canvasElement.clientHeight;
function draw() {
requestAnimationFrame(draw);
analyser.getByteFrequencyData(dataArray);
canvasCtx.clearRect(0, 0, canvasElement.width, canvasElement.height);
const barWidth = (canvasElement.width / bufferLength) * 1.6;
let barHeight;
let x = 0;
for (let i = 0; i < bufferLength; i++) {
barHeight = (dataArray[i] / 255) * canvasElement.height;
const r = (i * 10) % 255;
const g = 140;
const b = 230;
canvasCtx.fillStyle = `rgb(${r}, ${g}, ${b})`;
canvasCtx.fillRect(x, canvasElement.height - barHeight, barWidth - 2, barHeight);
x += barWidth;
}
}
draw();
}
audio.addEventListener('play', initVisualizer);
function createSparkle() {
const sparkle = document.createElement('div');
sparkle.className = 'sparkle'; sparkle.innerHTML = 'β¨';
sparkle.style.left = Math.random() * 100 + 'vw';
document.getElementById('sparkles-container').appendChild(sparkle);
setTimeout(() => sparkle.remove(), 4000);
}
const ultimateSecrets = [
{ t: "Mana kiya tha na {name}! ab text padhte raho....π", c: "#ff416c" },
{ t: "You are so stubbornπ", c: "#7950f2" },
{ t: "Smile toh aa gayi hogi ab tak.πΈ", c: "#f08c00" },
{ t: "You'll never find someone who cheers you up like this... π", c: "#7b3f00" },
{ t: "Honestly, annoying you is my favorite thing to do! π", c: "#a18cd1" },
{ t: "Chalo now stop being angry", c: "#7b3f00" },
{ t: "Oye, you look so cute when you are angry! β¨", c: "#e84393" },
{ t: "Zyada nakhre mat dikhaya kro meko sharm aati haiπ«£π", c: "#0984e3" },
{ t: "Chalo ab bahut trolling ho gayi, dil se sorry! ποΈ", c: "#ff4757" },
{ t: "Are you smiling now? Yes or No? Reply fast! πββοΈ", c: "#2ed573" },
{ t: "No. 1 nakhre wali Ladki! π", c: "#f9ca24" },
{ t: "100 times sorry to {name}! β¨", c: "#6d597a" }
];
// --- Feature 5: Typewriter Effect Helper ---
function typeWriter(text, element, speed = 40) {
element.textContent = ""; // Use textContent to preserve all spaces on mobile
let i = 0;
function type() {
if (i < text.length) {
element.textContent += text.charAt(i);
i++;
setTimeout(type, speed);
}
}
type();
}
let trollIdx = 0;
let loopStarted = false;
function startUltimateTroll() {
if (loopStarted) return;
loopStarted = true;
trollBox.classList.remove('glowing-border');
// Pehla message bina delay ke start hoga
trollMsg.style.opacity = 1;
typeWriter(ultimateSecrets[trollIdx].t, trollMsg);
trollBox.style.borderColor = ultimateSecrets[trollIdx].c;
trollMsg.style.color = ultimateSecrets[trollIdx].c;
trollIdx = (trollIdx + 1) % ultimateSecrets.length;
setInterval(() => {
trollMsg.style.opacity = 0;
setTimeout(() => {
trollMsg.style.opacity = 1;
typeWriter(ultimateSecrets[trollIdx].t, trollMsg);
trollBox.style.borderColor = ultimateSecrets[trollIdx].c;
trollMsg.style.color = ultimateSecrets[trollIdx].c;
trollIdx = (trollIdx + 1) % ultimateSecrets.length;
}, 300);
confetti({ particleCount: 20, spread: 50, colors: [ultimateSecrets[trollIdx].c] });
}, 3800); // 3.8s isliye kiya taaki typing completely khatam ho jaye
}