Spaces:
Running
Running
Bot commited on
Commit Β·
e6ca063
1
Parent(s): 31fcb83
feat: increase fireball size and speed
Browse files- static/main.js +48 -5
static/main.js
CHANGED
|
@@ -129,6 +129,7 @@ let pendingFireballPos = null;
|
|
| 129 |
const hearts = [];
|
| 130 |
const particles = [];
|
| 131 |
let nextHeartSpawn = 0;
|
|
|
|
| 132 |
|
| 133 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 134 |
// GESTURE DETECTION
|
|
@@ -270,6 +271,36 @@ class Heart {
|
|
| 270 |
}
|
| 271 |
}
|
| 272 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 274 |
// NEON WIREFRAME DRAWING
|
| 275 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -464,12 +495,24 @@ function detectLoop() {
|
|
| 464 |
mirroredHands.forEach((hand, i) => {
|
| 465 |
drawHand(hand, i);
|
| 466 |
if (isFingerHeart(hand)) {
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 472 |
}
|
|
|
|
|
|
|
| 473 |
}
|
| 474 |
});
|
| 475 |
|
|
|
|
| 129 |
const hearts = [];
|
| 130 |
const particles = [];
|
| 131 |
let nextHeartSpawn = 0;
|
| 132 |
+
let heartCharges = [0, 0];
|
| 133 |
|
| 134 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 135 |
// GESTURE DETECTION
|
|
|
|
| 271 |
}
|
| 272 |
}
|
| 273 |
|
| 274 |
+
function drawHeartWireframe(ctx, x, y, size, progress) {
|
| 275 |
+
ctx.save();
|
| 276 |
+
ctx.translate(x, y);
|
| 277 |
+
const s = size / 15;
|
| 278 |
+
ctx.scale(s, s);
|
| 279 |
+
ctx.lineWidth = 3 / s;
|
| 280 |
+
ctx.strokeStyle = '#ff0077';
|
| 281 |
+
ctx.shadowBlur = 15;
|
| 282 |
+
ctx.shadowColor = '#ff0077';
|
| 283 |
+
|
| 284 |
+
ctx.beginPath();
|
| 285 |
+
ctx.moveTo(0, 5);
|
| 286 |
+
ctx.bezierCurveTo(-5, 0, -10, -5, -10, -10);
|
| 287 |
+
ctx.bezierCurveTo(-10, -15, -5, -20, 0, -15);
|
| 288 |
+
ctx.bezierCurveTo(5, -20, 10, -15, 10, -10);
|
| 289 |
+
ctx.bezierCurveTo(10, -5, 5, 0, 0, 5);
|
| 290 |
+
|
| 291 |
+
const pathLength = 80;
|
| 292 |
+
ctx.setLineDash([pathLength]);
|
| 293 |
+
ctx.lineDashOffset = pathLength * (1 - progress);
|
| 294 |
+
|
| 295 |
+
ctx.stroke();
|
| 296 |
+
|
| 297 |
+
if (progress >= 1.0) {
|
| 298 |
+
ctx.fillStyle = 'rgba(255, 0, 119, 0.3)';
|
| 299 |
+
ctx.fill();
|
| 300 |
+
}
|
| 301 |
+
ctx.restore();
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 305 |
// NEON WIREFRAME DRAWING
|
| 306 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 495 |
mirroredHands.forEach((hand, i) => {
|
| 496 |
drawHand(hand, i);
|
| 497 |
if (isFingerHeart(hand)) {
|
| 498 |
+
heartCharges[i] = Math.min(60, (heartCharges[i] || 0) + 2);
|
| 499 |
+
const progress = heartCharges[i] / 60;
|
| 500 |
+
|
| 501 |
+
const hx = (hand[4].x + hand[8].x) / 2 * canvas.width;
|
| 502 |
+
const hy = (hand[4].y + hand[8].y) / 2 * canvas.height;
|
| 503 |
+
|
| 504 |
+
drawHeartWireframe(ctx, hx, hy, 40, progress);
|
| 505 |
+
|
| 506 |
+
if (progress >= 1.0) {
|
| 507 |
+
makingHeart = true;
|
| 508 |
+
if (frameCount >= nextHeartSpawn) {
|
| 509 |
+
hearts.push(new Heart(hand[8].x * canvas.width, hand[8].y * canvas.height));
|
| 510 |
+
nextHeartSpawn = frameCount + (30 + Math.random() * 150);
|
| 511 |
+
audio.play('heart');
|
| 512 |
+
}
|
| 513 |
}
|
| 514 |
+
} else {
|
| 515 |
+
heartCharges[i] = Math.max(0, (heartCharges[i] || 0) - 5);
|
| 516 |
}
|
| 517 |
});
|
| 518 |
|