Code edit (16 edits merged)
Please save this source code
User prompt
permet la deÌcoupe des gateaux 'confetti' dans le jeu principal sans alteÌrer le mini-jeu. Reprend les memes eÌleÌments : - ajouter un CutEffect - creÌeÌer 2 minicakes
User prompt
permet la deÌcoupe des gateaux 'confetti' dans le jeu principal sans alteÌrer le mini-jeu
User prompt
Change le nombre de nains aÌ 20
User prompt
Joue le son youpi quand un nain attrape un minicake
User prompt
Le squashingSound doit eÌtre joueÌ deÌs le deÌbut du squashing anim, pas aÌ la fin
User prompt
Joue cut sound quand un gaÌteau est coupeÌ en miniCakes
User prompt
Joue squashing sound quand un nain se fait eÌcraser
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
dans performImpatienceAnimation, change aleÌatoirement la direction du Nain (scaleX) aÌ 1 ou -1
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'performImpatienceAnimation')' in or related to this line: 'self.performImpatienceAnimation = function () {' Line Number: 1678
User prompt
ajoute une petite animation d'impatience (de petits sauts rapide) au Nain quand il est arriveÌ au x de son gateau cible et qu'il attend. creÌe une fonction deÌdieÌe dans la classe. n'utilise pas le jumpPlayed qui est pour autre chose.
User prompt
l'animation de saut doit etre faite en boucle apreÌs que le Nain ai trouveÌ sa cible et qu'il est arriveÌ aÌ proximiteÌ du x du gateau
Code edit (15 edits merged)
Please save this source code
User prompt
ajoute une petite animation de petits sauts au Nain quand il est arriveÌ au x de son gateau cible et qu'il attend. creÌe une fonction deÌdieÌe dans la classe
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
il semblerait que le x ne soit pas pris en compte pour la detection de l'ecrasement des nains : apreÌs eÌtre eÌcraseÌ 1 fois ils sont eÌcraseÌs meme si ils ne touchent pas de gateau : corrige cela
Code edit (1 edits merged)
Please save this source code
User prompt
pour lintersection de l'eÌcrasement utilise boundingBox au lieu du gateau entier
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: cake.getChildByName is not a function' in or related to this line: 'var boundingBox = cake.getChildByName('boundingBox');' Line Number: 683
User prompt
Please fix the bug: 'TypeError: cake.getChildByName is not a function' in or related to this line: 'if (self.intersects(cake.getChildByName('boundingBox')) && self.state === 'empty') {' Line Number: 683
===================================================================
--- original.js
+++ change.js
@@ -352,10 +352,10 @@
var cake = self.attachAsset('cake_' + cakeIndex, {
anchorX: 0.5,
anchorY: 0.5
});
- cake.scaleX = 1.0;
- cake.scaleY = 1.0;
+ cake.scaleX = 1.2;
+ cake.scaleY = 1.2;
cake.x = Math.random() * 2048;
cake.y = -cake.height / 2;
cake.speedY = 5 + Math.random() * 5;
cake.assetId = 'cake_' + cakeIndex; // Store asset ID for mini cakes
@@ -371,13 +371,18 @@
miniCake2.y = cake.y;
miniGameMiniCakes.push(miniCake1, miniCake2);
miniGameMiddlegroundContainer.addChild(miniCake1);
miniGameMiddlegroundContainer.addChild(miniCake2);
+ var index = miniGameCurrentCakes.indexOf(cake);
+ if (index !== -1) {
+ miniGameCurrentCakes.splice(index, 1);
+ }
cake.destroy();
});
var boundingBox = self.attachAsset('boundingBox', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ alpha: 0
});
cake.borderBox = boundingBox;
cake.addChild(boundingBox);
self.cakes.push(cake);
@@ -399,9 +404,9 @@
}
}
};
self.start = function () {
- LK.setInterval(self.spawnCake, 2000);
+ LK.setInterval(self.spawnCake, 1000);
};
});
var Confetti = Container.expand(function (cakeIndex) {
var self = Container.call(this);
@@ -505,9 +510,9 @@
self.speedX = 7;
self.targetX = self.x;
self.lastX = self.x;
self.targetCooldown = 0; // Cooldown counter for changing targets
- self.maxTargetCooldown = 15; // RĂ©duit de 30 Ă 15 pour chercher des cibles plus souvent
+ self.maxTargetCooldown = 60; // 60 frames = 1 seconde Ă 60 FPS
self.idleTime = 0; // Compteur pour le temps d'inactivité
self.maxIdleTime = 30; // Temps maximum d'inactivité avant de chercher activement une cible
// Update function for movement and animation
self.update = function () {
@@ -628,28 +633,16 @@
}
});
// Check for intersection with non-miniCakes
if (self.state === 'empty' && !self.isSquashing) {
- // Vérifier d'abord s'il y a réellement des gùteaux
- if (miniGameCurrentCakes.length > 0) {
- miniGameCurrentCakes.forEach(function (cake, index) {
- // VĂ©rifier que le gĂąteau existe, qu'il est dans une position valide,
- // et que le nain n'est pas trop prĂšs du bord droit (oĂč il vient d'ĂȘtre repositionnĂ©)
- if (cake && cake.y < 2600 && self.x < 2000) {
- // Utiliser notre méthode d'intersection personnalisée
- if (self.intersects(cake.borderBox)) {
- console.log("Intersection détectée avec gùteau:", {
- nainX: self.x,
- nainY: self.y,
- cakeX: cake.x,
- cakeY: cake.y
- });
- self.squashAnimation(cake);
- return;
- }
- }
- });
- }
+ 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
@@ -657,8 +650,11 @@
};
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) {
+ if (self.currentTarget && Math.abs(self.x - self.currentTarget.x) < 5) {
+ self.jumpAnimation(); // Trigger jump animation when close to target cake
+ }
self.currentTarget = self.findClosestMiniCake() || self.findClosestFallingCake();
if (self.currentTarget) {
self.targetCooldown = self.maxTargetCooldown; // Reset cooldown
self.targetX = self.currentTarget.x;
@@ -726,44 +722,64 @@
cake.cakeIndex = Math.floor(Math.random() * 10000); // Générer un index unique
}
// Vérifier si ce gùteau est déjà ciblé par un autre nain
var isTargeted = false;
+ var isTooCrowded = false;
for (var j = 0; j < miniGameDwarfs.length; j++) {
+ var otherDwarf = miniGameDwarfs[j];
// Ne pas vérifier le nain actuel
- if (miniGameDwarfs[j].dwarfIndex !== self.dwarfIndex && miniGameDwarfs[j].targetCakeIndex === cake.cakeIndex) {
- isTargeted = true;
- break;
+ if (otherDwarf.dwarfIndex !== self.dwarfIndex) {
+ // Vérifier si le gùteau est déjà ciblé
+ if (otherDwarf.targetCakeIndex === cake.cakeIndex) {
+ isTargeted = true;
+ break;
+ }
+ // Vérifier si un autre nain est déjà trop proche de ce gùteau
+ if (otherDwarf.targetCakeIndex !== -1 && Math.abs(otherDwarf.x - cake.x) < 300) {
+ isTooCrowded = true;
+ break;
+ }
}
}
- // Si le gùteau n'est pas ciblé, l'ajouter aux gùteaux disponibles
- if (!isTargeted) {
+ // Si le gùteau n'est pas ciblé et n'est pas trop proche d'un autre nain, l'ajouter aux gùteaux disponibles
+ if (!isTargeted && !isTooCrowded) {
availableCakeIndices.push(i); // Stocker l'index dans le tableau miniGameCurrentCakes
}
}
- // S'il y a des gĂąteaux disponibles, en choisir un
+ // S'il y a des gĂąteaux disponibles, en choisir un AU HASARD
if (availableCakeIndices.length > 0) {
- // Trouver le gĂąteau le plus proche parmi les disponibles
- var closestCakeIndex = -1;
- var minDistance = Infinity;
- for (var k = 0; k < availableCakeIndices.length; k++) {
- var cakeIndex = availableCakeIndices[k];
- var availableCake = miniGameCurrentCakes[cakeIndex];
- var dx = self.x - availableCake.x;
- var dy = self.y - availableCake.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance < minDistance) {
- minDistance = distance;
- closestCakeIndex = cakeIndex;
+ // SĂ©lectionner un gĂąteau au hasard parmi les disponibles
+ var randomIndex = Math.floor(Math.random() * availableCakeIndices.length);
+ var selectedCakeIndex = availableCakeIndices[randomIndex];
+ var selectedCake = miniGameCurrentCakes[selectedCakeIndex];
+ self.targetCakeIndex = selectedCake.cakeIndex;
+ return selectedCake;
+ }
+ // Si tous les gùteaux sont déjà ciblés ou trop proches d'autres nains,
+ // essayer de trouver un gĂąteau qui n'est pas ciblĂ©, mĂȘme s'il est proche d'un autre nain
+ availableCakeIndices = [];
+ for (var i = 0; i < miniGameCurrentCakes.length; i++) {
+ var cake = miniGameCurrentCakes[i];
+ var isTargeted = false;
+ for (var j = 0; j < miniGameDwarfs.length; j++) {
+ if (miniGameDwarfs[j].dwarfIndex !== self.dwarfIndex && miniGameDwarfs[j].targetCakeIndex === cake.cakeIndex) {
+ isTargeted = true;
+ break;
}
}
- if (closestCakeIndex !== -1) {
- var selectedCake = miniGameCurrentCakes[closestCakeIndex];
- self.targetCakeIndex = selectedCake.cakeIndex;
- return selectedCake;
+ if (!isTargeted) {
+ availableCakeIndices.push(i);
}
}
- // Si tous les gùteaux sont déjà ciblés ou s'il n'y a pas de gùteau disponible,
- // choisir le plus proche
+ // S'il y a des gùteaux non ciblés, en choisir un au hasard
+ if (availableCakeIndices.length > 0) {
+ var randomIndex = Math.floor(Math.random() * availableCakeIndices.length);
+ var selectedCakeIndex = availableCakeIndices[randomIndex];
+ var selectedCake = miniGameCurrentCakes[selectedCakeIndex];
+ self.targetCakeIndex = selectedCake.cakeIndex;
+ return selectedCake;
+ }
+ // Si tous les gùteaux sont déjà ciblés, choisir le plus proche
var closestCake = null;
var minDistance = Infinity;
miniGameCurrentCakes.forEach(function (cake) {
var dx = self.x - cake.x;
@@ -804,9 +820,9 @@
return closestMiniCake;
};
// Function to alternate frames for animation
self.animateFrames = function () {
- if (self.x !== self.lastX) {
+ if (self.x !== self.lastX && !self.isSquashing) {
self.animationCounter++;
if (self.animationCounter >= self.animationDelay) {
if (self.state === 'full') {
if (dwarfFullFrame1.visible) {
@@ -831,75 +847,60 @@
self.currentFrame = dwarfFullFrame1.visible ? dwarfFullFrame1 : dwarfFullFrame2.visible ? dwarfFullFrame2 : dwarfEmptyFrame1.visible ? dwarfEmptyFrame1 : dwarfEmptyFrame2;
self.currentFrame.scaleX = self.speedX ? Math.sign(self.speedX) : 1;
};
self.squashAnimation = function (cake) {
- // Vérifier que l'animation n'est pas déjà en cours et qu'un gùteau valide est fourni
- if (self.isSquashing || !cake) {
+ if (self.isSquashing) {
return;
- }
+ } // Prevent re-triggering if already squashing
self.isSquashing = true; // Set flag to indicate squash is in progress
tween(self.currentFrame, {
scaleY: 0
}, {
duration: 400,
easing: tween.easeInOut,
onFinish: function onFinish() {
- // Repositionner le nain à droite de l'écran avec une position aléatoire
+ // Repositionner le nain Ă droite de l'Ă©cran
self.x = 2300 + Math.floor(Math.random() * 100);
- // RĂ©initialiser l'Ă©tat du nain
- self.state = 'empty';
- self.targetCakeIndex = -1;
- self.targetCooldown = 0;
- self.speedX = 7;
- // RĂ©initialiser les frames d'animation
- dwarfFullFrame1.visible = false;
- dwarfFullFrame2.visible = false;
- dwarfEmptyFrame1.visible = true;
- dwarfEmptyFrame2.visible = false;
// ArrĂȘter et faire disparaĂźtre le gĂąteau
- if (cake && typeof cake.destroy === 'function') {
- cake.speedY = 0;
- tween(cake, {
- alpha: 0
- }, {
- duration: 600,
- easing: tween.easeOut,
- onFinish: function onFinish() {
- // Vérifier à nouveau que le gùteau existe toujours avant de le détruire
- if (cake && typeof cake.destroy === 'function') {
- cake.destroy(); // Remove the cake after it fades out
- }
- }
- });
- }
- // RĂ©initialiser l'Ă©chelle du nain
- tween(self.currentFrame, {
- scaleY: 1
+ cake.speedY = 0;
+ tween(cake, {
+ alpha: 0
}, {
- duration: 200,
- easing: tween.easeInOut,
+ duration: 600,
+ easing: tween.easeOut,
onFinish: function onFinish() {
- // Réinitialiser le flag d'écrasement seulement aprÚs que l'animation soit complÚtement terminée
- self.isSquashing = false;
+ var index = miniGameCurrentCakes.indexOf(cake);
+ if (index !== -1) {
+ miniGameCurrentCakes.splice(index, 1);
+ }
+ cake.destroy(); // Remove the cake after it fades out
+ // RĂ©initialiser l'Ă©tat du nain
+ self.state = 'empty';
+ self.targetCakeIndex = -1;
+ self.targetCooldown = 0;
+ self.animationCounter = 0;
+ self.speedX = 7;
+ // RĂ©initialiser les frames d'animation
+ dwarfFullFrame1.visible = false;
+ dwarfFullFrame2.visible = false;
+ dwarfEmptyFrame1.visible = true;
+ dwarfEmptyFrame2.visible = false;
+ // RĂ©initialiser l'Ă©chelle du nain
+ tween(self.currentFrame, {
+ scaleY: 1
+ }, {
+ duration: 10,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ // Réinitialiser le flag d'écrasement seulement aprÚs que l'animation soit complÚtement terminée
+ self.isSquashing = false;
+ }
+ });
}
});
}
});
};
- self.intersects = function (obj) {
- // Calculer les limites du nain
- var nainLeft = self.x - 40; // Approximation de la largeur/2
- var nainRight = self.x + 40;
- var nainTop = self.y - 80; // Approximation de la hauteur/2
- var nainBottom = self.y + 80;
- // Calculer les limites de l'objet
- var objLeft = obj.x - obj.width / 2;
- var objRight = obj.x + obj.width / 2;
- var objTop = obj.y - obj.height / 2;
- var objBottom = obj.y + obj.height / 2;
- // VĂ©rifier si les rectangles se chevauchent
- return nainLeft < objRight && nainRight > objLeft && nainTop < objBottom && nainBottom > objTop;
- };
});
var MiniCake = Container.expand(function (originalCake) {
var self = Container.call(this);
var miniCakeGraphics = self.attachAsset(originalCake.assetId, {
@@ -1435,9 +1436,9 @@
var miniGamebackground;
var switchButtonMini;
var chef;
var miniGameDwarfs = []; // Variable globale pour stocker les nains
-var miniGameDwarfCount = 1; //3; // Nombre de nains à créer
+var miniGameDwarfCount = 3; // Nombre de nains à créer
var miniGameCurrentCakes = []; // Global array to store falling cakes
var miniGameMiniCakes = []; // Global array to track mini cakes
function toggleMiniGame() {
if (isMiniGameRunning) {
@@ -1620,5 +1621,27 @@
cakeRainManager.start();
}
// Call the function to initialize game variables
initializeGameVariables();
-initializeminiGameVariables();
\ No newline at end of file
+initializeminiGameVariables();
+self.jumpAnimation = function () {
+ if (!self.jumpPlayed) {
+ var baseY = self.y;
+ tween(self, {
+ y: baseY - 50
+ }, {
+ duration: 200,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ y: baseY
+ }, {
+ duration: 200,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ self.jumpPlayed = true; // Mark the jump animation as played
+ }
+ });
+ }
+ });
+ }
+};
\ 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