User prompt
ajouter une class pour le chef sans l'ajouter au jeu. integre dans la classe la possibiliter de le deฬ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 deฬplacement de miniGameContainer de y = 2732 aฬ y=0 et anime le mouvement de mainGameContainer de y = 0 aฬ y = -2732
Code edit (1 edits merged)
Please save this source code
User prompt
creฬ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
@@ -360,17 +360,17 @@
y: 2732 - 150
};
self.targetX = self.position.x;
// Add a shadow effect
- var shadow = LK.getAsset('masque', {
+ var shadow = self.attachAsset('masque', {
anchorX: 0.5,
- anchorY: 0.5,
- width: 120,
- height: 40
+ anchorY: 0.5
});
shadow.tint = 0x000000;
shadow.alpha = 0.3;
- shadow.y = chefGraphics.height / 2 - 10;
+ shadow.width = 120;
+ shadow.height = 40;
+ shadow.y = 10;
self.addChild(shadow);
// Add chef after shadow (layering)
self.addChild(chefGraphics);
// Update function for movement
@@ -628,8 +628,12 @@
}
});
}
};
+ // Add event listener
+ self.on('down', function () {
+ self.onClick();
+ });
return self;
});
// Cake Manager for mini-game
var MiniGameCakeManager = Container.expand(function () {
@@ -757,15 +761,17 @@
// UI for mini-game
var MiniGameUI = Container.expand(function () {
var self = Container.call(this);
// Background panel
- var panel = LK.getAsset('masque', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: 400,
- height: 150
+ var panel = self.attachAsset('masque', {
+ anchorX: 0,
+ anchorY: 0
});
- panel.x = 2048 / 2 - 200;
+ 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:', {
@@ -873,14 +879,18 @@
};
// 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;
+ 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,
@@ -916,12 +926,14 @@
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();
+ 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,
@@ -934,9 +946,9 @@
continueButton.x = 2048 / 2 - 150;
continueButton.y = resultsPanel.y + 400;
continueButton.interactive = true;
continueButton.buttonMode = true;
- continueButton.on('pointerdown', function () {
+ continueButton.on('down', function () {
// Play sound
LK.getSound('clickSound').play();
// Return to main game
switchToMainGame();
@@ -947,15 +959,18 @@
self.removeChild(rewardResultText);
self.removeChild(continueButton);
});
self.addChild(continueButton);
- // Button hover effect
- continueButton.on('pointerover', function () {
- buttonGraphics.tint = 0x3E8E41;
+ // Add a simple animation to the button
+ tween(continueButton, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 500,
+ easing: tween.easeInOut,
+ loop: true,
+ yoyo: true
});
- continueButton.on('pointerout', function () {
- buttonGraphics.tint = 0xFFFFFF;
- });
};
return self;
});
// ResetButton class
@@ -1006,10 +1021,12 @@
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
+ 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
var noButton = foregroundContainer.addChild(LK.getAsset('noButton', {
anchorX: 0.5,
anchorY: 0.5
}));
@@ -1101,43 +1118,71 @@
icon.x = -120;
self.addChild(icon);
// Upgrade name text
var nameText = new Text2('Upgrade', {
- size: 30,
+ size: 24,
fill: 0xFFFFFF,
- fontWeight: '900'
+ fontWeight: 'bold'
});
- nameText.anchor.set(0, 0.5);
- nameText.x = -80;
- nameText.y = -20;
+ nameText.anchor.set(0.5, 0.5);
+ nameText.x = 0;
+ nameText.y = -upgradeGraphics.height / 4;
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'
+ var upgradeText = new Text2('10', {
+ size: 24,
+ fill: 0xFFD700,
+ fontWeight: 'bold',
+ dropShadow: true,
+ dropShadowColor: 0x000000,
+ dropShadowBlur: 5,
+ dropShadowDistance: 5
});
- 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
+ upgradeText.anchor.set(0.5, 0);
+ upgradeText.x = 0;
+ upgradeText.y = upgradeGraphics.height / 2 + 20; // Position text below the upgrade button
+ self.addChild(upgradeText);
+ // Add cake graphics
+ self.cakeGraphics = self.attachAsset('cake_0', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: 80,
+ height: 80
});
- levelText.anchor.set(0.5, 0.5);
- levelText.x = 120;
- levelText.y = 30;
- self.addChild(levelText);
+ self.cakeGraphics.x = 120;
+ self.addChild(self.cakeGraphics);
+ // Update upgrade text
+ self.updateUpgradeText = function () {
+ upgradeText.setText(formatPrice(self.price));
+ };
+ // Update cake graphics
+ self.updateCakeGraphics = function () {
+ var cakeIndex = Math.min(self.level + 1, 9);
+ tween(self.cakeGraphics, {
+ alpha: 0
+ }, {
+ duration: 500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ self.removeChild(self.cakeGraphics);
+ self.cakeGraphics = self.attachAsset('cake_' + cakeIndex, {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: 80,
+ height: 80
+ });
+ self.cakeGraphics.x = 120;
+ self.cakeGraphics.alpha = 0;
+ self.addChild(self.cakeGraphics);
+ tween(self.cakeGraphics, {
+ alpha: 1
+ }, {
+ duration: 500,
+ easing: tween.easeIn
+ });
+ }
+ });
+ };
// Initialize upgrade
self.initialize = function (id, name, description, basePrice, cakesPerSecondIncrease, cakesPerClickIncrease, iconAsset) {
self.id = id;
self.name = name;
@@ -1148,11 +1193,10 @@
self.cakesPerClickIncrease = cakesPerClickIncrease;
self.level = 0;
// Update texts
nameText.text = name;
- descriptionText.text = description;
- priceText.text = basePrice;
- levelText.text = 'Lv. ' + self.level;
+ upgradeText.text = basePrice;
+ upgradeText.setText(formatPrice(self.price));
// Update icon
if (iconAsset) {
self.removeChild(icon);
icon = self.attachAsset(iconAsset, {
@@ -1168,9 +1212,9 @@
};
// 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;
+ upgradeText.setText(formatPrice(self.price));
};
// Buy upgrade
self.buy = function () {
// Check if player has enough cakes
@@ -1179,9 +1223,9 @@
cakes -= self.price;
updateCakeCounter();
// Increase level
self.level++;
- levelText.text = 'Lv. ' + self.level;
+ upgradeText.setText('Lv. ' + self.level);
// Update price
self.updatePrice();
// Increase cakes per second
cakesPerSecond += self.cakesPerSecondIncrease;
@@ -1199,24 +1243,8 @@
// 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
- };
- 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);
- };
return self;
});
/****
@@ -1234,12 +1262,8 @@
/****
* Game Code
****/
-function updateAnimations(dt) {
- // Placeholder for animation updates
- // Add animation update logic here if needed
-}
// Global array for upgrade prices
var upgradePrices = [10,
// $10
100,
@@ -1369,10 +1393,8 @@
newCakeButton.newCake.onClick();
});
}
// Declare game variables
-var cakesPerSecondCounter = 0; // Initialize cakesPerSecondCounter to track time for cakes per second
-var cakesPerSecondCounter = 0; // Initialize cakesPerSecondCounter to track time for cakes per second
var backgroundContainer;
var middleContainer;
var foregroundContainer;
var currentScore;
@@ -1425,28 +1447,29 @@
endMiniGame();
}
}, 1000);
// Set up input handling for mini-game
- LK.stage.on('pointermove', handleMiniGamePointerMove);
- LK.stage.on('pointerdown', handleMiniGamePointerMove);
+ LK.stage.on('mousemove', handleMiniGamePointerMove);
+ LK.stage.on('mousedown', handleMiniGamePointerMove);
}
// Handle mini-game pointer movement
function handleMiniGamePointerMove(event) {
if (!isMiniGameMode) {
return;
}
- var position = event.data.global;
- miniGameChef.setTargetPosition(position.x);
+ // Get mouse position
+ var mouseX = event.clientX || event.pageX;
+ miniGameChef.setTargetPosition(mouseX);
}
// 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);
+ LK.stage.off('mousemove', handleMiniGamePointerMove);
+ LK.stage.off('mousedown', handleMiniGamePointerMove);
// Calculate reward based on score
miniGameReward = Math.floor(miniGameCakeManager.gameScore / 10);
// Add reward to player's cakes
cakes += miniGameReward;
@@ -1563,25 +1586,27 @@
});
// 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
+ LK.stage.addChild(miniGameContainer);
+ // Initialize mini-game components
miniGameChef = new ChefCharacter();
+ miniGameChef.x = 2048 / 2;
+ miniGameChef.y = 2732 - 150;
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;
+ 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, 16);
+ LK.ticker.add(gameLoop);
}
// Call the function to initialize game variables
initializeGameVariables();
// Game loop
@@ -1594,28 +1619,16 @@
updateCakeCounter();
}
// Only update main game animations if not in mini-game mode
if (!isMiniGameMode) {
- // Update animations
- updateAnimations(dt);
+ // Update confetti manager
+ if (typeof confettiManager !== 'undefined') {
+ confettiManager.update();
+ }
} 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);
-};
\ No newline at end of file
+// Initialize cakesPerSecondCounter
+var cakesPerSecondCounter = 0;
\ 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.
gaฬteau ( pas reฬaliste ). Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
sparkles
gaฬteau. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
gaฬteau. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
gaฬteau. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
dessin de toque de chef
eฬtoile doreฬe toute simple comme dans les commentaires d'un site web
une patisserie (gaฬ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 centreฬe d'une machine magique en forme de pieฬce monteฬe arc-en-ciel avec une petite entreฬe d'alimentation en bas au milieu, un treฬs grand hublot central et un tube transparent dirigeฬ 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