User prompt
ajouter une class pour le chef sans l'ajouter au jeu. integre dans la classe la possibiliter de le déplacer horizontalement
Code edit (11 edits merged)
Please save this source code
User prompt
quand on appuie sur switch button: - appel switchToMiniGame dans switchToMiniGame : anime le déplacement de miniGameContainer de y = 2732 à y=0 et anime le mouvement de mainGameContainer de y = 0 à y = -2732
Code edit (1 edits merged)
Please save this source code
User prompt
crée un class pour le bouton switch mais ne l'ajoute pas
User prompt
Please fix the bug: 'Timeout.tick error: updateCakeCounter is not defined' in or related to this line: 'updateCakeCounter();' Line Number: 1665
User prompt
Please fix the bug: 'Timeout.tick error: cakesPerSecond is not defined' in or related to this line: 'cakes += cakesPerSecond;' Line Number: 1664
User prompt
Please fix the bug: 'Timeout.tick error: cakes is not defined' in or related to this line: 'cakes += cakesPerSecond;' Line Number: 1663
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: cakes is not defined' in or related to this line: 'cakes += miniGameReward;' Line Number: 1524
User prompt
Please fix the bug: 'LK.onUpdate is not a function' in or related to this line: 'self.destroy();' Line Number: 531
User prompt
Please fix the bug: 'LK.onUpdate is not a function' in or related to this line: 'self.destroy();' Line Number: 528
User prompt
Please fix the bug: 'LK.onUpdate is not a function' in or related to this line: 'LK.onUpdate(gameLoop);' Line Number: 1654
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: cakes is not defined' in or related to this line: 'cakes += miniGameReward;' Line Number: 1518
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'add')' in or related to this line: 'LK.ticker.add(gameLoop);' Line Number: 1651
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: updateAnimations is not defined' in or related to this line: 'updateAnimations(dt);' Line Number: 1638
User prompt
Please fix the bug: 'Timeout.tick error: cakesPerSecondCounter is not defined' in or related to this line: 'function gameLoop(dt) {' Line Number: 1626
User prompt
Please fix the bug: 'Timeout.tick error: cakesPerSecondCounter is not defined' in or related to this line: 'cakesPerSecondCounter += dt;' Line Number: 1627
User prompt
Please fix the bug: 'LK.onUpdate is not a function' in or related to this line: 'LK.onUpdate(gameLoop);' Line Number: 1620
User prompt
Please fix the bug: 'Graphics is not a constructor' in or related to this line: 'var shadow = new Graphics();' Line Number: 407
User prompt
Please fix the bug: 'Graphics is not a constructor' in or related to this line: 'var panel = new Graphics();' Line Number: 800
User prompt
Please fix the bug: 'upgrade.updateCakeGraphics is not a function' in or related to this line: 'upgrade.updateCakeGraphics(); // Update cake graphics based on new upgrade level' Line Number: 1544
User prompt
Please fix the bug: 'upgrade.updateCakeGraphics is not a function' in or related to this line: 'upgrade.updateCakeGraphics(); // Update cake graphics based on new upgrade level' Line Number: 1544
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { score: 0, autoClickerCount: 0, upgradeMultiplier: 1 }); /**** * Classes ****/ // AutoClicker class var AutoClicker = Container.expand(function () { var self = Container.call(this); self.startAutoClicking = function () { self.autoClickerInterval = LK.setInterval(function () { if (self.autoClickerCount > 0) { bigCake.emit('down'); // Trigger the 'down' event on bigCake to simulate a click } if (self.autoClickerCount > 1 && self.autoClickerCount < autoClicksPerSecond.length) { bigCake.emit('down'); // Trigger the 'down' event on bigCake to simulate a click currentScore += upgradeMultiplier[upgradeLevel] * autoClicksPerSecond[self.autoClickerCount]; // Increment score by the upgrade multiplier per click score.updateScore(currentScore); storage.score = currentScore; // Save the updated score storage.timestamp = Date.now(); // Save the current timestamp } }, 1000); }; // Create a shadow effect by adding a black tinted, semi-transparent duplicate of autoClickerGraphics var shadowGraphics = self.attachAsset('autoClicker', { anchorX: 0.5, anchorY: 0.5 }); shadowGraphics.tint = 0x000000; // Tint the shadow black shadowGraphics.alpha = 0.5; // Make the shadow semi-transparent shadowGraphics.y = 10; // Position the shadow slightly below the autoClicker button self.addChild(shadowGraphics); var autoClickerGraphics = self.attachAsset('autoClicker', { anchorX: 0.5, anchorY: 0.5 }); // Add 'Worker' text above the auto clicker image var workerLabel = new Text2('Worker', { size: 60, fill: 0x1E90FF, // Match price text color fontWeight: '900', dropShadow: true, dropShadowColor: 0x000000, dropShadowBlur: 5, dropShadowDistance: 5 }); workerLabel.anchor.set(0.5, 1); // Center the text horizontally and align it to the bottom workerLabel.fill = 0x0000FF; // Change text color to blue workerLabel.y = autoClickerGraphics.y - autoClickerGraphics.height / 2 - 10; // Adjust text position to -10 above the auto clicker image self.addChild(workerLabel); // Attach the chef's toque image on top of the auto clicker button var toqueGraphics = self.attachAsset('toque', { anchorX: 0.5, anchorY: 0.5 }); toqueGraphics.y = 0; // Move the toque slightly higher on the auto clicker self.addChild(toqueGraphics); self.cost = 100; // Initial cost of the auto clicker self.autoClickerCount = 0; self.stars = []; // Array to store the list of stars var priceText = new Text2('$' + self.cost, { size: 80, fill: 0x1E90FF, fontWeight: '900', // Make the text bolder dropShadow: true, // Enable drop shadow dropShadowColor: 0x000000, // Set drop shadow color to black dropShadowBlur: 5, // Set drop shadow blur dropShadowDistance: 5 // Set drop shadow distance }); priceText.setText('$' + self.cost); // Update the price text to reflect the current cost priceText.anchor.set(0.5, 0); priceText.x = 0; priceText.y = autoClickerGraphics.height / 2 + 0; // Position text below the auto clicker button self.addChild(priceText); self.updatePriceText = function () { priceText.setText(formatPrice(self.cost)); // Update the price text to reflect the current cost }; self.initStars = function () { // Clear existing stars self.stars.forEach(function (star) { star.destroy(); }); self.stars = []; // Create new stars based on autoClickerCount for (var i = 0; i < self.autoClickerCount; i++) { var star = self.attachAsset('etoile', { anchorX: 0.5, anchorY: 0.5 }); star.y = toqueGraphics.y + toqueGraphics.height / 2 + star.height / 2; self.stars.push(star); } self.displayStars(); // Update positions of all stars based on the current count }; self.displayStars = function () { // Update positions of all stars based on the current count self.stars.forEach(function (star, index) { if (self.autoClickerCount === 1) { star.x = 0; // Position the first star at x = 0 } else if (self.autoClickerCount === 2) { star.x = index === 0 ? -30 : 30; // Position the second star at x = -60 and the third at x = 60 } else if (self.autoClickerCount === 3) { star.x = index === 0 ? -70 : index === 1 ? 0 : 70; star.y = index === 0 ? 70 : index === 1 ? 100 : 70; } else if (self.autoClickerCount > 3) { var angle = index * (Math.PI * 2 / self.autoClickerCount); star.x = Math.cos(angle) * 100; // x varies between -100 and 100 star.y = Math.sin(angle) * 100; // y varies between -100 and 100 } }); }; self.onClick = function () { if (currentScore >= self.cost && self.autoClickerCount < 9) { currentScore -= self.cost; // Deduct the cost from the current score score.updateScore(currentScore); // Update the score display self.autoClickerCount += 1; // Increase the number of auto clickers // Add a star under the toque for each upgrade, up to 3 stars if (self.autoClickerCount <= 9) { var star = self.attachAsset('etoile', { anchorX: 0.5, anchorY: 0.5 }); star.y = toqueGraphics.y + toqueGraphics.height / 2 + star.height / 2; // Position the star under the toque self.stars.push(star); // Add the star to the stars array } self.displayStars(); // Update positions of all stars based on the current count storage.autoClickerCount = self.autoClickerCount; // Save the updated auto clicker count if (self.autoClickerCount === 1) { self.startAutoClicking(); // Start auto clicking only when the first auto clicker is purchased } self.cost = autoClickerPrices[Math.min(self.autoClickerCount, autoClickerPrices.length - 1)]; // Update the cost using the autoClickerPrices array storage.autoClickerCost = self.cost; // Save the updated auto clicker cost self.updatePriceText(); // Update the price text to reflect the new cost LK.getSound('buyAutoclickerSound').play(); // Play buyAutoclickerSound when an autoclicker is purchased autoClickerText.fill = currentScore >= self.cost ? 0x00FF00 : 0xFF0000; // Update text color based on affordability // Animate the autoClicker button tween(autoClickerGraphics, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100, easing: tween.easeInOut, onFinish: function onFinish() { tween(autoClickerGraphics, { scaleX: 1, scaleY: 1 }, { duration: 100, easing: tween.easeInOut }); } }); // Animate the shadowGraphics in the same way tween(shadowGraphics, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100, easing: tween.easeInOut, onFinish: function onFinish() { tween(shadowGraphics, { scaleX: 1, scaleY: 1 }, { duration: 100, easing: tween.easeInOut }); } }); // Animate the toqueGraphics in the same way tween(toqueGraphics, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100, easing: tween.easeInOut, onFinish: function onFinish() { tween(toqueGraphics, { scaleX: 1, scaleY: 1 }, { duration: 100, easing: tween.easeInOut }); } }); } else { tween(self, { alpha: 0.2 }, { duration: 100, easing: tween.easeInOut, onFinish: function onFinish() { tween(self, { alpha: 1 }, { duration: 100, easing: tween.easeInOut, onFinish: function onFinish() { tween(self, { alpha: 0.2 }, { duration: 100, easing: tween.easeInOut, onFinish: function onFinish() { tween(self, { alpha: 1 }, { duration: 100, easing: tween.easeInOut }); } }); } }); } }); LK.getSound('errorsond').play(); // Play error sound } }; return self; }); // BigCake class var BigCake = Container.expand(function () { var self = Container.call(this); var bigCakeGraphics = self.attachAsset('bigCake', { anchorX: 0.5, anchorY: 0.5 }); self.on('down', function (x, y, obj) { // Use ConfettiManager to create confetti effect confettiManager.popCakes(self.x, self.y, 5); LK.getSound('clickSound').play(); currentScore += upgradeMultiplier[upgradeLevel]; // Increment score by the upgrade multiplier per click score.updateScore(currentScore); storage.score = currentScore; // Save the updated score storage.timestamp = Date.now(); // Save the current timestamp // Add a bump animation tween(self, { scaleX: 1.2, scaleY: 1.2 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.easeIn }); } }); // Removed the creation of falling cakes }); }); // Board class var Board = Container.expand(function () { var self = Container.call(this); self.boardGraphics = self.attachAsset('board', { anchorX: 0.5, anchorY: 0.5 }); self.boardGraphics.alpha = 1; // Make the board fully opaque self.addChild(self.boardGraphics); }); // BonusCake class var BonusCake = Container.expand(function () { var self = Container.call(this); self.speedY = -10; // Initial upward speed self.gravity = 0.2; // Gravity effect self.speedX = (Math.random() - 0.5) * 10; // Random horizontal speed var bonusCakeGraphics = self.attachAsset('bonusCake', { anchorX: 0.5, anchorY: 0.5 }); self.on('down', function (x, y, obj) { LK.setTimeout(function () { LK.getSound('cheers').play(); // Play cheers sound after 1 second }, 1000); // Flash screen white for 500ms when bonus cake is clicked LK.effects.flashScreen(0xffffff, 500); LK.getSound('bonusSound').play(); // Play bonus sound // Define what happens when the bonus cake is clicked var clickCount = 0; var clickInterval = LK.setInterval(function () { if (clickCount < 100) { bigCake.emit('down'); // Trigger the 'down' event on bigCake to simulate a click clickCount++; } else { LK.clearInterval(clickInterval); } }, 100); // 100ms delay between each click LK.getSound('clickSound').play(); // Play click sound tween(self, { scaleX: 20, scaleY: 20, alpha: 0 }, { duration: 3000, easing: tween.easeOut, onFinish: function onFinish() { self.destroy(); // Remove the bonus cake after animation } }); }); self.update = function () { self.rotation += 0.1; // Rotate the bonus cake while it falls self.y += self.speedY; self.x += self.speedX; self.speedY += self.gravity; // Apply gravity if (self.y > 2732 + self.height / 2) { self.destroy(); // Remove the bonus cake if it goes off-screen } }; }); var BonusCakeManager = Container.expand(function () { var self = Container.call(this); self.popBonus = function () { LK.getSound('ohoh').play(); // Play 'ohoh' sound when BonusCake appears var bonusCake = new BonusCake(); bonusCake.x = bigCake.x; bonusCake.y = bigCake.y; foregroundContainer.addChild(bonusCake); }; self.start = function () { function triggerPopBonus() { self.popBonus(); var randomInterval = 120000 + Math.random() * 60000; // Random interval between 3min (180000ms) and 6min (360000ms) LK.setTimeout(triggerPopBonus, randomInterval); } triggerPopBonus(); }; }); // Chef character (player) var ChefCharacter = Container.expand(function () { var self = Container.call(this); // Chef graphics var chefGraphics = self.attachAsset('chef', { anchorX: 0.5, anchorY: 0.5 }); // Chef position and movement variables self.speed = 15; self.position = { x: 2048 / 2, y: 2732 - 150 }; self.targetX = self.position.x; // Add a shadow effect var shadow = new Graphics(); shadow.beginFill(0x000000, 0.3); shadow.drawEllipse(0, 10, 60, 20); shadow.endFill(); shadow.y = chefGraphics.height / 2 - 10; self.addChild(shadow); // Add chef after shadow (layering) self.addChild(chefGraphics); // Update function for movement self.update = function () { // Only update if in mini-game mode if (!isMiniGameMode) { return; } // Move towards target position with smooth movement self.position.x += (self.targetX - self.position.x) * 0.2; self.x = self.position.x; self.y = self.position.y; // Animate chef slightly based on movement var movementSpeed = Math.abs(self.targetX - self.position.x); if (movementSpeed > 1) { chefGraphics.rotation = (self.targetX > self.position.x ? 1 : -1) * Math.min(movementSpeed * 0.001, 0.1); } else { chefGraphics.rotation = 0; } }; // Handle touch/mouse input self.setTargetPosition = function (x) { self.targetX = Math.max(50, Math.min(2048 - 50, x)); }; return self; }); var Confetti = Container.expand(function (cakeIndex) { var self = Container.call(this); cakeIndex = cakeIndex ? cakeIndex : 0; var confettiGraphics = self.attachAsset('cake_' + Math.max(0, Math.min(cakeIndex, 9)), { anchorX: 0.5, anchorY: 0.5 }); confettiGraphics.visible = true; self.speedY = -10; // Initial upward speed self.gravity = 0.2; // Gravity effect self.speedX = (Math.random() - 0.5) * 10; // Random horizontal speed self.update = function () { if (self.lastY === undefined) { self.lastY = self.y; } self.y += self.speedY; self.x += self.speedX; self.speedY += self.gravity; // Apply gravity if (confettiGraphics && self.y > 2732 + confettiGraphics.height / 2) { self.destroy(); } }; }); // Confetti manager for visual effects var ConfettiManager = Container.expand(function () { var self = Container.call(this); self.particles = []; // Pop confetti effect self.popCakes = function (x, y, count) { for (var i = 0; i < count; i++) { var particle = new Container(); // Random cake type for confetti var cakeIndex = Math.floor(Math.random() * 10); var particleGraphics = particle.attachAsset('cake_' + cakeIndex, { anchorX: 0.5, anchorY: 0.5 }); // Scale down for confetti effect particle.scale.set(0.3 + Math.random() * 0.2); // Random position around the catch point particle.x = x; particle.y = y; // Random velocity particle.vx = (Math.random() - 0.5) * 10; particle.vy = -5 - Math.random() * 5; // Random rotation particle.rotation = Math.random() * Math.PI * 2; particle.vr = (Math.random() - 0.5) * 0.2; self.addChild(particle); self.particles.push(particle); } // Start update loop if not already running if (!self.updateInterval) { self.updateInterval = LK.setInterval(function () { self.update(); }, 16); // ~60fps } }; // Update all particles self.update = function () { var gravity = 0.2; var friction = 0.98; for (var i = self.particles.length - 1; i >= 0; i--) { var particle = self.particles[i]; // Apply gravity particle.vy += gravity; // Apply friction particle.vx *= friction; particle.vy *= friction; // Update position particle.x += particle.vx; particle.y += particle.vy; // Update rotation particle.rotation += particle.vr; // Fade out particle.alpha -= 0.01; // Remove if faded out or off screen if (particle.alpha <= 0 || particle.y > 2732 + 50) { self.removeChild(particle); self.particles.splice(i, 1); } } // Stop update loop if no particles left if (self.particles.length === 0) { LK.clearInterval(self.updateInterval); self.updateInterval = null; self.destroy(); } }; return self; }); // Falling Cake class var FallingCake = Container.expand(function () { var self = Container.call(this); // Random cake type (0-9) var cakeIndex = Math.floor(Math.random() * 10); // Cake graphics var cakeGraphics = self.attachAsset('cake_' + cakeIndex, { anchorX: 0.5, anchorY: 0.5 }); // Add rotation animation var rotationDirection = Math.random() > 0.5 ? 1 : -1; var rotationSpeed = (Math.random() * 0.02 + 0.01) * rotationDirection; // Cake properties self.speed = 5 + Math.random() * 3; self.value = (cakeIndex + 1) * 10; // Value based on cake type self.active = true; self.cakeType = cakeIndex; // Special cakes (rare) if (Math.random() < 0.05) { // 5% chance for special cake self.isSpecial = true; self.value *= 5; cakeGraphics.tint = 0xFFD700; // Gold tint for special cakes // Add sparkle effect var _sparkle = function sparkle() { if (!self.active) { return; } var sparkleEffect = new Container(); var sparkleGraphics = sparkleEffect.attachAsset('etoile', { anchorX: 0.5, anchorY: 0.5, alpha: 0.8 }); sparkleEffect.x = (Math.random() - 0.5) * cakeGraphics.width; sparkleEffect.y = (Math.random() - 0.5) * cakeGraphics.height; sparkleEffect.scale.set(0.5 + Math.random() * 0.5); self.addChild(sparkleEffect); tween(sparkleEffect, { alpha: 0, scaleX: 0, scaleY: 0 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { self.removeChild(sparkleEffect); sparkleEffect.destroy(); } }); if (self.active) { LK.setTimeout(_sparkle, 300 + Math.random() * 300); } }; _sparkle(); } // Update function for falling self.update = function () { if (!self.active || !isMiniGameMode) { return; } self.y += self.speed; cakeGraphics.rotation += rotationSpeed; // Check if cake is out of bounds if (self.y > 2732 + 50) { self.active = false; } }; // Destroy function self.destroy = function () { self.active = false; Container.prototype.destroy.call(self); }; return self; }); // Mini-Game Button class var MiniGameButton = Container.expand(function () { var self = Container.call(this); // Button graphics with shadow effect var shadowGraphics = self.attachAsset('buttonPrice', { anchorX: 0.5, anchorY: 0.5 }); shadowGraphics.tint = 0x000000; shadowGraphics.alpha = 0.5; shadowGraphics.y = 10; self.addChild(shadowGraphics); var buttonGraphics = self.attachAsset('buttonPrice', { anchorX: 0.5, anchorY: 0.5 }); // Add a chef icon to the button var chefIcon = self.attachAsset('chef', { anchorX: 0.5, anchorY: 0.5, width: 60, height: 92 }); chefIcon.y = -20; self.addChild(chefIcon); // Button text var buttonText = new Text2('MINI-GAME', { size: 30, fill: 0xFFFFFF, fontWeight: '900', dropShadow: true, dropShadowColor: 0x000000, dropShadowBlur: 5, dropShadowDistance: 5 }); buttonText.anchor.set(0.5, 0.5); buttonText.y = 40; self.addChild(buttonText); // Click handler self.onClick = function () { // Only allow switching if not already in mini-game mode if (!isMiniGameMode) { // Play sound LK.getSound('clickSound').play(); // Switch to mini-game mode switchToMiniGame(); // Button animation tween(buttonGraphics, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100, easing: tween.easeInOut, onFinish: function onFinish() { tween(buttonGraphics, { scaleX: 1, scaleY: 1 }, { duration: 100, easing: tween.easeInOut }); } }); } }; return self; }); // Cake Manager for mini-game var MiniGameCakeManager = Container.expand(function () { var self = Container.call(this); self.cakes = []; self.spawnInterval = null; self.spawnRate = 1000; // ms between cake spawns self.difficultyTimer = 0; self.gameScore = 0; self.combo = 0; self.comboTimer = null; // Start spawning cakes self.start = function () { self.spawnInterval = LK.setInterval(function () { if (isMiniGameMode) { self.spawnCake(); } }, self.spawnRate); // Increase difficulty over time self.difficultyTimer = LK.setInterval(function () { if (isMiniGameMode) { self.spawnRate = Math.max(300, self.spawnRate - 50); LK.clearInterval(self.spawnInterval); self.spawnInterval = LK.setInterval(function () { if (isMiniGameMode) { self.spawnCake(); } }, self.spawnRate); } }, 10000); // Increase difficulty every 10 seconds }; // Stop spawning cakes self.stop = function () { LK.clearInterval(self.spawnInterval); LK.clearInterval(self.difficultyTimer); LK.clearInterval(self.comboTimer); // Clear all cakes self.cakes.forEach(function (cake) { cake.destroy(); }); self.cakes = []; }; // Spawn a new cake self.spawnCake = function () { var cake = new FallingCake(); cake.x = 50 + Math.random() * (2048 - 100); // Random x position cake.y = -50; // Start above screen self.addChild(cake); self.cakes.push(cake); }; // Update all cakes and check collisions self.update = function (chef) { if (!isMiniGameMode) { return; } // Update each cake for (var i = self.cakes.length - 1; i >= 0; i--) { var cake = self.cakes[i]; if (!cake.active) { self.cakes.splice(i, 1); continue; } cake.update(); // Check collision with chef if (self.checkCollision(cake, chef)) { // Calculate score with combo var points = cake.value * (1 + self.combo * 0.1); self.gameScore += Math.floor(points); // Increment combo self.combo++; // Reset combo timer LK.clearTimeout(self.comboTimer); self.comboTimer = LK.setTimeout(function () { self.combo = 0; }, 2000); // Play catch sound LK.getSound('clickSound').play(); // Create score popup self.createScorePopup(cake.x, cake.y, Math.floor(points), cake.isSpecial); // Create effect at catch position var effect = new ConfettiManager(); effect.popCakes(cake.x, cake.y, cake.isSpecial ? 10 : 5); miniGameContainer.addChild(effect); // Remove cake cake.destroy(); self.cakes.splice(i, 1); } } }; // Create score popup self.createScorePopup = function (x, y, score, isSpecial) { var popup = new Text2('+' + score, { size: isSpecial ? 60 : 40, fill: isSpecial ? 0xFFD700 : 0xFFFFFF, fontWeight: '900', dropShadow: true, dropShadowColor: 0x000000, dropShadowBlur: 5, dropShadowDistance: 5 }); popup.anchor.set(0.5, 0.5); popup.x = x; popup.y = y; self.addChild(popup); tween(popup, { y: popup.y - 80, alpha: 0 }, { duration: 1000, easing: tween.easeOut, onFinish: function onFinish() { self.removeChild(popup); popup.destroy(); } }); }; // Simple collision detection self.checkCollision = function (cake, chef) { var dx = Math.abs(cake.x - chef.position.x); var dy = Math.abs(cake.y - chef.position.y); return dx < 70 && dy < 100; // Adjust collision box as needed }; return self; }); // UI for mini-game var MiniGameUI = Container.expand(function () { var self = Container.call(this); // Background panel var panel = new Graphics(); panel.beginFill(0x000000, 0.5); panel.drawRoundedRect(0, 0, 400, 150, 20); panel.endFill(); panel.x = 2048 / 2 - 200; panel.y = 20; self.addChild(panel); // Score text var scoreLabel = new Text2('Score:', { size: 30, fill: 0xFFFFFF, fontWeight: '900' }); scoreLabel.x = panel.x + 20; scoreLabel.y = panel.y + 20; self.addChild(scoreLabel); var scoreText = new Text2('0', { size: 30, fill: 0xFFFFFF, fontWeight: '900' }); scoreText.x = panel.x + 200; scoreText.y = panel.y + 20; self.addChild(scoreText); // Combo text var comboLabel = new Text2('Combo:', { size: 30, fill: 0xFFFFFF, fontWeight: '900' }); comboLabel.x = panel.x + 20; comboLabel.y = panel.y + 60; self.addChild(comboLabel); var comboText = new Text2('x1', { size: 30, fill: 0xFFFFFF, fontWeight: '900' }); comboText.x = panel.x + 200; comboText.y = panel.y + 60; self.addChild(comboText); // Time text var timeLabel = new Text2('Time:', { size: 30, fill: 0xFFFFFF, fontWeight: '900' }); timeLabel.x = panel.x + 20; timeLabel.y = panel.y + 100; self.addChild(timeLabel); var timeText = new Text2('60s', { size: 30, fill: 0xFFFFFF, fontWeight: '900' }); timeText.x = panel.x + 200; timeText.y = panel.y + 100; self.addChild(timeText); // Update UI self.update = function (score, combo, timeRemaining) { scoreText.text = score.toString(); comboText.text = 'x' + (combo + 1).toString(); timeText.text = timeRemaining + 's'; // Pulse combo text when combo increases if (combo > 0) { comboText.tint = 0xFFD700; // Gold color for combo tween(comboText, { scaleX: 1.2, scaleY: 1.2 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { tween(comboText, { scaleX: 1, scaleY: 1 }, { duration: 100, easing: tween.easeIn }); } }); } else { comboText.tint = 0xFFFFFF; } // Warning color when time is low if (timeRemaining <= 10) { timeText.tint = 0xFF0000; // Pulse time text if (timeRemaining % 2 === 0) { tween(timeText, { scaleX: 1.2, scaleY: 1.2 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { tween(timeText, { scaleX: 1, scaleY: 1 }, { duration: 300, easing: tween.easeIn }); } }); } } else { timeText.tint = 0xFFFFFF; } }; // Results screen self.showResults = function (score, reward) { // Create results panel var resultsPanel = new Graphics(); resultsPanel.beginFill(0x000000, 0.8); resultsPanel.drawRoundedRect(0, 0, 800, 600, 30); resultsPanel.endFill(); resultsPanel.x = 2048 / 2 - 400; resultsPanel.y = 2732 / 2 - 300; self.addChild(resultsPanel); // Results title var titleText = new Text2('GAME OVER!', { size: 60, fill: 0xFFFFFF, fontWeight: '900', dropShadow: true, dropShadowColor: 0x000000, dropShadowBlur: 5, dropShadowDistance: 5 }); titleText.anchor.set(0.5, 0); titleText.x = 2048 / 2; titleText.y = resultsPanel.y + 50; self.addChild(titleText); // Score result var scoreResultText = new Text2('Your Score: ' + score, { size: 40, fill: 0xFFFFFF, fontWeight: '900' }); scoreResultText.anchor.set(0.5, 0); scoreResultText.x = 2048 / 2; scoreResultText.y = resultsPanel.y + 150; self.addChild(scoreResultText); // Reward result var rewardResultText = new Text2('Cake Reward: ' + reward, { size: 40, fill: 0xFFD700, fontWeight: '900' }); rewardResultText.anchor.set(0.5, 0); rewardResultText.x = 2048 / 2; rewardResultText.y = resultsPanel.y + 220; self.addChild(rewardResultText); // Continue button var continueButton = new Container(); var buttonGraphics = new Graphics(); buttonGraphics.beginFill(0x4CAF50); buttonGraphics.drawRoundedRect(0, 0, 300, 80, 15); buttonGraphics.endFill(); continueButton.addChild(buttonGraphics); var buttonText = new Text2('CONTINUE', { size: 40, fill: 0xFFFFFF, fontWeight: '900' }); buttonText.anchor.set(0.5, 0.5); buttonText.x = 150; buttonText.y = 40; continueButton.addChild(buttonText); continueButton.x = 2048 / 2 - 150; continueButton.y = resultsPanel.y + 400; continueButton.interactive = true; continueButton.buttonMode = true; continueButton.on('pointerdown', function () { // Play sound LK.getSound('clickSound').play(); // Return to main game switchToMainGame(); // Remove results screen self.removeChild(resultsPanel); self.removeChild(titleText); self.removeChild(scoreResultText); self.removeChild(rewardResultText); self.removeChild(continueButton); }); self.addChild(continueButton); // Button hover effect continueButton.on('pointerover', function () { buttonGraphics.tint = 0x3E8E41; }); continueButton.on('pointerout', function () { buttonGraphics.tint = 0xFFFFFF; }); }; return self; }); // ResetButton class var ResetButton = Container.expand(function () { var self = Container.call(this); var resetButtonGraphics = self.attachAsset('resetButton', { anchorX: 0.5, anchorY: 0.5 }); self.on('down', function () { if (isResetConfirmationDisplayed) { return; } // Prevent re-clicking if confirmation is already displayed LK.getSound('resetSound').play(); // Play reset sound isResetConfirmationDisplayed = true; // Set to true when reset confirmation is shown // Create a mask to prevent clicking elsewhere during confirmation var mask = foregroundContainer.addChild(LK.getAsset('masque', { anchorX: 0.5, anchorY: 0.5 })); mask.x = 2048 / 2; mask.y = 2732 / 2; mask.alpha = 0.5; // Make the mask semi-transparent // Create a new board behind the yes and no buttons for confirmation var confirmationBoard = foregroundContainer.addChild(new Board()); confirmationBoard.x = 2048 / 2 - 80; confirmationBoard.y = 2732 / 2 - 100; confirmationBoard.scaleX = -1.5; // Mirror the board horizontally and make it wider confirmationBoard.alpha = 1; // Make the board opaque // Add a text above the yes and no buttons var restartText = new Text2('Restart from Zero?', { size: 120, // Increase the size of the text fill: 0xFF0000, // Change color to red fontWeight: 'bold', dropShadow: true, dropShadowColor: 0x000000, dropShadowBlur: 10, // Increase shadow blur for more pronounced effect dropShadowDistance: 5 }); restartText.anchor.set(0.5, 1); // Center the text horizontally and align it to the bottom restartText.x = 2048 / 2; // Center horizontally restartText.y = 2732 / 2 - 500; // Position above the buttons foregroundContainer.addChild(restartText); // Create yes and no buttons for confirmation var yesButton = foregroundContainer.addChild(LK.getAsset('yesButton', { anchorX: 0.5, anchorY: 0.5 })); yesButton.x = 2048 / 3; // Position yes button one-third from the left yesButton.y = 2732 / 2; // Center vertically var noButton = foregroundContainer.addChild(LK.getAsset('noButton', { anchorX: 0.5, anchorY: 0.5 })); noButton.x = 2048 * 2 / 3; // Position no button two-thirds from the left noButton.y = 2732 / 2; // Center vertically // Event listener for yes button yesButton.on('down', function () { LK.getSound('clearedSound').play(); // Play cleared sound when yes is pressed currentScore = 0; // Reset the score to zero upgradeLevel = 0; // Reset the upgrade level to zero score.updateScore(currentScore); // Update the score display autoClicker.cost = 100; // Reset auto clicker cost to initial value autoClicker.autoClickerCount = 0; // Reset auto clicker count autoClicker.updatePriceText(); // Update the auto clicker price text autoClicker.initStars(); // Update stars when the game is reset upgrade.cost = 10; // Reset upgrade cost to initial value upgrade.multiplier = 1; // Reset upgrade multiplier upgrade.updateUpgradeText(); // Update the upgrade price text upgrade.updateCakeGraphics(); // Update cake graphics based on new upgrade level storage.score = currentScore; // Save the reset score storage.autoClickerCount = autoClicker.autoClickerCount; // Save the reset auto clicker count storage.autoClickerCost = autoClicker.cost; // Save the reset auto clicker cost storage.upgradeMultiplier = upgrade.multiplier; // Save the reset upgrade multiplier storage.upgradeCost = upgrade.cost; // Save the reset upgrade cost // Remove confirmation buttons yesButton.destroy(); mask.destroy(); // Remove the mask noButton.destroy(); confirmationBoard.destroy(); // Hide the confirmation board restartText.destroy(); // Remove the 'Restart from Zero?' text isResetConfirmationDisplayed = false; // Set to false when reset confirmation is dismissed }); // Event listener for no button noButton.on('down', function () { LK.getSound('resetSound').play(); // Play reset sound // Remove confirmation buttons without resetting yesButton.destroy(); mask.destroy(); // Remove the mask noButton.destroy(); confirmationBoard.destroy(); // Hide the confirmation board restartText.destroy(); // Remove the 'Restart from Zero?' text isResetConfirmationDisplayed = false; // Set to false when reset confirmation is dismissed }); }); }); // Score class var Score = Container.expand(function () { var self = Container.call(this); var scoreText = new Text2('0', { size: 200, fill: 0xFFFDD0, dropShadow: true, // Enable drop shadow dropShadowColor: 0x000000, // Set drop shadow color to black dropShadowBlur: 5, // Set drop shadow blur dropShadowDistance: 5 // Set drop shadow distance }); scoreText.anchor.set(0.5, 0); self.addChild(scoreText); self.updateScore = function (newScore) { scoreText.setText('$' + newScore.toString()); }; }); // Upgrade class var Upgrade = Container.expand(function () { var self = Container.call(this); // Upgrade properties self.id = ''; self.name = ''; self.description = ''; self.price = 0; self.cakesPerSecondIncrease = 0; self.cakesPerClickIncrease = 0; self.level = 0; // Upgrade graphics var upgradeGraphics = self.attachAsset('buttonPrice', { anchorX: 0.5, anchorY: 0.5 }); // Upgrade icon var icon = self.attachAsset('cake_0', { anchorX: 0.5, anchorY: 0.5, width: 60, height: 60 }); icon.x = -120; self.addChild(icon); // Upgrade name text var nameText = new Text2('Upgrade', { size: 30, fill: 0xFFFFFF, fontWeight: '900' }); nameText.anchor.set(0, 0.5); nameText.x = -80; nameText.y = -20; self.addChild(nameText); // Upgrade description text var descriptionText = new Text2('Description', { size: 20, fill: 0xFFFFFF }); descriptionText.anchor.set(0, 0.5); descriptionText.x = -80; descriptionText.y = 10; self.addChild(descriptionText); // Upgrade price text var priceText = new Text2('100', { size: 30, fill: 0xFFFFFF, fontWeight: '900' }); priceText.anchor.set(0.5, 0.5); priceText.x = 120; self.addChild(priceText); // Upgrade level text var levelText = new Text2('Lv. 0', { size: 20, fill: 0xFFFFFF }); levelText.anchor.set(0.5, 0.5); levelText.x = 120; levelText.y = 30; self.addChild(levelText); // Initialize upgrade self.initialize = function (id, name, description, basePrice, cakesPerSecondIncrease, cakesPerClickIncrease, iconAsset) { self.id = id; self.name = name; self.description = description; self.basePrice = basePrice; self.price = basePrice; self.cakesPerSecondIncrease = cakesPerSecondIncrease; self.cakesPerClickIncrease = cakesPerClickIncrease; self.level = 0; // Update texts nameText.text = name; descriptionText.text = description; priceText.text = basePrice; levelText.text = 'Lv. ' + self.level; // Update icon if (iconAsset) { self.removeChild(icon); icon = self.attachAsset(iconAsset, { anchorX: 0.5, anchorY: 0.5, width: 60, height: 60 }); icon.x = -120; self.addChild(icon); } return self; }; // Update upgrade price based on level self.updatePrice = function () { self.price = Math.floor(self.basePrice * Math.pow(1.15, self.level)); priceText.text = self.price; }; // Buy upgrade self.buy = function () { // Check if player has enough cakes if (cakes >= self.price) { // Subtract price from cakes cakes -= self.price; updateCakeCounter(); // Increase level self.level++; levelText.text = 'Lv. ' + self.level; // Update price self.updatePrice(); // Increase cakes per second cakesPerSecond += self.cakesPerSecondIncrease; updateCakesPerSecondCounter(); // Increase cakes per click cakesPerClick += self.cakesPerClickIncrease; // Play purchase sound LK.getSound('achat').play(); // Create animation var animation = new CakeAnimation(); animation.x = self.x; animation.y = self.y; foregroundContainer.addChild(animation); } else { // Not enough cakes LK.getSound('errorsond').play(); // Play error sound } }; self.updateUpgradeText = function () { priceText.setText('$' + self.price); // Update the price text to reflect the current cost }; return self; }); /**** * Initialize Game ****/ /**** * Initialize Game * Set up the game environment and initial configurations ****/ var game = new LK.Game({ // No title, no description // Always backgroundColor is black backgroundColor: 0x000000 }); /**** * Game Code ****/ // Global array for upgrade prices var upgradePrices = [10, // $10 100, // $100 1000, // $1,000 10000, // $10,000 100000, // $100,000 1000000, // $1,000,000 10000000, // $10,000,000 100000000, // $100,000,000 1000000000, // $1,000,000,000 10000000000 // $10,000,000,000 ]; // Global array for auto clicker prices var autoClickerPrices = [100, // $100 1000, // $1,000 20000, // $10,000 300000, // $100,000 4000000, // $1,000,000 50000000, // $10,000,000 600000000, // $100,000,000 7000000000, // $1,000,000,000 80000000000, // $10,000,000,000 900000000000 // $100,000,000,000 ]; // Global array for the number of auto clicks per second var autoClicksPerSecond = [1, // 0 10, // 1 50, // 2 150, // 3 500, // 4 1500, // 5 5000, // 6 20000, // 7 100000, // 8 500000 // 9 ]; // Global array for upgrade multipliers var upgradeMultiplier = [1, // Niveau 0 2, // Niveau 1 5, // Niveau 2 10, // Niveau 3 20, // Niveau 4 50, // Niveau 5 100, // Niveau 6 200, // Niveau 7 500, // Niveau 8 1000 // Niveau 9 ]; /**** * Game Code * Main game logic and event handling ****/ /**** * Assets * Initialize all game assets including images, sounds, and music ****/ // Declare game variables var bonusCakeManager; // Declare bonusCakeManager globally var cakeList = ['cake_0', 'cake_1', 'cake_2', 'cake_3', 'cake_4', 'cake_5', 'cake_6', 'cake_8', 'cake_9']; var isResetConfirmationDisplayed = false; // Track if reset confirmation is displayed var upgradeLevel = storage.upgradeLevel || 0; // Load saved upgrade level or default to 0 var confettiManager; // Declare confettiManager globally // Sounds // Music /**** * Plugins * Import necessary plugins for tweening animations and storage management ****/ // Function to format prices function formatPrice(value) { if (value >= 1e18) { // Quintillion return '$' + (value / 1e18).toFixed(1) + 'Q'; } else if (value >= 1e15) { // Quadrillion return '$' + (value / 1e15).toFixed(1) + 'Qa'; } else if (value >= 1e12) { // Trillion return '$' + (value / 1e12).toFixed(1) + 'T'; } else if (value >= 1e9) { // Billion return '$' + (value / 1e9).toFixed(1) + 'B'; } else if (value >= 1e6) { // Million return '$' + (value / 1e6).toFixed(1) + 'M'; } else { return '$' + value; } } if (typeof newCakeButton !== 'undefined' && newCakeButton.newCake) { newCakeButton.newCake.on('down', function (x, y, obj) { newCakeButton.newCake.onClick(); }); } // Declare game variables var backgroundContainer; var middleContainer; var foregroundContainer; var currentScore; var score; var lastTimestamp; var timeElapsed; var clicksSinceLastSession; var autoClicker; var upgrade; var autoClickerText; var bigCake; var resetButton; var board; // Mini-game global variables var isMiniGameMode = false; // Controls which game mode is active var miniGameContainer; // Container for the mini-game var miniGameChef; var miniGameCakeManager; var miniGameUI; var miniGameTimer; var miniGameDuration = 60; // 60 seconds var miniGameTimeRemaining; var miniGameReward = 0; // Switch to mini-game mode function switchToMiniGame() { if (isMiniGameMode) { return; } isMiniGameMode = true; // Move main game containers off-screen (instead of hiding them) // This preserves the game state while making them invisible backgroundContainer.x = -5000; middleContainer.x = -5000; foregroundContainer.x = -5000; // Show mini-game container miniGameContainer.visible = true; // Reset mini-game variables miniGameTimeRemaining = miniGameDuration; miniGameCakeManager.gameScore = 0; miniGameCakeManager.combo = 0; // Start mini-game miniGameCakeManager.start(); // Start timer miniGameTimer = LK.setInterval(function () { miniGameTimeRemaining--; // Update UI miniGameUI.update(miniGameCakeManager.gameScore, miniGameCakeManager.combo, miniGameTimeRemaining); // Check if game is over if (miniGameTimeRemaining <= 0) { endMiniGame(); } }, 1000); // Set up input handling for mini-game LK.stage.on('pointermove', handleMiniGamePointerMove); LK.stage.on('pointerdown', handleMiniGamePointerMove); } // Handle mini-game pointer movement function handleMiniGamePointerMove(event) { if (!isMiniGameMode) { return; } var position = event.data.global; miniGameChef.setTargetPosition(position.x); } // End mini-game function endMiniGame() { // Stop timer LK.clearInterval(miniGameTimer); // Stop cake manager miniGameCakeManager.stop(); // Remove input handlers LK.stage.off('pointermove', handleMiniGamePointerMove); LK.stage.off('pointerdown', handleMiniGamePointerMove); // Calculate reward based on score miniGameReward = Math.floor(miniGameCakeManager.gameScore / 10); // Add reward to player's cakes cakes += miniGameReward; // Show results screen miniGameUI.showResults(miniGameCakeManager.gameScore, miniGameReward); } // Switch back to main game function switchToMainGame() { if (!isMiniGameMode) { return; } isMiniGameMode = false; // Move main game containers back to original position backgroundContainer.x = 0; middleContainer.x = 0; foregroundContainer.x = 0; // Hide mini-game container miniGameContainer.visible = false; // Update main game UI to reflect new cake count updateCakeCounter(); } // Initialize game variables function initializeGameVariables() { backgroundContainer = new Container(); game.addChild(backgroundContainer); // Initialize middleContainer middleContainer = new Container(); game.addChild(middleContainer); // Initialize foregroundContainer foregroundContainer = new Container(); game.addChild(foregroundContainer); background = backgroundContainer.addChild(LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5 })); background.x = 2048 / 2; background.y = 2732 / 2; background.scaleX = 2048 / background.width; // Scale background to fit the game width background.scaleY = 2732 / background.height; // Scale background to fit the game height // Initialize board board = foregroundContainer.addChild(new Board()); board.x = 2240; board.y = 1230; // Center board vertically board.boardGraphics.alpha = 0.8; // Set transparency of the right board to 0.8 // Initialize bigCake bigCake = middleContainer.addChild(new BigCake()); bigCake.x = 2048 / 2; bigCake.y = 2732 / 2; // Initialize score score = game.addChild(new Score()); score.x = 2048 / 2; score.y = 30; // Position score even higher at the top center currentScore = storage.score || 0; // Load saved score or default to 0 score.updateScore(currentScore); // Refresh the score display with the loaded score // Calculate the number of clicks since the last session lastTimestamp = storage.timestamp || Date.now(); timeElapsed = Date.now() - lastTimestamp; clicksSinceLastSession = Math.floor(timeElapsed / 1000); // Assuming 1 click per second as a baseline console.log("Clicks since last session: ", clicksSinceLastSession); currentScore += clicksSinceLastSession; // Add clicks since last session to the current score score.updateScore(currentScore); // Update the score display with the new score storage.score = currentScore; // Save the updated score // Initialize auto clicker autoClicker = foregroundContainer.addChild(new AutoClicker()); autoClicker.autoClickerCount = storage.autoClickerCount || 0; // Load saved auto clicker count or default to 0 autoClicker.cost = storage.autoClickerCost || autoClickerPrices[0]; // Load saved auto clicker cost or default to initial cost from autoClickerPrices array autoClicker.updatePriceText(); // Update the price text to reflect the loaded cost autoClicker.initStars(); // Initialize and update the display of stars based on the current autoClickerCount if (autoClicker.autoClickerCount > 0) { autoClicker.startAutoClicking(); // Start auto-clicking if there are saved auto-clickers } // Initialize upgrade upgrade = foregroundContainer.addChild(new Upgrade()); upgrade.multiplier = storage.upgradeMultiplier || 1; // Load saved upgrade multiplier or default to 1 upgrade.cost = storage.upgradeCost || upgradePrices[0]; // Load saved upgrade cost or default to initial cost from upgradePrices array upgrade.updateUpgradeText(); // Update the upgrade price text to reflect the loaded cost upgrade.updateCakeGraphics(); // Update cake graphics based on new upgrade level upgrade.x = 2048 - upgrade.width / 2 - 10; // Position upgrade button on the right side of the screen upgrade.y = 2732 / 2 - upgrade.height + 140; // Position upgrade button slightly lower on the screen // Event listener for upgrade button clicks upgrade.on('down', function (x, y, obj) { upgrade.onClick(); }); // Initialize reset button resetButton = backgroundContainer.addChild(new ResetButton()); // Initialize confetti manager confettiManager = new ConfettiManager(); // Initialize bonus cake manager bonusCakeManager = new BonusCakeManager(); LK.setTimeout(function () { bonusCakeManager.start(); // Start the bonus cake manager after 1 minute }, 60000); resetButton.x = 2048 - resetButton.width / 2 - 40; // Add margin to the right edge resetButton.y = score.y + score.height / 2 + 10; // Adjust reset button position to be slightly higher // Initialize auto clicker text autoClickerText = new Text2('Auto Clicker: $' + autoClicker.cost, { size: 100, fill: currentScore >= autoClicker.cost ? 0x00FF00 : 0xFF0000 }); autoClickerText.anchor.set(0.5, 0); autoClickerText.x = autoClicker.x; autoClickerText.y = autoClicker.y - autoClicker.height / 2 - 50; // Position text above the auto clicker button game.addChild(autoClickerText); // Update autoClickerText immediately after loading the game autoClicker.x = 2048 - autoClicker.width / 2 - 10; // Position auto clicker button on the right side of the screen autoClicker.y = 2732 / 2 + 160; // Position auto clicker button slightly lower on the screen // Event listener for auto clicker clicks autoClicker.on('down', function (x, y, obj) { autoClicker.onClick(); }); // Play bakery music in a loop throughout the game LK.playMusic('musiqueclicker', { loop: true }); // Initialize mini-game container miniGameContainer = new Container(); miniGameContainer.visible = false; game.addChild(miniGameContainer); // Initialize mini-game UI miniGameUI = new MiniGameUI(); miniGameContainer.addChild(miniGameUI); // Initialize mini-game chef miniGameChef = new ChefCharacter(); miniGameContainer.addChild(miniGameChef); // Initialize mini-game cake manager miniGameCakeManager = new MiniGameCakeManager(); miniGameContainer.addChild(miniGameCakeManager); // Initialize mini-game button var miniGameButton = new MiniGameButton(); miniGameButton.x = 2048 / 2 - 150; miniGameButton.y = 2732 / 2 - 200; foregroundContainer.addChild(miniGameButton); // Set up game loop LK.onUpdate(gameLoop); } // Call the function to initialize game variables initializeGameVariables(); // Game loop function gameLoop(dt) { // Update the cakes per second counter cakesPerSecondCounter += dt; if (cakesPerSecondCounter >= 1) { cakesPerSecondCounter = 0; cakes += cakesPerSecond; updateCakeCounter(); } // Only update main game animations if not in mini-game mode if (!isMiniGameMode) { // Update animations updateAnimations(dt); } else { // Update mini-game miniGameChef.update(); miniGameCakeManager.update(miniGameChef); } } self.updateUpgradeText = function () { priceText.setText('$' + self.price); // Update the price text to reflect the current cost }; self.updateCakeGraphics = function () { // Logic to update cake graphics based on the current upgrade level var cakeAssetId = 'cake_' + Math.min(self.level, 9); // Ensure the level doesn't exceed available cake assets self.removeChild(icon); icon = self.attachAsset(cakeAssetId, { anchorX: 0.5, anchorY: 0.5, width: 60, height: 60 }); icon.x = -120; self.addChild(icon); };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
score: 0,
autoClickerCount: 0,
upgradeMultiplier: 1
});
/****
* Classes
****/
// AutoClicker class
var AutoClicker = Container.expand(function () {
var self = Container.call(this);
self.startAutoClicking = function () {
self.autoClickerInterval = LK.setInterval(function () {
if (self.autoClickerCount > 0) {
bigCake.emit('down'); // Trigger the 'down' event on bigCake to simulate a click
}
if (self.autoClickerCount > 1 && self.autoClickerCount < autoClicksPerSecond.length) {
bigCake.emit('down'); // Trigger the 'down' event on bigCake to simulate a click
currentScore += upgradeMultiplier[upgradeLevel] * autoClicksPerSecond[self.autoClickerCount]; // Increment score by the upgrade multiplier per click
score.updateScore(currentScore);
storage.score = currentScore; // Save the updated score
storage.timestamp = Date.now(); // Save the current timestamp
}
}, 1000);
};
// Create a shadow effect by adding a black tinted, semi-transparent duplicate of autoClickerGraphics
var shadowGraphics = self.attachAsset('autoClicker', {
anchorX: 0.5,
anchorY: 0.5
});
shadowGraphics.tint = 0x000000; // Tint the shadow black
shadowGraphics.alpha = 0.5; // Make the shadow semi-transparent
shadowGraphics.y = 10; // Position the shadow slightly below the autoClicker button
self.addChild(shadowGraphics);
var autoClickerGraphics = self.attachAsset('autoClicker', {
anchorX: 0.5,
anchorY: 0.5
});
// Add 'Worker' text above the auto clicker image
var workerLabel = new Text2('Worker', {
size: 60,
fill: 0x1E90FF,
// Match price text color
fontWeight: '900',
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowBlur: 5,
dropShadowDistance: 5
});
workerLabel.anchor.set(0.5, 1); // Center the text horizontally and align it to the bottom
workerLabel.fill = 0x0000FF; // Change text color to blue
workerLabel.y = autoClickerGraphics.y - autoClickerGraphics.height / 2 - 10; // Adjust text position to -10 above the auto clicker image
self.addChild(workerLabel);
// Attach the chef's toque image on top of the auto clicker button
var toqueGraphics = self.attachAsset('toque', {
anchorX: 0.5,
anchorY: 0.5
});
toqueGraphics.y = 0; // Move the toque slightly higher on the auto clicker
self.addChild(toqueGraphics);
self.cost = 100; // Initial cost of the auto clicker
self.autoClickerCount = 0;
self.stars = []; // Array to store the list of stars
var priceText = new Text2('$' + self.cost, {
size: 80,
fill: 0x1E90FF,
fontWeight: '900',
// Make the text bolder
dropShadow: true,
// Enable drop shadow
dropShadowColor: 0x000000,
// Set drop shadow color to black
dropShadowBlur: 5,
// Set drop shadow blur
dropShadowDistance: 5 // Set drop shadow distance
});
priceText.setText('$' + self.cost); // Update the price text to reflect the current cost
priceText.anchor.set(0.5, 0);
priceText.x = 0;
priceText.y = autoClickerGraphics.height / 2 + 0; // Position text below the auto clicker button
self.addChild(priceText);
self.updatePriceText = function () {
priceText.setText(formatPrice(self.cost)); // Update the price text to reflect the current cost
};
self.initStars = function () {
// Clear existing stars
self.stars.forEach(function (star) {
star.destroy();
});
self.stars = [];
// Create new stars based on autoClickerCount
for (var i = 0; i < self.autoClickerCount; i++) {
var star = self.attachAsset('etoile', {
anchorX: 0.5,
anchorY: 0.5
});
star.y = toqueGraphics.y + toqueGraphics.height / 2 + star.height / 2;
self.stars.push(star);
}
self.displayStars(); // Update positions of all stars based on the current count
};
self.displayStars = function () {
// Update positions of all stars based on the current count
self.stars.forEach(function (star, index) {
if (self.autoClickerCount === 1) {
star.x = 0; // Position the first star at x = 0
} else if (self.autoClickerCount === 2) {
star.x = index === 0 ? -30 : 30; // Position the second star at x = -60 and the third at x = 60
} else if (self.autoClickerCount === 3) {
star.x = index === 0 ? -70 : index === 1 ? 0 : 70;
star.y = index === 0 ? 70 : index === 1 ? 100 : 70;
} else if (self.autoClickerCount > 3) {
var angle = index * (Math.PI * 2 / self.autoClickerCount);
star.x = Math.cos(angle) * 100; // x varies between -100 and 100
star.y = Math.sin(angle) * 100; // y varies between -100 and 100
}
});
};
self.onClick = function () {
if (currentScore >= self.cost && self.autoClickerCount < 9) {
currentScore -= self.cost; // Deduct the cost from the current score
score.updateScore(currentScore); // Update the score display
self.autoClickerCount += 1; // Increase the number of auto clickers
// Add a star under the toque for each upgrade, up to 3 stars
if (self.autoClickerCount <= 9) {
var star = self.attachAsset('etoile', {
anchorX: 0.5,
anchorY: 0.5
});
star.y = toqueGraphics.y + toqueGraphics.height / 2 + star.height / 2; // Position the star under the toque
self.stars.push(star); // Add the star to the stars array
}
self.displayStars(); // Update positions of all stars based on the current count
storage.autoClickerCount = self.autoClickerCount; // Save the updated auto clicker count
if (self.autoClickerCount === 1) {
self.startAutoClicking(); // Start auto clicking only when the first auto clicker is purchased
}
self.cost = autoClickerPrices[Math.min(self.autoClickerCount, autoClickerPrices.length - 1)]; // Update the cost using the autoClickerPrices array
storage.autoClickerCost = self.cost; // Save the updated auto clicker cost
self.updatePriceText(); // Update the price text to reflect the new cost
LK.getSound('buyAutoclickerSound').play(); // Play buyAutoclickerSound when an autoclicker is purchased
autoClickerText.fill = currentScore >= self.cost ? 0x00FF00 : 0xFF0000; // Update text color based on affordability
// Animate the autoClicker button
tween(autoClickerGraphics, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(autoClickerGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
easing: tween.easeInOut
});
}
});
// Animate the shadowGraphics in the same way
tween(shadowGraphics, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(shadowGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
easing: tween.easeInOut
});
}
});
// Animate the toqueGraphics in the same way
tween(toqueGraphics, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(toqueGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
easing: tween.easeInOut
});
}
});
} else {
tween(self, {
alpha: 0.2
}, {
duration: 100,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(self, {
alpha: 1
}, {
duration: 100,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(self, {
alpha: 0.2
}, {
duration: 100,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(self, {
alpha: 1
}, {
duration: 100,
easing: tween.easeInOut
});
}
});
}
});
}
});
LK.getSound('errorsond').play(); // Play error sound
}
};
return self;
});
// BigCake class
var BigCake = Container.expand(function () {
var self = Container.call(this);
var bigCakeGraphics = self.attachAsset('bigCake', {
anchorX: 0.5,
anchorY: 0.5
});
self.on('down', function (x, y, obj) {
// Use ConfettiManager to create confetti effect
confettiManager.popCakes(self.x, self.y, 5);
LK.getSound('clickSound').play();
currentScore += upgradeMultiplier[upgradeLevel]; // Increment score by the upgrade multiplier per click
score.updateScore(currentScore);
storage.score = currentScore; // Save the updated score
storage.timestamp = Date.now(); // Save the current timestamp
// Add a bump animation
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeIn
});
}
});
// Removed the creation of falling cakes
});
});
// Board class
var Board = Container.expand(function () {
var self = Container.call(this);
self.boardGraphics = self.attachAsset('board', {
anchorX: 0.5,
anchorY: 0.5
});
self.boardGraphics.alpha = 1; // Make the board fully opaque
self.addChild(self.boardGraphics);
});
// BonusCake class
var BonusCake = Container.expand(function () {
var self = Container.call(this);
self.speedY = -10; // Initial upward speed
self.gravity = 0.2; // Gravity effect
self.speedX = (Math.random() - 0.5) * 10; // Random horizontal speed
var bonusCakeGraphics = self.attachAsset('bonusCake', {
anchorX: 0.5,
anchorY: 0.5
});
self.on('down', function (x, y, obj) {
LK.setTimeout(function () {
LK.getSound('cheers').play(); // Play cheers sound after 1 second
}, 1000);
// Flash screen white for 500ms when bonus cake is clicked
LK.effects.flashScreen(0xffffff, 500);
LK.getSound('bonusSound').play(); // Play bonus sound
// Define what happens when the bonus cake is clicked
var clickCount = 0;
var clickInterval = LK.setInterval(function () {
if (clickCount < 100) {
bigCake.emit('down'); // Trigger the 'down' event on bigCake to simulate a click
clickCount++;
} else {
LK.clearInterval(clickInterval);
}
}, 100); // 100ms delay between each click
LK.getSound('clickSound').play(); // Play click sound
tween(self, {
scaleX: 20,
scaleY: 20,
alpha: 0
}, {
duration: 3000,
easing: tween.easeOut,
onFinish: function onFinish() {
self.destroy(); // Remove the bonus cake after animation
}
});
});
self.update = function () {
self.rotation += 0.1; // Rotate the bonus cake while it falls
self.y += self.speedY;
self.x += self.speedX;
self.speedY += self.gravity; // Apply gravity
if (self.y > 2732 + self.height / 2) {
self.destroy(); // Remove the bonus cake if it goes off-screen
}
};
});
var BonusCakeManager = Container.expand(function () {
var self = Container.call(this);
self.popBonus = function () {
LK.getSound('ohoh').play(); // Play 'ohoh' sound when BonusCake appears
var bonusCake = new BonusCake();
bonusCake.x = bigCake.x;
bonusCake.y = bigCake.y;
foregroundContainer.addChild(bonusCake);
};
self.start = function () {
function triggerPopBonus() {
self.popBonus();
var randomInterval = 120000 + Math.random() * 60000; // Random interval between 3min (180000ms) and 6min (360000ms)
LK.setTimeout(triggerPopBonus, randomInterval);
}
triggerPopBonus();
};
});
// Chef character (player)
var ChefCharacter = Container.expand(function () {
var self = Container.call(this);
// Chef graphics
var chefGraphics = self.attachAsset('chef', {
anchorX: 0.5,
anchorY: 0.5
});
// Chef position and movement variables
self.speed = 15;
self.position = {
x: 2048 / 2,
y: 2732 - 150
};
self.targetX = self.position.x;
// Add a shadow effect
var shadow = new Graphics();
shadow.beginFill(0x000000, 0.3);
shadow.drawEllipse(0, 10, 60, 20);
shadow.endFill();
shadow.y = chefGraphics.height / 2 - 10;
self.addChild(shadow);
// Add chef after shadow (layering)
self.addChild(chefGraphics);
// Update function for movement
self.update = function () {
// Only update if in mini-game mode
if (!isMiniGameMode) {
return;
}
// Move towards target position with smooth movement
self.position.x += (self.targetX - self.position.x) * 0.2;
self.x = self.position.x;
self.y = self.position.y;
// Animate chef slightly based on movement
var movementSpeed = Math.abs(self.targetX - self.position.x);
if (movementSpeed > 1) {
chefGraphics.rotation = (self.targetX > self.position.x ? 1 : -1) * Math.min(movementSpeed * 0.001, 0.1);
} else {
chefGraphics.rotation = 0;
}
};
// Handle touch/mouse input
self.setTargetPosition = function (x) {
self.targetX = Math.max(50, Math.min(2048 - 50, x));
};
return self;
});
var Confetti = Container.expand(function (cakeIndex) {
var self = Container.call(this);
cakeIndex = cakeIndex ? cakeIndex : 0;
var confettiGraphics = self.attachAsset('cake_' + Math.max(0, Math.min(cakeIndex, 9)), {
anchorX: 0.5,
anchorY: 0.5
});
confettiGraphics.visible = true;
self.speedY = -10; // Initial upward speed
self.gravity = 0.2; // Gravity effect
self.speedX = (Math.random() - 0.5) * 10; // Random horizontal speed
self.update = function () {
if (self.lastY === undefined) {
self.lastY = self.y;
}
self.y += self.speedY;
self.x += self.speedX;
self.speedY += self.gravity; // Apply gravity
if (confettiGraphics && self.y > 2732 + confettiGraphics.height / 2) {
self.destroy();
}
};
});
// Confetti manager for visual effects
var ConfettiManager = Container.expand(function () {
var self = Container.call(this);
self.particles = [];
// Pop confetti effect
self.popCakes = function (x, y, count) {
for (var i = 0; i < count; i++) {
var particle = new Container();
// Random cake type for confetti
var cakeIndex = Math.floor(Math.random() * 10);
var particleGraphics = particle.attachAsset('cake_' + cakeIndex, {
anchorX: 0.5,
anchorY: 0.5
});
// Scale down for confetti effect
particle.scale.set(0.3 + Math.random() * 0.2);
// Random position around the catch point
particle.x = x;
particle.y = y;
// Random velocity
particle.vx = (Math.random() - 0.5) * 10;
particle.vy = -5 - Math.random() * 5;
// Random rotation
particle.rotation = Math.random() * Math.PI * 2;
particle.vr = (Math.random() - 0.5) * 0.2;
self.addChild(particle);
self.particles.push(particle);
}
// Start update loop if not already running
if (!self.updateInterval) {
self.updateInterval = LK.setInterval(function () {
self.update();
}, 16); // ~60fps
}
};
// Update all particles
self.update = function () {
var gravity = 0.2;
var friction = 0.98;
for (var i = self.particles.length - 1; i >= 0; i--) {
var particle = self.particles[i];
// Apply gravity
particle.vy += gravity;
// Apply friction
particle.vx *= friction;
particle.vy *= friction;
// Update position
particle.x += particle.vx;
particle.y += particle.vy;
// Update rotation
particle.rotation += particle.vr;
// Fade out
particle.alpha -= 0.01;
// Remove if faded out or off screen
if (particle.alpha <= 0 || particle.y > 2732 + 50) {
self.removeChild(particle);
self.particles.splice(i, 1);
}
}
// Stop update loop if no particles left
if (self.particles.length === 0) {
LK.clearInterval(self.updateInterval);
self.updateInterval = null;
self.destroy();
}
};
return self;
});
// Falling Cake class
var FallingCake = Container.expand(function () {
var self = Container.call(this);
// Random cake type (0-9)
var cakeIndex = Math.floor(Math.random() * 10);
// Cake graphics
var cakeGraphics = self.attachAsset('cake_' + cakeIndex, {
anchorX: 0.5,
anchorY: 0.5
});
// Add rotation animation
var rotationDirection = Math.random() > 0.5 ? 1 : -1;
var rotationSpeed = (Math.random() * 0.02 + 0.01) * rotationDirection;
// Cake properties
self.speed = 5 + Math.random() * 3;
self.value = (cakeIndex + 1) * 10; // Value based on cake type
self.active = true;
self.cakeType = cakeIndex;
// Special cakes (rare)
if (Math.random() < 0.05) {
// 5% chance for special cake
self.isSpecial = true;
self.value *= 5;
cakeGraphics.tint = 0xFFD700; // Gold tint for special cakes
// Add sparkle effect
var _sparkle = function sparkle() {
if (!self.active) {
return;
}
var sparkleEffect = new Container();
var sparkleGraphics = sparkleEffect.attachAsset('etoile', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.8
});
sparkleEffect.x = (Math.random() - 0.5) * cakeGraphics.width;
sparkleEffect.y = (Math.random() - 0.5) * cakeGraphics.height;
sparkleEffect.scale.set(0.5 + Math.random() * 0.5);
self.addChild(sparkleEffect);
tween(sparkleEffect, {
alpha: 0,
scaleX: 0,
scaleY: 0
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
self.removeChild(sparkleEffect);
sparkleEffect.destroy();
}
});
if (self.active) {
LK.setTimeout(_sparkle, 300 + Math.random() * 300);
}
};
_sparkle();
}
// Update function for falling
self.update = function () {
if (!self.active || !isMiniGameMode) {
return;
}
self.y += self.speed;
cakeGraphics.rotation += rotationSpeed;
// Check if cake is out of bounds
if (self.y > 2732 + 50) {
self.active = false;
}
};
// Destroy function
self.destroy = function () {
self.active = false;
Container.prototype.destroy.call(self);
};
return self;
});
// Mini-Game Button class
var MiniGameButton = Container.expand(function () {
var self = Container.call(this);
// Button graphics with shadow effect
var shadowGraphics = self.attachAsset('buttonPrice', {
anchorX: 0.5,
anchorY: 0.5
});
shadowGraphics.tint = 0x000000;
shadowGraphics.alpha = 0.5;
shadowGraphics.y = 10;
self.addChild(shadowGraphics);
var buttonGraphics = self.attachAsset('buttonPrice', {
anchorX: 0.5,
anchorY: 0.5
});
// Add a chef icon to the button
var chefIcon = self.attachAsset('chef', {
anchorX: 0.5,
anchorY: 0.5,
width: 60,
height: 92
});
chefIcon.y = -20;
self.addChild(chefIcon);
// Button text
var buttonText = new Text2('MINI-GAME', {
size: 30,
fill: 0xFFFFFF,
fontWeight: '900',
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowBlur: 5,
dropShadowDistance: 5
});
buttonText.anchor.set(0.5, 0.5);
buttonText.y = 40;
self.addChild(buttonText);
// Click handler
self.onClick = function () {
// Only allow switching if not already in mini-game mode
if (!isMiniGameMode) {
// Play sound
LK.getSound('clickSound').play();
// Switch to mini-game mode
switchToMiniGame();
// Button animation
tween(buttonGraphics, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(buttonGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
easing: tween.easeInOut
});
}
});
}
};
return self;
});
// Cake Manager for mini-game
var MiniGameCakeManager = Container.expand(function () {
var self = Container.call(this);
self.cakes = [];
self.spawnInterval = null;
self.spawnRate = 1000; // ms between cake spawns
self.difficultyTimer = 0;
self.gameScore = 0;
self.combo = 0;
self.comboTimer = null;
// Start spawning cakes
self.start = function () {
self.spawnInterval = LK.setInterval(function () {
if (isMiniGameMode) {
self.spawnCake();
}
}, self.spawnRate);
// Increase difficulty over time
self.difficultyTimer = LK.setInterval(function () {
if (isMiniGameMode) {
self.spawnRate = Math.max(300, self.spawnRate - 50);
LK.clearInterval(self.spawnInterval);
self.spawnInterval = LK.setInterval(function () {
if (isMiniGameMode) {
self.spawnCake();
}
}, self.spawnRate);
}
}, 10000); // Increase difficulty every 10 seconds
};
// Stop spawning cakes
self.stop = function () {
LK.clearInterval(self.spawnInterval);
LK.clearInterval(self.difficultyTimer);
LK.clearInterval(self.comboTimer);
// Clear all cakes
self.cakes.forEach(function (cake) {
cake.destroy();
});
self.cakes = [];
};
// Spawn a new cake
self.spawnCake = function () {
var cake = new FallingCake();
cake.x = 50 + Math.random() * (2048 - 100); // Random x position
cake.y = -50; // Start above screen
self.addChild(cake);
self.cakes.push(cake);
};
// Update all cakes and check collisions
self.update = function (chef) {
if (!isMiniGameMode) {
return;
}
// Update each cake
for (var i = self.cakes.length - 1; i >= 0; i--) {
var cake = self.cakes[i];
if (!cake.active) {
self.cakes.splice(i, 1);
continue;
}
cake.update();
// Check collision with chef
if (self.checkCollision(cake, chef)) {
// Calculate score with combo
var points = cake.value * (1 + self.combo * 0.1);
self.gameScore += Math.floor(points);
// Increment combo
self.combo++;
// Reset combo timer
LK.clearTimeout(self.comboTimer);
self.comboTimer = LK.setTimeout(function () {
self.combo = 0;
}, 2000);
// Play catch sound
LK.getSound('clickSound').play();
// Create score popup
self.createScorePopup(cake.x, cake.y, Math.floor(points), cake.isSpecial);
// Create effect at catch position
var effect = new ConfettiManager();
effect.popCakes(cake.x, cake.y, cake.isSpecial ? 10 : 5);
miniGameContainer.addChild(effect);
// Remove cake
cake.destroy();
self.cakes.splice(i, 1);
}
}
};
// Create score popup
self.createScorePopup = function (x, y, score, isSpecial) {
var popup = new Text2('+' + score, {
size: isSpecial ? 60 : 40,
fill: isSpecial ? 0xFFD700 : 0xFFFFFF,
fontWeight: '900',
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowBlur: 5,
dropShadowDistance: 5
});
popup.anchor.set(0.5, 0.5);
popup.x = x;
popup.y = y;
self.addChild(popup);
tween(popup, {
y: popup.y - 80,
alpha: 0
}, {
duration: 1000,
easing: tween.easeOut,
onFinish: function onFinish() {
self.removeChild(popup);
popup.destroy();
}
});
};
// Simple collision detection
self.checkCollision = function (cake, chef) {
var dx = Math.abs(cake.x - chef.position.x);
var dy = Math.abs(cake.y - chef.position.y);
return dx < 70 && dy < 100; // Adjust collision box as needed
};
return self;
});
// UI for mini-game
var MiniGameUI = Container.expand(function () {
var self = Container.call(this);
// Background panel
var panel = new Graphics();
panel.beginFill(0x000000, 0.5);
panel.drawRoundedRect(0, 0, 400, 150, 20);
panel.endFill();
panel.x = 2048 / 2 - 200;
panel.y = 20;
self.addChild(panel);
// Score text
var scoreLabel = new Text2('Score:', {
size: 30,
fill: 0xFFFFFF,
fontWeight: '900'
});
scoreLabel.x = panel.x + 20;
scoreLabel.y = panel.y + 20;
self.addChild(scoreLabel);
var scoreText = new Text2('0', {
size: 30,
fill: 0xFFFFFF,
fontWeight: '900'
});
scoreText.x = panel.x + 200;
scoreText.y = panel.y + 20;
self.addChild(scoreText);
// Combo text
var comboLabel = new Text2('Combo:', {
size: 30,
fill: 0xFFFFFF,
fontWeight: '900'
});
comboLabel.x = panel.x + 20;
comboLabel.y = panel.y + 60;
self.addChild(comboLabel);
var comboText = new Text2('x1', {
size: 30,
fill: 0xFFFFFF,
fontWeight: '900'
});
comboText.x = panel.x + 200;
comboText.y = panel.y + 60;
self.addChild(comboText);
// Time text
var timeLabel = new Text2('Time:', {
size: 30,
fill: 0xFFFFFF,
fontWeight: '900'
});
timeLabel.x = panel.x + 20;
timeLabel.y = panel.y + 100;
self.addChild(timeLabel);
var timeText = new Text2('60s', {
size: 30,
fill: 0xFFFFFF,
fontWeight: '900'
});
timeText.x = panel.x + 200;
timeText.y = panel.y + 100;
self.addChild(timeText);
// Update UI
self.update = function (score, combo, timeRemaining) {
scoreText.text = score.toString();
comboText.text = 'x' + (combo + 1).toString();
timeText.text = timeRemaining + 's';
// Pulse combo text when combo increases
if (combo > 0) {
comboText.tint = 0xFFD700; // Gold color for combo
tween(comboText, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(comboText, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
easing: tween.easeIn
});
}
});
} else {
comboText.tint = 0xFFFFFF;
}
// Warning color when time is low
if (timeRemaining <= 10) {
timeText.tint = 0xFF0000;
// Pulse time text
if (timeRemaining % 2 === 0) {
tween(timeText, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(timeText, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.easeIn
});
}
});
}
} else {
timeText.tint = 0xFFFFFF;
}
};
// Results screen
self.showResults = function (score, reward) {
// Create results panel
var resultsPanel = new Graphics();
resultsPanel.beginFill(0x000000, 0.8);
resultsPanel.drawRoundedRect(0, 0, 800, 600, 30);
resultsPanel.endFill();
resultsPanel.x = 2048 / 2 - 400;
resultsPanel.y = 2732 / 2 - 300;
self.addChild(resultsPanel);
// Results title
var titleText = new Text2('GAME OVER!', {
size: 60,
fill: 0xFFFFFF,
fontWeight: '900',
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowBlur: 5,
dropShadowDistance: 5
});
titleText.anchor.set(0.5, 0);
titleText.x = 2048 / 2;
titleText.y = resultsPanel.y + 50;
self.addChild(titleText);
// Score result
var scoreResultText = new Text2('Your Score: ' + score, {
size: 40,
fill: 0xFFFFFF,
fontWeight: '900'
});
scoreResultText.anchor.set(0.5, 0);
scoreResultText.x = 2048 / 2;
scoreResultText.y = resultsPanel.y + 150;
self.addChild(scoreResultText);
// Reward result
var rewardResultText = new Text2('Cake Reward: ' + reward, {
size: 40,
fill: 0xFFD700,
fontWeight: '900'
});
rewardResultText.anchor.set(0.5, 0);
rewardResultText.x = 2048 / 2;
rewardResultText.y = resultsPanel.y + 220;
self.addChild(rewardResultText);
// Continue button
var continueButton = new Container();
var buttonGraphics = new Graphics();
buttonGraphics.beginFill(0x4CAF50);
buttonGraphics.drawRoundedRect(0, 0, 300, 80, 15);
buttonGraphics.endFill();
continueButton.addChild(buttonGraphics);
var buttonText = new Text2('CONTINUE', {
size: 40,
fill: 0xFFFFFF,
fontWeight: '900'
});
buttonText.anchor.set(0.5, 0.5);
buttonText.x = 150;
buttonText.y = 40;
continueButton.addChild(buttonText);
continueButton.x = 2048 / 2 - 150;
continueButton.y = resultsPanel.y + 400;
continueButton.interactive = true;
continueButton.buttonMode = true;
continueButton.on('pointerdown', function () {
// Play sound
LK.getSound('clickSound').play();
// Return to main game
switchToMainGame();
// Remove results screen
self.removeChild(resultsPanel);
self.removeChild(titleText);
self.removeChild(scoreResultText);
self.removeChild(rewardResultText);
self.removeChild(continueButton);
});
self.addChild(continueButton);
// Button hover effect
continueButton.on('pointerover', function () {
buttonGraphics.tint = 0x3E8E41;
});
continueButton.on('pointerout', function () {
buttonGraphics.tint = 0xFFFFFF;
});
};
return self;
});
// ResetButton class
var ResetButton = Container.expand(function () {
var self = Container.call(this);
var resetButtonGraphics = self.attachAsset('resetButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.on('down', function () {
if (isResetConfirmationDisplayed) {
return;
} // Prevent re-clicking if confirmation is already displayed
LK.getSound('resetSound').play(); // Play reset sound
isResetConfirmationDisplayed = true; // Set to true when reset confirmation is shown
// Create a mask to prevent clicking elsewhere during confirmation
var mask = foregroundContainer.addChild(LK.getAsset('masque', {
anchorX: 0.5,
anchorY: 0.5
}));
mask.x = 2048 / 2;
mask.y = 2732 / 2;
mask.alpha = 0.5; // Make the mask semi-transparent
// Create a new board behind the yes and no buttons for confirmation
var confirmationBoard = foregroundContainer.addChild(new Board());
confirmationBoard.x = 2048 / 2 - 80;
confirmationBoard.y = 2732 / 2 - 100;
confirmationBoard.scaleX = -1.5; // Mirror the board horizontally and make it wider
confirmationBoard.alpha = 1; // Make the board opaque
// Add a text above the yes and no buttons
var restartText = new Text2('Restart from Zero?', {
size: 120,
// Increase the size of the text
fill: 0xFF0000,
// Change color to red
fontWeight: 'bold',
dropShadow: true,
dropShadowColor: 0x000000,
dropShadowBlur: 10,
// Increase shadow blur for more pronounced effect
dropShadowDistance: 5
});
restartText.anchor.set(0.5, 1); // Center the text horizontally and align it to the bottom
restartText.x = 2048 / 2; // Center horizontally
restartText.y = 2732 / 2 - 500; // Position above the buttons
foregroundContainer.addChild(restartText);
// Create yes and no buttons for confirmation
var yesButton = foregroundContainer.addChild(LK.getAsset('yesButton', {
anchorX: 0.5,
anchorY: 0.5
}));
yesButton.x = 2048 / 3; // Position yes button one-third from the left
yesButton.y = 2732 / 2; // Center vertically
var noButton = foregroundContainer.addChild(LK.getAsset('noButton', {
anchorX: 0.5,
anchorY: 0.5
}));
noButton.x = 2048 * 2 / 3; // Position no button two-thirds from the left
noButton.y = 2732 / 2; // Center vertically
// Event listener for yes button
yesButton.on('down', function () {
LK.getSound('clearedSound').play(); // Play cleared sound when yes is pressed
currentScore = 0; // Reset the score to zero
upgradeLevel = 0; // Reset the upgrade level to zero
score.updateScore(currentScore); // Update the score display
autoClicker.cost = 100; // Reset auto clicker cost to initial value
autoClicker.autoClickerCount = 0; // Reset auto clicker count
autoClicker.updatePriceText(); // Update the auto clicker price text
autoClicker.initStars(); // Update stars when the game is reset
upgrade.cost = 10; // Reset upgrade cost to initial value
upgrade.multiplier = 1; // Reset upgrade multiplier
upgrade.updateUpgradeText(); // Update the upgrade price text
upgrade.updateCakeGraphics(); // Update cake graphics based on new upgrade level
storage.score = currentScore; // Save the reset score
storage.autoClickerCount = autoClicker.autoClickerCount; // Save the reset auto clicker count
storage.autoClickerCost = autoClicker.cost; // Save the reset auto clicker cost
storage.upgradeMultiplier = upgrade.multiplier; // Save the reset upgrade multiplier
storage.upgradeCost = upgrade.cost; // Save the reset upgrade cost
// Remove confirmation buttons
yesButton.destroy();
mask.destroy(); // Remove the mask
noButton.destroy();
confirmationBoard.destroy(); // Hide the confirmation board
restartText.destroy(); // Remove the 'Restart from Zero?' text
isResetConfirmationDisplayed = false; // Set to false when reset confirmation is dismissed
});
// Event listener for no button
noButton.on('down', function () {
LK.getSound('resetSound').play(); // Play reset sound
// Remove confirmation buttons without resetting
yesButton.destroy();
mask.destroy(); // Remove the mask
noButton.destroy();
confirmationBoard.destroy(); // Hide the confirmation board
restartText.destroy(); // Remove the 'Restart from Zero?' text
isResetConfirmationDisplayed = false; // Set to false when reset confirmation is dismissed
});
});
});
// Score class
var Score = Container.expand(function () {
var self = Container.call(this);
var scoreText = new Text2('0', {
size: 200,
fill: 0xFFFDD0,
dropShadow: true,
// Enable drop shadow
dropShadowColor: 0x000000,
// Set drop shadow color to black
dropShadowBlur: 5,
// Set drop shadow blur
dropShadowDistance: 5 // Set drop shadow distance
});
scoreText.anchor.set(0.5, 0);
self.addChild(scoreText);
self.updateScore = function (newScore) {
scoreText.setText('$' + newScore.toString());
};
});
// Upgrade class
var Upgrade = Container.expand(function () {
var self = Container.call(this);
// Upgrade properties
self.id = '';
self.name = '';
self.description = '';
self.price = 0;
self.cakesPerSecondIncrease = 0;
self.cakesPerClickIncrease = 0;
self.level = 0;
// Upgrade graphics
var upgradeGraphics = self.attachAsset('buttonPrice', {
anchorX: 0.5,
anchorY: 0.5
});
// Upgrade icon
var icon = self.attachAsset('cake_0', {
anchorX: 0.5,
anchorY: 0.5,
width: 60,
height: 60
});
icon.x = -120;
self.addChild(icon);
// Upgrade name text
var nameText = new Text2('Upgrade', {
size: 30,
fill: 0xFFFFFF,
fontWeight: '900'
});
nameText.anchor.set(0, 0.5);
nameText.x = -80;
nameText.y = -20;
self.addChild(nameText);
// Upgrade description text
var descriptionText = new Text2('Description', {
size: 20,
fill: 0xFFFFFF
});
descriptionText.anchor.set(0, 0.5);
descriptionText.x = -80;
descriptionText.y = 10;
self.addChild(descriptionText);
// Upgrade price text
var priceText = new Text2('100', {
size: 30,
fill: 0xFFFFFF,
fontWeight: '900'
});
priceText.anchor.set(0.5, 0.5);
priceText.x = 120;
self.addChild(priceText);
// Upgrade level text
var levelText = new Text2('Lv. 0', {
size: 20,
fill: 0xFFFFFF
});
levelText.anchor.set(0.5, 0.5);
levelText.x = 120;
levelText.y = 30;
self.addChild(levelText);
// Initialize upgrade
self.initialize = function (id, name, description, basePrice, cakesPerSecondIncrease, cakesPerClickIncrease, iconAsset) {
self.id = id;
self.name = name;
self.description = description;
self.basePrice = basePrice;
self.price = basePrice;
self.cakesPerSecondIncrease = cakesPerSecondIncrease;
self.cakesPerClickIncrease = cakesPerClickIncrease;
self.level = 0;
// Update texts
nameText.text = name;
descriptionText.text = description;
priceText.text = basePrice;
levelText.text = 'Lv. ' + self.level;
// Update icon
if (iconAsset) {
self.removeChild(icon);
icon = self.attachAsset(iconAsset, {
anchorX: 0.5,
anchorY: 0.5,
width: 60,
height: 60
});
icon.x = -120;
self.addChild(icon);
}
return self;
};
// Update upgrade price based on level
self.updatePrice = function () {
self.price = Math.floor(self.basePrice * Math.pow(1.15, self.level));
priceText.text = self.price;
};
// Buy upgrade
self.buy = function () {
// Check if player has enough cakes
if (cakes >= self.price) {
// Subtract price from cakes
cakes -= self.price;
updateCakeCounter();
// Increase level
self.level++;
levelText.text = 'Lv. ' + self.level;
// Update price
self.updatePrice();
// Increase cakes per second
cakesPerSecond += self.cakesPerSecondIncrease;
updateCakesPerSecondCounter();
// Increase cakes per click
cakesPerClick += self.cakesPerClickIncrease;
// Play purchase sound
LK.getSound('achat').play();
// Create animation
var animation = new CakeAnimation();
animation.x = self.x;
animation.y = self.y;
foregroundContainer.addChild(animation);
} else {
// Not enough cakes
LK.getSound('errorsond').play(); // Play error sound
}
};
self.updateUpgradeText = function () {
priceText.setText('$' + self.price); // Update the price text to reflect the current cost
};
return self;
});
/****
* Initialize Game
****/
/****
* Initialize Game
* Set up the game environment and initial configurations
****/
var game = new LK.Game({
// No title, no description
// Always backgroundColor is black
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Global array for upgrade prices
var upgradePrices = [10,
// $10
100,
// $100
1000,
// $1,000
10000,
// $10,000
100000,
// $100,000
1000000,
// $1,000,000
10000000,
// $10,000,000
100000000,
// $100,000,000
1000000000,
// $1,000,000,000
10000000000 // $10,000,000,000
];
// Global array for auto clicker prices
var autoClickerPrices = [100,
// $100
1000,
// $1,000
20000,
// $10,000
300000,
// $100,000
4000000,
// $1,000,000
50000000,
// $10,000,000
600000000,
// $100,000,000
7000000000,
// $1,000,000,000
80000000000,
// $10,000,000,000
900000000000 // $100,000,000,000
];
// Global array for the number of auto clicks per second
var autoClicksPerSecond = [1,
// 0
10,
// 1
50,
// 2
150,
// 3
500,
// 4
1500,
// 5
5000,
// 6
20000,
// 7
100000,
// 8
500000 // 9
];
// Global array for upgrade multipliers
var upgradeMultiplier = [1,
// Niveau 0
2,
// Niveau 1
5,
// Niveau 2
10,
// Niveau 3
20,
// Niveau 4
50,
// Niveau 5
100,
// Niveau 6
200,
// Niveau 7
500,
// Niveau 8
1000 // Niveau 9
];
/****
* Game Code
* Main game logic and event handling
****/
/****
* Assets
* Initialize all game assets including images, sounds, and music
****/
// Declare game variables
var bonusCakeManager; // Declare bonusCakeManager globally
var cakeList = ['cake_0', 'cake_1', 'cake_2', 'cake_3', 'cake_4', 'cake_5', 'cake_6', 'cake_8', 'cake_9'];
var isResetConfirmationDisplayed = false; // Track if reset confirmation is displayed
var upgradeLevel = storage.upgradeLevel || 0; // Load saved upgrade level or default to 0
var confettiManager; // Declare confettiManager globally
// Sounds
// Music
/****
* Plugins
* Import necessary plugins for tweening animations and storage management
****/
// Function to format prices
function formatPrice(value) {
if (value >= 1e18) {
// Quintillion
return '$' + (value / 1e18).toFixed(1) + 'Q';
} else if (value >= 1e15) {
// Quadrillion
return '$' + (value / 1e15).toFixed(1) + 'Qa';
} else if (value >= 1e12) {
// Trillion
return '$' + (value / 1e12).toFixed(1) + 'T';
} else if (value >= 1e9) {
// Billion
return '$' + (value / 1e9).toFixed(1) + 'B';
} else if (value >= 1e6) {
// Million
return '$' + (value / 1e6).toFixed(1) + 'M';
} else {
return '$' + value;
}
}
if (typeof newCakeButton !== 'undefined' && newCakeButton.newCake) {
newCakeButton.newCake.on('down', function (x, y, obj) {
newCakeButton.newCake.onClick();
});
}
// Declare game variables
var backgroundContainer;
var middleContainer;
var foregroundContainer;
var currentScore;
var score;
var lastTimestamp;
var timeElapsed;
var clicksSinceLastSession;
var autoClicker;
var upgrade;
var autoClickerText;
var bigCake;
var resetButton;
var board;
// Mini-game global variables
var isMiniGameMode = false; // Controls which game mode is active
var miniGameContainer; // Container for the mini-game
var miniGameChef;
var miniGameCakeManager;
var miniGameUI;
var miniGameTimer;
var miniGameDuration = 60; // 60 seconds
var miniGameTimeRemaining;
var miniGameReward = 0;
// Switch to mini-game mode
function switchToMiniGame() {
if (isMiniGameMode) {
return;
}
isMiniGameMode = true;
// Move main game containers off-screen (instead of hiding them)
// This preserves the game state while making them invisible
backgroundContainer.x = -5000;
middleContainer.x = -5000;
foregroundContainer.x = -5000;
// Show mini-game container
miniGameContainer.visible = true;
// Reset mini-game variables
miniGameTimeRemaining = miniGameDuration;
miniGameCakeManager.gameScore = 0;
miniGameCakeManager.combo = 0;
// Start mini-game
miniGameCakeManager.start();
// Start timer
miniGameTimer = LK.setInterval(function () {
miniGameTimeRemaining--;
// Update UI
miniGameUI.update(miniGameCakeManager.gameScore, miniGameCakeManager.combo, miniGameTimeRemaining);
// Check if game is over
if (miniGameTimeRemaining <= 0) {
endMiniGame();
}
}, 1000);
// Set up input handling for mini-game
LK.stage.on('pointermove', handleMiniGamePointerMove);
LK.stage.on('pointerdown', handleMiniGamePointerMove);
}
// Handle mini-game pointer movement
function handleMiniGamePointerMove(event) {
if (!isMiniGameMode) {
return;
}
var position = event.data.global;
miniGameChef.setTargetPosition(position.x);
}
// End mini-game
function endMiniGame() {
// Stop timer
LK.clearInterval(miniGameTimer);
// Stop cake manager
miniGameCakeManager.stop();
// Remove input handlers
LK.stage.off('pointermove', handleMiniGamePointerMove);
LK.stage.off('pointerdown', handleMiniGamePointerMove);
// Calculate reward based on score
miniGameReward = Math.floor(miniGameCakeManager.gameScore / 10);
// Add reward to player's cakes
cakes += miniGameReward;
// Show results screen
miniGameUI.showResults(miniGameCakeManager.gameScore, miniGameReward);
}
// Switch back to main game
function switchToMainGame() {
if (!isMiniGameMode) {
return;
}
isMiniGameMode = false;
// Move main game containers back to original position
backgroundContainer.x = 0;
middleContainer.x = 0;
foregroundContainer.x = 0;
// Hide mini-game container
miniGameContainer.visible = false;
// Update main game UI to reflect new cake count
updateCakeCounter();
}
// Initialize game variables
function initializeGameVariables() {
backgroundContainer = new Container();
game.addChild(backgroundContainer);
// Initialize middleContainer
middleContainer = new Container();
game.addChild(middleContainer);
// Initialize foregroundContainer
foregroundContainer = new Container();
game.addChild(foregroundContainer);
background = backgroundContainer.addChild(LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5
}));
background.x = 2048 / 2;
background.y = 2732 / 2;
background.scaleX = 2048 / background.width; // Scale background to fit the game width
background.scaleY = 2732 / background.height; // Scale background to fit the game height
// Initialize board
board = foregroundContainer.addChild(new Board());
board.x = 2240;
board.y = 1230; // Center board vertically
board.boardGraphics.alpha = 0.8; // Set transparency of the right board to 0.8
// Initialize bigCake
bigCake = middleContainer.addChild(new BigCake());
bigCake.x = 2048 / 2;
bigCake.y = 2732 / 2;
// Initialize score
score = game.addChild(new Score());
score.x = 2048 / 2;
score.y = 30; // Position score even higher at the top center
currentScore = storage.score || 0; // Load saved score or default to 0
score.updateScore(currentScore); // Refresh the score display with the loaded score
// Calculate the number of clicks since the last session
lastTimestamp = storage.timestamp || Date.now();
timeElapsed = Date.now() - lastTimestamp;
clicksSinceLastSession = Math.floor(timeElapsed / 1000); // Assuming 1 click per second as a baseline
console.log("Clicks since last session: ", clicksSinceLastSession);
currentScore += clicksSinceLastSession; // Add clicks since last session to the current score
score.updateScore(currentScore); // Update the score display with the new score
storage.score = currentScore; // Save the updated score
// Initialize auto clicker
autoClicker = foregroundContainer.addChild(new AutoClicker());
autoClicker.autoClickerCount = storage.autoClickerCount || 0; // Load saved auto clicker count or default to 0
autoClicker.cost = storage.autoClickerCost || autoClickerPrices[0]; // Load saved auto clicker cost or default to initial cost from autoClickerPrices array
autoClicker.updatePriceText(); // Update the price text to reflect the loaded cost
autoClicker.initStars(); // Initialize and update the display of stars based on the current autoClickerCount
if (autoClicker.autoClickerCount > 0) {
autoClicker.startAutoClicking(); // Start auto-clicking if there are saved auto-clickers
}
// Initialize upgrade
upgrade = foregroundContainer.addChild(new Upgrade());
upgrade.multiplier = storage.upgradeMultiplier || 1; // Load saved upgrade multiplier or default to 1
upgrade.cost = storage.upgradeCost || upgradePrices[0]; // Load saved upgrade cost or default to initial cost from upgradePrices array
upgrade.updateUpgradeText(); // Update the upgrade price text to reflect the loaded cost
upgrade.updateCakeGraphics(); // Update cake graphics based on new upgrade level
upgrade.x = 2048 - upgrade.width / 2 - 10; // Position upgrade button on the right side of the screen
upgrade.y = 2732 / 2 - upgrade.height + 140; // Position upgrade button slightly lower on the screen
// Event listener for upgrade button clicks
upgrade.on('down', function (x, y, obj) {
upgrade.onClick();
});
// Initialize reset button
resetButton = backgroundContainer.addChild(new ResetButton());
// Initialize confetti manager
confettiManager = new ConfettiManager();
// Initialize bonus cake manager
bonusCakeManager = new BonusCakeManager();
LK.setTimeout(function () {
bonusCakeManager.start(); // Start the bonus cake manager after 1 minute
}, 60000);
resetButton.x = 2048 - resetButton.width / 2 - 40; // Add margin to the right edge
resetButton.y = score.y + score.height / 2 + 10; // Adjust reset button position to be slightly higher
// Initialize auto clicker text
autoClickerText = new Text2('Auto Clicker: $' + autoClicker.cost, {
size: 100,
fill: currentScore >= autoClicker.cost ? 0x00FF00 : 0xFF0000
});
autoClickerText.anchor.set(0.5, 0);
autoClickerText.x = autoClicker.x;
autoClickerText.y = autoClicker.y - autoClicker.height / 2 - 50; // Position text above the auto clicker button
game.addChild(autoClickerText);
// Update autoClickerText immediately after loading the game
autoClicker.x = 2048 - autoClicker.width / 2 - 10; // Position auto clicker button on the right side of the screen
autoClicker.y = 2732 / 2 + 160; // Position auto clicker button slightly lower on the screen
// Event listener for auto clicker clicks
autoClicker.on('down', function (x, y, obj) {
autoClicker.onClick();
});
// Play bakery music in a loop throughout the game
LK.playMusic('musiqueclicker', {
loop: true
});
// Initialize mini-game container
miniGameContainer = new Container();
miniGameContainer.visible = false;
game.addChild(miniGameContainer);
// Initialize mini-game UI
miniGameUI = new MiniGameUI();
miniGameContainer.addChild(miniGameUI);
// Initialize mini-game chef
miniGameChef = new ChefCharacter();
miniGameContainer.addChild(miniGameChef);
// Initialize mini-game cake manager
miniGameCakeManager = new MiniGameCakeManager();
miniGameContainer.addChild(miniGameCakeManager);
// Initialize mini-game button
var miniGameButton = new MiniGameButton();
miniGameButton.x = 2048 / 2 - 150;
miniGameButton.y = 2732 / 2 - 200;
foregroundContainer.addChild(miniGameButton);
// Set up game loop
LK.onUpdate(gameLoop);
}
// Call the function to initialize game variables
initializeGameVariables();
// Game loop
function gameLoop(dt) {
// Update the cakes per second counter
cakesPerSecondCounter += dt;
if (cakesPerSecondCounter >= 1) {
cakesPerSecondCounter = 0;
cakes += cakesPerSecond;
updateCakeCounter();
}
// Only update main game animations if not in mini-game mode
if (!isMiniGameMode) {
// Update animations
updateAnimations(dt);
} else {
// Update mini-game
miniGameChef.update();
miniGameCakeManager.update(miniGameChef);
}
}
self.updateUpgradeText = function () {
priceText.setText('$' + self.price); // Update the price text to reflect the current cost
};
self.updateCakeGraphics = function () {
// Logic to update cake graphics based on the current upgrade level
var cakeAssetId = 'cake_' + Math.min(self.level, 9); // Ensure the level doesn't exceed available cake assets
self.removeChild(icon);
icon = self.attachAsset(cakeAssetId, {
anchorX: 0.5,
anchorY: 0.5,
width: 60,
height: 60
});
icon.x = -120;
self.addChild(icon);
};
a button saying 'reset'. In-Game asset. 2d. Blank background. High contrast.
enlève ça
interieure de patiserie. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gâteau ( pas réaliste ). Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
sparkles
gâteau. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
gâteau. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
gâteau. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
dessin de toque de chef
étoile dorée toute simple comme dans les commentaires d'un site web
une patisserie (gâteau) simple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
interieure de patiserie vide avec uniquement le sol et les murs. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
trace blanche verticale d'un effet de coup de ninja
Vue de face centrée d'une machine magique en forme de pièce montée arc-en-ciel avec une petite entrée d'alimentation en bas au milieu, un très grand hublot central et un tube transparent dirigé vers le haut.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
errorsond
Sound effect
relaxsond
Sound effect
clickSound
Sound effect
musiqueclicker
Music
buySound
Sound effect
resetSound
Sound effect
buyAutoclickerSound
Sound effect
clearedSound
Sound effect
bonusSound
Sound effect
ohoh
Sound effect
cheers
Sound effect
squashingSound
Sound effect
CutSound
Sound effect
youpi
Sound effect
canonSound
Sound effect
yeahh
Sound effect
nooo
Sound effect
machineError
Sound effect
aspire
Sound effect