Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 't.boundingBox.destroy is not a function' in or related to this line: 'if (cake.y > 2732 + cake.height / 2) {' Line Number: 443
User prompt
Please fix the bug: 'Timeout.tick error: LK.Rectangle is not a constructor' in or related to this line: 'cake.boundingBox = new LK.Rectangle(cake.x - cake.width / 2, cake.y - cake.height / 2, cake.width, cake.height);' Line Number: 408
User prompt
ajoute une bounding box aux gateaux produits par CakeRainMAnager
User prompt
ne met pas à jour le Nain si il est en train d'être écrasé
Code edit (1 edits merged)
Please save this source code
User prompt
stocke si on est en mode mini-jeu. au chargement si le stockage indique que le joueur était en mini-jeu; bascule en mini-jeu automatiquement après 1sec ↪💡 Consider importing and using the following plugins: @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
User prompt
après avoir arrété le gateau fait le disparaitre en 300ms transparence ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (4 edits merged)
Please save this source code
User prompt
quand un nain est écrasé, arrête le mouvement du gateau qui l'écrase
Code edit (1 edits merged)
Please save this source code
User prompt
ne déclenche pas l'anim squashAnimation si elle est déjà en cours
Code edit (2 edits merged)
Please save this source code
User prompt
extrait l'anim Squash dans une fonction à part de Dwarf
Code edit (1 edits merged)
Please save this source code
User prompt
Squash anim should be to scaleY:0 and then dwarf should be moved to x=-310, restore its scaleY to 1
User prompt
Dans Dwarf, utilise anchorY: 0
User prompt
Maintenant fait que quand un gateau (non miniCake) touche un Nain empty, le Nain est écrasé (animation scaleY)
Code edit (1 edits merged)
Please save this source code
User prompt
analyse pourquoi le nain n'est plus visible et/ou ne bouge plus quand il repasse de full à empty
Code edit (1 edits merged)
Please save this source code
User prompt
quand le Nain arrive à x=-300 bascule son mode de full à empty
Code edit (2 edits merged)
Please save this source code
User prompt
augmente la vitesse du nain à 10 quand il passe en mode full
===================================================================
--- original.js
+++ change.js
@@ -455,10 +455,14 @@
}
});
};
});
-var Dwarf = Container.expand(function () {
+var Dwarf = Container.expand(function (dwarfIndex) {
var self = Container.call(this);
+ // Stocker l'index du nain
+ self.dwarfIndex = dwarfIndex || 0;
+ // 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', {
anchorX: 0.5,
anchorY: 0.5
@@ -502,10 +506,41 @@
self.update = function () {
if (!isMiniGameRunning) {
return;
} // Only update if the mini-game is active
+ // Debug logs pour suivre l'état du nain
+ if (self.x <= -290 && self.x >= -310 && self.state === 'full') {
+ console.log("Nain approche de -300:", {
+ x: self.x,
+ y: self.y,
+ state: self.state,
+ speedX: self.speedX,
+ lastX: self.lastX,
+ visible: {
+ emptyFrame1: dwarfEmptyFrame1.visible,
+ emptyFrame2: dwarfEmptyFrame2.visible,
+ fullFrame1: dwarfFullFrame1.visible,
+ fullFrame2: dwarfFullFrame2.visible
+ }
+ });
+ }
// Check if the dwarf reaches x = -300 and switch mode from full to empty
- if (self.lastX > -300 && self.x <= -300 && self.state === 'full') {
+ if (self.x <= -300 && self.state === 'full') {
+ console.log("TRANSITION: Nain passe de full à empty", {
+ avant: {
+ x: self.x,
+ y: self.y,
+ state: self.state,
+ speedX: self.speedX,
+ lastX: self.lastX,
+ visible: {
+ emptyFrame1: dwarfEmptyFrame1.visible,
+ emptyFrame2: dwarfEmptyFrame2.visible,
+ fullFrame1: dwarfFullFrame1.visible,
+ fullFrame2: dwarfFullFrame2.visible
+ }
+ }
+ });
self.state = 'empty';
self.x = 2348;
self.y = 2732 - 180; // Réinitialiser la position Y
dwarfEmptyFrame1.visible = true;
@@ -514,8 +549,23 @@
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
+ console.log("TRANSITION: Nain après changement", {
+ après: {
+ x: self.x,
+ y: self.y,
+ state: self.state,
+ speedX: self.speedX,
+ lastX: self.lastX,
+ visible: {
+ emptyFrame1: dwarfEmptyFrame1.visible,
+ emptyFrame2: dwarfEmptyFrame2.visible,
+ fullFrame1: dwarfFullFrame1.visible,
+ fullFrame2: dwarfFullFrame2.visible
+ }
+ }
+ });
}
// Decrement cooldown if active
if (self.targetCooldown > 0) {
self.targetCooldown--;
@@ -581,8 +631,28 @@
miniCake.destroy();
miniGameMiniCakes.splice(index, 1);
}
});
+ // Check for intersection with non-miniCakes
+ miniGameCurrentCakes.forEach(function (cake, index) {
+ if (self.intersects(cake) && self.state === 'empty') {
+ // Squash animation
+ tween(self.currentFrame, {
+ scaleY: 0.5
+ }, {
+ duration: 200,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ tween(self.currentFrame, {
+ scaleY: 1
+ }, {
+ duration: 200,
+ easing: tween.easeInOut
+ });
+ }
+ });
+ }
+ });
// Animate frames
self.animateFrames();
// Update lastX
self.lastX = self.x;
@@ -633,21 +703,89 @@
});
}
};
self.findClosestFallingCake = function () {
- // Browse miniGameCurrentCakes
+ // Vérifier si le gâteau actuellement ciblé existe toujours
+ if (self.targetCakeIndex !== -1) {
+ // Parcourir le tableau pour trouver si le gâteau avec cet index existe encore
+ var cakeStillExists = false;
+ for (var i = 0; i < miniGameCurrentCakes.length; i++) {
+ if (miniGameCurrentCakes[i].cakeIndex === self.targetCakeIndex) {
+ cakeStillExists = true;
+ return miniGameCurrentCakes[i]; // Continuer à cibler le même gâteau
+ }
+ }
+ if (!cakeStillExists) {
+ self.targetCakeIndex = -1; // Le gâteau n'existe plus, réinitialiser la cible
+ }
+ }
+ // Chercher un nouveau gâteau à cibler
+ var availableCakeIndices = [];
+ // Parcourir tous les gâteaux disponibles
+ for (var i = 0; i < miniGameCurrentCakes.length; i++) {
+ var cake = miniGameCurrentCakes[i];
+ // Si le gâteau n'a pas d'index, lui en attribuer un
+ if (cake.cakeIndex === undefined) {
+ 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;
+ for (var j = 0; j < miniGameDwarfs.length; j++) {
+ // Ne pas vérifier le nain actuel
+ if (miniGameDwarfs[j].dwarfIndex !== self.dwarfIndex && miniGameDwarfs[j].targetCakeIndex === cake.cakeIndex) {
+ isTargeted = true;
+ break;
+ }
+ }
+ // Si le gâteau n'est pas ciblé, l'ajouter aux gâteaux disponibles
+ if (!isTargeted) {
+ availableCakeIndices.push(i); // Stocker l'index dans le tableau miniGameCurrentCakes
+ }
+ }
+ // S'il y a des gâteaux disponibles, en choisir un
+ 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;
+ }
+ }
+ if (closestCakeIndex !== -1) {
+ var selectedCake = miniGameCurrentCakes[closestCakeIndex];
+ self.targetCakeIndex = selectedCake.cakeIndex;
+ return selectedCake;
+ }
+ }
+ // 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
var closestCake = null;
var minDistance = Infinity;
miniGameCurrentCakes.forEach(function (cake) {
- // Calcul de la distance euclidienne (distance réelle) entre le nain et le gâteau
var dx = self.x - cake.x;
var dy = self.y - cake.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < minDistance) {
minDistance = distance;
closestCake = cake;
}
});
+ if (closestCake) {
+ // Si le gâteau n'a pas d'index, lui en attribuer un
+ if (closestCake.cakeIndex === undefined) {
+ closestCake.cakeIndex = Math.floor(Math.random() * 10000);
+ }
+ self.targetCakeIndex = closestCake.cakeIndex;
+ } else {
+ self.targetCakeIndex = -1;
+ }
return closestCake;
};
self.findClosestMiniCake = function () {
var closestMiniCake = null;
@@ -1230,9 +1368,10 @@
var miniGameForegroundContainer;
var miniGamebackground;
var switchButtonMini;
var chef;
-var dwarfs = [];
+var miniGameDwarfs = []; // Variable globale pour stocker les nains
+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) {
@@ -1392,13 +1531,17 @@
switchButtonMini.y = switchButtonMini.height * 0.5;
switchButtonMini.scale.y = -1;
miniGameForegroundContainer.addChild(switchButtonMini);
// Dwarfs
- var dwarf1 = new Dwarf();
- dwarf1.x = 2048 + 300;
- dwarf1.y = 2732 - 180;
- miniGameMiddlegroundContainer.addChild(dwarf1);
- dwarfs.push(dwarf1);
+ miniGameDwarfs = []; // Réinitialiser le tableau des nains
+ for (var i = 0; i < miniGameDwarfCount; i++) {
+ var dwarf = new Dwarf(i);
+ // Répartir les nains sur toute la largeur de l'écran
+ dwarf.x = 500 + Math.floor((2048 - 1000) * (i / (miniGameDwarfCount - 1 || 1)));
+ dwarf.y = 2732 - 180;
+ miniGameMiddlegroundContainer.addChild(dwarf);
+ miniGameDwarfs.push(dwarf);
+ }
var cakeRainManager = new CakeRainManager();
miniGameMiddlegroundContainer.addChild(cakeRainManager);
cakeRainManager.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