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
===================================================================
--- original.js
+++ change.js
@@ -229,9 +229,8 @@
});
LK.getSound('errorsond').play(); // Play error sound
}
};
- return self;
});
// BigCake class
var BigCake = Container.expand(function () {
var self = Container.call(this);
@@ -344,60 +343,8 @@
}
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 = self.attachAsset('masque', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- shadow.tint = 0x000000;
- shadow.alpha = 0.3;
- shadow.width = 120;
- shadow.height = 40;
- shadow.y = 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.3;
- 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)), {
@@ -419,563 +366,19 @@
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);
+ self.popCakes = function (x, y, numConfetti) {
+ for (var i = 0; i < numConfetti; i++) {
+ var confetti = middleContainer.addChild(new Confetti(upgradeLevel));
+ confetti.x = x;
+ confetti.y = y;
+ confetti.speedY = -15; // Initial upward speed
}
- // 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,
- width: 40,
- height: 40
- });
- // 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
- });
- }
- });
- }
- };
- // Add event listener
- self.on('down', function () {
- self.onClick();
- });
- 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 = self.attachAsset('masque', {
- anchorX: 0,
- anchorY: 0
- });
- panel.tint = 0x000000;
- panel.alpha = 0.8;
- panel.width = 1000;
- panel.height = 1200;
- panel.x = 2048 / 2 - 500;
- 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 = self.attachAsset('masque', {
- anchorX: 0,
- anchorY: 0
- });
- resultsPanel.tint = 0x000000;
- resultsPanel.alpha = 0.8;
- resultsPanel.width = 1000;
- resultsPanel.height = 1200;
- resultsPanel.x = 2048 / 2 - 500;
- resultsPanel.y = 20;
- 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 = continueButton.attachAsset('yesButton', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- buttonGraphics.width = 300;
- buttonGraphics.height = 80;
- 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('down', 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);
- // Add a simple animation to the button
- tween(continueButton, {
- scaleX: 1.1,
- scaleY: 1.1
- }, {
- duration: 500,
- easing: tween.easeInOut,
- loop: true,
- yoyo: true
- });
- };
- return self;
-});
// ResetButton class
var ResetButton = Container.expand(function () {
var self = Container.call(this);
var resetButtonGraphics = self.attachAsset('resetButton', {
@@ -1023,12 +426,10 @@
var yesButton = foregroundContainer.addChild(LK.getAsset('yesButton', {
anchorX: 0.5,
anchorY: 0.5
}));
- yesButton.width = 300;
- yesButton.height = 100;
- yesButton.x = 2048 / 2; // Position yes button at the center
- yesButton.y = resultsPanel.y + resultsPanel.height - 150; // Center vertically
+ 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
}));
@@ -1093,8 +494,17 @@
self.updateScore = function (newScore) {
scoreText.setText('$' + newScore.toString());
};
});
+// SwitchButton class
+var SwitchButton = Container.expand(function () {
+ var self = Container.call(this);
+ var switchButtonGraphics = self.attachAsset('buttonSwitch', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Add any additional properties or methods for the switch button here
+});
// Upgrade class
var Upgrade = Container.expand(function () {
var self = Container.call(this);
// Create a shadow effect by adding a black tinted, semi-transparent duplicate of upgradeGraphics
@@ -1205,52 +615,91 @@
confettiManager.popCakes(bigCake.x, bigCake.y, 5); // Call popCakes using bigCake's coordinates
LK.getSound('buySound').play(); // Play buy sound when upgrade is purchased
// Animate the upgrade button
tween(upgradeGraphics, {
- scaleX: 1.2,
- scaleY: 1.2
+ scaleX: 0.9,
+ scaleY: 0.9
}, {
- duration: 200,
- easing: tween.easeOut,
+ duration: 100,
+ easing: tween.easeInOut,
onFinish: function onFinish() {
tween(upgradeGraphics, {
scaleX: 1,
scaleY: 1
}, {
- duration: 200,
- easing: tween.easeIn
+ 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 cakeGraphics in the same way
+ tween(self.cakeGraphics, {
+ scaleX: 0.9,
+ scaleY: 0.9
+ }, {
+ duration: 100,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ tween(self.cakeGraphics, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100,
+ easing: tween.easeInOut
+ });
+ }
+ });
} else {
- // Play error sound if not enough cakes
- LK.getSound('errorsond').play();
- // Shake the upgrade button to indicate error
- tween(upgradeGraphics, {
- x: 10
+ tween(self, {
+ alpha: 0.2
}, {
- duration: 50,
+ duration: 100,
easing: tween.easeInOut,
onFinish: function onFinish() {
- tween(upgradeGraphics, {
- x: -10
+ tween(self, {
+ alpha: 1
}, {
duration: 100,
easing: tween.easeInOut,
onFinish: function onFinish() {
- tween(upgradeGraphics, {
- x: 0
+ tween(self, {
+ alpha: 0.2
}, {
- duration: 50,
- easing: tween.easeInOut
+ 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;
});
/****
* Initialize Game
@@ -1267,12 +716,8 @@
/****
* Game Code
****/
-function updateCakeCounter() {
- // Update the cake counter display or logic here
- console.log("Cakes: " + cakes);
-}
// Global array for upgrade prices
var upgradePrices = [10,
// $10
100,
@@ -1402,9 +847,8 @@
newCakeButton.newCake.onClick();
});
}
// Declare game variables
-var cakes = 0; // Initialize cakes variable to track the number of cakes
var backgroundContainer;
var middleContainer;
var foregroundContainer;
var currentScore;
@@ -1417,89 +861,8 @@
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 = -2048;
- middleContainer.x = -2048;
- foregroundContainer.x = -2048;
- // 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--;
- miniGameUI.update(miniGameCakeManager.gameScore, miniGameCakeManager.combo, miniGameTimeRemaining);
- // Check if game is over
- if (miniGameTimeRemaining <= 0) {
- endMiniGame();
- }
- }, 1000);
- // Set up input handling for mini-game
- miniGameContainer.on('move', handleMiniGamePointerMove);
- miniGameContainer.on('down', handleMiniGamePointerMove);
-}
-// Handle mini-game pointer movement
-function handleMiniGamePointerMove(event) {
- if (!isMiniGameMode) {
- return;
- }
- // Get mouse position
- miniGameChef.setTargetPosition(event.x);
-}
-// End mini-game
-function endMiniGame() {
- // Stop timer
- LK.clearInterval(miniGameTimer);
- // Stop cake manager
- miniGameCakeManager.stop();
- // Remove input handlers
- miniGameContainer.off('move', handleMiniGamePointerMove);
- miniGameContainer.off('down', 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);
@@ -1591,54 +954,7 @@
// Play bakery music in a loop throughout the game
LK.playMusic('musiqueclicker', {
loop: true
});
- // Initialize mini-game container
- miniGameContainer = new Container();
- miniGameContainer.visible = false;
- LK.stage.addChild(miniGameContainer);
- // Initialize mini-game components
- miniGameChef = new ChefCharacter();
- miniGameChef.x = 2048 / 2;
- miniGameChef.y = 2732 - 150;
- miniGameContainer.addChild(miniGameChef);
- miniGameCakeManager = new MiniGameCakeManager();
- miniGameContainer.addChild(miniGameCakeManager);
- miniGameUI = new MiniGameUI();
- miniGameContainer.addChild(miniGameUI);
- confettiManager = new ConfettiManager();
- miniGameContainer.addChild(confettiManager);
- // Add mini-game button to main game
- miniGameButton = new MiniGameButton();
- miniGameButton.x = 2048 / 2;
- miniGameButton.y = 2732 / 2 + 400;
- foregroundContainer.addChild(miniGameButton);
- // Set up game loop
- LK.setInterval(gameLoop, 1000 / 60); // 60 FPS
}
// Call the function to initialize game variables
-initializeGameVariables();
-// Game loop
-function gameLoop() {
- // Update the cakes per second counter
- cakesPerSecondCounter += 1 / 60; // Assuming 60 FPS
- if (cakesPerSecondCounter >= 1) {
- cakesPerSecondCounter = 0;
- cakes += cakesPerSecond;
- updateCakeCounter();
- }
- // Only update main game animations if not in mini-game mode
- if (!isMiniGameMode) {
- // Update confetti manager
- if (typeof confettiManager !== 'undefined') {
- confettiManager.update();
- }
- } else {
- // Update mini-game
- miniGameChef.update();
- miniGameCakeManager.update(miniGameChef);
- }
-}
-// Initialize cakesPerSecond variable
-var cakesPerSecond = 0;
-// Initialize cakesPerSecondCounter
-var cakesPerSecondCounter = 0;
\ No newline at end of file
+initializeGameVariables();
\ No newline at end of file
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