User prompt
Ajoute une fonctionnaliteĢ qui compte le nombre de Dauphins que le joueur a eĢleveĢ depuis ses deĢbuts dans le jeu, A chaque nouveau dauphins eĢlever (lors d'une nouvelle partie, ou un dauphin acheter), Le compteur de dauphins eĢlever monte de 1 a chaque dauphin eĢlever, Le nombre de dauphins eĢlever est persistant d'une partie a une autre, Et est afficheĢ a l'ui du joueur āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Fait en sorte que le joueur garde ses dauphins d'une partie a une autre āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Je veux personnaliseĢ le fond du jeu avec mon propre asset
User prompt
Ajoute ces expressions pour les dauphins : * Expressions / EĢtats : Heureux (cÅurs flottants, eĢtincelles), AffameĢ (bulle de penseĢe avec un poisson), Neutre, Triste (si neĢgligeĢ). āŖš” Consider importing and using the following plugins: @upit/tween.v1
User prompt
Ajoute 54 nouvelles questions au quizz
User prompt
Fait en sorte que le joueur puisse gagner de la dauphibouffe en reĢpondant correctement aux quizz, ou aĢ chaque fois qu'il caresse un dauphin (le joueur gagne 5 dauphibouffe a chaque fois qu'il caresse un dauphin, et aleĢatoirement entre 10 et 30 dauphibouffe a chaque quizz reĢpondue correctement), ajoute un boutton rose a texte blanc "nourrir" sous chaque dauphin du joueur, ou le joueur, en appuyant dessus peut nourir son dauphin āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Toute la progression du joueur (les noms de ses dauphins, leurs niveaux,leurs cerceaux posseĢdes ) doivent eĢtre sauvegardeĢe de manieĢre persistante dans le storage āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Au pire fait en sorte que les noms geĢneĢrique de dauphins soient aleĢatoires entre une base de donneĢes de 80 noms de dauphins diffeĢrents (pas de flipper , des noms originaux stp) āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Tu comprends donc rien, je te demande de faire en sorte que quand le joueur choisis le nom de son dauphin, le nom personnaliseĢ de son dauphin reste le nom personnaliseĢ de son dauphin, Meme si le joueur rejoue plus tard, ça doit eĢtre sauvegardeĢe avec le storage, et ne plus affiche de nom geĢneĢrique ou flipper etc...NON juste le nom personnaliseĢ choisis par le joueur āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Tu comprends donc rien, je te demande de faire en sorte que quand le joueur choisis le nom de son dauphin, le nom personnaliseĢ de son dauphin reste le nom personnaliseĢ de son dauphin, Meme si le joueur rejoue plus tard, ça doit eĢtre sauvegardeĢe avec le storage, et ne plus affiche de nom geĢneĢrique ou flipper etc...NON juste le nom personnaliseĢ choisis par le joueur āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Au pire au lieu d'un nom geĢneĢrique de dauphins, fait en sorte que le nom du dauphin soit de façon permanente le nom choisis par le joueur ! āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Mais faut que le nouveau nom du dauphin soit sauvegarder de façon persistante deĢs que le joueur change le nom du dauphin !!!! Et que ça soit sauvegarder localement āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Mais faut que le nouveau nom du dauphin soit sauvegarder de façon persistante deĢs que le joueur change le nom du dauphin !!!! Et que ça soit sauvegarder localement āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Mais faut que le nouveau nom du dauphin soit sauvegarder de façon persistante deĢs que le joueur change le nom du dauphin !!!! āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Fait en sorte que au lieu du nom flipper, il y est le nom personnaliseĢ du dauphin qui soit sauvegarder de façon persistante si le joueur la preĢceĢdemment changer, et ça pour chaque dauphin que posseĢde le joueur āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Fait en sorte que au lieu du nom flipper, il y est le nom personnaliseĢ du dauphin qui soit sauvegarder de façon persistante si le joueur la preĢceĢdemment changer, et ça pour chaque dauphin que posseĢde le joueur āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Fait en sorte que les noms des dauphins, les dauphins posseĢder par le joueur, leurs cerceaux posseĢder et leur niveau soit sauvegarder (quand le joueur change le nom de son dauphin le nouveau nom doit eĢtre sauvegardeĢe de façon permanente et remplacer l'ancien) āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Fait en sorte que les noms des dauphins, les dauphins posseĢder par le joueur, leurs cerceaux posseĢder et leur niveau soit sauvegarder (quand le joueur change le nom de son dauphin le nouveau nom doit eĢtre sauvegardeĢe de façon permanente et remplacer l'ancien) āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Fait en sorte que les noms des dauphins, les dauphins posseĢder par le joueur, leurs cerceaux posseĢder et leur niveau soit sauvegarder (et que quand le joueur change le nom de son dauphin, le nouveau nom soit sauvegarder de manieĢre permanente) āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Fait en sorte que les noms des dauphins, les dauphins posseĢder par le joueur, leurs cerceaux posseĢder et leur niveau soit sauvegarder āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Fait en sorte que les noms des dauphins, les dauphins posseĢder par le joueur, leurs cerceaux posseĢder et leur niveau soit sauvegarder āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toGlobal')' in or related to this line: 'var localPos = self.toLocal(obj.parent.toGlobal(obj.position));' Line Number: 240
User prompt
CorrigeĢ les problemes
User prompt
Ajoute la fonctionnaliteĢ qui permet au joueur de caresser ses dauphins (3 Dauphicoins par caresse et une caresse par dauphin toutes les minutes seulement) avec un bouton violet a texte blanc "caresser" sous chaque dauphin du joueur Par la meĢme occasion, fait en sorte que la progression du joueur et de ses dauphins (Nombre de Dauphicoins, dauphibouffe, cerceaux acheteĢs et posseĢder par les dauphins, niveaux des dauphins , noms des Dauphins) Soient sauvegardes ! āŖš” Consider importing and using the following plugins: @upit/storage.v1
User prompt
CorrigeĢ les probleĢmes
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Coral = Container.expand(function (type, x, y) { var self = Container.call(this); var coralTypes = ['coral1', 'coral2', 'coral3']; var coralAsset = coralTypes[type % 3]; var coral = self.attachAsset(coralAsset, { anchorX: 0.5, anchorY: 1 }); self.x = x || 0; self.y = y || 0; self.update = function () { // Gentle swaying animation coral.rotation = Math.sin(Date.now() * 0.0008) * 0.1; }; return self; }); var Dolphin = Container.expand(function (name, x, y) { var self = Container.call(this); // Dolphin properties self.dolphinName = name || 'Flipper'; self.happiness = Math.floor(Math.random() * 50) + 25; self.level = 1; self.lastPetTime = 0; self.petCooldown = 60000; // 1 minute self.maxHappiness = 100; self.ownedHoops = []; // Track owned hoops self.hoopIcons = []; // Visual representations of owned hoops // Graphics var dolphinBody = self.attachAsset('dolphin', { anchorX: 0.5, anchorY: 0.5 }); // Happiness bar background var happinessBarBg = self.attachAsset('happinessBarBg', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -80 }); // Happiness bar var happinessBar = self.attachAsset('happinessBar', { anchorX: 0, anchorY: 0.5, x: -80, y: -80 }); // Cooldown bar background var cooldownBarBg = self.attachAsset('cooldownBarBg', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -55 }); // Cooldown bar var cooldownBar = self.attachAsset('cooldownBar', { anchorX: 0, anchorY: 0.5, x: -80, y: -55 }); // Name text var nameText = new Text2(self.dolphinName, { size: 36, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.x = 0; nameText.y = -120; self.addChild(nameText); // Store reference for external access self.nameText = nameText; // Pet button var petButton = self.attachAsset('petButton', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 80 }); var petButtonText = new Text2('Caresser', { size: 28, fill: 0xFFFFFF }); petButtonText.anchor.set(0.5, 0.5); petButtonText.x = 0; petButtonText.y = 80; self.addChild(petButtonText); // Level text var levelText = new Text2('Niv.' + self.level, { size: 28, fill: 0xFFEB3B }); levelText.anchor.set(0.5, 0.5); levelText.x = 0; levelText.y = -100; self.addChild(levelText); // Store reference for external access self.levelText = levelText; self.updateHappinessBar = function () { var percentage = self.happiness / self.maxHappiness; happinessBar.scaleX = percentage; if (self.happiness >= self.maxHappiness) { self.levelUp(); } }; self.updateCooldownBar = function () { var now = Date.now(); var timeSinceLastPet = now - self.lastPetTime; var cooldownRemaining = Math.max(0, self.petCooldown - timeSinceLastPet); var percentage = cooldownRemaining / self.petCooldown; cooldownBar.scaleX = percentage; cooldownBar.visible = percentage > 0; cooldownBarBg.visible = percentage > 0; }; self.addHoopIcon = function (hoopType) { // Add hoop type to owned hoops self.ownedHoops.push(hoopType); // Create small hoop icon var hoopAssetNames = ['hoop', 'hoopCute', 'hoopTricolore', 'hoopEnflamme', 'hoopOcean']; var hoopIcon = self.attachAsset(hoopAssetNames[hoopType] || 'hoop', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.3, scaleY: 0.3 }); // Position icon next to dolphin var iconIndex = self.hoopIcons.length; hoopIcon.x = 120 + iconIndex * 40; hoopIcon.y = 0; self.hoopIcons.push(hoopIcon); // Save hoop progression immediately updateUI(); }; self.canPet = function () { var now = Date.now(); return now - self.lastPetTime >= self.petCooldown; }; self.pet = function () { if (!self.canPet()) return false; self.lastPetTime = Date.now(); self.happiness = Math.min(self.happiness + 10, self.maxHappiness); dauphicoins += 3; // Pet animation tween(dolphinBody, { scaleX: 1.2, scaleY: 1.2 }, { duration: 200, easing: tween.easeOut }); tween(dolphinBody, { scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.easeIn }); LK.getSound('pet').play(); LK.getSound('coin').play(); self.updateHappinessBar(); updateUI(); return true; }; self.feed = function () { if (dauphibouffe <= 0) return false; dauphibouffe--; self.happiness = Math.min(self.happiness + 20, self.maxHappiness); // Feed animation tween(dolphinBody, { tint: 0x8bc34a }, { duration: 300 }); tween(dolphinBody, { tint: 0x4fa8d8 }, { duration: 300 }); self.updateHappinessBar(); updateUI(); return true; }; self.levelUp = function () { self.level++; self.happiness = 0; self.maxHappiness += 10; trainerXP += 10; // Level up animation LK.effects.flashObject(self, 0xffeb3b, 1000); LK.getSound('levelup').play(); self.levelText.setText('Niv.' + self.level); self.updateHappinessBar(); updateUI(); // Check trainer level up var newTrainerLevel = Math.floor(trainerXP / 50) + 1; if (newTrainerLevel > trainerLevel) { trainerLevel = newTrainerLevel; updateUI(); } }; self.down = function (x, y, obj) { var localPos; if (obj && obj.parent && obj.parent.toGlobal) { localPos = self.toLocal(obj.parent.toGlobal(obj.position)); } else { localPos = { x: x, y: y }; } // Check if pet button was clicked if (localPos.x >= -80 && localPos.x <= 80 && localPos.y >= 50 && localPos.y <= 110) { if (self.canPet()) { self.pet(); } } else { // Original dolphin body click behavior if (self.canPet()) { self.pet(); } else { // Show feed option if has food if (dauphibouffe > 0) { self.feed(); } } } }; self.update = function () { self.updateCooldownBar(); // Gentle floating animation dolphinBody.y = Math.sin(Date.now() * 0.001) * 10; }; // Position dolphin self.x = x || 0; self.y = y || 0; // Initialize bars self.updateHappinessBar(); self.updateCooldownBar(); return self; }); var Hoop = Container.expand(function (x, y) { var self = Container.call(this); var hoop = self.attachAsset('hoop', { anchorX: 0.5, anchorY: 0.5 }); // Make hoop hollow by reducing alpha in center hoop.alpha = 0.3; self.hoopType = 0; // Default to golden hoop self.attachedDolphin = null; self.x = x || 0; self.y = y || 0; self.update = function () { // Gentle rotation hoop.rotation += 0.01; // Apply color based on hoop type if (hoopTypes && hoopTypes[self.hoopType]) { hoop.tint = hoopTypes[self.hoopType].color; } // Follow attached dolphin if any if (self.attachedDolphin) { self.x = self.attachedDolphin.x; self.y = self.attachedDolphin.y - 50; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x0066cc }); /**** * Game Code ****/ // Game variables var dolphins = []; var corals = []; var hoops = []; var dauphicoins = storage.dauphicoins !== undefined ? storage.dauphicoins : 50; var dauphibouffe = storage.dauphibouffe !== undefined ? storage.dauphibouffe : 3; var trainerLevel = storage.trainerLevel !== undefined ? storage.trainerLevel : 1; var trainerXP = storage.trainerXP !== undefined ? storage.trainerXP : 0; // Database of 80 unique dolphin names var dolphinNames = ['Luna', 'Neptune', 'Océan', 'Azur', 'Coral', 'Marina', 'Aqua', 'Bleu', 'Splash', 'Bubble', 'Wave', 'Tide', 'Storm', 'Misty', 'Pearl', 'Crystal', 'Echo', 'Sonic', 'Melody', 'Harmony', 'Rhythm', 'Jazz', 'Blues', 'Tempo', 'Atlas', 'Zeus', 'Triton', 'Poseidon', 'Apollo', 'Orion', 'Cosmos', 'Nova', 'Star', 'Comet', 'Galaxy', 'Meteor', 'Stellar', 'Solar', 'Lunar', 'Cosmic', 'Aquarius', 'Pisces', 'Delphinus', 'Cetus', 'Orca', 'Narval', 'Beluga', 'Marlin', 'Spirit', 'Dream', 'Hope', 'Joy', 'Grace', 'Faith', 'Love', 'Peace', 'Thunder', 'Lightning', 'Rain', 'Frost', 'Snow', 'Ice', 'Wind', 'Breeze', 'Coral', 'Reef', 'Lagoon', 'Bay', 'Cove', 'Shore', 'Beach', 'Dune', 'Captain', 'Admiral', 'Sailor', 'Navigator', 'Explorer', 'Voyager', 'Pioneer', 'Ranger']; // Track used names to avoid duplicates - load from storage var usedNames = storage.usedNames || []; // Hoop types with their properties var hoopTypes = [{ name: 'Cerceau Doré', price: 50, color: 0xFFD700 }, { name: 'Cerceau Cute', price: 25, color: 0xFF69B4 }, { name: 'Cerceau Tricolore', price: 34, color: 0x0000FF }, { name: 'Cerceau Enflammé', price: 45, color: 0xFF4500 }, { name: 'Cerceau de l\'Océan', price: 50, color: 0x00CED1 }]; // UI elements var coinText, foodText, trainerText; var shopModal = null; var quizModal = null; var hoopSelectionModal = null; var dolphinSelectionModal = null; var namingModal = null; var keyboardModal = null; var selectedHoopType = null; var selectedDolphinForNaming = null; var currentInputText = ''; // Quiz questions var quizQuestions = [{ question: "Qu'utilisent les dauphins pour l'écholocation ?", answers: ["Ondes sonores", "Ondes lumineuses", "Champs magnétiques", "Champs électriques"], correct: 0 }, { question: "Combien de temps les dauphins peuvent-ils retenir leur respiration ?", answers: ["5 minutes", "15 minutes", "30 minutes", "1 heure"], correct: 1 }, { question: "Comment appelle-t-on un groupe de dauphins ?", answers: ["Banc", "Pod", "Troupeau", "Meute"], correct: 1 }, { question: "Comment les dauphins dorment-ils ?", answers: ["Complètement inconscients", "Une moitié du cerveau à la fois", "Ne dorment jamais", "Seulement la nuit"], correct: 1 }, { question: "Quelle est la plus grande espèce de dauphin ?", answers: ["Grand dauphin", "Orque", "Dauphin à long bec", "Dauphin sombre"], correct: 1 }]; function getRandomDolphinName() { // If all names are used, reset the used names array if (usedNames.length >= dolphinNames.length) { usedNames = []; } var availableNames = []; for (var i = 0; i < dolphinNames.length; i++) { var name = dolphinNames[i]; var nameUsed = false; for (var j = 0; j < usedNames.length; j++) { if (usedNames[j] === name) { nameUsed = true; break; } } if (!nameUsed) { availableNames.push(name); } } // Pick random name from available names var randomIndex = Math.floor(Math.random() * availableNames.length); var selectedName = availableNames[randomIndex]; // Mark this name as used usedNames.push(selectedName); return selectedName; } function updateUI() { if (coinText) coinText.setText('Dauphicoins: ' + dauphicoins); if (foodText) foodText.setText('Dauphibouffe: ' + dauphibouffe); if (trainerText) trainerText.setText('Dresseur Niv.' + trainerLevel + ' (' + trainerXP + ' XP)'); // Save to storage with error handling try { storage.dauphicoins = dauphicoins; storage.dauphibouffe = dauphibouffe; storage.trainerLevel = trainerLevel; storage.trainerXP = trainerXP; // Save complete dolphin progression data including names, levels, and owned hoops var dolphinData = []; for (var i = 0; i < dolphins.length; i++) { var dolphin = dolphins[i]; if (dolphin && dolphin.dolphinName) { dolphinData.push({ name: dolphin.dolphinName, happiness: dolphin.happiness, level: dolphin.level, maxHappiness: dolphin.maxHappiness, lastPetTime: dolphin.lastPetTime, ownedHoops: dolphin.ownedHoops || [], x: dolphin.x, y: dolphin.y, petCooldown: dolphin.petCooldown }); } } storage.dolphinData = dolphinData; // Save complete game progression storage.dolphinCount = dolphins.length; storage.usedNames = usedNames; } catch (e) { console.log('Storage error:', e); } } function createShopModal() { if (shopModal) return; shopModal = new Container(); var modalBg = shopModal.attachAsset('modalBg', { anchorX: 0.5, anchorY: 0.5, alpha: 0.9 }); var panel = shopModal.attachAsset('panel', { anchorX: 0.5, anchorY: 0.5 }); var titleText = new Text2('Boutique des Dauphins', { size: 70, fill: 0x000000 }); titleText.anchor.set(0.5, 0.5); titleText.x = 0; titleText.y = -320; shopModal.addChild(titleText); // New dolphin button var newDolphinBtn = shopModal.attachAsset('button', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -180, scaleX: 1.5, scaleY: 1.3 }); var dolphinBtnText = new Text2('Nouveau Dauphin (100 Dauphicoins)', { size: 36, fill: 0x000000 }); dolphinBtnText.anchor.set(0.5, 0.5); dolphinBtnText.x = 0; dolphinBtnText.y = -180; shopModal.addChild(dolphinBtnText); // Hoop buttons for each type for (var h = 0; h < hoopTypes.length; h++) { var hoopBtn = shopModal.attachAsset('button', { anchorX: 0.5, anchorY: 0.5, x: (h % 3 - 1) * 300, y: -60 + Math.floor(h / 3) * 140, scaleX: 1.4, scaleY: 1.2 }); var hoopBtnText = new Text2(hoopTypes[h].name + ' (' + hoopTypes[h].price + ' Dauphicoins)', { size: 32, fill: 0x000000 }); hoopBtnText.anchor.set(0.5, 0.5); hoopBtnText.x = (h % 3 - 1) * 300; hoopBtnText.y = -60 + Math.floor(h / 3) * 140; shopModal.addChild(hoopBtnText); } // Close button var closeBtn = shopModal.attachAsset('button', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 250, scaleX: 1.2, scaleY: 1.0 }); var closeBtnText = new Text2('Fermer', { size: 42, fill: 0x000000 }); closeBtnText.anchor.set(0.5, 0.5); closeBtnText.x = 0; closeBtnText.y = 250; shopModal.addChild(closeBtnText); shopModal.x = 1024; shopModal.y = 1366; shopModal.down = function (x, y, obj) { var localPos; if (obj.parent && obj.parent.toGlobal) { localPos = shopModal.toLocal(obj.parent.toGlobal(obj.position)); } else { localPos = { x: x, y: y }; } // Check new dolphin button if (localPos.x >= -150 && localPos.x <= 150 && localPos.y >= -220 && localPos.y <= -140) { if (dauphicoins >= 100) { dauphicoins -= 100; // Create unique random name for new dolphin var randomName = getRandomDolphinName(); var newDolphin = new Dolphin(randomName, 400 + dolphins.length % 3 * 300, 800 + Math.floor(dolphins.length / 3) * 300); dolphins.push(newDolphin); game.addChild(newDolphin); updateUI(); LK.getSound('coin').play(); } } // Check hoop buttons for (var h = 0; h < hoopTypes.length; h++) { var btnX = (h % 3 - 1) * 300; var btnY = -60 + Math.floor(h / 3) * 140; if (localPos.x >= btnX - 140 && localPos.x <= btnX + 140 && localPos.y >= btnY - 50 && localPos.y <= btnY + 50) { if (dauphicoins >= hoopTypes[h].price) { selectedHoopType = h; game.removeChild(shopModal); shopModal = null; createHoopSelectionModal(); } break; } } // Check close button if (localPos.x >= -120 && localPos.x <= 120 && localPos.y >= 210 && localPos.y <= 290) { game.removeChild(shopModal); shopModal = null; } }; game.addChild(shopModal); } function createHoopSelectionModal() { if (hoopSelectionModal || dolphins.length === 0) return; hoopSelectionModal = new Container(); var modalBg = hoopSelectionModal.attachAsset('modalBg', { anchorX: 0.5, anchorY: 0.5, alpha: 0.8 }); var panel = hoopSelectionModal.attachAsset('panel', { anchorX: 0.5, anchorY: 0.5 }); var titleText = new Text2('Choisir un Dauphin pour le Cerceau', { size: 50, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 0; titleText.y = -300; hoopSelectionModal.addChild(titleText); // Dolphin selection buttons for (var d = 0; d < dolphins.length; d++) { var dolphinBtn = hoopSelectionModal.attachAsset('button', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -200 + d * 80 }); var dolphinBtnText = new Text2(dolphins[d].dolphinName, { size: 36, fill: 0xFFFFFF }); dolphinBtnText.anchor.set(0.5, 0.5); dolphinBtnText.x = 0; dolphinBtnText.y = -200 + d * 80; hoopSelectionModal.addChild(dolphinBtnText); } // Cancel button var cancelBtn = hoopSelectionModal.attachAsset('button', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 200, scaleX: 0.8, scaleY: 0.8 }); var cancelBtnText = new Text2('Annuler', { size: 36, fill: 0xFFFFFF }); cancelBtnText.anchor.set(0.5, 0.5); cancelBtnText.x = 0; cancelBtnText.y = 200; hoopSelectionModal.addChild(cancelBtnText); hoopSelectionModal.x = 1024; hoopSelectionModal.y = 1366; hoopSelectionModal.down = function (x, y, obj) { var localPos; if (obj.parent && obj.parent.toGlobal) { localPos = hoopSelectionModal.toLocal(obj.parent.toGlobal(obj.position)); } else { localPos = { x: x, y: y }; } // Check dolphin buttons for (var d = 0; d < dolphins.length; d++) { var buttonY = -200 + d * 80; if (localPos.x >= -100 && localPos.x <= 100 && localPos.y >= buttonY - 30 && localPos.y <= buttonY + 30) { // Purchase hoop for selected dolphin dauphicoins -= hoopTypes[selectedHoopType].price; dolphins[d].addHoopIcon(selectedHoopType); // Save updated hoop data immediately updateUI(); LK.getSound('coin').play(); game.removeChild(hoopSelectionModal); hoopSelectionModal = null; break; } } // Check cancel button if (localPos.x >= -80 && localPos.x <= 80 && localPos.y >= 170 && localPos.y <= 230) { game.removeChild(hoopSelectionModal); hoopSelectionModal = null; } }; game.addChild(hoopSelectionModal); } function createDolphinNamingModal() { if (namingModal || dolphins.length === 0) return; namingModal = new Container(); var modalBg = namingModal.attachAsset('modalBg', { anchorX: 0.5, anchorY: 0.5, alpha: 0.8 }); var panel = namingModal.attachAsset('panel', { anchorX: 0.5, anchorY: 0.5 }); var titleText = new Text2('Choisir un Dauphin à Renommer', { size: 50, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 0; titleText.y = -300; namingModal.addChild(titleText); // Dolphin selection buttons for (var d = 0; d < dolphins.length; d++) { var dolphinBtn = namingModal.attachAsset('button', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -200 + d * 80 }); var dolphinBtnText = new Text2(dolphins[d].dolphinName, { size: 36, fill: 0xFFFFFF }); dolphinBtnText.anchor.set(0.5, 0.5); dolphinBtnText.x = 0; dolphinBtnText.y = -200 + d * 80; namingModal.addChild(dolphinBtnText); } // Cancel button var cancelBtn = namingModal.attachAsset('button', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 200, scaleX: 0.8, scaleY: 0.8 }); var cancelBtnText = new Text2('Annuler', { size: 36, fill: 0xFFFFFF }); cancelBtnText.anchor.set(0.5, 0.5); cancelBtnText.x = 0; cancelBtnText.y = 200; namingModal.addChild(cancelBtnText); namingModal.x = 1024; namingModal.y = 1366; namingModal.down = function (x, y, obj) { var localPos; if (obj.parent && obj.parent.toGlobal) { localPos = namingModal.toLocal(obj.parent.toGlobal(obj.position)); } else { localPos = { x: x, y: y }; } // Check dolphin buttons for (var d = 0; d < dolphins.length; d++) { var buttonY = -200 + d * 80; if (localPos.x >= -100 && localPos.x <= 100 && localPos.y >= buttonY - 30 && localPos.y <= buttonY + 30) { selectedDolphinForNaming = dolphins[d]; currentInputText = dolphins[d].dolphinName; game.removeChild(namingModal); namingModal = null; createKeyboardModal(); break; } } // Check cancel button if (localPos.x >= -80 && localPos.x <= 80 && localPos.y >= 170 && localPos.y <= 230) { game.removeChild(namingModal); namingModal = null; } }; game.addChild(namingModal); } function createKeyboardModal() { if (keyboardModal) return; keyboardModal = new Container(); var modalBg = keyboardModal.attachAsset('modalBg', { anchorX: 0.5, anchorY: 0.5, alpha: 0.95 }); var panel = keyboardModal.attachAsset('panel', { anchorX: 0.5, anchorY: 0.5 }); var titleText = new Text2('Nouveau Nom', { size: 60, fill: 0x000000 }); titleText.anchor.set(0.5, 0.5); titleText.x = 0; titleText.y = -350; keyboardModal.addChild(titleText); // Input display var inputText = new Text2(currentInputText, { size: 50, fill: 0x1976D2 }); inputText.anchor.set(0.5, 0.5); inputText.x = 0; inputText.y = -280; keyboardModal.addChild(inputText); // Keyboard layout with better spacing var keyboard = [['A', 'B', 'C', 'D', 'E', 'F', 'G'], ['H', 'I', 'J', 'K', 'L', 'M', 'N'], ['O', 'P', 'Q', 'R', 'S', 'T', 'U'], ['V', 'W', 'X', 'Y', 'Z', '1', '2'], ['3', '4', '5', '6', '7', '8', '9'], ['0', 'ESPACE', 'EFFACER', 'TOUT EFFACER', 'VALIDER']]; for (var row = 0; row < keyboard.length; row++) { for (var col = 0; col < keyboard[row].length; col++) { var key = keyboard[row][col]; // Better spacing calculation to prevent overlap var keySpacing = key.length > 1 ? 120 : 90; var startOffset = row === 5 ? -200 : (keyboard[row].length - 1) * keySpacing * -0.5; var keyBtn = keyboardModal.attachAsset('button', { anchorX: 0.5, anchorY: 0.5, x: startOffset + col * keySpacing, y: -150 + row * 70, scaleX: key.length > 1 ? 1.6 : 1.2, scaleY: 1.2 }); // Set button background color based on key type if (key === 'EFFACER') { keyBtn.tint = 0xFF6644; } else if (key === 'TOUT EFFACER') { keyBtn.tint = 0xFF4444; } else if (key === 'VALIDER') { keyBtn.tint = 0x44AA44; } else if (key === 'ESPACE') { keyBtn.tint = 0x4488CC; } else { keyBtn.tint = 0xFFFFFF; } // Create text with better visibility var keyText = new Text2(key, { size: key.length > 1 ? 20 : 28, fill: 0x000000 }); keyText.anchor.set(0.5, 0.5); keyText.x = startOffset + col * keySpacing; keyText.y = -150 + row * 70; keyboardModal.addChild(keyText); } } keyboardModal.x = 1024; keyboardModal.y = 1366; keyboardModal.down = function (x, y, obj) { var localPos; if (obj.parent && obj.parent.toGlobal) { localPos = keyboardModal.toLocal(obj.parent.toGlobal(obj.position)); } else { localPos = { x: x, y: y }; } // Check keyboard buttons with updated spacing for (var row = 0; row < keyboard.length; row++) { for (var col = 0; col < keyboard[row].length; col++) { var key = keyboard[row][col]; // Updated position calculation to match button creation var keySpacing = key.length > 1 ? 120 : 90; var startOffset = row === 5 ? -200 : (keyboard[row].length - 1) * keySpacing * -0.5; var keyX = startOffset + col * keySpacing; var keyY = -150 + row * 70; var keyWidth = key.length > 1 ? 96 : 54; // Based on scale factors var keyHeight = 36; // Based on scale factors if (localPos.x >= keyX - keyWidth && localPos.x <= keyX + keyWidth && localPos.y >= keyY - keyHeight && localPos.y <= keyY + keyHeight) { if (key === 'ESPACE') { if (currentInputText.length < 15) { currentInputText += ' '; } } else if (key === 'EFFACER') { if (currentInputText.length > 0) { currentInputText = currentInputText.slice(0, -1); } } else if (key === 'TOUT EFFACER') { currentInputText = ''; } else if (key === 'VALIDER') { if (currentInputText.length > 0 && selectedDolphinForNaming) { // Permanently set the custom name chosen by player selectedDolphinForNaming.dolphinName = currentInputText; // Update dolphin name display to show custom name selectedDolphinForNaming.nameText.setText(currentInputText); // Immediately force save the custom name to ensure it persists between sessions try { var dolphinData = []; for (var i = 0; i < dolphins.length; i++) { var dolphin = dolphins[i]; if (dolphin && dolphin.dolphinName) { dolphinData.push({ name: dolphin.dolphinName, happiness: dolphin.happiness, level: dolphin.level, maxHappiness: dolphin.maxHappiness, lastPetTime: dolphin.lastPetTime, ownedHoops: dolphin.ownedHoops || [], x: dolphin.x, y: dolphin.y }); } } storage.dolphinData = dolphinData; // Force save immediately to ensure persistence storage.dolphinCount = dolphins.length; } catch (e) { console.log('Storage error saving dolphin name:', e); } // Also update UI to save other game data updateUI(); } game.removeChild(keyboardModal); keyboardModal = null; selectedDolphinForNaming = null; currentInputText = ''; return; } else if (currentInputText.length < 15) { currentInputText += key; } inputText.setText(currentInputText); return; } } } }; game.addChild(keyboardModal); } function createQuizModal() { if (quizModal) return; var currentQuestion = quizQuestions[Math.floor(Math.random() * quizQuestions.length)]; quizModal = new Container(); var modalBg = quizModal.attachAsset('modalBg', { anchorX: 0.5, anchorY: 0.5, alpha: 0.8 }); var panel = quizModal.attachAsset('panel', { anchorX: 0.5, anchorY: 0.5 }); var titleText = new Text2('Quiz Marin', { size: 60, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 0; titleText.y = -350; quizModal.addChild(titleText); var questionText = new Text2(currentQuestion.question, { size: 44, fill: 0xFFFFFF }); questionText.anchor.set(0.5, 0.5); questionText.x = 0; questionText.y = -250; quizModal.addChild(questionText); // Answer buttons for (var i = 0; i < currentQuestion.answers.length; i++) { var answerBtn = quizModal.attachAsset('button', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -100 + i * 80 }); var answerText = new Text2(currentQuestion.answers[i], { size: 36, fill: 0xFFFFFF }); answerText.anchor.set(0.5, 0.5); answerText.x = 0; answerText.y = -100 + i * 80; quizModal.addChild(answerText); } quizModal.x = 1024; quizModal.y = 1366; quizModal.down = function (x, y, obj) { var localPos; if (obj.parent && obj.parent.toGlobal) { localPos = quizModal.toLocal(obj.parent.toGlobal(obj.position)); } else { localPos = { x: x, y: y }; } // Check answer buttons for (var i = 0; i < currentQuestion.answers.length; i++) { var buttonY = -100 + i * 80; if (localPos.x >= -100 && localPos.x <= 100 && localPos.y >= buttonY - 30 && localPos.y <= buttonY + 30) { if (i === currentQuestion.correct) { dauphibouffe += 2; LK.getSound('correct').play(); LK.effects.flashScreen(0x4caf50, 500); } else { LK.effects.flashScreen(0xf44336, 500); } updateUI(); game.removeChild(quizModal); quizModal = null; break; } } }; game.addChild(quizModal); } // Create background corals for (var i = 0; i < 8; i++) { var coral = new Coral(i, 200 + i * 250, 2700 - Math.random() * 200); corals.push(coral); game.addChild(coral); } // Load saved dolphins or create starting dolphin if (storage.dolphinData && storage.dolphinData.length > 0) { for (var i = 0; i < storage.dolphinData.length; i++) { var data = storage.dolphinData[i]; if (data && data.name) { // Create dolphin with the exact saved custom name - this is permanent var savedDolphin = new Dolphin(data.name, data.x || 1024, data.y || 1200); savedDolphin.happiness = data.happiness || 50; savedDolphin.level = data.level || 1; savedDolphin.maxHappiness = data.maxHappiness || 100; savedDolphin.lastPetTime = data.lastPetTime || 0; savedDolphin.petCooldown = data.petCooldown || 60000; savedDolphin.ownedHoops = data.ownedHoops || []; // Ensure the custom name is permanently retained - no generic names savedDolphin.dolphinName = data.name; // Display the custom name permanently savedDolphin.nameText.setText(data.name); // Update level display to match saved level using stored reference if (savedDolphin.levelText) { savedDolphin.levelText.setText('Niv.' + savedDolphin.level); } // Update happiness bars to reflect saved state savedDolphin.updateHappinessBar(); // Restore hoop icons without triggering additional saves for (var h = 0; h < savedDolphin.ownedHoops.length; h++) { // Create small hoop icon var hoopAssetNames = ['hoop', 'hoopCute', 'hoopTricolore', 'hoopEnflamme', 'hoopOcean']; var hoopIcon = savedDolphin.attachAsset(hoopAssetNames[savedDolphin.ownedHoops[h]] || 'hoop', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.3, scaleY: 0.3 }); // Position icon next to dolphin hoopIcon.x = 120 + h * 40; hoopIcon.y = 0; savedDolphin.hoopIcons.push(hoopIcon); } dolphins.push(savedDolphin); game.addChild(savedDolphin); } } } else { // Create starting dolphin with random name that can be changed var randomStartName = getRandomDolphinName(); var firstDolphin = new Dolphin(randomStartName, 1024, 1200); dolphins.push(firstDolphin); game.addChild(firstDolphin); } // Create UI coinText = new Text2('Dauphicoins: ' + dauphicoins, { size: 48, fill: 0xFFEB3B }); coinText.anchor.set(0, 0); coinText.x = 120; coinText.y = 50; LK.gui.topLeft.addChild(coinText); foodText = new Text2('Dauphibouffe: ' + dauphibouffe, { size: 48, fill: 0x8BC34A }); foodText.anchor.set(0, 0); foodText.x = 120; foodText.y = 120; LK.gui.topLeft.addChild(foodText); trainerText = new Text2('Dresseur Niv.' + trainerLevel + ' (' + trainerXP + ' XP)', { size: 48, fill: 0xFFFFFF }); trainerText.anchor.set(0.5, 0); trainerText.x = 0; trainerText.y = 50; LK.gui.top.addChild(trainerText); // Shop button var shopBtn = LK.gui.bottomLeft.attachAsset('shopButton', { anchorX: 0, anchorY: 1, x: 50, y: -50 }); var shopBtnText = new Text2('Boutique', { size: 36, fill: 0xFFFFFF }); shopBtnText.anchor.set(0, 1); shopBtnText.x = 50; shopBtnText.y = -50; LK.gui.bottomLeft.addChild(shopBtnText); // Quiz button var quizBtn = LK.gui.bottomRight.attachAsset('quizButton', { anchorX: 1, anchorY: 1, x: -50, y: -50 }); var quizBtnText = new Text2('Quiz', { size: 36, fill: 0xFFFFFF }); quizBtnText.anchor.set(1, 1); quizBtnText.x = -50; quizBtnText.y = -50; LK.gui.bottomRight.addChild(quizBtnText); // Naming button var namingBtn = LK.gui.bottomRight.attachAsset('button', { anchorX: 1, anchorY: 1, x: -50, y: -130, scaleX: 1.2, scaleY: 0.8 }); var namingBtnText = new Text2('Nommer un dauphin', { size: 28, fill: 0xFFFFFF }); namingBtnText.anchor.set(1, 1); namingBtnText.x = -50; namingBtnText.y = -130; LK.gui.bottomRight.addChild(namingBtnText); // Button event handlers LK.gui.bottomLeft.down = function (x, y, obj) { createShopModal(); }; LK.gui.bottomRight.down = function (x, y, obj) { // Check if naming button was clicked if (y >= -160 && y <= -100) { createDolphinNamingModal(); } else if (y >= -80 && y <= -20) { createQuizModal(); } }; // Play background music LK.playMusic('underwater'); // Initialize UI updateUI(); // Game update loop game.update = function () { // Update all dolphins for (var i = 0; i < dolphins.length; i++) { dolphins[i].update(); } // Update corals for (var i = 0; i < corals.length; i++) { corals[i].update(); } // Update hoops for (var i = 0; i < hoops.length; i++) { hoops[i].update(); } };
===================================================================
--- original.js
+++ change.js
@@ -135,8 +135,10 @@
var iconIndex = self.hoopIcons.length;
hoopIcon.x = 120 + iconIndex * 40;
hoopIcon.y = 0;
self.hoopIcons.push(hoopIcon);
+ // Save hoop progression immediately
+ updateUI();
};
self.canPet = function () {
var now = Date.now();
return now - self.lastPetTime >= self.petCooldown;
@@ -291,10 +293,10 @@
var trainerLevel = storage.trainerLevel !== undefined ? storage.trainerLevel : 1;
var trainerXP = storage.trainerXP !== undefined ? storage.trainerXP : 0;
// Database of 80 unique dolphin names
var dolphinNames = ['Luna', 'Neptune', 'OcƩan', 'Azur', 'Coral', 'Marina', 'Aqua', 'Bleu', 'Splash', 'Bubble', 'Wave', 'Tide', 'Storm', 'Misty', 'Pearl', 'Crystal', 'Echo', 'Sonic', 'Melody', 'Harmony', 'Rhythm', 'Jazz', 'Blues', 'Tempo', 'Atlas', 'Zeus', 'Triton', 'Poseidon', 'Apollo', 'Orion', 'Cosmos', 'Nova', 'Star', 'Comet', 'Galaxy', 'Meteor', 'Stellar', 'Solar', 'Lunar', 'Cosmic', 'Aquarius', 'Pisces', 'Delphinus', 'Cetus', 'Orca', 'Narval', 'Beluga', 'Marlin', 'Spirit', 'Dream', 'Hope', 'Joy', 'Grace', 'Faith', 'Love', 'Peace', 'Thunder', 'Lightning', 'Rain', 'Frost', 'Snow', 'Ice', 'Wind', 'Breeze', 'Coral', 'Reef', 'Lagoon', 'Bay', 'Cove', 'Shore', 'Beach', 'Dune', 'Captain', 'Admiral', 'Sailor', 'Navigator', 'Explorer', 'Voyager', 'Pioneer', 'Ranger'];
-// Track used names to avoid duplicates
-var usedNames = [];
+// Track used names to avoid duplicates - load from storage
+var usedNames = storage.usedNames || [];
// Hoop types with their properties
var hoopTypes = [{
name: 'Cerceau DorƩ',
price: 50,
@@ -384,9 +386,9 @@
storage.dauphicoins = dauphicoins;
storage.dauphibouffe = dauphibouffe;
storage.trainerLevel = trainerLevel;
storage.trainerXP = trainerXP;
- // Save dolphin data with enhanced properties including names, owned hoops, and levels
+ // Save complete dolphin progression data including names, levels, and owned hoops
var dolphinData = [];
for (var i = 0; i < dolphins.length; i++) {
var dolphin = dolphins[i];
if (dolphin && dolphin.dolphinName) {
@@ -397,15 +399,17 @@
maxHappiness: dolphin.maxHappiness,
lastPetTime: dolphin.lastPetTime,
ownedHoops: dolphin.ownedHoops || [],
x: dolphin.x,
- y: dolphin.y
+ y: dolphin.y,
+ petCooldown: dolphin.petCooldown
});
}
}
storage.dolphinData = dolphinData;
- // Save number of dolphins owned by player
+ // Save complete game progression
storage.dolphinCount = dolphins.length;
+ storage.usedNames = usedNames;
} catch (e) {
console.log('Storage error:', e);
}
}
@@ -949,8 +953,9 @@
savedDolphin.happiness = data.happiness || 50;
savedDolphin.level = data.level || 1;
savedDolphin.maxHappiness = data.maxHappiness || 100;
savedDolphin.lastPetTime = data.lastPetTime || 0;
+ savedDolphin.petCooldown = data.petCooldown || 60000;
savedDolphin.ownedHoops = data.ownedHoops || [];
// Ensure the custom name is permanently retained - no generic names
savedDolphin.dolphinName = data.name;
// Display the custom name permanently
@@ -960,11 +965,22 @@
savedDolphin.levelText.setText('Niv.' + savedDolphin.level);
}
// Update happiness bars to reflect saved state
savedDolphin.updateHappinessBar();
- // Restore hoop icons
+ // Restore hoop icons without triggering additional saves
for (var h = 0; h < savedDolphin.ownedHoops.length; h++) {
- savedDolphin.addHoopIcon(savedDolphin.ownedHoops[h]);
+ // Create small hoop icon
+ var hoopAssetNames = ['hoop', 'hoopCute', 'hoopTricolore', 'hoopEnflamme', 'hoopOcean'];
+ var hoopIcon = savedDolphin.attachAsset(hoopAssetNames[savedDolphin.ownedHoops[h]] || 'hoop', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.3,
+ scaleY: 0.3
+ });
+ // Position icon next to dolphin
+ hoopIcon.x = 120 + h * 40;
+ hoopIcon.y = 0;
+ savedDolphin.hoopIcons.push(hoopIcon);
}
dolphins.push(savedDolphin);
game.addChild(savedDolphin);
}
Bouton bleu. In-Game asset. 2d. High contrast. No shadows
Coral. In-Game asset. 2d. High contrast. No shadows
Coral bleu. In-Game asset. 2d. High contrast. No shadows
Coral rouge. In-Game asset. 2d. High contrast. No shadows
nourriture pour dauphins. In-Game asset. 2d. High contrast. No shadows
Cerceau doreĢe. In-Game asset. 2d. High contrast. No shadows
Fond d'eĢcran oceĢan mignon. In-Game asset. 2d. High contrast. No shadows
Dauphin. In-Game asset. 2d. High contrast. No shadows
Cerceau de couleur rose mignon. In-Game asset. 2d. High contrast. No shadows
Cerceau enflammeĢ. In-Game asset. 2d. High contrast. No shadows
Cerceau tricolore. In-Game asset. 2d. High contrast. No shadows
Cerceau de l'oceĢan. In-Game asset. 2d. High contrast. No shadows
Poisson. In-Game asset. 2d. High contrast. No shadows
Coeur. In-Game asset. 2d. High contrast. No shadows
eĢclat. In-Game asset. 2d. High contrast. No shadows
Fond d'eĢcran oceĢan mignon. In-Game asset. 2d. High contrast. No shadows