Code edit (17 edits merged)
Please save this source code
User prompt
pour la lumiere centrale ajoute aussi une animation de rotation ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
l'animation des lumière de la machine doit etre faite en boucle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Anime la CakeMachine en faisant changer la transparence des lumières en boucle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (3 edits merged)
Please save this source code
User prompt
ajoute lightCentral et lightSide à CakeMachine
Code edit (1 edits merged)
Please save this source code
Code edit (10 edits merged)
Please save this source code
User prompt
stop le CakeRainManager quand on est pas en mode mini jeu 1
Code edit (1 edits merged)
Please save this source code
User prompt
dans toggleMiniGame; ajoute un flag pour empêcher un autre appel à toggleMiniGame tant que les animations de transition ne sont pas terminées
Code edit (1 edits merged)
Please save this source code
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'width')' in or related to this line: 'switchButtonMini.x = switchButtonThird.width * 0.5;' Line Number: 1736
Code edit (1 edits merged)
Please save this source code
Code edit (16 edits merged)
Please save this source code
User prompt
permet la découpe des gateaux 'confetti' dans le jeu principal sans altérer le mini-jeu. Reprend les memes éléments : - ajouter un CutEffect - crééer 2 minicakes
User prompt
permet la découpe des gateaux 'confetti' dans le jeu principal sans altérer le mini-jeu
User prompt
Change le nombre de nains à 20
User prompt
Joue le son youpi quand un nain attrape un minicake
User prompt
Le squashingSound doit être joué dés le début du squashing anim, pas à la fin
User prompt
Joue cut sound quand un gâteau est coupé en miniCakes
User prompt
Joue squashing sound quand un nain se fait écraser
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -343,8 +343,28 @@
}
triggerPopBonus();
};
});
+// CakeMachine class
+var CakeMachine = Container.expand(function () {
+ var self = Container.call(this);
+ // Attacher l'asset de la machine à gâteaux
+ var cakeMachineGraphics = self.attachAsset('cakeMachine', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // État de la machine
+ self.isActive = false;
+ // Méthode pour activer la machine
+ self.activate = function () {
+ self.isActive = true;
+ };
+ // Méthode pour désactiver la machine
+ self.deactivate = function () {
+ self.isActive = false;
+ };
+ return self;
+});
var CakeRainManager = Container.expand(function () {
var self = Container.call(this);
self.cakes = [];
self.spawnCake = function () {
@@ -491,8 +511,10 @@
var Dwarf = Container.expand(function (dwarfIndex) {
var self = Container.call(this);
// Stocker l'index du nain
self.dwarfIndex = dwarfIndex || 0;
+ // Propriété pour identifier le mini-jeu auquel appartient le nain
+ self.miniGame = 1; // Par défaut, appartient au mini-jeu 1
// Index du gâteau ciblé actuellement (-1 signifie aucun gâteau ciblé)
self.targetCakeIndex = -1;
// Attach assets for full and empty states
var dwarfFullFrame1 = self.attachAsset('dwarf_full_frame_1', {
@@ -540,31 +562,35 @@
if (isMiniGameRunning !== 1 && isMiniGameRunning !== 2 || self.isSquashing) {
return;
} // Only update if the mini-game or third game is active and not being squashed
// Comportement spécifique au troisième jeu
- if (isMiniGameRunning === 2) {
- // Animation du nain
- self.animationCounter++;
- if (self.animationCounter >= self.animationDelay) {
- self.animationCounter = 0;
- if (self.state === 'full') {
- dwarfFullFrame1.visible = !dwarfFullFrame1.visible;
- dwarfFullFrame2.visible = !dwarfFullFrame2.visible;
- dwarfEmptyFrame1.visible = false;
- dwarfEmptyFrame2.visible = false;
- } else {
- dwarfEmptyFrame1.visible = !dwarfEmptyFrame1.visible;
- dwarfEmptyFrame2.visible = !dwarfEmptyFrame2.visible;
- dwarfFullFrame1.visible = false;
- dwarfFullFrame2.visible = false;
+ if (isMiniGameRunning === 2 && self.miniGame === 2) {
+ self.speedX = 5;
+ // Animation du nain seulement s'il n'est pas en attente
+ if (!self.waitingAtCenter) {
+ self.animationCounter++;
+ if (self.animationCounter >= self.animationDelay) {
+ self.animationCounter = 0;
+ if (self.state === 'full') {
+ dwarfFullFrame1.visible = !dwarfFullFrame1.visible;
+ dwarfFullFrame2.visible = !dwarfFullFrame2.visible;
+ dwarfEmptyFrame1.visible = false;
+ dwarfEmptyFrame2.visible = false;
+ } else {
+ dwarfEmptyFrame1.visible = !dwarfEmptyFrame1.visible;
+ dwarfEmptyFrame2.visible = !dwarfEmptyFrame2.visible;
+ dwarfFullFrame1.visible = false;
+ dwarfFullFrame2.visible = false;
+ }
}
}
+ self.currentFrame = dwarfFullFrame1.visible ? dwarfFullFrame1 : dwarfFullFrame2.visible ? dwarfFullFrame2 : dwarfEmptyFrame1.visible ? dwarfEmptyFrame1 : dwarfEmptyFrame2;
+ self.currentFrame.scaleX = -1;
// Gestion du comportement du nain dans le troisième jeu
if (self.state === 'full') {
// Le nain se déplace vers x=1024
- if (self.x > 1024) {
+ if (self.x > 1000) {
self.x -= self.speedX;
- self.scale.x = -1; // Orientation vers la gauche
} else if (!self.waitingAtCenter) {
// Arrivé au centre, attendre 1 seconde
self.waitingAtCenter = true;
LK.setTimeout(function () {
@@ -580,9 +606,8 @@
} else {
// En mode empty, continuer jusqu'à x=-300
if (self.x > -300) {
self.x -= self.speedX;
- self.scale.x = -1; // Orientation vers la gauche
} else {
// Réinitialiser le nain à droite en mode full
self.x = 2300;
self.state = 'full';
@@ -594,91 +619,93 @@
}
return; // Ne pas exécuter le reste du code pour le mini-jeu
}
// Comportement original du mini-jeu (isMiniGameRunning === 1)
- // Check if the dwarf reaches x = -300 and switch mode from full to empty
- if (self.x <= -300 && self.state === 'full') {
- self.state = 'empty';
- self.x = 2348;
- self.y = 2732 - 180; // Réinitialiser la position Y
- dwarfEmptyFrame1.visible = true;
- dwarfEmptyFrame2.visible = false;
- dwarfFullFrame1.visible = false;
- dwarfFullFrame2.visible = false;
- self.jumpPlayed = false; // Reset jump animation flag
- self.targetCooldown = 0; // Forcer la recherche d'une nouvelle cible immédiatement
- self.speedX = 7; // Réinitialiser la vitesse
- }
- // Decrement cooldown if active
- if (self.targetCooldown > 0) {
- self.targetCooldown--;
- }
- // Si le nain est immobile, incrémenter le compteur d'inactivité
- if (Math.abs(self.speedX) < 0.1) {
- self.idleTime++;
- } else {
- self.idleTime = 0;
- }
- // Si le nain est inactif depuis trop longtemps, forcer la recherche d'une nouvelle cible
- if (self.idleTime >= self.maxIdleTime) {
- self.targetCooldown = 0;
- self.idleTime = 0;
- }
- // Move the dwarf towards the closest falling cake on the x-axis
- if (self.state === 'full') {
- self.searchForCakeInFullMode();
- } else {
- self.searchForCakeInEmptyMode();
- }
- // Calculate distance to target
- var distanceToTarget = self.targetX - self.x;
- var absDistance = Math.abs(distanceToTarget);
- if (absDistance > threshold) {
- // Gradually adjust speed based on distance for smoother movement
- var direction = distanceToTarget > 0 ? 1 : -1;
- var speedFactor = Math.min(1, absDistance / 200); // Scale speed based on distance
- self.speedX = direction * baseSpeed * speedFactor;
- self.x += self.speedX;
- } else if (absDistance > 0) {
- // Slow down as we approach the target
- var slowSpeed = baseSpeed * 0.5;
- self.speedX = distanceToTarget > 0 ? Math.min(slowSpeed, distanceToTarget) : Math.max(-slowSpeed, distanceToTarget);
- self.x += self.speedX;
- } else {
- // Si le nain est exactement à la position cible, réinitialiser le cooldown
- // pour qu'il cherche une nouvelle cible au prochain cycle
- self.targetCooldown = 0;
- }
- // Check for intersection with miniCakes
- miniGameMiniCakes.forEach(function (miniCake, index) {
- if (self.intersects(miniCake)) {
- LK.getSound('youpi').play(); // Play 'youpi' sound when a dwarf catches a minicake
- // Enter 'full' mode
- self.state = 'full';
- dwarfEmptyFrame1.visible = false;
+ if (isMiniGameRunning === 1 && self.miniGame === 1) {
+ // Check if the dwarf reaches x = -300 and switch mode from full to empty
+ if (self.x <= -300 && self.state === 'full') {
+ self.state = 'empty';
+ self.x = 2348;
+ self.y = 2732 - 180; // Réinitialiser la position Y
+ dwarfEmptyFrame1.visible = true;
dwarfEmptyFrame2.visible = false;
- dwarfFullFrame1.visible = true;
+ dwarfFullFrame1.visible = false;
dwarfFullFrame2.visible = false;
- // Remove the miniCake
- miniCake.destroy();
- miniGameMiniCakes.splice(index, 1);
+ self.jumpPlayed = false; // Reset jump animation flag
+ self.targetCooldown = 0; // Forcer la recherche d'une nouvelle cible immédiatement
+ self.speedX = 7; // Réinitialiser la vitesse
}
- });
- // Check for intersection with non-miniCakes
- if (self.state === 'empty' && !self.isSquashing) {
- miniGameCurrentCakes.forEach(function (cake, index) {
- //self.x >= cake.borderBox.x - cake.borderBox.width / 2 && self.x <= cake.borderBox.x + cake.borderBox.width / 2
- if (cake && cake.y < 2500 && !cake.hasSquashed && self.intersects(cake.borderBox)) {
- cake.hasSquashed = true; // Marquer le gâteau comme ayant déjà écrasé un nain
- self.squashAnimation(cake);
- return;
+ // Decrement cooldown if active
+ if (self.targetCooldown > 0) {
+ self.targetCooldown--;
+ }
+ // Si le nain est immobile, incrémenter le compteur d'inactivité
+ if (Math.abs(self.speedX) < 0.1) {
+ self.idleTime++;
+ } else {
+ self.idleTime = 0;
+ }
+ // Si le nain est inactif depuis trop longtemps, forcer la recherche d'une nouvelle cible
+ if (self.idleTime >= self.maxIdleTime) {
+ self.targetCooldown = 0;
+ self.idleTime = 0;
+ }
+ // Move the dwarf towards the closest falling cake on the x-axis
+ if (self.state === 'full') {
+ self.searchForCakeInFullMode();
+ } else {
+ self.searchForCakeInEmptyMode();
+ }
+ // Calculate distance to target
+ var distanceToTarget = self.targetX - self.x;
+ var absDistance = Math.abs(distanceToTarget);
+ if (absDistance > threshold) {
+ // Gradually adjust speed based on distance for smoother movement
+ var direction = distanceToTarget > 0 ? 1 : -1;
+ var speedFactor = Math.min(1, absDistance / 200); // Scale speed based on distance
+ self.speedX = direction * baseSpeed * speedFactor;
+ self.x += self.speedX;
+ } else if (absDistance > 0) {
+ // Slow down as we approach the target
+ var slowSpeed = baseSpeed * 0.5;
+ self.speedX = distanceToTarget > 0 ? Math.min(slowSpeed, distanceToTarget) : Math.max(-slowSpeed, distanceToTarget);
+ self.x += self.speedX;
+ } else {
+ // Si le nain est exactement à la position cible, réinitialiser le cooldown
+ // pour qu'il cherche une nouvelle cible au prochain cycle
+ self.targetCooldown = 0;
+ }
+ // Check for intersection with miniCakes
+ miniGameMiniCakes.forEach(function (miniCake, index) {
+ if (self.intersects(miniCake)) {
+ LK.getSound('youpi').play(); // Play 'youpi' sound when a dwarf catches a minicake
+ // Enter 'full' mode
+ self.state = 'full';
+ dwarfEmptyFrame1.visible = false;
+ dwarfEmptyFrame2.visible = false;
+ dwarfFullFrame1.visible = true;
+ dwarfFullFrame2.visible = false;
+ // Remove the miniCake
+ miniCake.destroy();
+ miniGameMiniCakes.splice(index, 1);
}
});
+ // Check for intersection with non-miniCakes
+ if (self.state === 'empty' && !self.isSquashing) {
+ miniGameCurrentCakes.forEach(function (cake, index) {
+ //self.x >= cake.borderBox.x - cake.borderBox.width / 2 && self.x <= cake.borderBox.x + cake.borderBox.width / 2
+ if (cake && cake.y < 2500 && !cake.hasSquashed && self.intersects(cake.borderBox)) {
+ cake.hasSquashed = true; // Marquer le gâteau comme ayant déjà écrasé un nain
+ self.squashAnimation(cake);
+ return;
+ }
+ });
+ }
+ // Animate frames
+ self.animateFrames();
+ // Update lastX
+ self.lastX = self.x;
}
- // Animate frames
- self.animateFrames();
- // Update lastX
- self.lastX = self.x;
};
self.searchForCakeInEmptyMode = function () {
// Chercher une nouvelle cible si le cooldown est terminé ou si la cible actuelle est invalide
if (self.targetCooldown === 0 || !self.currentTarget || self.currentTarget.y > 2732 + self.currentTarget.height / 2) {
@@ -1059,9 +1086,9 @@
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
+ score.updateScore(currentScore);
autoClicker.cost = 100; // Reset auto clicker cost to initial value
autoClicker.autoClickerCount = 0; // Reset auto clicker count
autoClicker.updatePriceText(); // Update the price text to reflect the new cost
autoClicker.initStars(); // Update stars when the game is reset
@@ -1131,8 +1158,9 @@
var ThirdDwarfManager = Container.expand(function () {
var self = Container.call(this);
self.spawnDwarf = function (dwarfIndex) {
var dwarf = new Dwarf(dwarfIndex);
+ dwarf.miniGame = 2; // Définir que ce nain appartient au mini-jeu 2
dwarf.x = 2300 + dwarfIndex * 1024; // Position initiale décalée selon l'index
dwarf.y = 2732 - 180; // Base y position
dwarf.speedX = 5; // Vitesse fixe pour un mouvement uniforme
dwarf.state = 'full'; // Commencer en mode full
@@ -1512,8 +1540,9 @@
var bigCake;
var resetButton;
var switchButton;
var board;
+var thirdGameCakeMachine; // Variable globale pour la machine à gâteaux du troisième jeu
////////////////////////////////////////////////////////////////////////
////////////////////////// MINI GAME CODE /////////////////////////////
////////////////////////////////////////////////////////////////////////
var isMiniGameRunning = 0;
@@ -1818,8 +1847,13 @@
switchButtonThird.x = 1024;
switchButtonThird.y = switchButtonThird.height * 0.5;
switchButtonThird.scale.y = -1;
thirdGameForegroundContainer.addChild(switchButtonThird);
+ // Initialize thirdGameCakeMachine
+ thirdGameCakeMachine = new CakeMachine();
+ thirdGameMiddlegroundContainer.addChild(thirdGameCakeMachine);
+ thirdGameCakeMachine.x = 1024;
+ thirdGameCakeMachine.y = 1600;
// Create and start the ThirdDwarfManager
thirdDwarfManager = new ThirdDwarfManager();
thirdGameMiddlegroundContainer.addChild(thirdDwarfManager);
thirdDwarfManager.start();
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