User prompt
rakamın üstünde her tarafa patlasın ve rengarenk olsun
User prompt
confetiler yukarıdan patlayarak aşağıya insin bir kaç kerede patlamasın
User prompt
konfetiler çok daha görkemli olsun
User prompt
1.3 saniye sonra başa dön
User prompt
Please fix the bug: 'Uncaught TypeError: LK.effects.confetti is not a function' in or related to this line: 'LK.effects.confetti();' Line Number: 221
User prompt
Please fix the bug: 'Uncaught TypeError: LK.effects.confetti is not a function' in or related to this line: 'LK.effects.confetti();' Line Number: 221
User prompt
artarakta 10x olunca azalarakta 0 olunca konfetiler patlasın game over yazısını gösterme
User prompt
artarakta 10x olunca azalarakta 0 olunca konfetiler patlasın game over yazısını gösterme
User prompt
oyun başa dönmeden önce flashı kaldır konfeti patlat
User prompt
konfetiler patlasın
User prompt
Please fix the bug: 'Uncaught TypeError: LK.effects.confetti is not a function' in or related to this line: 'LK.effects.confetti();' Line Number: 221
User prompt
artarakta 10x olunca azalarakta 0 olunca konfetiler patlasın game over olmasın başa dönsün oyun
User prompt
1.3 saniyeye düşür
User prompt
artarak diyince tıkladığım rakamın 1x ile azalarak dediğimde rakamın 10x ile başla
User prompt
10 katına geldikten sonra 2 saniye geçsin
User prompt
her sayı kendisinin 10 katına gelince oyun bitsin
User prompt
her sayı kendisi kadar çoğalsın
User prompt
1 olmasın
User prompt
rakamlar 1 den 9 a kadar olsun başlangıçta
Code edit (1 edits merged)
Please save this source code
User prompt
İleri-Geri Sayma Oyunu
Initial prompt
ileri doğru ve geri doğru sayma oyunu yapıcaz ekranda öncelikle bir giriş ekranı olucak oraya saymak istediği rakama tıklayacak sonra o rakam tıkladıkça ileri doğru sayıcak
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xffffff // White background for clarity }); /**** * Game Code ****/ // --- GLOBALS --- var countingDirection = 1; // 1: up, -1: down var startNumber = 0; var targetNumber = 10; var currentNumber = 0; var gameStarted = false; // UI elements var numberText = null; var infoText = null; var optionButtons = []; var directionButtons = []; var selectedTarget = null; var selectedDirection = null; // --- UI HELPERS --- // Create a button as a colored box with text, returns a Container function createButton(label, x, y, width, height, color, onTap) { var btn = new Container(); var box = btn.attachAsset('buttonBox', { width: width, height: height, color: color, anchorX: 0.5, anchorY: 0.5 }); var txt = new Text2(label, { size: 80, fill: 0xFFFFFF }); txt.anchor.set(0.5, 0.5); txt.x = 0; txt.y = 0; btn.addChild(txt); btn.x = x; btn.y = y; btn.interactive = true; btn.down = function (x, y, obj) { if (onTap) onTap(); }; return btn; } // --- GAME SETUP --- // Show the pre-game menu: select target number and direction function showMenu() { gameStarted = false; // Remove previous UI if any if (numberText) { numberText.destroy(); numberText = null; } if (infoText) { infoText.destroy(); infoText = null; } for (var i = 0; i < optionButtons.length; i++) { optionButtons[i].destroy(); } optionButtons = []; for (var i = 0; i < directionButtons.length; i++) { directionButtons[i].destroy(); } directionButtons = []; // Info text infoText = new Text2("Bir hedef sayı seçin", { size: 90, fill: 0x222222 }); infoText.anchor.set(0.5, 0); infoText.x = 2048 / 2; infoText.y = 250; game.addChild(infoText); // Target number options (2-9) var targets = [2, 3, 4, 5, 6, 7, 8, 9]; var btnW = 200, btnH = 180; var gap = 40; var totalW = targets.length * btnW + (targets.length - 1) * gap; var startX = (2048 - totalW) / 2 + btnW / 2; for (var i = 0; i < targets.length; i++) { (function (idx) { var t = targets[idx]; var btn = createButton("" + t, startX + idx * (btnW + gap), 600, btnW, btnH, 0x4a90e2, function () { selectTarget(t, idx); }); optionButtons.push(btn); game.addChild(btn); })(i); } // Direction selection: "Artarak" (up), "Azalarak" (down) var dirLabels = ["Artarak", "Azalarak"]; var dirVals = [1, -1]; var dirBtnW = 400, dirBtnH = 150; var dirGap = 100; var dirStartX = (2048 - (2 * dirBtnW + dirGap)) / 2 + dirBtnW / 2; for (var i = 0; i < 2; i++) { (function (idx) { var btn = createButton(dirLabels[idx], dirStartX + idx * (dirBtnW + dirGap), 950, dirBtnW, dirBtnH, 0x7ed957, function () { selectDirection(dirVals[idx], idx); }); directionButtons.push(btn); game.addChild(btn); })(i); } } // When a target number is selected function selectTarget(t, idx) { targetNumber = t; selectedTarget = idx; // Highlight selected for (var i = 0; i < optionButtons.length; i++) { optionButtons[i].children[0].tint = i === idx ? 0xffc107 : 0xffffff; } // If direction already selected, start game if (selectedDirection !== null) { startGame(); } } // When a direction is selected function selectDirection(dir, idx) { countingDirection = dir; selectedDirection = idx; // Highlight selected for (var i = 0; i < directionButtons.length; i++) { directionButtons[i].children[0].tint = i === idx ? 0xffc107 : 0xffffff; } // If target already selected, start game if (selectedTarget !== null) { startGame(); } } // --- GAMEPLAY --- function startGame() { // Remove menu UI if (infoText) { infoText.destroy(); infoText = null; } for (var i = 0; i < optionButtons.length; i++) { optionButtons[i].destroy(); } optionButtons = []; for (var i = 0; i < directionButtons.length; i++) { directionButtons[i].destroy(); } directionButtons = []; // Set start number if (countingDirection === 1) { startNumber = targetNumber; // artarak: start at 1x target } else { startNumber = targetNumber * 10; // azalarak: start at 10x target } currentNumber = startNumber; // Show current number numberText = new Text2("" + currentNumber, { size: 350, fill: 0x222222 }); numberText.anchor.set(0.5, 0.5); numberText.x = 2048 / 2; numberText.y = 2732 / 2; game.addChild(numberText); gameStarted = true; } // --- GAME INTERACTION --- // On tap/click anywhere, increment or decrement number game.down = function (x, y, obj) { if (!gameStarted) return; // Animate numberText (scale up and back) tween(numberText, { scaleX: 1.2, scaleY: 1.2 }, { duration: 80, easing: tween.easeOut, onFinish: function onFinish() { tween(numberText, { scaleX: 1, scaleY: 1 }, { duration: 80, easing: tween.easeIn }); } }); // Update number if (countingDirection === 1) { currentNumber += targetNumber; } else { currentNumber -= targetNumber; } numberText.setText("" + currentNumber); // Check for win if (countingDirection === 1 && currentNumber >= targetNumber * 10) { // Artarak: 10x reached gameStarted = false; // Show confetti, no game over // Spectacular confetti: multi-stage, multi-size, multi-origin, with trails and bursts (function spectacularConfettiBurst() { var confettiColors = [0xffc107, 0x4a90e2, 0x7ed957, 0xe94e77, 0xffffff, 0xf44336, 0x00e6e6, 0xff69b4, 0x8d4fff, 0x00c853]; var burstCenters = [{ x: 2048 / 2, y: 2732 / 2 }, { x: 2048 / 2 - 300, y: 2732 / 2 - 200 }, { x: 2048 / 2 + 300, y: 2732 / 2 - 200 }, { x: 2048 / 2 - 400, y: 2732 / 2 + 100 }, { x: 2048 / 2 + 400, y: 2732 / 2 + 100 }]; // Main burst for (var b = 0; b < burstCenters.length; b++) { var center = burstCenters[b]; var count = b === 0 ? 60 : 30; for (var i = 0; i < count; i++) { (function () { var confetti = new Container(); var color = confettiColors[Math.floor(Math.random() * confettiColors.length)]; var size = 32 + Math.random() * 48; var circ = confetti.attachAsset('centerCircle', { width: size, height: size, color: color, anchorX: 0.5, anchorY: 0.5 }); confetti.x = center.x; confetti.y = center.y; game.addChild(confetti); // Random velocity and direction var angle = Math.random() * Math.PI * 2; var speed = 22 + Math.random() * 18 + (b === 0 ? 10 : 0); var vx = Math.cos(angle) * speed; var vy = Math.sin(angle) * speed; var gravity = 0.8 + Math.random() * 0.7; var rotSpeed = (Math.random() - 0.5) * 0.3; var life = 70 + Math.floor(Math.random() * 40) + (b === 0 ? 20 : 0); // Add a trail effect var trailStep = 0; confetti.update = function () { confetti.x += vx; confetti.y += vy; vy += gravity; circ.rotation += rotSpeed; life--; // Trail: every 4 frames, spawn a tiny faded dot if (life > 10 && trailStep++ % 4 === 0) { var trail = new Container(); var tsize = size * 0.3 * Math.random(); var trailCirc = trail.attachAsset('centerCircle', { width: tsize, height: tsize, color: color, anchorX: 0.5, anchorY: 0.5 }); trail.x = confetti.x; trail.y = confetti.y; trail.alpha = 0.5; game.addChild(trail); var trailLife = 18 + Math.floor(Math.random() * 8); trail.update = function () { trail.alpha -= 0.025; trailLife--; if (trailLife <= 0) trail.destroy(); }; } if (life <= 0) { confetti.destroy(); } }; })(); } } // Extra: after 0.3s, spawn a "rain" of confetti from the top LK.setTimeout(function () { for (var i = 0; i < 40; i++) { (function () { var confetti = new Container(); var color = confettiColors[Math.floor(Math.random() * confettiColors.length)]; var size = 24 + Math.random() * 32; var circ = confetti.attachAsset('centerCircle', { width: size, height: size, color: color, anchorX: 0.5, anchorY: 0.5 }); confetti.x = 200 + Math.random() * (2048 - 400); confetti.y = -40 - Math.random() * 100; game.addChild(confetti); var vx = (Math.random() - 0.5) * 6; var vy = 16 + Math.random() * 8; var gravity = 0.5 + Math.random() * 0.3; var rotSpeed = (Math.random() - 0.5) * 0.2; var life = 80 + Math.floor(Math.random() * 30); confetti.update = function () { confetti.x += vx; confetti.y += vy; vy += gravity; circ.rotation += rotSpeed; life--; if (life <= 0 || confetti.y > 2732 + 100) { confetti.destroy(); } }; })(); } }, 300); // Extra: after 0.7s, spawn a "pop" of big confetti from the center LK.setTimeout(function () { for (var i = 0; i < 18; i++) { (function () { var confetti = new Container(); var color = confettiColors[Math.floor(Math.random() * confettiColors.length)]; var size = 80 + Math.random() * 40; var circ = confetti.attachAsset('centerCircle', { width: size, height: size, color: color, anchorX: 0.5, anchorY: 0.5 }); confetti.x = 2048 / 2; confetti.y = 2732 / 2; game.addChild(confetti); var angle = Math.random() * Math.PI * 2; var speed = 12 + Math.random() * 10; var vx = Math.cos(angle) * speed; var vy = Math.sin(angle) * speed; var gravity = 0.6 + Math.random() * 0.4; var rotSpeed = (Math.random() - 0.5) * 0.15; var life = 40 + Math.floor(Math.random() * 20); confetti.update = function () { confetti.x += vx; confetti.y += vy; vy += gravity; circ.rotation += rotSpeed; life--; if (life <= 0) { confetti.destroy(); } }; })(); } }, 700); })(); // 1.3 seconds later, reset to start LK.setTimeout(function () { showMenu(); }, 1300); } else if (countingDirection === -1 && currentNumber <= 0) { // Azalarak: 0 reached gameStarted = false; // Show confetti, no game over // Spectacular confetti: multi-stage, multi-size, multi-origin, with trails and bursts (function spectacularConfettiBurst() { var confettiColors = [0xffc107, 0x4a90e2, 0x7ed957, 0xe94e77, 0xffffff, 0xf44336, 0x00e6e6, 0xff69b4, 0x8d4fff, 0x00c853]; var burstCenters = [{ x: 2048 / 2, y: 2732 / 2 }, { x: 2048 / 2 - 300, y: 2732 / 2 - 200 }, { x: 2048 / 2 + 300, y: 2732 / 2 - 200 }, { x: 2048 / 2 - 400, y: 2732 / 2 + 100 }, { x: 2048 / 2 + 400, y: 2732 / 2 + 100 }]; // Main burst for (var b = 0; b < burstCenters.length; b++) { var center = burstCenters[b]; var count = b === 0 ? 60 : 30; for (var i = 0; i < count; i++) { (function () { var confetti = new Container(); var color = confettiColors[Math.floor(Math.random() * confettiColors.length)]; var size = 32 + Math.random() * 48; var circ = confetti.attachAsset('centerCircle', { width: size, height: size, color: color, anchorX: 0.5, anchorY: 0.5 }); confetti.x = center.x; confetti.y = center.y; game.addChild(confetti); // Random velocity and direction var angle = Math.random() * Math.PI * 2; var speed = 22 + Math.random() * 18 + (b === 0 ? 10 : 0); var vx = Math.cos(angle) * speed; var vy = Math.sin(angle) * speed; var gravity = 0.8 + Math.random() * 0.7; var rotSpeed = (Math.random() - 0.5) * 0.3; var life = 70 + Math.floor(Math.random() * 40) + (b === 0 ? 20 : 0); // Add a trail effect var trailStep = 0; confetti.update = function () { confetti.x += vx; confetti.y += vy; vy += gravity; circ.rotation += rotSpeed; life--; // Trail: every 4 frames, spawn a tiny faded dot if (life > 10 && trailStep++ % 4 === 0) { var trail = new Container(); var tsize = size * 0.3 * Math.random(); var trailCirc = trail.attachAsset('centerCircle', { width: tsize, height: tsize, color: color, anchorX: 0.5, anchorY: 0.5 }); trail.x = confetti.x; trail.y = confetti.y; trail.alpha = 0.5; game.addChild(trail); var trailLife = 18 + Math.floor(Math.random() * 8); trail.update = function () { trail.alpha -= 0.025; trailLife--; if (trailLife <= 0) trail.destroy(); }; } if (life <= 0) { confetti.destroy(); } }; })(); } } // Extra: after 0.3s, spawn a "rain" of confetti from the top LK.setTimeout(function () { for (var i = 0; i < 40; i++) { (function () { var confetti = new Container(); var color = confettiColors[Math.floor(Math.random() * confettiColors.length)]; var size = 24 + Math.random() * 32; var circ = confetti.attachAsset('centerCircle', { width: size, height: size, color: color, anchorX: 0.5, anchorY: 0.5 }); confetti.x = 200 + Math.random() * (2048 - 400); confetti.y = -40 - Math.random() * 100; game.addChild(confetti); var vx = (Math.random() - 0.5) * 6; var vy = 16 + Math.random() * 8; var gravity = 0.5 + Math.random() * 0.3; var rotSpeed = (Math.random() - 0.5) * 0.2; var life = 80 + Math.floor(Math.random() * 30); confetti.update = function () { confetti.x += vx; confetti.y += vy; vy += gravity; circ.rotation += rotSpeed; life--; if (life <= 0 || confetti.y > 2732 + 100) { confetti.destroy(); } }; })(); } }, 300); // Extra: after 0.7s, spawn a "pop" of big confetti from the center LK.setTimeout(function () { for (var i = 0; i < 18; i++) { (function () { var confetti = new Container(); var color = confettiColors[Math.floor(Math.random() * confettiColors.length)]; var size = 80 + Math.random() * 40; var circ = confetti.attachAsset('centerCircle', { width: size, height: size, color: color, anchorX: 0.5, anchorY: 0.5 }); confetti.x = 2048 / 2; confetti.y = 2732 / 2; game.addChild(confetti); var angle = Math.random() * Math.PI * 2; var speed = 12 + Math.random() * 10; var vx = Math.cos(angle) * speed; var vy = Math.sin(angle) * speed; var gravity = 0.6 + Math.random() * 0.4; var rotSpeed = (Math.random() - 0.5) * 0.15; var life = 40 + Math.floor(Math.random() * 20); confetti.update = function () { confetti.x += vx; confetti.y += vy; vy += gravity; circ.rotation += rotSpeed; life--; if (life <= 0) { confetti.destroy(); } }; })(); } }, 700); })(); // 1.3 seconds later, reset to start LK.setTimeout(function () { showMenu(); }, 1300); } }; // --- GAME RESET --- // When game is reset, show menu again game.on('reset', function () { showMenu(); }); // --- INITIALIZE --- showMenu();
===================================================================
--- original.js
+++ change.js
@@ -208,90 +208,328 @@
if (countingDirection === 1 && currentNumber >= targetNumber * 10) {
// Artarak: 10x reached
gameStarted = false;
// Show confetti, no game over
- // Simple confetti effect: spawn colored circles with random velocities
- for (var i = 0; i < 40; i++) {
- (function () {
- var confetti = new Container();
- var colors = [0xffc107, 0x4a90e2, 0x7ed957, 0xe94e77, 0xffffff, 0xf44336];
- var color = colors[Math.floor(Math.random() * colors.length)];
- var size = 40 + Math.random() * 30;
- var circ = confetti.attachAsset('centerCircle', {
- width: size,
- height: size,
- color: color,
- anchorX: 0.5,
- anchorY: 0.5
- });
- confetti.x = 2048 / 2;
- confetti.y = 2732 / 2;
- game.addChild(confetti);
- // Random velocity and direction
- var angle = Math.random() * Math.PI * 2;
- var speed = 18 + Math.random() * 12;
- var vx = Math.cos(angle) * speed;
- var vy = Math.sin(angle) * speed;
- var gravity = 0.7 + Math.random() * 0.5;
- var rotSpeed = (Math.random() - 0.5) * 0.2;
- var life = 60 + Math.floor(Math.random() * 30);
- confetti.update = function () {
- confetti.x += vx;
- confetti.y += vy;
- vy += gravity;
- circ.rotation += rotSpeed;
- life--;
- if (life <= 0) {
- confetti.destroy();
- }
- };
- })();
- }
+ // Spectacular confetti: multi-stage, multi-size, multi-origin, with trails and bursts
+ (function spectacularConfettiBurst() {
+ var confettiColors = [0xffc107, 0x4a90e2, 0x7ed957, 0xe94e77, 0xffffff, 0xf44336, 0x00e6e6, 0xff69b4, 0x8d4fff, 0x00c853];
+ var burstCenters = [{
+ x: 2048 / 2,
+ y: 2732 / 2
+ }, {
+ x: 2048 / 2 - 300,
+ y: 2732 / 2 - 200
+ }, {
+ x: 2048 / 2 + 300,
+ y: 2732 / 2 - 200
+ }, {
+ x: 2048 / 2 - 400,
+ y: 2732 / 2 + 100
+ }, {
+ x: 2048 / 2 + 400,
+ y: 2732 / 2 + 100
+ }];
+ // Main burst
+ for (var b = 0; b < burstCenters.length; b++) {
+ var center = burstCenters[b];
+ var count = b === 0 ? 60 : 30;
+ for (var i = 0; i < count; i++) {
+ (function () {
+ var confetti = new Container();
+ var color = confettiColors[Math.floor(Math.random() * confettiColors.length)];
+ var size = 32 + Math.random() * 48;
+ var circ = confetti.attachAsset('centerCircle', {
+ width: size,
+ height: size,
+ color: color,
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ confetti.x = center.x;
+ confetti.y = center.y;
+ game.addChild(confetti);
+ // Random velocity and direction
+ var angle = Math.random() * Math.PI * 2;
+ var speed = 22 + Math.random() * 18 + (b === 0 ? 10 : 0);
+ var vx = Math.cos(angle) * speed;
+ var vy = Math.sin(angle) * speed;
+ var gravity = 0.8 + Math.random() * 0.7;
+ var rotSpeed = (Math.random() - 0.5) * 0.3;
+ var life = 70 + Math.floor(Math.random() * 40) + (b === 0 ? 20 : 0);
+ // Add a trail effect
+ var trailStep = 0;
+ confetti.update = function () {
+ confetti.x += vx;
+ confetti.y += vy;
+ vy += gravity;
+ circ.rotation += rotSpeed;
+ life--;
+ // Trail: every 4 frames, spawn a tiny faded dot
+ if (life > 10 && trailStep++ % 4 === 0) {
+ var trail = new Container();
+ var tsize = size * 0.3 * Math.random();
+ var trailCirc = trail.attachAsset('centerCircle', {
+ width: tsize,
+ height: tsize,
+ color: color,
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ trail.x = confetti.x;
+ trail.y = confetti.y;
+ trail.alpha = 0.5;
+ game.addChild(trail);
+ var trailLife = 18 + Math.floor(Math.random() * 8);
+ trail.update = function () {
+ trail.alpha -= 0.025;
+ trailLife--;
+ if (trailLife <= 0) trail.destroy();
+ };
+ }
+ if (life <= 0) {
+ confetti.destroy();
+ }
+ };
+ })();
+ }
+ }
+ // Extra: after 0.3s, spawn a "rain" of confetti from the top
+ LK.setTimeout(function () {
+ for (var i = 0; i < 40; i++) {
+ (function () {
+ var confetti = new Container();
+ var color = confettiColors[Math.floor(Math.random() * confettiColors.length)];
+ var size = 24 + Math.random() * 32;
+ var circ = confetti.attachAsset('centerCircle', {
+ width: size,
+ height: size,
+ color: color,
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ confetti.x = 200 + Math.random() * (2048 - 400);
+ confetti.y = -40 - Math.random() * 100;
+ game.addChild(confetti);
+ var vx = (Math.random() - 0.5) * 6;
+ var vy = 16 + Math.random() * 8;
+ var gravity = 0.5 + Math.random() * 0.3;
+ var rotSpeed = (Math.random() - 0.5) * 0.2;
+ var life = 80 + Math.floor(Math.random() * 30);
+ confetti.update = function () {
+ confetti.x += vx;
+ confetti.y += vy;
+ vy += gravity;
+ circ.rotation += rotSpeed;
+ life--;
+ if (life <= 0 || confetti.y > 2732 + 100) {
+ confetti.destroy();
+ }
+ };
+ })();
+ }
+ }, 300);
+ // Extra: after 0.7s, spawn a "pop" of big confetti from the center
+ LK.setTimeout(function () {
+ for (var i = 0; i < 18; i++) {
+ (function () {
+ var confetti = new Container();
+ var color = confettiColors[Math.floor(Math.random() * confettiColors.length)];
+ var size = 80 + Math.random() * 40;
+ var circ = confetti.attachAsset('centerCircle', {
+ width: size,
+ height: size,
+ color: color,
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ confetti.x = 2048 / 2;
+ confetti.y = 2732 / 2;
+ game.addChild(confetti);
+ var angle = Math.random() * Math.PI * 2;
+ var speed = 12 + Math.random() * 10;
+ var vx = Math.cos(angle) * speed;
+ var vy = Math.sin(angle) * speed;
+ var gravity = 0.6 + Math.random() * 0.4;
+ var rotSpeed = (Math.random() - 0.5) * 0.15;
+ var life = 40 + Math.floor(Math.random() * 20);
+ confetti.update = function () {
+ confetti.x += vx;
+ confetti.y += vy;
+ vy += gravity;
+ circ.rotation += rotSpeed;
+ life--;
+ if (life <= 0) {
+ confetti.destroy();
+ }
+ };
+ })();
+ }
+ }, 700);
+ })();
// 1.3 seconds later, reset to start
LK.setTimeout(function () {
showMenu();
}, 1300);
} else if (countingDirection === -1 && currentNumber <= 0) {
// Azalarak: 0 reached
gameStarted = false;
// Show confetti, no game over
- // Simple confetti effect: spawn colored circles with random velocities
- for (var i = 0; i < 40; i++) {
- (function () {
- var confetti = new Container();
- var colors = [0xffc107, 0x4a90e2, 0x7ed957, 0xe94e77, 0xffffff, 0xf44336];
- var color = colors[Math.floor(Math.random() * colors.length)];
- var size = 40 + Math.random() * 30;
- var circ = confetti.attachAsset('centerCircle', {
- width: size,
- height: size,
- color: color,
- anchorX: 0.5,
- anchorY: 0.5
- });
- confetti.x = 2048 / 2;
- confetti.y = 2732 / 2;
- game.addChild(confetti);
- // Random velocity and direction
- var angle = Math.random() * Math.PI * 2;
- var speed = 18 + Math.random() * 12;
- var vx = Math.cos(angle) * speed;
- var vy = Math.sin(angle) * speed;
- var gravity = 0.7 + Math.random() * 0.5;
- var rotSpeed = (Math.random() - 0.5) * 0.2;
- var life = 60 + Math.floor(Math.random() * 30);
- confetti.update = function () {
- confetti.x += vx;
- confetti.y += vy;
- vy += gravity;
- circ.rotation += rotSpeed;
- life--;
- if (life <= 0) {
- confetti.destroy();
- }
- };
- })();
- }
+ // Spectacular confetti: multi-stage, multi-size, multi-origin, with trails and bursts
+ (function spectacularConfettiBurst() {
+ var confettiColors = [0xffc107, 0x4a90e2, 0x7ed957, 0xe94e77, 0xffffff, 0xf44336, 0x00e6e6, 0xff69b4, 0x8d4fff, 0x00c853];
+ var burstCenters = [{
+ x: 2048 / 2,
+ y: 2732 / 2
+ }, {
+ x: 2048 / 2 - 300,
+ y: 2732 / 2 - 200
+ }, {
+ x: 2048 / 2 + 300,
+ y: 2732 / 2 - 200
+ }, {
+ x: 2048 / 2 - 400,
+ y: 2732 / 2 + 100
+ }, {
+ x: 2048 / 2 + 400,
+ y: 2732 / 2 + 100
+ }];
+ // Main burst
+ for (var b = 0; b < burstCenters.length; b++) {
+ var center = burstCenters[b];
+ var count = b === 0 ? 60 : 30;
+ for (var i = 0; i < count; i++) {
+ (function () {
+ var confetti = new Container();
+ var color = confettiColors[Math.floor(Math.random() * confettiColors.length)];
+ var size = 32 + Math.random() * 48;
+ var circ = confetti.attachAsset('centerCircle', {
+ width: size,
+ height: size,
+ color: color,
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ confetti.x = center.x;
+ confetti.y = center.y;
+ game.addChild(confetti);
+ // Random velocity and direction
+ var angle = Math.random() * Math.PI * 2;
+ var speed = 22 + Math.random() * 18 + (b === 0 ? 10 : 0);
+ var vx = Math.cos(angle) * speed;
+ var vy = Math.sin(angle) * speed;
+ var gravity = 0.8 + Math.random() * 0.7;
+ var rotSpeed = (Math.random() - 0.5) * 0.3;
+ var life = 70 + Math.floor(Math.random() * 40) + (b === 0 ? 20 : 0);
+ // Add a trail effect
+ var trailStep = 0;
+ confetti.update = function () {
+ confetti.x += vx;
+ confetti.y += vy;
+ vy += gravity;
+ circ.rotation += rotSpeed;
+ life--;
+ // Trail: every 4 frames, spawn a tiny faded dot
+ if (life > 10 && trailStep++ % 4 === 0) {
+ var trail = new Container();
+ var tsize = size * 0.3 * Math.random();
+ var trailCirc = trail.attachAsset('centerCircle', {
+ width: tsize,
+ height: tsize,
+ color: color,
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ trail.x = confetti.x;
+ trail.y = confetti.y;
+ trail.alpha = 0.5;
+ game.addChild(trail);
+ var trailLife = 18 + Math.floor(Math.random() * 8);
+ trail.update = function () {
+ trail.alpha -= 0.025;
+ trailLife--;
+ if (trailLife <= 0) trail.destroy();
+ };
+ }
+ if (life <= 0) {
+ confetti.destroy();
+ }
+ };
+ })();
+ }
+ }
+ // Extra: after 0.3s, spawn a "rain" of confetti from the top
+ LK.setTimeout(function () {
+ for (var i = 0; i < 40; i++) {
+ (function () {
+ var confetti = new Container();
+ var color = confettiColors[Math.floor(Math.random() * confettiColors.length)];
+ var size = 24 + Math.random() * 32;
+ var circ = confetti.attachAsset('centerCircle', {
+ width: size,
+ height: size,
+ color: color,
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ confetti.x = 200 + Math.random() * (2048 - 400);
+ confetti.y = -40 - Math.random() * 100;
+ game.addChild(confetti);
+ var vx = (Math.random() - 0.5) * 6;
+ var vy = 16 + Math.random() * 8;
+ var gravity = 0.5 + Math.random() * 0.3;
+ var rotSpeed = (Math.random() - 0.5) * 0.2;
+ var life = 80 + Math.floor(Math.random() * 30);
+ confetti.update = function () {
+ confetti.x += vx;
+ confetti.y += vy;
+ vy += gravity;
+ circ.rotation += rotSpeed;
+ life--;
+ if (life <= 0 || confetti.y > 2732 + 100) {
+ confetti.destroy();
+ }
+ };
+ })();
+ }
+ }, 300);
+ // Extra: after 0.7s, spawn a "pop" of big confetti from the center
+ LK.setTimeout(function () {
+ for (var i = 0; i < 18; i++) {
+ (function () {
+ var confetti = new Container();
+ var color = confettiColors[Math.floor(Math.random() * confettiColors.length)];
+ var size = 80 + Math.random() * 40;
+ var circ = confetti.attachAsset('centerCircle', {
+ width: size,
+ height: size,
+ color: color,
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ confetti.x = 2048 / 2;
+ confetti.y = 2732 / 2;
+ game.addChild(confetti);
+ var angle = Math.random() * Math.PI * 2;
+ var speed = 12 + Math.random() * 10;
+ var vx = Math.cos(angle) * speed;
+ var vy = Math.sin(angle) * speed;
+ var gravity = 0.6 + Math.random() * 0.4;
+ var rotSpeed = (Math.random() - 0.5) * 0.15;
+ var life = 40 + Math.floor(Math.random() * 20);
+ confetti.update = function () {
+ confetti.x += vx;
+ confetti.y += vy;
+ vy += gravity;
+ circ.rotation += rotSpeed;
+ life--;
+ if (life <= 0) {
+ confetti.destroy();
+ }
+ };
+ })();
+ }
+ }, 700);
+ })();
// 1.3 seconds later, reset to start
LK.setTimeout(function () {
showMenu();
}, 1300);