User prompt
Haz las opciones más pequeñas para que se puedan ver todas
User prompt
Extiende las historias hasta llegar al capítulo 5
User prompt
Extiende las historias y haz más finales
User prompt
Haz el texto narrativo más pequeño
User prompt
Haz los botones y los textos el doble de grandes y más separados entre sí
User prompt
Haz los botones más grandes y más separados entre sí
User prompt
Haz los botones más separados entre sí
User prompt
Haz los textos y los botones más grandes
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage.storyProgress = {' Line Number: 799 ↪💡 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.storyProgress = {' Line Number: 799 ↪💡 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.storyProgress = {' Line Number: 796 ↪💡 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.storyProgress = {' Line Number: 796 ↪💡 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.storyProgress = {' Line Number: 793
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage.storyProgress = {' Line Number: 789 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'chapter')' in or related to this line: 'var chapterText = new Text2(translations[currentLanguage].chapter + ' 1', {' Line Number: 742
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'chapter')' in or related to this line: 'var chapterText = new Text2(translations[currentLanguage].chapter + ' 1', {' Line Number: 742
User prompt
Haz que el juego tenga una opción para cambiarse entre el idioma inglés y el idioma español ↪💡 Consider importing and using the following plugins: @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Choose Your Path
Initial prompt
Un juego del estilo "Decide tu propia aventura" donde el jugador va tomando decisiones a medida que va avanzando en el juego, el jugador se va encontrando con diferentes personajes y va descubriendo la historia del mundo. El juego tiene múltiples finales dependiendo de las decisones que tome el jugador.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { language: "en" }); /**** * Classes ****/ var ChoiceButton = Container.expand(function (text, callback) { var self = Container.call(this); var buttonBg = self.attachAsset('choiceButton', { anchorX: 0.5, anchorY: 0.5 }); var buttonText = new Text2(text, { size: 40, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.isHovered = false; self.callback = callback; self.down = function (x, y, obj) { if (self.callback) { self.callback(); } }; self.setHover = function (hover) { if (hover && !self.isHovered) { self.isHovered = true; tween(buttonBg, { scaleX: 1.1, scaleY: 1.1 }, { duration: 200 }); buttonBg.tint = 0x533483; } else if (!hover && self.isHovered) { self.isHovered = false; tween(buttonBg, { scaleX: 1.0, scaleY: 1.0 }, { duration: 200 }); buttonBg.tint = 0xffffff; } }; return self; }); var ProgressIndicator = Container.expand(function () { var self = Container.call(this); var progressBg = self.attachAsset('progressBar', { anchorX: 0.5, anchorY: 0.5 }); progressBg.alpha = 0.3; var progressFill = self.attachAsset('progressFill', { anchorX: 0, anchorY: 0.5 }); progressFill.x = -800; self.setProgress = function (percentage) { var targetWidth = 1600 * (percentage / 100); tween(progressFill, { width: targetWidth }, { duration: 500 }); }; return self; }); var StoryPanel = Container.expand(function () { var self = Container.call(this); var panelBg = self.attachAsset('textPanel', { anchorX: 0.5, anchorY: 0.5 }); panelBg.alpha = 0.9; var storyText = new Text2('', { size: 45, fill: 0xFFFFFF }); storyText.anchor.set(0.5, 0.5); self.addChild(storyText); self.setText = function (text) { storyText.setText(text); // Wrap text if too long if (storyText.width > 1700) { var words = text.split(' '); var lines = []; var currentLine = ''; for (var i = 0; i < words.length; i++) { var testLine = currentLine + words[i] + ' '; storyText.setText(testLine); if (storyText.width > 1700 && currentLine !== '') { lines.push(currentLine.trim()); currentLine = words[i] + ' '; } else { currentLine = testLine; } } lines.push(currentLine.trim()); storyText.setText(lines.join('\n')); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x0f0f23 }); /**** * Game Code ****/ // Initialize storage with safe defaults if not already set // Translation data if (!storage.storyProgress) { storage.storyProgress = { currentNode: "intro", history: [], visitedNodes: 0 }; } var translations = { en: { chapter: 'Chapter', newStory: 'Start New Story', language: 'Language' }, es: { chapter: 'Capítulo', newStory: 'Nueva Historia', language: 'Idioma' } }; // Story data structure (English) var storyDataEN = { intro: { text: "You wake up in a mysterious forest. The moonlight filters through ancient trees, casting eerie shadows. You hear distant sounds...", choices: [{ text: "Follow the sounds", next: "sounds" }, { text: "Stay hidden and observe", next: "hidden" }, { text: "Climb a tree for better view", next: "climb" }] }, sounds: { text: "You venture toward the sounds and discover a campfire with a hooded figure sitting alone. They look up as you approach.", choices: [{ text: "Greet them peacefully", next: "peaceful" }, { text: "Ask who they are", next: "suspicious" }, { text: "Back away slowly", next: "retreat" }] }, hidden: { text: "From your hiding spot, you observe strange lights dancing between the trees. They seem to pulse with life.", choices: [{ text: "Investigate the lights", next: "lights" }, { text: "Wait longer", next: "wait" }, { text: "Try to find another path", next: "path" }] }, climb: { text: "From the treetop, you see a vast landscape with a distant castle and what appears to be a village below.", choices: [{ text: "Head toward the castle", next: "castle" }, { text: "Go to the village", next: "village" }, { text: "Explore the forest more", next: "explore" }] }, peaceful: { text: "The figure smiles and offers you food. 'Traveler,' they say, 'you seem lost. I can help you find your way.'", choices: [{ text: "Accept their help", next: "accept_help" }, { text: "Politely decline", next: "decline_help" }] }, suspicious: { text: "The figure chuckles. 'I am someone who has been waiting for you. Your destiny calls, but the path is treacherous.'", choices: [{ text: "Ask about your destiny", next: "destiny" }, { text: "Express doubt", next: "doubt" }] }, retreat: { text: "As you back away, you step on a twig. The figure calls out, 'Don't be afraid! I mean no harm!'", choices: [{ text: "Stop and turn around", next: "turn_around" }, { text: "Continue retreating", next: "continue_retreat" }] }, lights: { text: "The lights are magical fireflies that lead you to an ancient shrine. Strange symbols glow on its surface.", choices: [{ text: "Touch the symbols", next: "symbols" }, { text: "Study them first", next: "study" }] }, wait: { text: "After waiting, you see the lights form a path leading deeper into the forest. It seems like an invitation.", choices: [{ text: "Follow the light path", next: "light_path" }, { text: "Ignore it and leave", next: "ignore" }] }, path: { text: "You find a winding path that leads to a crossroads with three different routes marked by stone markers.", choices: [{ text: "Take the left path", next: "left_path" }, { text: "Take the right path", next: "right_path" }] }, castle: { text: "You reach the castle gates. They're open, but darkness lurks within. This could be the end of your journey.", choices: [{ text: "Enter the castle", next: "ending_castle" }, { text: "Turn back", next: "ending_retreat" }] }, village: { text: "In the village, friendly people welcome you. You've found a new home and community.", choices: [{ text: "Stay with the villagers", next: "ending_village" }] }, explore: { text: "Deep in the forest, you discover ancient ruins that hold the secrets of this mysterious world.", choices: [{ text: "Become the guardian", next: "ending_guardian" }] }, accept_help: { text: "With their guidance, you find your way back to civilization and start a new chapter in your life.", choices: [{ text: "Begin your new life", next: "ending_new_life" }] }, decline_help: { text: "You thank them but choose to forge your own path, learning independence and self-reliance.", choices: [{ text: "Continue alone", next: "ending_independent" }] }, destiny: { text: "They reveal you're the chosen one who must save this realm. You accept the responsibility.", choices: [{ text: "Embrace your destiny", next: "ending_hero" }] }, doubt: { text: "Your skepticism proves wise. You discover they were testing your judgment. You pass their test.", choices: [{ text: "Accept their wisdom", next: "ending_wise" }] }, turn_around: { text: "You return and learn they're a helpful spirit guide who leads you to safety.", choices: [{ text: "Follow the spirit", next: "ending_guided" }] }, continue_retreat: { text: "You escape but remain lost in the forest forever, becoming part of its mystery.", choices: [{ text: "Accept your fate", next: "ending_lost" }] }, symbols: { text: "Touching the symbols grants you magical powers. You become a forest protector.", choices: [{ text: "Protect the forest", next: "ending_protector" }] }, study: { text: "Your careful study reveals the shrine's secrets without triggering any traps.", choices: [{ text: "Use the knowledge", next: "ending_scholar" }] }, light_path: { text: "The light path leads you to a realm of eternal beauty where you find true happiness.", choices: [{ text: "Stay in paradise", next: "ending_paradise" }] }, ignore: { text: "You leave the forest but always wonder what could have been. You live with regret.", choices: [{ text: "Live with uncertainty", next: "ending_regret" }] }, left_path: { text: "The left path leads to a hidden treasure that makes you wealthy beyond measure.", choices: [{ text: "Claim the treasure", next: "ending_wealthy" }] }, right_path: { text: "The right path brings you to a wise sage who teaches you the meaning of life.", choices: [{ text: "Learn from the sage", next: "ending_enlightened" }] }, // Endings ending_castle: { text: "You enter the castle and become its new ruler, bringing light to the darkness.", isEnding: true }, ending_retreat: { text: "You choose safety over adventure and return home, valuing caution over curiosity.", isEnding: true }, ending_village: { text: "You find happiness in simple community life, surrounded by friends and purpose.", isEnding: true }, ending_guardian: { text: "You become the eternal guardian of ancient secrets, protecting them for future generations.", isEnding: true }, ending_new_life: { text: "With help from others, you build a successful and fulfilling new life in civilization.", isEnding: true }, ending_independent: { text: "Your self-reliance leads to great personal growth and eventual success on your own terms.", isEnding: true }, ending_hero: { text: "You embrace your role as the chosen one and save the realm, becoming a legendary hero.", isEnding: true }, ending_wise: { text: "Your wisdom and caution are rewarded with knowledge and respect from the mystical beings.", isEnding: true }, ending_guided: { text: "The spirit guide leads you to enlightenment and you become a bridge between worlds.", isEnding: true }, ending_lost: { text: "You become part of the forest's eternal mystery, your story inspiring future travelers.", isEnding: true }, ending_protector: { text: "With magical powers, you protect the forest and its creatures for eternity.", isEnding: true }, ending_scholar: { text: "Your knowledge of the ancient symbols makes you a renowned scholar and historian.", isEnding: true }, ending_paradise: { text: "You find eternal happiness in the magical realm, living in perfect harmony.", isEnding: true }, ending_regret: { text: "You return to normal life but are forever changed by the mysterious encounter.", isEnding: true }, ending_wealthy: { text: "The treasure makes you rich, and you use your wealth to help others find their paths.", isEnding: true }, ending_enlightened: { text: "The sage's wisdom transforms you into a teacher who helps others find meaning.", isEnding: true } }; // Story data structure (Spanish) var storyDataES = { intro: { text: "Despiertas en un bosque misterioso. La luz de la luna se filtra a través de árboles antiguos, creando sombras inquietantes. Escuchas sonidos distantes...", choices: [{ text: "Seguir los sonidos", next: "sounds" }, { text: "Permanecer escondido y observar", next: "hidden" }, { text: "Trepar un árbol para ver mejor", next: "climb" }] }, sounds: { text: "Te aventuras hacia los sonidos y descubres una fogata con una figura encapuchada sentada sola. Te miran cuando te acercas.", choices: [{ text: "Saludarlos pacíficamente", next: "peaceful" }, { text: "Preguntar quiénes son", next: "suspicious" }, { text: "Retroceder lentamente", next: "retreat" }] }, hidden: { text: "Desde tu escondite, observas luces extrañas danzando entre los árboles. Parecen pulsar con vida.", choices: [{ text: "Investigar las luces", next: "lights" }, { text: "Esperar más tiempo", next: "wait" }, { text: "Tratar de encontrar otro camino", next: "path" }] }, climb: { text: "Desde la copa del árbol, ves un vasto paisaje con un castillo distante y lo que parece ser un pueblo abajo.", choices: [{ text: "Dirigirse hacia el castillo", next: "castle" }, { text: "Ir al pueblo", next: "village" }, { text: "Explorar más el bosque", next: "explore" }] }, peaceful: { text: "La figura sonríe y te ofrece comida. 'Viajero,' dice, 'pareces perdido. Puedo ayudarte a encontrar tu camino.'", choices: [{ text: "Aceptar su ayuda", next: "accept_help" }, { text: "Declinar educadamente", next: "decline_help" }] }, suspicious: { text: "La figura se ríe. 'Soy alguien que te ha estado esperando. Tu destino llama, pero el camino es traicionero.'", choices: [{ text: "Preguntar sobre tu destino", next: "destiny" }, { text: "Expresar dudas", next: "doubt" }] }, retreat: { text: "Al retroceder, pisas una rama. La figura grita, '¡No tengas miedo! ¡No pretendo hacerte daño!'", choices: [{ text: "Detenerse y darse la vuelta", next: "turn_around" }, { text: "Continuar retrocediendo", next: "continue_retreat" }] }, lights: { text: "Las luces son luciérnagas mágicas que te llevan a un santuario antiguo. Símbolos extraños brillan en su superficie.", choices: [{ text: "Tocar los símbolos", next: "symbols" }, { text: "Estudiarlos primero", next: "study" }] }, wait: { text: "Después de esperar, ves las luces formar un sendero que lleva más profundo al bosque. Parece una invitación.", choices: [{ text: "Seguir el sendero de luz", next: "light_path" }, { text: "Ignorarlo e irse", next: "ignore" }] }, path: { text: "Encuentras un sendero serpenteante que lleva a un cruce con tres rutas diferentes marcadas por marcadores de piedra.", choices: [{ text: "Tomar el sendero izquierdo", next: "left_path" }, { text: "Tomar el sendero derecho", next: "right_path" }] }, castle: { text: "Llegas a las puertas del castillo. Están abiertas, pero la oscuridad acecha dentro. Este podría ser el final de tu viaje.", choices: [{ text: "Entrar al castillo", next: "ending_castle" }, { text: "Darse la vuelta", next: "ending_retreat" }] }, village: { text: "En el pueblo, gente amigable te da la bienvenida. Has encontrado un nuevo hogar y comunidad.", choices: [{ text: "Quedarse con los aldeanos", next: "ending_village" }] }, explore: { text: "En lo profundo del bosque, descubres ruinas antiguas que guardan los secretos de este mundo misterioso.", choices: [{ text: "Convertirse en el guardián", next: "ending_guardian" }] }, accept_help: { text: "Con su guía, encuentras tu camino de regreso a la civilización y comienzas un nuevo capítulo en tu vida.", choices: [{ text: "Comenzar tu nueva vida", next: "ending_new_life" }] }, decline_help: { text: "Les agradeces pero eliges forjar tu propio camino, aprendiendo independencia y autosuficiencia.", choices: [{ text: "Continuar solo", next: "ending_independent" }] }, destiny: { text: "Te revelan que eres el elegido que debe salvar este reino. Aceptas la responsabilidad.", choices: [{ text: "Abrazar tu destino", next: "ending_hero" }] }, doubt: { text: "Tu escepticismo resulta sabio. Descubres que estaban probando tu juicio. Pasas su prueba.", choices: [{ text: "Aceptar su sabiduría", next: "ending_wise" }] }, turn_around: { text: "Regresas y aprendes que son un espíritu guía útil que te lleva a la seguridad.", choices: [{ text: "Seguir al espíritu", next: "ending_guided" }] }, continue_retreat: { text: "Escapas pero permaneces perdido en el bosque para siempre, convirtiéndote en parte de su misterio.", choices: [{ text: "Aceptar tu destino", next: "ending_lost" }] }, symbols: { text: "Tocar los símbolos te otorga poderes mágicos. Te conviertes en un protector del bosque.", choices: [{ text: "Proteger el bosque", next: "ending_protector" }] }, study: { text: "Tu estudio cuidadoso revela los secretos del santuario sin activar ninguna trampa.", choices: [{ text: "Usar el conocimiento", next: "ending_scholar" }] }, light_path: { text: "El sendero de luz te lleva a un reino de belleza eterna donde encuentras la verdadera felicidad.", choices: [{ text: "Quedarse en el paraíso", next: "ending_paradise" }] }, ignore: { text: "Dejas el bosque pero siempre te preguntas qué podría haber sido. Vives con arrepentimiento.", choices: [{ text: "Vivir con incertidumbre", next: "ending_regret" }] }, left_path: { text: "El sendero izquierdo lleva a un tesoro oculto que te hace rico más allá de toda medida.", choices: [{ text: "Reclamar el tesoro", next: "ending_wealthy" }] }, right_path: { text: "El sendero derecho te lleva a un sabio que te enseña el significado de la vida.", choices: [{ text: "Aprender del sabio", next: "ending_enlightened" }] }, // Endings ending_castle: { text: "Entras al castillo y te conviertes en su nuevo gobernante, trayendo luz a la oscuridad.", isEnding: true }, ending_retreat: { text: "Eliges la seguridad sobre la aventura y regresas a casa, valorando la precaución sobre la curiosidad.", isEnding: true }, ending_village: { text: "Encuentras la felicidad en la vida comunitaria simple, rodeado de amigos y propósito.", isEnding: true }, ending_guardian: { text: "Te conviertes en el guardián eterno de secretos antiguos, protegiéndolos para futuras generaciones.", isEnding: true }, ending_new_life: { text: "Con la ayuda de otros, construyes una nueva vida exitosa y plena en la civilización.", isEnding: true }, ending_independent: { text: "Tu autosuficiencia lleva a un gran crecimiento personal y eventual éxito en tus propios términos.", isEnding: true }, ending_hero: { text: "Abrazas tu papel como el elegido y salvas el reino, convirtiéndote en un héroe legendario.", isEnding: true }, ending_wise: { text: "Tu sabiduría y precaución son recompensadas con conocimiento y respeto de los seres místicos.", isEnding: true }, ending_guided: { text: "El espíritu guía te lleva a la iluminación y te conviertes en un puente entre mundos.", isEnding: true }, ending_lost: { text: "Te conviertes en parte del misterio eterno del bosque, tu historia inspira a futuros viajeros.", isEnding: true }, ending_protector: { text: "Con poderes mágicos, proteges el bosque y sus criaturas por la eternidad.", isEnding: true }, ending_scholar: { text: "Tu conocimiento de los símbolos antiguos te convierte en un erudito e historiador renombrado.", isEnding: true }, ending_paradise: { text: "Encuentras la felicidad eterna en el reino mágico, viviendo en perfecta armonía.", isEnding: true }, ending_regret: { text: "Regresas a la vida normal pero estás para siempre cambiado por el encuentro misterioso.", isEnding: true }, ending_wealthy: { text: "El tesoro te hace rico, y usas tu riqueza para ayudar a otros a encontrar sus caminos.", isEnding: true }, ending_enlightened: { text: "La sabiduría del sabio te transforma en un maestro que ayuda a otros a encontrar significado.", isEnding: true } }; // Language system var currentLanguage = storage.language || 'en'; // Current story data based on language var storyData = currentLanguage === 'es' ? storyDataES : storyDataEN; // Game state var currentStoryNode = 'intro'; var storyHistory = []; var totalNodes = Object.keys(storyData).length; var visitedNodes = 0; // UI Elements var background = game.attachAsset('storyBackground', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 }); var storyPanel = game.addChild(new StoryPanel()); storyPanel.x = 1024; storyPanel.y = 800; var progressIndicator = game.addChild(new ProgressIndicator()); progressIndicator.x = 1024; progressIndicator.y = 150; var choiceButtons = []; // Chapter indicator var chapterText = new Text2(translations[currentLanguage].chapter + ' 1', { size: 50, fill: 0xE94560 }); chapterText.anchor.set(0.5, 0); chapterText.x = 1024; chapterText.y = 200; game.addChild(chapterText); // Language toggle button var languageButton = game.addChild(new ChoiceButton(currentLanguage === 'en' ? 'Español' : 'English', function () { currentLanguage = currentLanguage === 'en' ? 'es' : 'en'; storage.language = currentLanguage; storyData = currentLanguage === 'es' ? storyDataES : storyDataEN; languageButton.children[1].setText(currentLanguage === 'en' ? 'Español' : 'English'); updateProgress(); displayCurrentStory(); })); languageButton.x = 1700; languageButton.y = 100; languageButton.scaleX = 0.6; languageButton.scaleY = 0.6; // Load saved progress var savedProgress = storage.storyProgress || {}; if (savedProgress.currentNode) { currentStoryNode = savedProgress.currentNode; storyHistory = savedProgress.history || []; visitedNodes = savedProgress.visitedNodes || 0; } function updateProgress() { var progressPercentage = visitedNodes / totalNodes * 100; progressIndicator.setProgress(progressPercentage); var chapterNumber = Math.floor(visitedNodes / 3) + 1; chapterText.setText(translations[currentLanguage].chapter + ' ' + chapterNumber); } function clearChoices() { for (var i = 0; i < choiceButtons.length; i++) { choiceButtons[i].destroy(); } choiceButtons = []; } function makeChoice(nextNode) { storyHistory.push(currentStoryNode); currentStoryNode = nextNode; visitedNodes++; // Save progress storage.storyProgress = { currentNode: currentStoryNode, history: storyHistory, visitedNodes: visitedNodes }; updateProgress(); displayCurrentStory(); } function displayCurrentStory() { var storyNode = storyData[currentStoryNode]; // Animate text appearance storyPanel.alpha = 0; storyPanel.setText(storyNode.text); tween(storyPanel, { alpha: 1 }, { duration: 1000 }); clearChoices(); if (storyNode.isEnding) { // Show ending var restartButton = game.addChild(new ChoiceButton(translations[currentLanguage].newStory, function () { // Reset game currentStoryNode = 'intro'; storyHistory = []; visitedNodes = 0; storage.storyProgress = {}; updateProgress(); displayCurrentStory(); })); restartButton.x = 1024; restartButton.y = 1500; choiceButtons.push(restartButton); // Update score based on ending var endingScore = visitedNodes * 10; LK.setScore(endingScore); // Show completion message LK.setTimeout(function () { LK.showYouWin(); }, 2000); } else { // Show choices var choices = storyNode.choices; var startY = 1400; var spacing = 150; for (var i = 0; i < choices.length; i++) { var choice = choices[i]; var button = game.addChild(new ChoiceButton(choice.text, function (nextNode) { return function () { makeChoice(nextNode); }; }(choice.next))); button.x = 1024; button.y = startY + i * spacing; button.alpha = 0; choiceButtons.push(button); // Animate button appearance tween(button, { alpha: 1 }, { duration: 500, easing: tween.easeOut }); } } } // Mouse interaction for button hover effects game.move = function (x, y, obj) { for (var i = 0; i < choiceButtons.length; i++) { var button = choiceButtons[i]; var distance = Math.sqrt(Math.pow(x - button.x, 2) + Math.pow(y - button.y, 2)); button.setHover(distance < 250); } }; // Initialize the game updateProgress(); displayCurrentStory();
===================================================================
--- original.js
+++ change.js