User prompt
Muy bien aunque el fondo no queda bien ajustado y en la pantalla de partidas guardadas no hay un fondo, además puedes reajustar el tamaño de los iconos del inventario para hacerlos iguales en tamaño y quede simétrico.
User prompt
A el menu de inicio le falta color y el boton de los idiomas esta muy pequeño de hecho todo en el principio se ve muy pequeño
User prompt
No funciono la duplica también es invisible y todo se sigue viendo nada más cuando esta en pausa... será por el petbody puedes eliminarlo ya que no lo vamos a usar ahora todos los digimon tienen su propia skin y depende de diferentes assets cada uno
User prompt
Bueno tengo una idea crea un codigo que duplique el sprite para ver que sucede
User prompt
Te recomiendo que analizes todo el codigo del juego y busques la forma de que tome en cuenta de mejor forma los assets que le pusimos a los Digimon
User prompt
Intenta reescalar los Digimon para ver
User prompt
Tenemos todos los assets pero hay un fallo que los hace invisibles aplica todas tus soluciones posible pa ver que sucede
User prompt
Para evolucionar de la etapa 1 a la 2 serian 10 minutos
User prompt
Puedes solucionar todas las fallas?
User prompt
Se supone que debo comenzar con el nivel de evolución 0 y todas las estadisticas de entrenamiento en 0 también
User prompt
Tenemos otra falla elimine todos los guardados y comence un nuevo juego pero sigo llevandome cosas de la partida anterior
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage[savePrefix + 'petName'] = undefined;' Line Number: 1409 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
El Digimon se hace visible cuando el juego entre en pausa tienes idea de por que? bueno mientras puedes añadir también un sistema para borrar la partida guardada?
User prompt
Intentalo de nuevo
User prompt
Lo unico que se sigue viendo son esos ojos que no necesito
User prompt
Vamos hacer toda la interfaz más grande y por cierto sigue sin aparecer la imagen del Digimon solo aparece cuando lo pongo en pausa
User prompt
Sigue sin aparecer la imagen del Digimon
User prompt
Esta pasando algo extraño no veo la imagen del digimon y eso que ya se las puse a todos
User prompt
Falta agregar el asset de todos ellos así les pones las imagenes creadas con tu ayuda
User prompt
Please fix the bug: 'TypeError: game.children[6].setText is not a function' in or related to this line: 'game.children[6].setText(currentDigimonName);' Line Number: 1735
User prompt
Muy bien ahora vamos a añadir la primera linea evolutiva que sera de Botamon a Wargreymon y también la de Punimon a MetalGarurumon, por ultimo añadiremos a Poyomon con 2 lineas finales como Seraphimon y Ophanimon. Esto hazlo por orden asignales los digi-huevos en ese orden. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Estoy viendo un gran bug y es que las estadisticas de partidas anteriores se siguen conservando aun cuando es un juego nuevo y por cierto también añade diferentes aparienciencias para los digi huevos con sus diferentes digimon y lineas evolutivas también ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage[savePrefix + 'energy'] = pet.energy;' Line Number: 1267 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage['save_' + saveCount] = saveData;' Line Number: 1254 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'TypeError: Cannot use 'in' operator to search for 'alpha' in null' in or related to this line: 'tween(self.statusIcon, {' Line Number: 212 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var ActionButton = Container.expand(function (text, color) { var self = Container.call(this); var buttonBg = self.attachAsset('button', { anchorX: 0.5, anchorY: 0.5, tint: color, scaleX: 1.4, scaleY: 1.4 }); var buttonText = new Text2(text, { size: 40, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.down = function (x, y, obj) { tween(self, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100 }); }; self.up = function (x, y, obj) { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 100 }); if (self.onPress) { self.onPress(); } }; return self; }); var DigiEgg = Container.expand(function (eggType, isLocked) { var self = Container.call(this); // Use specific egg assets for each type var eggAssetName = 'digiEgg' + eggType; var eggGraphics = self.attachAsset(eggAssetName, { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); // Add pattern overlay for visual distinction var patternShapes = ['ellipse', 'box', 'ellipse', 'box', 'ellipse', 'box']; var patternColors = [0x66BB6A, 0x42A5F5, 0xFFB74D, 0xBA68C8, 0xEF5350, 0xFF7043]; var pattern = self.attachAsset('petEye', { anchorX: 0.5, anchorY: 0.5, tint: patternColors[eggType], scaleX: 0.6, scaleY: 0.6, alpha: 0.7 }); // Add small decorative spots for (var i = 0; i < 3; i++) { var spot = self.attachAsset('petEye', { anchorX: 0.5, anchorY: 0.5, x: (Math.random() - 0.5) * 80, y: (Math.random() - 0.5) * 100, tint: patternColors[eggType], scaleX: 0.2 + Math.random() * 0.2, scaleY: 0.2 + Math.random() * 0.2, alpha: 0.5 }); } if (isLocked) { var lockOverlay = self.attachAsset('button', { anchorX: 0.5, anchorY: 0.5, tint: 0x666666, alpha: 0.7, scaleX: 0.3, scaleY: 0.3 }); var lockText = new Text2(getText('locked'), { size: 20, fill: 0xFFFFFF }); lockText.anchor.set(0.5, 0.5); lockText.y = 50; self.addChild(lockText); } self.eggType = eggType; self.isLocked = isLocked; self.down = function (x, y, obj) { if (!self.isLocked && self.onSelect) { tween(self, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100 }); self.onSelect(self.eggType); } }; self.up = function (x, y, obj) { if (!self.isLocked) { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }; return self; }); var DigitalPet = Container.expand(function () { var self = Container.call(this); // Pet graphics - will be updated based on evolution var body = null; var leftEye = self.attachAsset('petEye', { anchorX: 0.5, anchorY: 0.5, x: -40, y: -30 }); var rightEye = self.attachAsset('petEye', { anchorX: 0.5, anchorY: 0.5, x: 40, y: -30 }); // Pet stats self.hunger = storage.hunger || 100; self.happiness = storage.happiness || 100; self.fatigue = storage.fatigue || 0; // Changed from energy to fatigue, starts at 0 self.evolutionLevel = storage.evolutionLevel || 0; self.attack = storage.attack || 10; self.health = storage.health || 50; self.speed = storage.speed || 30; self.weight = storage.weight || 50; self.name = storage.petName || 'Digimon'; self.eggType = storage.eggType || 0; self.wins = storage.wins || 0; self.battles = storage.battles || 0; self.lastUpdateTime = Date.now(); // Health system self.injured = storage.injured || false; self.sick = storage.sick || false; self.injuryTime = storage.injuryTime || 0; self.sickTime = storage.sickTime || 0; self.hungerDeathTimer = storage.hungerDeathTimer || 0; // Stats display self.statsDisplay = null; self.showingStats = false; // Health status icon self.statusIcon = null; // Evolution colors self.evolutionColors = [0x4CAF50, 0x2196F3, 0xFF9800, 0x9C27B0, 0xF44336]; self.updateStatusIcon = function () { // Remove existing status icon if (self.statusIcon) { self.removeChild(self.statusIcon); self.statusIcon = null; } // Add status icon if injured or sick if (self.injured || self.sick) { self.statusIcon = new Container(); var iconBg = self.statusIcon.attachAsset('petEye', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2, tint: self.sick ? 0x800080 : 0xFF0000 // Purple for sick, red for injured }); var iconText = new Text2(self.sick ? '!' : '?', { size: 40, fill: 0xFFFFFF }); iconText.anchor.set(0.5, 0.5); self.statusIcon.addChild(iconText); self.statusIcon.x = 0; self.statusIcon.y = -150; // Position above Digimon self.addChild(self.statusIcon); // Pulsing animation if (self.statusIcon) { tween(self.statusIcon, { alpha: 0.3 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { if (self.statusIcon) { tween(self.statusIcon, { alpha: 1 }, { duration: 800, easing: tween.easeInOut }); } } }); } } }; self.updateAppearance = function () { // Remove old body if exists if (body) { self.removeChild(body); body = null; } // Choose asset based on evolution line and level var evolutionAssets = [ // Line 0: Botamon → WarGreymon ['botamon', 'koromon', 'agumon', 'greymon', 'metalgreymon', 'wargreymon'], // Line 1: Punimon → MetalGarurumon ['punimon', 'tsunomon', 'gabumon', 'garurumon', 'weregarurumon', 'metalgarurumon'], // Line 2: Poyomon → Seraphimon ['poyomon', 'tokomon', 'patamon', 'angemon', 'magnaangemon', 'seraphimon'], // Line 3: Poyomon → Ophanimon ['poyomon', 'tokomon', 'patamon', 'angewomon', 'magnadramon', 'ophanimon'], // Line 4: Fallback generic assets ['petBody', 'digimon_rookie', 'digimon_champion', 'digimon_ultimate', 'digimon_mega', 'digimon_ultra'], // Line 5: Fallback generic assets ['petBody', 'digimon_rookie', 'digimon_champion', 'digimon_ultimate', 'digimon_mega', 'digimon_ultra']]; var lineAssets = evolutionAssets[self.eggType] || evolutionAssets[4]; var assetName = lineAssets[self.evolutionLevel] || lineAssets[0]; // Create new body with evolution-specific asset body = self.attachAsset(assetName, { anchorX: 0.5, anchorY: 0.5 }); // Ensure body is visible and properly positioned if (body) { body.x = 0; body.y = 0; body.alpha = 1; body.visible = true; // Force the body to be added to the display list properly self.addChildAt(body, 0); // Ensure it stays visible by setting z-index body.zIndex = 1; } // Update the pet's display name based on evolution self.currentDigimonName = getCurrentDigimonName(self.eggType, self.evolutionLevel); // Enhanced evolution lines with more distinctive progressions var eggTypeColors = [ // Forest/Nature line (Green egg) - Plant-based evolution [0x4CAF50, 0x66BB6A, 0x8BC34A, 0xAED581, 0xC5E1A5], // Ocean/Water line (Blue egg) - Aquatic evolution [0x2196F3, 0x42A5F5, 0x64B5F6, 0x90CAF9, 0xBBDEFB], // Fire/Dragon line (Orange egg) - Fire-based evolution [0xFF9800, 0xFF7043, 0xF4511E, 0xD84315, 0xBF360C], // Shadow/Dark line (Purple egg) - Dark/psychic evolution [0x9C27B0, 0x8E24AA, 0x7B1FA2, 0x6A1B9A, 0x4A148C], // Lightning/Electric line (Red egg) - Electric evolution [0xF44336, 0xFF5252, 0xFF1744, 0xD500F9, 0xAA00FF], // Earth/Metal line (Dark Orange egg) - Rock/metal evolution [0xFF5722, 0x8D6E63, 0x6D4C41, 0x5D4037, 0x3E2723]]; var evolutionColors = eggTypeColors[self.eggType] || eggTypeColors[0]; var color = evolutionColors[self.evolutionLevel] || evolutionColors[0]; body.tint = color; // Scale based on evolution level and egg type var baseScale = 0.8 + self.eggType * 0.05; // Different base sizes per egg type var evolutionScale = 1 + self.evolutionLevel * 0.15; // Reduced scaling for better visibility var finalScale = baseScale * evolutionScale; body.scaleX = finalScale; body.scaleY = finalScale; // Eye expressions based on happiness if (self.happiness > 70) { leftEye.scaleY = 1; rightEye.scaleY = 1; } else if (self.happiness > 30) { leftEye.scaleY = 0.8; rightEye.scaleY = 0.8; } else { leftEye.scaleY = 0.5; rightEye.scaleY = 0.5; } // Eye color variations based on egg type var eyeColors = [0x000000, 0x1976D2, 0x8BC34A, 0x7B1FA2, 0xD32F2F, 0x5D4037]; var eyeColor = eyeColors[self.eggType] || 0x000000; leftEye.tint = eyeColor; rightEye.tint = eyeColor; }; // Initialize appearance self.updateAppearance(); // Force immediate visual update to ensure Digimon is visible LK.setTimeout(function () { self.updateAppearance(); }, 100); // Additional forced update with longer delay LK.setTimeout(function () { if (self && self.updateAppearance) { self.updateAppearance(); } }, 500); self.evolveCheck = function () { var avgStat = (self.hunger + self.happiness + (100 - self.fatigue)) / 3; var targetLevel = Math.floor(avgStat / 25); if (targetLevel > self.evolutionLevel && targetLevel < self.evolutionColors.length) { self.evolutionLevel = targetLevel; LK.getSound('evolve').play(); // Evolution animation tween(self, { scaleX: 1.5, scaleY: 1.5 }, { duration: 500, easing: tween.bounceOut, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 300, easing: tween.easeOut }); } }); self.updateAppearance(); LK.effects.flashScreen(0xFFD700, 1000); } }; self.update = function () { var currentTime = Date.now(); var deltaTime = (currentTime - self.lastUpdateTime) / 1000; self.lastUpdateTime = currentTime; // Decay stats over time - hunger no longer decreases automatically // self.hunger = Math.max(0, self.hunger - deltaTime * 2); // Removed automatic hunger decrease self.happiness = Math.max(0, self.happiness - deltaTime * 0.1); // Much slower happiness decrease (fun bar) // Energy is now fatigue - it doesn't decrease automatically, only increases during training // Health system timers if (self.injured) { self.injuryTime += deltaTime; // After 30 minutes (1800 seconds) injury becomes sickness if (self.injuryTime >= 1800) { self.injured = false; self.sick = true; self.injuryTime = 0; self.sickTime = 0; LK.effects.flashObject(self, 0x800080, 1000); } } if (self.sick) { self.sickTime += deltaTime; // Sick Digimon dies after some time without medicine if (self.sickTime >= 300) { // 5 minutes self.die(); return; } } // Hunger death timer if (self.hunger <= 0) { self.hungerDeathTimer += deltaTime; if (self.hungerDeathTimer >= 300) { // 5 minutes self.die(); return; } } else { self.hungerDeathTimer = 0; } // Idle animation if (LK.ticks % 120 === 0) { tween(self, { y: self.y - 20 }, { duration: 500, easing: tween.easeInOut, onFinish: function onFinish() { tween(self, { y: self.y + 20 }, { duration: 500, easing: tween.easeInOut }); } }); } self.updateAppearance(); self.updateStatusIcon(); // Update health status icon self.evolveCheck(); // Calculate defense based on weight self.defense = Math.floor(self.weight / 2); // Save stats storage.hunger = self.hunger; storage.happiness = self.happiness; storage.fatigue = self.fatigue; // Changed from energy to fatigue storage.evolutionLevel = self.evolutionLevel; storage.attack = self.attack; storage.health = self.health; storage.speed = self.speed; storage.weight = self.weight; storage.petName = self.name; storage.eggType = self.eggType; storage.wins = self.wins; storage.battles = self.battles; storage.injured = self.injured; storage.sick = self.sick; storage.injuryTime = self.injuryTime; storage.sickTime = self.sickTime; storage.hungerDeathTimer = self.hungerDeathTimer; }; self.down = function (x, y, obj) { if (self.showingStats) { self.hideStats(); } else { self.showStats(); } }; self.showStats = function () { if (self.statsDisplay) return; self.showingStats = true; var winRate = self.battles > 0 ? Math.round(self.wins / self.battles * 100) : 0; self.statsDisplay = new Container(); var statsBg = self.statsDisplay.attachAsset('gameArea', { anchorX: 0.5, anchorY: 0.5, scaleX: 3, scaleY: 2.5, tint: 0x263238, alpha: 0.9 }); var currentDigimonName = getCurrentDigimonName(self.eggType, self.evolutionLevel); var statsText = new Text2(self.name + ' (' + currentDigimonName + ')' + '\n\n' + getText('evolutionLevel') + ': ' + self.evolutionLevel + '\n' + getText('attack') + ': ' + Math.floor(self.attack) + '\n' + getText('health') + ': ' + Math.floor(self.health) + '\n' + getText('speed') + ': ' + Math.floor(self.speed) + '\n' + getText('defense') + ': ' + Math.floor(self.defense) + '\n' + getText('weight') + ': ' + Math.floor(self.weight) + '\n' + 'Win Rate: ' + winRate + '%', { size: 30, fill: 0xFFFFFF }); statsText.anchor.set(0.5, 0.5); self.statsDisplay.addChild(statsText); self.statsDisplay.x = 0; self.statsDisplay.y = -200; self.addChild(self.statsDisplay); // Auto hide after 3 seconds LK.setTimeout(function () { if (self.showingStats) { self.hideStats(); } }, 3000); }; self.hideStats = function () { if (self.statsDisplay) { self.removeChild(self.statsDisplay); self.statsDisplay = null; self.showingStats = false; } }; self.die = function () { LK.effects.flashScreen(0x000000, 2000); LK.setTimeout(function () { // Clear all storage and restart storage.hunger = 100; storage.happiness = 100; storage.energy = 100; storage.evolutionLevel = 0; storage.attack = 10; storage.health = 50; storage.speed = 30; storage.weight = 50; storage.injured = false; storage.sick = false; storage.injuryTime = 0; storage.sickTime = 0; storage.hungerDeathTimer = 0; // Give new starter items storage.smallMeat = 10; storage.blessing = 5; storage.medicine = 3; showMainMenu(); }, 2000); }; self.train = function () { // Increase fatigue during training self.fatigue = Math.min(100, self.fatigue + 15); if (self.fatigue > 80) { // Training while tired causes injury if (!self.injured && !self.sick) { self.injured = true; self.injuryTime = 0; LK.effects.flashObject(self, 0xFF0000, 1000); } } // Reduce hunger slightly during training self.hunger = Math.max(0, self.hunger - 3); }; return self; }); var Inventory = Container.expand(function () { var self = Container.call(this); // Initialize inventory items self.items = { smallMeat: storage.smallMeat || 0, mediumMeat: storage.mediumMeat || 0, largeMeat: storage.largeMeat || 0, sirloin: storage.sirloin || 0, blessing: storage.blessing || 0, medicine: storage.medicine || 0 }; self.slots = []; // Create inventory slots var itemTypes = ['smallMeat', 'mediumMeat', 'largeMeat', 'sirloin', 'blessing', 'medicine']; for (var i = 0; i < itemTypes.length; i++) { var slot = new Container(); var slotBg = slot.attachAsset('inventorySlot', { anchorX: 0.5, anchorY: 0.5 }); var itemIcon = slot.attachAsset(itemTypes[i], { anchorX: 0.5, anchorY: 0.5, scaleX: 2.0, scaleY: 2.0 }); var countText = new Text2('0', { size: 18, fill: 0xFFFFFF }); countText.anchor.set(0.5, 1); countText.y = 35; slot.addChild(countText); slot.itemType = itemTypes[i]; slot.x = i * 120; slot.y = 0; slot.down = function (x, y, obj) { if (self.items[this.itemType] > 0) { self.useItem(this.itemType); } }; self.addChild(slot); self.slots.push(slot); } self.useItem = function (itemType) { if (self.items[itemType] <= 0) return; self.items[itemType]--; switch (itemType) { case 'smallMeat': pet.hunger = Math.min(100, pet.hunger + 15); break; case 'mediumMeat': pet.hunger = Math.min(100, pet.hunger + 30); break; case 'largeMeat': pet.hunger = Math.min(100, pet.hunger + 50); break; case 'sirloin': pet.hunger = Math.min(100, pet.hunger + 75); break; case 'blessing': if (pet.injured) { pet.injured = false; pet.injuryTime = 0; LK.effects.flashObject(pet, 0xFFD700, 1000); } break; case 'medicine': if (pet.sick) { pet.sick = false; pet.sickTime = 0; LK.effects.flashObject(pet, 0x4CAF50, 1000); } break; } self.updateDisplay(); self.saveItems(); LK.getSound('feed').play(); }; self.updateDisplay = function () { for (var i = 0; i < self.slots.length; i++) { var slot = self.slots[i]; var count = self.items[slot.itemType]; slot.children[2].setText(count.toString()); } }; self.saveItems = function () { storage.smallMeat = self.items.smallMeat; storage.mediumMeat = self.items.mediumMeat; storage.largeMeat = self.items.largeMeat; storage.sirloin = self.items.sirloin; storage.blessing = self.items.blessing; storage.medicine = self.items.medicine; }; self.updateDisplay(); return self; }); var LanguageButton = Container.expand(function () { var self = Container.call(this); var buttonBg = self.attachAsset('languageButton', { anchorX: 0.5, anchorY: 0.5 }); var flagEN = self.attachAsset('flagEN', { anchorX: 0.5, anchorY: 0.5, x: -15, scaleX: 0.4, scaleY: 0.4 }); var flagES = self.attachAsset('flagES', { anchorX: 0.5, anchorY: 0.5, x: 15, scaleX: 0.4, scaleY: 0.4 }); // Add EN/ES text overlay var textEN = new Text2('EN', { size: 12, fill: 0xFFFFFF }); textEN.anchor.set(0.5, 0.5); textEN.x = -15; flagEN.addChild(textEN); var textES = new Text2('ES', { size: 12, fill: 0xFFFFFF }); textES.anchor.set(0.5, 0.5); textES.x = 15; flagES.addChild(textES); self.updateDisplay = function () { if (currentLanguage === 'en') { flagEN.alpha = 1; flagES.alpha = 0.5; } else { flagEN.alpha = 0.5; flagES.alpha = 1; } }; self.down = function (x, y, obj) { tween(self, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100 }); }; self.up = function (x, y, obj) { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 100 }); // Toggle language currentLanguage = currentLanguage === 'en' ? 'es' : 'en'; storage.currentLanguage = currentLanguage; self.updateDisplay(); updateAllTexts(); }; self.updateDisplay(); return self; }); var MainMenu = Container.expand(function () { var self = Container.call(this); var titleText = new Text2('Digital Pet', { size: 80, fill: 0x2196F3 }); titleText.anchor.set(0.5, 0.5); titleText.x = 1024; titleText.y = 400; self.addChild(titleText); var newGameButton = new ActionButton(getText('newGame'), 0x4CAF50); newGameButton.x = 1024; newGameButton.y = 800; newGameButton.onPress = function () { showEggSelection(); }; self.addChild(newGameButton); var savedGamesButton = new ActionButton(getText('savedGames'), 0x2196F3); savedGamesButton.x = 1024; savedGamesButton.y = 950; savedGamesButton.onPress = function () { showSavedGames(); }; self.addChild(savedGamesButton); return self; }); var MiniGame = Container.expand(function () { var self = Container.call(this); var gameArea = self.attachAsset('gameArea', { anchorX: 0.5, anchorY: 0.5 }); var target = self.attachAsset('target', { anchorX: 0.5, anchorY: 0.5 }); self.score = 0; self.timeLeft = 10; self.gameActive = false; var scoreText = new Text2('Score: 0', { size: 30, fill: 0x333333 }); scoreText.anchor.set(0.5, 0); scoreText.y = -180; self.addChild(scoreText); var timerText = new Text2('Time: 10', { size: 30, fill: 0x333333 }); timerText.anchor.set(0.5, 0); timerText.y = -140; self.addChild(timerText); self.startGame = function () { self.gameActive = true; self.score = 0; self.timeLeft = 10; scoreText.setText(getText('score') + ': 0'); timerText.setText(getText('time') + ': 10'); self.moveTarget(); var gameTimer = LK.setInterval(function () { self.timeLeft -= 0.1; timerText.setText(getText('time') + ': ' + Math.ceil(self.timeLeft)); if (self.timeLeft <= 0) { LK.clearInterval(gameTimer); self.endGame(); } }, 100); }; self.moveTarget = function () { if (!self.gameActive) return; var newX = (Math.random() - 0.5) * 300; var newY = (Math.random() - 0.5) * 300; tween(target, { x: newX, y: newY }, { duration: 200, easing: tween.easeOut }); }; self.endGame = function () { self.gameActive = false; var happiness = Math.min(20, self.score * 2); pet.happiness = Math.min(100, pet.happiness + happiness); pet.fatigue = Math.min(100, pet.fatigue + 10); // Increase fatigue instead of decreasing energy pet.hunger = Math.max(0, pet.hunger - 5); if (self.onGameEnd) { self.onGameEnd(self.score); } }; target.down = function (x, y, obj) { if (!self.gameActive) return; self.score++; scoreText.setText(getText('score') + ': ' + self.score); LK.getSound('play').play(); tween(target, { scaleX: 1.3, scaleY: 1.3 }, { duration: 100, onFinish: function onFinish() { tween(target, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); self.moveTarget(); }; return self; }); var Shop = Container.expand(function () { var self = Container.call(this); var shopBg = self.attachAsset('gameArea', { anchorX: 0.5, anchorY: 0.5, scaleX: 4, scaleY: 5, tint: 0xE3F2FD }); var titleText = new Text2(getText('shop'), { size: 60, fill: 0x1976D2 }); titleText.anchor.set(0.5, 0.5); titleText.y = -800; self.addChild(titleText); var moneyText = new Text2(getText('money') + ': ' + (storage.money || 0), { size: 40, fill: 0x388E3C }); moneyText.anchor.set(0.5, 0.5); moneyText.y = -700; self.addChild(moneyText); // Shop items var shopItems = [{ name: 'Super Food', price: 50, effect: 'hunger+50' }, { name: 'Energy Drink', price: 30, effect: 'energy+40' }, { name: 'Happy Toy', price: 40, effect: 'happiness+30' }]; var itemButtons = []; for (var i = 0; i < shopItems.length; i++) { var item = shopItems[i]; var itemButton = new ActionButton(item.name + ' (' + item.price + ')', 0xFF9800); itemButton.x = 0; itemButton.y = -400 + i * 150; itemButton.itemData = item; itemButton.onPress = function () { if ((storage.money || 0) >= this.itemData.price) { storage.money = (storage.money || 0) - this.itemData.price; // Apply item effect if (this.itemData.effect.includes('hunger')) { pet.hunger = Math.min(100, pet.hunger + 50); } else if (this.itemData.effect.includes('energy')) { pet.energy = Math.min(100, pet.energy + 40); } else if (this.itemData.effect.includes('happiness')) { pet.happiness = Math.min(100, pet.happiness + 30); } moneyText.setText(getText('money') + ': ' + storage.money); LK.getSound('feed').play(); } }; self.addChild(itemButton); itemButtons.push(itemButton); } var closeButton = new ActionButton('X', 0xF44336); closeButton.x = 600; closeButton.y = -800; closeButton.onPress = function () { LK.playMusic('Luna'); gameState = 'game'; game.removeChild(shop); }; self.addChild(closeButton); return self; }); var StatBar = Container.expand(function (label, color, iconAsset) { var self = Container.call(this); var background = self.attachAsset('statBar', { anchorX: 0, anchorY: 0.5 }); var fill = self.attachAsset('statFill', { anchorX: 0, anchorY: 0.5, tint: color, scaleX: 1 }); // Add icon if provided if (iconAsset) { var icon = self.attachAsset(iconAsset, { anchorX: 0.5, anchorY: 0.5, x: -120, scaleX: 1.2, scaleY: 1.2 }); } var labelText = new Text2(label, { size: 25, fill: 0x333333 }); labelText.anchor.set(0, 0.5); labelText.x = -80; self.addChild(labelText); self.updateValue = function (value) { var percentage = Math.max(0, Math.min(100, value)) / 100; tween(fill, { scaleX: percentage }, { duration: 300, easing: tween.easeOut }); }; self.updateLabel = function (newLabel) { labelText.setText(newLabel); }; return self; }); var Training = Container.expand(function () { var self = Container.call(this); var trainingBg = self.attachAsset('gameArea', { anchorX: 0.5, anchorY: 0.5, scaleX: 4, scaleY: 5, tint: 0xFFF3E0 }); var titleText = new Text2(getText('training'), { size: 60, fill: 0xE65100 }); titleText.anchor.set(0.5, 0.5); titleText.y = -800; self.addChild(titleText); // Training stats var attackBar = new TrainingBar(getText('attack'), 0xF44336, 100); attackBar.x = -150; attackBar.y = -500; self.addChild(attackBar); var healthBar = new TrainingBar(getText('health'), 0x4CAF50, 100); healthBar.x = -150; healthBar.y = -400; self.addChild(healthBar); var speedBar = new TrainingBar(getText('speed'), 0x2196F3, 100); speedBar.x = -150; speedBar.y = -300; self.addChild(speedBar); var weightText = new Text2(getText('weight') + ': ' + (pet.weight || 50), { size: 30, fill: 0x795548 }); weightText.anchor.set(0.5, 0.5); weightText.y = -150; self.addChild(weightText); // Training buttons var trainAttackButton = new ActionButton(getText('train') + ' ' + getText('attack'), 0xF44336); trainAttackButton.x = -200; trainAttackButton.y = 100; trainAttackButton.onPress = function () { if (pet.fatigue < 90) { // Check fatigue instead of energy pet.attack = Math.min(100, (pet.attack || 0) + 5); pet.weight = Math.max(20, (pet.weight || 50) - 1); pet.train(); attackBar.updateValue(pet.attack); weightText.setText(getText('weight') + ': ' + pet.weight); storage.money = (storage.money || 0) + 5; LK.getSound('play').play(); } }; self.addChild(trainAttackButton); var trainHealthButton = new ActionButton(getText('train') + ' ' + getText('health'), 0x4CAF50); trainHealthButton.x = 0; trainHealthButton.y = 100; trainHealthButton.onPress = function () { if (pet.fatigue < 90) { // Check fatigue instead of energy pet.health = Math.min(100, (pet.health || 0) + 5); pet.weight = Math.max(20, (pet.weight || 50) - 1); pet.train(); healthBar.updateValue(pet.health); weightText.setText(getText('weight') + ': ' + pet.weight); storage.money = (storage.money || 0) + 5; LK.getSound('play').play(); } }; self.addChild(trainHealthButton); var trainSpeedButton = new ActionButton(getText('train') + ' ' + getText('speed'), 0x2196F3); trainSpeedButton.x = 200; trainSpeedButton.y = 100; trainSpeedButton.onPress = function () { if (pet.fatigue < 90) { // Check fatigue instead of energy pet.speed = Math.min(100, (pet.speed || 0) + 5); pet.weight = Math.max(20, (pet.weight || 50) - 1); pet.train(); speedBar.updateValue(pet.speed); weightText.setText(getText('weight') + ': ' + pet.weight); storage.money = (storage.money || 0) + 5; LK.getSound('play').play(); } }; self.addChild(trainSpeedButton); var closeButton = new ActionButton('X', 0xF44336); closeButton.x = 600; closeButton.y = -800; closeButton.onPress = function () { LK.playMusic('Luna'); gameState = 'game'; game.removeChild(training); }; self.addChild(closeButton); self.updateBars = function () { attackBar.updateValue(pet.attack || 0); healthBar.updateValue(pet.health || 0); speedBar.updateValue(pet.speed || 0); weightText.setText(getText('weight') + ': ' + (pet.weight || 50)); }; return self; }); var TrainingBar = Container.expand(function (label, color, maxValue) { var self = Container.call(this); var background = self.attachAsset('statBar', { anchorX: 0, anchorY: 0.5 }); var fill = self.attachAsset('statFill', { anchorX: 0, anchorY: 0.5, tint: color, scaleX: 0 }); var labelText = new Text2(label, { size: 20, fill: 0x333333 }); labelText.anchor.set(0, 0.5); labelText.x = -80; self.addChild(labelText); var valueText = new Text2('0/' + maxValue, { size: 18, fill: 0x333333 }); valueText.anchor.set(1, 0.5); valueText.x = 320; self.addChild(valueText); self.updateValue = function (value) { var percentage = Math.max(0, Math.min(maxValue, value)) / maxValue; tween(fill, { scaleX: percentage }, { duration: 300, easing: tween.easeOut }); valueText.setText(Math.floor(value) + '/' + maxValue); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xE8F5E8 }); /**** * Game Code ****/ // Game state management var gameState = 'menu'; // 'menu', 'game', 'pause' var gameData = storage.gameData || {}; // Language system var languages = { en: { feed: "Feed", play: "Play", sleep: "Sleep", hunger: "Hunger", happy: "Fun", energy: "Fatigue", evolutionLevel: "Evolution Level", score: "Score", time: "Time", newGame: "New Game", savedGames: "Saved Games", mainMenu: "Main Menu", digimonName: "Digimon Name", chooseEgg: "Choose Your Digi-Egg", money: "Money", shop: "Shop", training: "Training", attack: "Attack", health: "Health", speed: "Speed", defense: "Defense", weight: "Weight", locked: "Locked", buy: "Buy", train: "Train" }, es: { feed: "Alimentar", play: "Jugar", sleep: "Dormir", hunger: "Hambre", happy: "Diversión", energy: "Fatiga", evolutionLevel: "Nivel de Evolución", score: "Puntuación", time: "Tiempo", newGame: "Nuevo Juego", savedGames: "Partidas Guardadas", mainMenu: "Menú Principal", digimonName: "Nombre del Digimon", chooseEgg: "Elige tu Digi-Huevo", money: "Dinero", shop: "Tienda", training: "Entrenamiento", attack: "Ataque", health: "Vida", speed: "Velocidad", defense: "Defensa", weight: "Peso", locked: "Bloqueado", buy: "Comprar", train: "Entrenar" } }; var currentLanguage = storage.currentLanguage || 'en'; function getText(key) { return languages[currentLanguage][key] || key; } function getCurrentDigimonName(eggType, evolutionLevel) { if (evolutionLines[eggType] && evolutionLines[eggType][evolutionLevel]) { return evolutionLines[eggType][evolutionLevel]; } return 'Digimon'; } // Game variables var mainMenu, pet, hungerBar, happinessBar, energyBar, evolutionText; var feedButton, playButton, sleepButton, shopButton, trainingButton; var shop, training; // Evolution lines data var evolutionLines = [ // Line 0: Botamon → WarGreymon (Forest/Nature line) ['Botamon', 'Koromon', 'Agumon', 'Greymon', 'MetalGreymon', 'WarGreymon'], // Line 1: Punimon → MetalGarurumon (Ocean/Water line) ['Punimon', 'Tsunomon', 'Gabumon', 'Garurumon', 'WereGarurumon', 'MetalGarurumon'], // Line 2: Poyomon → Seraphimon (Fire/Dragon line) ['Poyomon', 'Tokomon', 'Patamon', 'Angemon', 'MagnaAngemon', 'Seraphimon'], // Line 3: Poyomon → Ophanimon (Shadow/Dark line) ['Poyomon', 'Tokomon', 'Patamon', 'Angewomon', 'Magnadramon', 'Ophanimon'], // Line 4: Reserved for future (Lightning/Electric line) ['DigiEgg', 'Fresh', 'InTraining', 'Rookie', 'Champion', 'Ultimate'], // Line 5: Reserved for future (Earth/Metal line) ['DigiEgg', 'Fresh', 'InTraining', 'Rookie', 'Champion', 'Ultimate']]; // Initialize money if not exists if (!storage.money) storage.money = 100; function updateAllTexts() { if (gameState === 'game') { // Update action buttons if (playButton) playButton.children[1].setText(getText('play')); if (sleepButton) sleepButton.children[1].setText(getText('sleep')); if (shopButton) shopButton.children[1].setText(getText('shop')); if (trainingButton) trainingButton.children[1].setText(getText('training')); // Update stat bar labels if (hungerBar) hungerBar.updateLabel(getText('hunger')); if (happinessBar) happinessBar.updateLabel(getText('happy')); if (energyBar) energyBar.updateLabel(getText('energy')); // Update evolution text if (evolutionText && pet) evolutionText.setText(getText('evolutionLevel') + ': ' + pet.evolutionLevel); } } function showMainMenu() { gameState = 'menu'; LK.playMusic('menuMusic'); game.removeChildren(); mainMenu = game.addChild(new MainMenu()); } function showEggSelection() { game.removeChildren(); var titleText = new Text2(getText('chooseEgg'), { size: 60, fill: 0x2196F3 }); titleText.anchor.set(0.5, 0.5); titleText.x = 1024; titleText.y = 300; game.addChild(titleText); // Evolution line descriptions var eggDescriptions = ['Botamon Line\nBotamon → WarGreymon\nDragon Warrior', 'Punimon Line\nPunimon → MetalGarurumon\nBeast Knight', 'Poyomon Line\nPoyomon → Seraphimon\nAngel Guardian', 'Poyomon Line\nPoyomon → Ophanimon\nAngel Protector', 'Lightning Line\nElectric • Speed • Energy', 'Earth Line\nRock • Metal • Defense']; // Create 6 eggs (3 unlocked, 3 locked) var eggs = []; for (var i = 0; i < 6; i++) { var isLocked = i >= 3 && (storage.money || 0) < 500 && (storage.completedMissions || 0) < 1; var egg = new DigiEgg(i, isLocked); egg.x = 400 + i % 3 * 400; egg.y = 650 + Math.floor(i / 3) * 400; egg.onSelect = function (eggType) { showDigimonNaming(eggType); }; game.addChild(egg); eggs.push(egg); // Add evolution line description below each egg var lineText = new Text2(eggDescriptions[i], { size: 24, fill: 0x666666 }); lineText.anchor.set(0.5, 0.5); lineText.x = egg.x; lineText.y = egg.y + 150; game.addChild(lineText); } var backButton = new ActionButton(getText('mainMenu'), 0x9E9E9E); backButton.x = 200; backButton.y = 1200; backButton.onPress = function () { showMainMenu(); }; game.addChild(backButton); } function showSavedGames() { game.removeChildren(); var titleText = new Text2(getText('savedGames'), { size: 60, fill: 0x2196F3 }); titleText.anchor.set(0.5, 0.5); titleText.x = 1024; titleText.y = 400; game.addChild(titleText); // Check for saved games var saveCount = storage.saveCount || 0; var savedGames = []; for (var i = 0; i < saveCount; i++) { var petName = storage['save_' + i + '_petName']; if (petName) { var saveData = { petName: petName, evolutionLevel: storage['save_' + i + '_evolutionLevel'] || 0 }; savedGames.push(saveData); } } if (savedGames.length === 0) { var noSavesText = new Text2('No saved games yet', { size: 40, fill: 0x666666 }); noSavesText.anchor.set(0.5, 0.5); noSavesText.x = 1024; noSavesText.y = 600; game.addChild(noSavesText); } else { // Display saved games for (var i = 0; i < savedGames.length && i < 5; i++) { var saveData = savedGames[i]; var saveButton = new ActionButton(saveData.petName + ' (Lv.' + saveData.evolutionLevel + ')', 0x4CAF50); saveButton.x = 1024; saveButton.y = 500 + i * 100; saveButton.saveIndex = i; saveButton.onPress = function () { loadGame(this.saveIndex); }; game.addChild(saveButton); } } var backButton = new ActionButton(getText('mainMenu'), 0x9E9E9E); backButton.x = 1024; backButton.y = 1000; backButton.onPress = function () { showMainMenu(); }; game.addChild(backButton); } function saveGame() { // Get current save count var saveCount = storage.saveCount || 0; // Store save data as individual properties instead of nested object var savePrefix = 'save_' + saveCount + '_'; // Check if save with same name exists and replace it var existingSaveIndex = -1; for (var i = 0; i < saveCount; i++) { var existingName = storage['save_' + i + '_petName']; if (existingName && existingName === pet.name) { existingSaveIndex = i; break; } } if (existingSaveIndex >= 0) { // Replace existing save savePrefix = 'save_' + existingSaveIndex + '_'; } else { // Add new save if (saveCount >= 5) { // Remove oldest save and shift all saves down for (var j = 0; j < 4; j++) { var oldPrefix = 'save_' + (j + 1) + '_'; var newPrefix = 'save_' + j + '_'; storage[newPrefix + 'petName'] = storage[oldPrefix + 'petName']; storage[newPrefix + 'evolutionLevel'] = storage[oldPrefix + 'evolutionLevel']; storage[newPrefix + 'hunger'] = storage[oldPrefix + 'hunger']; storage[newPrefix + 'happiness'] = storage[oldPrefix + 'happiness']; storage[newPrefix + 'fatigue'] = storage[oldPrefix + 'fatigue']; // Changed from energy to fatigue storage[newPrefix + 'attack'] = storage[oldPrefix + 'attack']; storage[newPrefix + 'health'] = storage[oldPrefix + 'health']; storage[newPrefix + 'speed'] = storage[oldPrefix + 'speed']; storage[newPrefix + 'weight'] = storage[oldPrefix + 'weight']; storage[newPrefix + 'eggType'] = storage[oldPrefix + 'eggType']; storage[newPrefix + 'money'] = storage[oldPrefix + 'money']; storage[newPrefix + 'timestamp'] = storage[oldPrefix + 'timestamp']; } savePrefix = 'save_4_'; } else { storage.saveCount = saveCount + 1; } } // Store individual properties storage[savePrefix + 'petName'] = pet.name; storage[savePrefix + 'evolutionLevel'] = pet.evolutionLevel; storage[savePrefix + 'hunger'] = pet.hunger; storage[savePrefix + 'happiness'] = pet.happiness; storage[savePrefix + 'fatigue'] = pet.fatigue; // Changed from energy to fatigue storage[savePrefix + 'attack'] = pet.attack; storage[savePrefix + 'health'] = pet.health; storage[savePrefix + 'speed'] = pet.speed; storage[savePrefix + 'weight'] = pet.weight; storage[savePrefix + 'eggType'] = pet.eggType; storage[savePrefix + 'money'] = storage.money || 0; storage[savePrefix + 'timestamp'] = Date.now(); } function loadGame(saveIndex) { var savePrefix = 'save_' + saveIndex + '_'; var petName = storage[savePrefix + 'petName']; if (petName) { // Load all saved data storage.petName = petName; storage.evolutionLevel = storage[savePrefix + 'evolutionLevel'] || 0; storage.hunger = storage[savePrefix + 'hunger'] || 100; storage.happiness = storage[savePrefix + 'happiness'] || 100; storage.fatigue = storage[savePrefix + 'fatigue'] || 0; // Changed from energy to fatigue storage.attack = storage[savePrefix + 'attack'] || 10; storage.health = storage[savePrefix + 'health'] || 50; storage.speed = storage[savePrefix + 'speed'] || 30; storage.weight = storage[savePrefix + 'weight'] || 50; storage.eggType = storage[savePrefix + 'eggType'] || 0; storage.money = storage[savePrefix + 'money'] || 100; startNewGame(); } } function showDigimonNaming(eggType) { game.removeChildren(); var titleText = new Text2(getText('digimonName') + ' (Max 7 chars)', { size: 60, fill: 0x2196F3 }); titleText.anchor.set(0.5, 0.5); titleText.x = 1024; titleText.y = 300; game.addChild(titleText); // Custom name input system var customName = ''; var nameText = new Text2(customName || 'Enter name...', { size: 50, fill: customName ? 0x333333 : 0x999999 }); nameText.anchor.set(0.5, 0.5); nameText.x = 1024; nameText.y = 500; game.addChild(nameText); // Character input keyboard - organized in 3 rows of 9 letters each var keyboard = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; var keyboardButtons = []; var startX = 250; var startY = 700; var keyWidth = 140; var keyHeight = 90; var keySpacing = 10; for (var i = 0; i < keyboard.length; i++) { var letter = keyboard[i]; var keyButton = new Container(); // Create key background using new asset var keyBg = keyButton.attachAsset('keyboardKey', { anchorX: 0.5, anchorY: 0.5, scaleX: keyWidth / 120, scaleY: keyHeight / 80 }); // Add letter text var keyText = new Text2(letter, { size: 35, fill: 0xFFFFFF }); keyText.anchor.set(0.5, 0.5); keyButton.addChild(keyText); // Position in 3 rows of 9 var row = Math.floor(i / 9); var col = i % 9; keyButton.x = startX + col * (keyWidth + keySpacing); keyButton.y = startY + row * (keyHeight + keySpacing); keyButton.letter = letter; keyButton.down = function (x, y, obj) { tween(this, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100 }); }; keyButton.up = function (x, y, obj) { tween(this, { scaleX: 1, scaleY: 1 }, { duration: 100 }); if (customName.length < 7) { customName += this.letter; nameText.setText(customName); nameText.fill = 0x333333; } }; game.addChild(keyButton); keyboardButtons.push(keyButton); } // Add space and delete buttons with proper spacing var spaceButton = new Container(); var spaceBg = spaceButton.attachAsset('specialKey', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: keyHeight / 80 }); var spaceText = new Text2('SPACE', { size: 30, fill: 0xFFFFFF }); spaceText.anchor.set(0.5, 0.5); spaceButton.addChild(spaceText); spaceButton.x = 700; spaceButton.y = startY + 3 * (keyHeight + keySpacing); spaceButton.down = function (x, y, obj) { tween(this, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100 }); }; spaceButton.up = function (x, y, obj) { tween(this, { scaleX: 1, scaleY: 1 }, { duration: 100 }); if (customName.length < 7 && customName.length > 0) { customName += ' '; nameText.setText(customName); } }; game.addChild(spaceButton); var deleteButton = new Container(); var deleteBg = deleteButton.attachAsset('specialKey', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: keyHeight / 80, tint: 0xF44336 }); var deleteText = new Text2('DELETE', { size: 28, fill: 0xFFFFFF }); deleteText.anchor.set(0.5, 0.5); deleteButton.addChild(deleteText); deleteButton.x = 1100; deleteButton.y = startY + 3 * (keyHeight + keySpacing); deleteButton.down = function (x, y, obj) { tween(this, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100 }); }; deleteButton.up = function (x, y, obj) { tween(this, { scaleX: 1, scaleY: 1 }, { duration: 100 }); if (customName.length > 0) { customName = customName.slice(0, -1); nameText.setText(customName || 'Enter name...'); nameText.fill = customName ? 0x333333 : 0x999999; } }; game.addChild(deleteButton); // Preset name suggestions - positioned below keyboard var presetNames = ['Agumon', 'Gabumon', 'Patamon', 'Palmon', 'Gomamon', 'Biyomon']; var suggestionsText = new Text2('Quick select:', { size: 30, fill: 0x666666 }); suggestionsText.anchor.set(0.5, 0.5); suggestionsText.x = 1024; suggestionsText.y = 1200; game.addChild(suggestionsText); for (var i = 0; i < presetNames.length && i < 3; i++) { var nameButton = new ActionButton(presetNames[i], 0xFF9800); nameButton.x = 600 + i * 250; nameButton.y = 1280; nameButton.nameValue = presetNames[i]; nameButton.onPress = function () { customName = this.nameValue; nameText.setText(customName); nameText.fill = 0x333333; }; game.addChild(nameButton); } var confirmButton = new ActionButton('OK', 0x4CAF50); confirmButton.x = 1024; confirmButton.y = 1450; confirmButton.onPress = function () { if (customName.length > 0) { storage.petName = customName; storage.eggType = eggType; startNewGame(); } }; game.addChild(confirmButton); var backButton = new ActionButton(getText('mainMenu'), 0x9E9E9E); backButton.x = 1024; backButton.y = 1550; backButton.onPress = function () { showEggSelection(); }; game.addChild(backButton); } function startNewGame() { gameState = 'game'; game.removeChildren(); // Clear ALL storage data for a fresh start storage.hunger = 100; storage.happiness = 100; storage.fatigue = 0; storage.evolutionLevel = 0; storage.attack = 10; storage.health = 50; storage.speed = 30; storage.weight = 50; storage.wins = 0; storage.battles = 0; storage.injured = false; storage.sick = false; storage.injuryTime = 0; storage.sickTime = 0; storage.hungerDeathTimer = 0; storage.money = 100; // Initialize starter inventory for new games storage.smallMeat = 10; storage.mediumMeat = 0; storage.largeMeat = 0; storage.sirloin = 0; storage.blessing = 5; storage.medicine = 3; initializeGameplay(); } function initializeGameplay() { // Add background image var background = game.attachAsset('gameBackground', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); // Start game music LK.playMusic('Luna'); // Create pet pet = game.addChild(new DigitalPet()); pet.x = 1024; pet.y = 900; pet.scaleX = 1.5; pet.scaleY = 1.5; // UI Elements - scaled up for mobile hungerBar = new StatBar(getText('hunger'), 0xFF5722, 'hungerIcon'); hungerBar.x = 200; hungerBar.y = 300; hungerBar.scaleX = 1.5; hungerBar.scaleY = 1.5; game.addChild(hungerBar); happinessBar = new StatBar(getText('happy'), 0xFFEB3B, 'funIcon'); happinessBar.x = 200; happinessBar.y = 420; happinessBar.scaleX = 1.5; happinessBar.scaleY = 1.5; game.addChild(happinessBar); energyBar = new StatBar(getText('energy'), 0x2196F3, 'fatigueIcon'); // This will now show "Fatigue" energyBar.x = 200; energyBar.y = 540; energyBar.scaleX = 1.5; energyBar.scaleY = 1.5; game.addChild(energyBar); // Inventory - scaled up and repositioned var inventory = new Inventory(); inventory.x = 200; inventory.y = 1800; inventory.scaleX = 1.8; inventory.scaleY = 1.8; game.addChild(inventory); playButton = new ActionButton(getText('play'), 0xFF9800); playButton.x = 200; playButton.y = 1600; playButton.scaleX = 1.4; playButton.scaleY = 1.4; playButton.onPress = function () { if (pet.fatigue > 80) { // Check if too tired to play LK.effects.flashObject(pet, 0xFF0000, 500); return; } var miniGame = new MiniGame(); miniGame.x = 1024; miniGame.y = 1200; game.addChild(miniGame); miniGame.onGameEnd = function (score) { game.removeChild(miniGame); storage.money = (storage.money || 0) + score; }; miniGame.startGame(); }; game.addChild(playButton); sleepButton = new ActionButton(getText('sleep'), 0x9C27B0); sleepButton.x = 520; sleepButton.y = 1600; sleepButton.scaleX = 1.4; sleepButton.scaleY = 1.4; sleepButton.onPress = function () { pet.fatigue = Math.max(0, pet.fatigue - 30); // Reduce fatigue instead of increasing energy pet.hunger = Math.max(0, pet.hunger - 5); LK.getSound('sleep').play(); tween(pet, { alpha: 0.5 }, { duration: 500, onFinish: function onFinish() { tween(pet, { alpha: 1 }, { duration: 500 }); } }); }; game.addChild(sleepButton); shopButton = new ActionButton(getText('shop'), 0x795548); shopButton.x = 840; shopButton.y = 1600; shopButton.scaleX = 1.4; shopButton.scaleY = 1.4; shopButton.onPress = function () { LK.playMusic('shopMusic'); shop = game.addChild(new Shop()); shop.x = 1024; shop.y = 1366; gameState = 'pause'; }; game.addChild(shopButton); trainingButton = new ActionButton(getText('training'), 0xE65100); trainingButton.x = 1160; trainingButton.y = 1600; trainingButton.scaleX = 1.4; trainingButton.scaleY = 1.4; trainingButton.onPress = function () { LK.playMusic('trainingMusic'); training = game.addChild(new Training()); training.x = 1024; training.y = 1366; training.updateBars(); gameState = 'pause'; }; game.addChild(trainingButton); // Add save game button var saveButton = new ActionButton('Save', 0x607D8B); saveButton.x = 1480; saveButton.y = 1600; saveButton.scaleX = 1.4; saveButton.scaleY = 1.4; saveButton.onPress = function () { if (pet) { saveGame(); LK.effects.flashScreen(0x4CAF50, 500); } }; game.addChild(saveButton); // Evolution display evolutionText = new Text2(getText('evolutionLevel') + ': 0', { size: 60, fill: 0x333333 }); evolutionText.anchor.set(0.5, 0); evolutionText.x = 1024; evolutionText.y = 680; game.addChild(evolutionText); // Current Digimon name display var digimonNameText = new Text2('', { size: 80, fill: 0x2196F3 }); digimonNameText.anchor.set(0.5, 0); digimonNameText.x = 1024; digimonNameText.y = 600; game.addChild(digimonNameText); // Money display var moneyText = new Text2(getText('money') + ': ' + (storage.money || 0), { size: 45, fill: 0x388E3C }); moneyText.anchor.set(0, 0); moneyText.x = 150; moneyText.y = 120; LK.gui.topLeft.addChild(moneyText); updateAllTexts(); } // Language button var languageButton = new LanguageButton(); LK.gui.topRight.addChild(languageButton); languageButton.x = -50; languageButton.y = 50; // Start with main menu showMainMenu(); game.update = function () { if (gameState === 'game' && pet) { // Force pet visibility every frame to fix rendering issue if (pet && pet.children && pet.children.length > 2) { var petBody = pet.children[0]; // The body should be the first child if (petBody) { petBody.visible = true; petBody.alpha = 1; } } // Update stat bars hungerBar.updateValue(pet.hunger); happinessBar.updateValue(pet.happiness); energyBar.updateValue(pet.fatigue); // Use fatigue instead of energy // Update evolution display evolutionText.setText(getText('evolutionLevel') + ': ' + pet.evolutionLevel); // Update current Digimon name display if (game.children[7] && game.children[7].setText) { // digimonNameText is now the 8th child (index 7) due to scaling changes var currentDigimonName = getCurrentDigimonName(pet.eggType, pet.evolutionLevel); game.children[7].setText(currentDigimonName); } // Update money display if (LK.gui.topLeft.children[0]) { LK.gui.topLeft.children[0].setText(getText('money') + ': ' + (storage.money || 0)); } // Warning effects for low stats if (pet.hunger < 20 && LK.ticks % 60 === 0) { LK.effects.flashObject(hungerBar, 0xFF0000, 300); } if (pet.happiness < 20 && LK.ticks % 60 === 0) { LK.effects.flashObject(happinessBar, 0xFF0000, 300); } if (pet.fatigue > 80 && LK.ticks % 60 === 0) { // Warning when fatigue is high LK.effects.flashObject(energyBar, 0xFF0000, 300); } } };
===================================================================
--- original.js
+++ change.js
@@ -240,8 +240,12 @@
body.x = 0;
body.y = 0;
body.alpha = 1;
body.visible = true;
+ // Force the body to be added to the display list properly
+ self.addChildAt(body, 0);
+ // Ensure it stays visible by setting z-index
+ body.zIndex = 1;
}
// Update the pet's display name based on evolution
self.currentDigimonName = getCurrentDigimonName(self.eggType, self.evolutionLevel);
// Enhanced evolution lines with more distinctive progressions
@@ -1548,30 +1552,42 @@
LK.playMusic('Luna');
// Create pet
pet = game.addChild(new DigitalPet());
pet.x = 1024;
- pet.y = 800;
- // UI Elements
+ pet.y = 900;
+ pet.scaleX = 1.5;
+ pet.scaleY = 1.5;
+ // UI Elements - scaled up for mobile
hungerBar = new StatBar(getText('hunger'), 0xFF5722, 'hungerIcon');
- hungerBar.x = 400;
- hungerBar.y = 200;
+ hungerBar.x = 200;
+ hungerBar.y = 300;
+ hungerBar.scaleX = 1.5;
+ hungerBar.scaleY = 1.5;
game.addChild(hungerBar);
happinessBar = new StatBar(getText('happy'), 0xFFEB3B, 'funIcon');
- happinessBar.x = 400;
- happinessBar.y = 280;
+ happinessBar.x = 200;
+ happinessBar.y = 420;
+ happinessBar.scaleX = 1.5;
+ happinessBar.scaleY = 1.5;
game.addChild(happinessBar);
energyBar = new StatBar(getText('energy'), 0x2196F3, 'fatigueIcon'); // This will now show "Fatigue"
- energyBar.x = 400;
- energyBar.y = 360;
+ energyBar.x = 200;
+ energyBar.y = 540;
+ energyBar.scaleX = 1.5;
+ energyBar.scaleY = 1.5;
game.addChild(energyBar);
- // Inventory
+ // Inventory - scaled up and repositioned
var inventory = new Inventory();
- inventory.x = 300;
- inventory.y = 1450;
+ inventory.x = 200;
+ inventory.y = 1800;
+ inventory.scaleX = 1.8;
+ inventory.scaleY = 1.8;
game.addChild(inventory);
playButton = new ActionButton(getText('play'), 0xFF9800);
- playButton.x = 120;
- playButton.y = 1300;
+ playButton.x = 200;
+ playButton.y = 1600;
+ playButton.scaleX = 1.4;
+ playButton.scaleY = 1.4;
playButton.onPress = function () {
if (pet.fatigue > 80) {
// Check if too tired to play
LK.effects.flashObject(pet, 0xFF0000, 500);
@@ -1588,10 +1604,12 @@
miniGame.startGame();
};
game.addChild(playButton);
sleepButton = new ActionButton(getText('sleep'), 0x9C27B0);
- sleepButton.x = 320;
- sleepButton.y = 1300;
+ sleepButton.x = 520;
+ sleepButton.y = 1600;
+ sleepButton.scaleX = 1.4;
+ sleepButton.scaleY = 1.4;
sleepButton.onPress = function () {
pet.fatigue = Math.max(0, pet.fatigue - 30); // Reduce fatigue instead of increasing energy
pet.hunger = Math.max(0, pet.hunger - 5);
LK.getSound('sleep').play();
@@ -1609,10 +1627,12 @@
});
};
game.addChild(sleepButton);
shopButton = new ActionButton(getText('shop'), 0x795548);
- shopButton.x = 520;
- shopButton.y = 1300;
+ shopButton.x = 840;
+ shopButton.y = 1600;
+ shopButton.scaleX = 1.4;
+ shopButton.scaleY = 1.4;
shopButton.onPress = function () {
LK.playMusic('shopMusic');
shop = game.addChild(new Shop());
shop.x = 1024;
@@ -1620,10 +1640,12 @@
gameState = 'pause';
};
game.addChild(shopButton);
trainingButton = new ActionButton(getText('training'), 0xE65100);
- trainingButton.x = 720;
- trainingButton.y = 1300;
+ trainingButton.x = 1160;
+ trainingButton.y = 1600;
+ trainingButton.scaleX = 1.4;
+ trainingButton.scaleY = 1.4;
trainingButton.onPress = function () {
LK.playMusic('trainingMusic');
training = game.addChild(new Training());
training.x = 1024;
@@ -1633,10 +1655,12 @@
};
game.addChild(trainingButton);
// Add save game button
var saveButton = new ActionButton('Save', 0x607D8B);
- saveButton.x = 920;
- saveButton.y = 1300;
+ saveButton.x = 1480;
+ saveButton.y = 1600;
+ saveButton.scaleX = 1.4;
+ saveButton.scaleY = 1.4;
saveButton.onPress = function () {
if (pet) {
saveGame();
LK.effects.flashScreen(0x4CAF50, 500);
@@ -1644,32 +1668,32 @@
};
game.addChild(saveButton);
// Evolution display
evolutionText = new Text2(getText('evolutionLevel') + ': 0', {
- size: 40,
+ size: 60,
fill: 0x333333
});
evolutionText.anchor.set(0.5, 0);
evolutionText.x = 1024;
- evolutionText.y = 600;
+ evolutionText.y = 680;
game.addChild(evolutionText);
// Current Digimon name display
var digimonNameText = new Text2('', {
- size: 50,
+ size: 80,
fill: 0x2196F3
});
digimonNameText.anchor.set(0.5, 0);
digimonNameText.x = 1024;
- digimonNameText.y = 540;
+ digimonNameText.y = 600;
game.addChild(digimonNameText);
// Money display
var moneyText = new Text2(getText('money') + ': ' + (storage.money || 0), {
- size: 30,
+ size: 45,
fill: 0x388E3C
});
moneyText.anchor.set(0, 0);
- moneyText.x = 100;
- moneyText.y = 100;
+ moneyText.x = 150;
+ moneyText.y = 120;
LK.gui.topLeft.addChild(moneyText);
updateAllTexts();
}
// Language button
@@ -1680,19 +1704,27 @@
// Start with main menu
showMainMenu();
game.update = function () {
if (gameState === 'game' && pet) {
+ // Force pet visibility every frame to fix rendering issue
+ if (pet && pet.children && pet.children.length > 2) {
+ var petBody = pet.children[0]; // The body should be the first child
+ if (petBody) {
+ petBody.visible = true;
+ petBody.alpha = 1;
+ }
+ }
// Update stat bars
hungerBar.updateValue(pet.hunger);
happinessBar.updateValue(pet.happiness);
energyBar.updateValue(pet.fatigue); // Use fatigue instead of energy
// Update evolution display
evolutionText.setText(getText('evolutionLevel') + ': ' + pet.evolutionLevel);
// Update current Digimon name display
- if (game.children[6] && game.children[6].setText) {
- // digimonNameText is the 7th child (index 6)
+ if (game.children[7] && game.children[7].setText) {
+ // digimonNameText is now the 8th child (index 7) due to scaling changes
var currentDigimonName = getCurrentDigimonName(pet.eggType, pet.evolutionLevel);
- game.children[6].setText(currentDigimonName);
+ game.children[7].setText(currentDigimonName);
}
// Update money display
if (LK.gui.topLeft.children[0]) {
LK.gui.topLeft.children[0].setText(getText('money') + ': ' + (storage.money || 0));
Bandera de idioma español. In-Game asset. 2d. High contrast. No shadows
Bandera de Idioma inglés curvada con sus primeras letras EN. In-Game asset. 2d. High contrast. No shadows
Planeta tierra con un libro. In-Game asset. 2d. High contrast. No shadows
Pelusa roja de ojos amarillos tierno. In-Game asset. 2d. High contrast. No shadows
Marco de menu con relleno sin ningun texto. In-Game asset. 2d. High contrast. No shadows
Fondo de ambiente digital con azul y verde. In-Game asset. 2d. High contrast. No shadows
Carne pequeña. In-Game asset. 2d. High contrast. No shadows
Carne Grande. In-Game asset. 2d. High contrast. No shadows
Sirloin. In-Game asset. 2d. High contrast. No shadows
Medicina. In-Game asset. 2d. High contrast. No shadows
Benda. In-Game asset. 2d. High contrast. No shadows
Agumon. In-Game asset. 2d. High contrast. No shadows
barra llena. In-Game asset. 2d. High contrast. No shadows
boton sin texto. In-Game asset. 2d. High contrast. No shadows
zzZZZ. In-Game asset. 2d. High contrast. No shadows
Greymon. In-Game asset. 2d. High contrast. No shadows
Wargreymon. In-Game asset. 2d. High contrast. No shadows
Metalgreymon. In-Game asset. 2d. High contrast. No shadows
Omegamon. In-Game asset. 2d. High contrast. No shadows
Cara Koromon feliz. In-Game asset. 2d. High contrast. No shadows
Botamon. In-Game asset. 2d. High contrast. No shadows
Angemon. In-Game asset. 2d. High contrast. No shadows
Angewomon. In-Game asset. 2d. High contrast. No shadows
Gabumon. In-Game asset. 2d. High contrast. No shadows
Garurumon. In-Game asset. 2d. High contrast. No shadows
Magnaangemon. In-Game asset. 2d. High contrast. No shadows
magnadramon. In-Game asset. 2d. High contrast. No shadows
Metalgarurumon. In-Game asset. 2d. High contrast. No shadows
Ophanimon blue armor complete body sensual. In-Game asset. 2d. High contrast. No shadows
Poyomon. In-Game asset. 2d. High contrast. No shadows
Patamon. In-Game asset. 2d. High contrast. No shadows
Punimon. In-Game asset. 2d. High contrast. No shadows
Seraphimon. In-Game asset. 2d. High contrast. No shadows
Tokomon. In-Game asset. 2d. High contrast. No shadows
Tsunomon. In-Game asset. 2d. High contrast. No shadows
Weregarurumon. In-Game asset. 2d. High contrast. No shadows
Digi huevo de botamon. In-Game asset. 2d. High contrast. No shadows
Digi huevo con el patron clasico de Punimon. In-Game asset. 2d. High contrast. No shadows
Digi huevo con el patron clasico de Puyomon. In-Game asset. 2d. High contrast. No shadows
Moneda ojo monstruo. In-Game asset. 2d. High contrast. No shadows
Labrys personaje de Persona 4 Arena con ropa de tendera.. In-Game asset. 2d. High contrast. No shadows
Mesa de tienda para poner un personaje detras. In-Game asset. 2d. High contrast. No shadows
Tecla gris. In-Game asset. 2d. High contrast. No shadows
Caca rosada. In-Game asset. 2d. High contrast. No shadows
Jabón. In-Game asset. 2d. High contrast. No shadows