/****
* 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: 60,
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: 65,
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 > 1600) {
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 > 1600 && 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
try {
if (!storage.storyProgress) {
storage.storyProgress = {
currentNode: "intro",
history: [],
visitedNodes: 0
};
}
} catch (e) {
// Fallback if storage is not available
storage = {
storyProgress: {
currentNode: "intro",
history: [],
visitedNodes: 0
},
language: "en"
};
}
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"
}, {
text: "Ask about the treacherous path",
next: "shadow_realm"
}]
},
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"
}, {
text: "Search for a magical grove",
next: "magical_grove"
}, {
text: "Look for crystal caves",
next: "crystal_caves"
}]
},
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
},
// New extended story paths
magical_grove: {
text: "You discover a hidden grove where time moves differently. Ancient trees whisper secrets of past and future.",
choices: [{
text: "Listen to the whispers",
next: "time_whispers"
}, {
text: "Plant a new tree",
next: "plant_tree"
}, {
text: "Meditate in the center",
next: "grove_meditation"
}, {
text: "Touch the temporal nexus",
next: "temporal_nexus"
}]
},
temporal_nexus: {
text: "You touch a swirling portal of temporal energy. Reality fractures around you as you see all possible timelines at once.",
choices: [{
text: "Try to control the timelines",
next: "timeline_master"
}, {
text: "Let yourself drift through time",
next: "time_wanderer"
}, {
text: "Anchor yourself to the present",
next: "present_anchor"
}]
},
timeline_master: {
text: "You grasp the threads of time itself. With great concentration, you learn to weave destiny and reshape reality.",
choices: [{
text: "Become the architect of fate",
next: "fate_architect"
}, {
text: "Create a perfect timeline",
next: "perfect_timeline"
}, {
text: "Restore the natural order",
next: "time_guardian"
}]
},
time_wanderer: {
text: "You drift through countless timelines, experiencing infinite lives and possibilities. Each journey teaches you something new.",
choices: [{
text: "Choose to settle in a peaceful timeline",
next: "peaceful_timeline"
}, {
text: "Continue wandering eternally",
next: "eternal_drifter"
}, {
text: "Gather fragments of all timelines",
next: "timeline_collector"
}]
},
present_anchor: {
text: "You fight against the temporal currents, anchoring yourself to your original timeline. The effort transforms you.",
choices: [{
text: "Become immune to time magic",
next: "time_immune"
}, {
text: "Gain power over temporal storms",
next: "storm_controller"
}, {
text: "Create a safe haven from time",
next: "temporal_sanctuary"
}]
},
fate_architect: {
text: "As master of destiny, you reshape the world according to your vision. Every choice creates ripples across reality.",
choices: [{
text: "Design a world without suffering",
next: "ending_world_designer"
}, {
text: "Create challenges to strengthen souls",
next: "ending_soul_forger"
}]
},
perfect_timeline: {
text: "You craft a timeline where every choice leads to the best possible outcome for everyone.",
choices: [{
text: "Oversee your perfect creation",
next: "ending_perfect_overseer"
}, {
text: "Step back and let it evolve",
next: "ending_humble_creator"
}]
},
time_guardian: {
text: "You become the protector of temporal balance, ensuring no one else disrupts the natural flow of time.",
choices: [{
text: "Guard time eternally",
next: "ending_eternal_sentinel"
}, {
text: "Train others to share the burden",
next: "ending_time_academy"
}]
},
peaceful_timeline: {
text: "You find a timeline of eternal peace and harmony, where conflicts are resolved through understanding.",
choices: [{
text: "Become an ambassador of peace",
next: "ending_peace_ambassador"
}, {
text: "Protect this peaceful world",
next: "ending_peace_guardian"
}]
},
eternal_drifter: {
text: "You choose to wander through time forever, becoming a legend whispered across all timelines.",
choices: [{
text: "Guide lost souls across time",
next: "ending_temporal_guide"
}, {
text: "Record the stories of all timelines",
next: "ending_infinite_chronicler"
}]
},
timeline_collector: {
text: "You gather the best aspects from every timeline, creating a unique perspective on existence.",
choices: [{
text: "Share these collected wisdoms",
next: "ending_wisdom_synthesizer"
}, {
text: "Use the knowledge to help others",
next: "ending_multiversal_helper"
}]
},
time_immune: {
text: "Your immunity to temporal effects makes you a beacon of stability in an ever-changing universe.",
choices: [{
text: "Help others resist time magic",
next: "ending_stability_teacher"
}, {
text: "Explore realms beyond time",
next: "ending_beyond_time"
}]
},
storm_controller: {
text: "You command the chaotic forces that tear through time, directing them with precision and wisdom.",
choices: [{
text: "Use storms to heal temporal wounds",
next: "ending_temporal_healer"
}, {
text: "Create new realities from chaos",
next: "ending_chaos_weaver"
}]
},
temporal_sanctuary: {
text: "Your sanctuary becomes a refuge for those displaced by temporal accidents and time magic.",
choices: [{
text: "Welcome all temporal refugees",
next: "ending_sanctuary_keeper"
}, {
text: "Build a community outside time",
next: "ending_timeless_founder"
}]
},
time_whispers: {
text: "The whispers reveal visions of possible futures. You see yourself in different roles across time.",
choices: [{
text: "Choose the path of the healer",
next: "ending_healer"
}, {
text: "Choose the path of the inventor",
next: "ending_inventor"
}, {
text: "Choose to remain a wanderer",
next: "ending_eternal_wanderer"
}]
},
plant_tree: {
text: "Your planted tree grows instantly, creating a bridge between realms. You become its caretaker.",
choices: [{
text: "Tend the bridge tree",
next: "ending_bridge_keeper"
}, {
text: "Travel between realms",
next: "ending_realm_traveler"
}]
},
grove_meditation: {
text: "Deep meditation reveals your true purpose. You understand the balance of all things.",
choices: [{
text: "Become a balance keeper",
next: "ending_balance_keeper"
}, {
text: "Share this wisdom",
next: "ending_wisdom_spreader"
}]
},
crystal_caves: {
text: "You find crystalline caves that sing with harmonic frequencies. Each crystal holds memories.",
choices: [{
text: "Touch the memory crystals",
next: "memory_crystals"
}, {
text: "Create new harmonies",
next: "crystal_music"
}, {
text: "Take a crystal as companion",
next: "crystal_companion"
}]
},
memory_crystals: {
text: "The crystals show you memories of all who came before. You understand the cycle of life.",
choices: [{
text: "Preserve these memories",
next: "ending_memory_keeper"
}, {
text: "Add your own memories",
next: "ending_legacy_weaver"
}]
},
crystal_music: {
text: "Your music with the crystals creates beautiful melodies that heal hearts across the land.",
choices: [{
text: "Become a crystal musician",
next: "ending_crystal_bard"
}, {
text: "Teach others this music",
next: "ending_harmony_teacher"
}]
},
crystal_companion: {
text: "The crystal becomes your lifelong companion, guiding you on adventures across many worlds.",
choices: [{
text: "Explore new worlds together",
next: "ending_world_explorer"
}, {
text: "Return home with wisdom",
next: "ending_transformed_return"
}]
},
shadow_realm: {
text: "You slip into a realm of shadows where your fears take physical form, but so does your courage.",
choices: [{
text: "Face your fears directly",
next: "confront_fears"
}, {
text: "Befriend the shadows",
next: "shadow_alliance"
}, {
text: "Use courage to light the way",
next: "courage_light"
}]
},
confront_fears: {
text: "By facing your fears, you transform them into strengths. You become fearless.",
choices: [{
text: "Help others face their fears",
next: "ending_fear_helper"
}, {
text: "Become a shadow warrior",
next: "ending_shadow_warrior"
}]
},
shadow_alliance: {
text: "The shadows become your allies, teaching you to see truth hidden in darkness.",
choices: [{
text: "Become a truth seeker",
next: "ending_truth_seeker"
}, {
text: "Master shadow magic",
next: "ending_shadow_mage"
}]
},
courage_light: {
text: "Your courage creates light that banishes the shadow realm's darkness forever.",
choices: [{
text: "Become a light bringer",
next: "ending_light_bringer"
}, {
text: "Guard against future darkness",
next: "ending_darkness_sentinel"
}]
},
// New endings
ending_healer: {
text: "You become a legendary healer, using time magic to cure ailments across all ages.",
isEnding: true
},
ending_inventor: {
text: "Your inventions, inspired by time's wisdom, revolutionize the world and solve great problems.",
isEnding: true
},
ending_eternal_wanderer: {
text: "You choose the path of eternal wandering, experiencing infinite adventures across time.",
isEnding: true
},
ending_bridge_keeper: {
text: "As keeper of the bridge tree, you maintain peace between different realms forever.",
isEnding: true
},
ending_realm_traveler: {
text: "You become an interdimensional traveler, bringing knowledge and hope to countless worlds.",
isEnding: true
},
ending_balance_keeper: {
text: "You maintain the cosmic balance, ensuring harmony between all forces of nature.",
isEnding: true
},
ending_wisdom_spreader: {
text: "You travel the world sharing the grove's wisdom, enlightening all who listen.",
isEnding: true
},
ending_memory_keeper: {
text: "You become the eternal keeper of memories, preserving the stories of all living beings.",
isEnding: true
},
ending_legacy_weaver: {
text: "You weave new stories into the crystal memories, ensuring future generations learn from the past.",
isEnding: true
},
ending_crystal_bard: {
text: "Your crystal music becomes legendary, healing hearts and inspiring love wherever you go.",
isEnding: true
},
ending_harmony_teacher: {
text: "You establish a school of crystal harmony, teaching others to heal the world through music.",
isEnding: true
},
ending_world_explorer: {
text: "With your crystal companion, you discover infinite worlds and become a multiversal adventurer.",
isEnding: true
},
ending_transformed_return: {
text: "You return home transformed, using your crystal's wisdom to improve your original world.",
isEnding: true
},
ending_fear_helper: {
text: "You dedicate your life to helping others overcome their fears, becoming a beacon of courage.",
isEnding: true
},
ending_shadow_warrior: {
text: "You become a warrior who fights darkness wherever it threatens innocent lives.",
isEnding: true
},
ending_truth_seeker: {
text: "You devote yourself to uncovering hidden truths, exposing lies and bringing justice.",
isEnding: true
},
ending_shadow_mage: {
text: "You master shadow magic, using it to protect the innocent and maintain cosmic balance.",
isEnding: true
},
ending_light_bringer: {
text: "You become a bringer of light, illuminating dark places and bringing hope to the hopeless.",
isEnding: true
},
ending_darkness_sentinel: {
text: "You stand eternal guard against darkness, ensuring shadow realms never threaten the world again.",
isEnding: true
},
// Chapter 5 endings - Time and Multiverse
ending_world_designer: {
text: "You become the architect of reality itself, designing worlds where every being can find happiness and purpose.",
isEnding: true
},
ending_soul_forger: {
text: "You create meaningful challenges that help souls grow stronger, becoming the ultimate teacher through experience.",
isEnding: true
},
ending_perfect_overseer: {
text: "You watch over your perfect timeline, making subtle adjustments to maintain eternal harmony.",
isEnding: true
},
ending_humble_creator: {
text: "Your perfect creation evolves beyond your imagination, proving that the best art comes from letting go.",
isEnding: true
},
ending_eternal_sentinel: {
text: "You become the eternal guardian of time itself, ensuring the natural flow of cause and effect.",
isEnding: true
},
ending_time_academy: {
text: "You establish an academy that trains temporal guardians, ensuring time will always be protected.",
isEnding: true
},
ending_peace_ambassador: {
text: "You become a legendary peacemaker, traveling between timelines to resolve conflicts with wisdom.",
isEnding: true
},
ending_peace_guardian: {
text: "You dedicate yourself to protecting the peaceful timeline, ensuring it remains a sanctuary for all.",
isEnding: true
},
ending_temporal_guide: {
text: "You become a legendary guide who helps lost souls find their way through the maze of time.",
isEnding: true
},
ending_infinite_chronicler: {
text: "You record the infinite stories of all timelines, becoming the ultimate keeper of universal history.",
isEnding: true
},
ending_wisdom_synthesizer: {
text: "You synthesize the wisdom of infinite timelines, becoming the greatest teacher in all realities.",
isEnding: true
},
ending_multiversal_helper: {
text: "You use your knowledge of all timelines to help beings across the multiverse achieve their potential.",
isEnding: true
},
ending_stability_teacher: {
text: "You teach others to resist temporal chaos, becoming the anchor that keeps reality stable.",
isEnding: true
},
ending_beyond_time: {
text: "You transcend time itself, exploring dimensions and realities that exist beyond temporal concepts.",
isEnding: true
},
ending_temporal_healer: {
text: "You use temporal storms to heal wounds in time itself, mending broken timelines and lost histories.",
isEnding: true
},
ending_chaos_weaver: {
text: "You master the art of creating order from chaos, building new realities from temporal fragments.",
isEnding: true
},
ending_sanctuary_keeper: {
text: "Your sanctuary becomes a beacon of hope for all displaced by time, offering shelter and new beginnings.",
isEnding: true
},
ending_timeless_founder: {
text: "You build a community that exists outside time, where beings from all eras live together in harmony.",
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"
}, {
text: "Preguntar sobre el camino traicionero",
next: "shadow_realm"
}]
},
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"
}, {
text: "Buscar un bosque mágico",
next: "magical_grove"
}, {
text: "Buscar cuevas de cristal",
next: "crystal_caves"
}]
},
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
},
// Nuevos caminos de historia extendidos
magical_grove: {
text: "Descubres un bosque oculto donde el tiempo se mueve diferente. Árboles antiguos susurran secretos del pasado y futuro.",
choices: [{
text: "Escuchar los susurros",
next: "time_whispers"
}, {
text: "Plantar un nuevo árbol",
next: "plant_tree"
}, {
text: "Meditar en el centro",
next: "grove_meditation"
}, {
text: "Tocar el nexo temporal",
next: "temporal_nexus"
}]
},
temporal_nexus: {
text: "Tocas un portal giratorio de energía temporal. La realidad se fractura a tu alrededor mientras ves todas las líneas temporales posibles a la vez.",
choices: [{
text: "Intentar controlar las líneas temporales",
next: "timeline_master"
}, {
text: "Dejarte llevar a través del tiempo",
next: "time_wanderer"
}, {
text: "Anclarte al presente",
next: "present_anchor"
}]
},
timeline_master: {
text: "Capturas los hilos del tiempo mismo. Con gran concentración, aprendes a tejer el destino y remodelar la realidad.",
choices: [{
text: "Convertirte en el arquitecto del destino",
next: "fate_architect"
}, {
text: "Crear una línea temporal perfecta",
next: "perfect_timeline"
}, {
text: "Restaurar el orden natural",
next: "time_guardian"
}]
},
time_wanderer: {
text: "Derivas a través de innumerables líneas temporales, experimentando vidas infinitas y posibilidades. Cada viaje te enseña algo nuevo.",
choices: [{
text: "Elegir establecerte en una línea temporal pacífica",
next: "peaceful_timeline"
}, {
text: "Continuar vagando eternamente",
next: "eternal_drifter"
}, {
text: "Reunir fragmentos de todas las líneas temporales",
next: "timeline_collector"
}]
},
present_anchor: {
text: "Luchas contra las corrientes temporales, anclándote a tu línea temporal original. El esfuerzo te transforma.",
choices: [{
text: "Volverte inmune a la magia del tiempo",
next: "time_immune"
}, {
text: "Ganar poder sobre las tormentas temporales",
next: "storm_controller"
}, {
text: "Crear un refugio seguro del tiempo",
next: "temporal_sanctuary"
}]
},
fate_architect: {
text: "Como maestro del destino, remoldeas el mundo según tu visión. Cada elección crea ondas a través de la realidad.",
choices: [{
text: "Diseñar un mundo sin sufrimiento",
next: "ending_world_designer"
}, {
text: "Crear desafíos para fortalecer las almas",
next: "ending_soul_forger"
}]
},
perfect_timeline: {
text: "Creas una línea temporal donde cada elección lleva al mejor resultado posible para todos.",
choices: [{
text: "Supervisar tu creación perfecta",
next: "ending_perfect_overseer"
}, {
text: "Retroceder y dejar que evolucione",
next: "ending_humble_creator"
}]
},
time_guardian: {
text: "Te conviertes en el protector del equilibrio temporal, asegurando que nadie más perturbe el flujo natural del tiempo.",
choices: [{
text: "Guardar el tiempo eternamente",
next: "ending_eternal_sentinel"
}, {
text: "Entrenar a otros para compartir la carga",
next: "ending_time_academy"
}]
},
peaceful_timeline: {
text: "Encuentras una línea temporal de paz eterna y armonía, donde los conflictos se resuelven a través del entendimiento.",
choices: [{
text: "Convertirte en un embajador de la paz",
next: "ending_peace_ambassador"
}, {
text: "Proteger este mundo pacífico",
next: "ending_peace_guardian"
}]
},
eternal_drifter: {
text: "Eliges vagar por el tiempo para siempre, convirtiéndote en una leyenda susurrada a través de todas las líneas temporales.",
choices: [{
text: "Guiar almas perdidas a través del tiempo",
next: "ending_temporal_guide"
}, {
text: "Registrar las historias de todas las líneas temporales",
next: "ending_infinite_chronicler"
}]
},
timeline_collector: {
text: "Reúnes los mejores aspectos de cada línea temporal, creando una perspectiva única sobre la existencia.",
choices: [{
text: "Compartir estas sabidurías recolectadas",
next: "ending_wisdom_synthesizer"
}, {
text: "Usar el conocimiento para ayudar a otros",
next: "ending_multiversal_helper"
}]
},
time_immune: {
text: "Tu inmunidad a los efectos temporales te convierte en un faro de estabilidad en un universo en constante cambio.",
choices: [{
text: "Ayudar a otros a resistir la magia del tiempo",
next: "ending_stability_teacher"
}, {
text: "Explorar reinos más allá del tiempo",
next: "ending_beyond_time"
}]
},
storm_controller: {
text: "Comandas las fuerzas caóticas que desgarran el tiempo, dirigiéndolas con precisión y sabiduría.",
choices: [{
text: "Usar tormentas para sanar heridas temporales",
next: "ending_temporal_healer"
}, {
text: "Crear nuevas realidades del caos",
next: "ending_chaos_weaver"
}]
},
temporal_sanctuary: {
text: "Tu santuario se convierte en un refugio para aquellos desplazados por accidentes temporales y magia del tiempo.",
choices: [{
text: "Dar la bienvenida a todos los refugiados temporales",
next: "ending_sanctuary_keeper"
}, {
text: "Construir una comunidad fuera del tiempo",
next: "ending_timeless_founder"
}]
},
time_whispers: {
text: "Los susurros revelan visiones de futuros posibles. Te ves a ti mismo en diferentes roles a través del tiempo.",
choices: [{
text: "Elegir el camino del curandero",
next: "ending_healer"
}, {
text: "Elegir el camino del inventor",
next: "ending_inventor"
}, {
text: "Elegir seguir siendo un vagabundo",
next: "ending_eternal_wanderer"
}]
},
plant_tree: {
text: "Tu árbol plantado crece instantáneamente, creando un puente entre reinos. Te conviertes en su cuidador.",
choices: [{
text: "Cuidar el árbol puente",
next: "ending_bridge_keeper"
}, {
text: "Viajar entre reinos",
next: "ending_realm_traveler"
}]
},
grove_meditation: {
text: "La meditación profunda revela tu verdadero propósito. Entiendes el equilibrio de todas las cosas.",
choices: [{
text: "Convertirse en guardián del equilibrio",
next: "ending_balance_keeper"
}, {
text: "Compartir esta sabiduría",
next: "ending_wisdom_spreader"
}]
},
crystal_caves: {
text: "Encuentras cuevas cristalinas que cantan con frecuencias armónicas. Cada cristal guarda memorias.",
choices: [{
text: "Tocar los cristales de memoria",
next: "memory_crystals"
}, {
text: "Crear nuevas armonías",
next: "crystal_music"
}, {
text: "Tomar un cristal como compañero",
next: "crystal_companion"
}]
},
memory_crystals: {
text: "Los cristales te muestran memorias de todos los que vinieron antes. Entiendes el ciclo de la vida.",
choices: [{
text: "Preservar estas memorias",
next: "ending_memory_keeper"
}, {
text: "Añadir tus propias memorias",
next: "ending_legacy_weaver"
}]
},
crystal_music: {
text: "Tu música con los cristales crea melodías hermosas que sanan corazones a través de la tierra.",
choices: [{
text: "Convertirse en músico de cristal",
next: "ending_crystal_bard"
}, {
text: "Enseñar esta música a otros",
next: "ending_harmony_teacher"
}]
},
crystal_companion: {
text: "El cristal se convierte en tu compañero de vida, guiándote en aventuras a través de muchos mundos.",
choices: [{
text: "Explorar nuevos mundos juntos",
next: "ending_world_explorer"
}, {
text: "Regresar a casa con sabiduría",
next: "ending_transformed_return"
}]
},
shadow_realm: {
text: "Te deslizas a un reino de sombras donde tus miedos toman forma física, pero también tu valor.",
choices: [{
text: "Enfrentar tus miedos directamente",
next: "confront_fears"
}, {
text: "Hacer amistad con las sombras",
next: "shadow_alliance"
}, {
text: "Usar valor para iluminar el camino",
next: "courage_light"
}]
},
confront_fears: {
text: "Al enfrentar tus miedos, los transformas en fortalezas. Te vuelves intrépido.",
choices: [{
text: "Ayudar a otros a enfrentar sus miedos",
next: "ending_fear_helper"
}, {
text: "Convertirse en guerrero de las sombras",
next: "ending_shadow_warrior"
}]
},
shadow_alliance: {
text: "Las sombras se vuelven tus aliadas, enseñándote a ver la verdad oculta en la oscuridad.",
choices: [{
text: "Convertirse en buscador de la verdad",
next: "ending_truth_seeker"
}, {
text: "Dominar la magia de las sombras",
next: "ending_shadow_mage"
}]
},
courage_light: {
text: "Tu valor crea luz que destierra la oscuridad del reino de las sombras para siempre.",
choices: [{
text: "Convertirse en portador de luz",
next: "ending_light_bringer"
}, {
text: "Proteger contra futuras oscuridades",
next: "ending_darkness_sentinel"
}]
},
// Nuevos finales
ending_healer: {
text: "Te conviertes en un curandero legendario, usando magia del tiempo para curar dolencias en todas las edades.",
isEnding: true
},
ending_inventor: {
text: "Tus inventos, inspirados por la sabiduría del tiempo, revolucionan el mundo y resuelven grandes problemas.",
isEnding: true
},
ending_eternal_wanderer: {
text: "Eliges el camino del vagabundeo eterno, experimentando aventuras infinitas a través del tiempo.",
isEnding: true
},
ending_bridge_keeper: {
text: "Como guardián del árbol puente, mantienes la paz entre diferentes reinos para siempre.",
isEnding: true
},
ending_realm_traveler: {
text: "Te conviertes en un viajero interdimensional, llevando conocimiento y esperanza a mundos incontables.",
isEnding: true
},
ending_balance_keeper: {
text: "Mantienes el equilibrio cósmico, asegurando armonía entre todas las fuerzas de la naturaleza.",
isEnding: true
},
ending_wisdom_spreader: {
text: "Viajas por el mundo compartiendo la sabiduría del bosque, iluminando a todos los que escuchan.",
isEnding: true
},
ending_memory_keeper: {
text: "Te conviertes en el guardián eterno de memorias, preservando las historias de todos los seres vivos.",
isEnding: true
},
ending_legacy_weaver: {
text: "Tejes nuevas historias en las memorias de cristal, asegurando que futuras generaciones aprendan del pasado.",
isEnding: true
},
ending_crystal_bard: {
text: "Tu música de cristal se vuelve legendaria, sanando corazones e inspirando amor dondequiera que vayas.",
isEnding: true
},
ending_harmony_teacher: {
text: "Estableces una escuela de armonía cristalina, enseñando a otros a sanar el mundo a través de la música.",
isEnding: true
},
ending_world_explorer: {
text: "Con tu compañero de cristal, descubres mundos infinitos y te conviertes en un aventurero multiversal.",
isEnding: true
},
ending_transformed_return: {
text: "Regresas a casa transformado, usando la sabiduría de tu cristal para mejorar tu mundo original.",
isEnding: true
},
ending_fear_helper: {
text: "Dedicas tu vida a ayudar a otros a superar sus miedos, convirtiéndote en un faro de valor.",
isEnding: true
},
ending_shadow_warrior: {
text: "Te conviertes en un guerrero que lucha contra la oscuridad dondequiera que amenace vidas inocentes.",
isEnding: true
},
ending_truth_seeker: {
text: "Te dedicas a descubrir verdades ocultas, exponiendo mentiras y trayendo justicia.",
isEnding: true
},
ending_shadow_mage: {
text: "Dominas la magia de las sombras, usándola para proteger a los inocentes y mantener el equilibrio cósmico.",
isEnding: true
},
ending_light_bringer: {
text: "Te conviertes en un portador de luz, iluminando lugares oscuros y trayendo esperanza a los sin esperanza.",
isEnding: true
},
ending_darkness_sentinel: {
text: "Te conviertes en guardián eterno contra la oscuridad, asegurando que los reinos sombríos nunca amenacen el mundo otra vez.",
isEnding: true
},
// Finales del Capítulo 5 - Tiempo y Multiverso
ending_world_designer: {
text: "Te conviertes en el arquitecto de la realidad misma, diseñando mundos donde cada ser puede encontrar felicidad y propósito.",
isEnding: true
},
ending_soul_forger: {
text: "Creas desafíos significativos que ayudan a las almas a crecer más fuertes, convirtiéndote en el maestro definitivo a través de la experiencia.",
isEnding: true
},
ending_perfect_overseer: {
text: "Vigilas tu línea temporal perfecta, haciendo ajustes sutiles para mantener la armonía eterna.",
isEnding: true
},
ending_humble_creator: {
text: "Tu creación perfecta evoluciona más allá de tu imaginación, demostrando que el mejor arte viene de soltar el control.",
isEnding: true
},
ending_eternal_sentinel: {
text: "Te conviertes en el guardián eterno del tiempo mismo, asegurando el flujo natural de causa y efecto.",
isEnding: true
},
ending_time_academy: {
text: "Estableces una academia que entrena guardianes temporales, asegurando que el tiempo siempre esté protegido.",
isEnding: true
},
ending_peace_ambassador: {
text: "Te conviertes en un pacificador legendario, viajando entre líneas temporales para resolver conflictos con sabiduría.",
isEnding: true
},
ending_peace_guardian: {
text: "Te dedicas a proteger la línea temporal pacífica, asegurando que permanezca como un santuario para todos.",
isEnding: true
},
ending_temporal_guide: {
text: "Te conviertes en un guía legendario que ayuda a las almas perdidas a encontrar su camino a través del laberinto del tiempo.",
isEnding: true
},
ending_infinite_chronicler: {
text: "Registras las historias infinitas de todas las líneas temporales, convirtiéndote en el guardián definitivo de la historia universal.",
isEnding: true
},
ending_wisdom_synthesizer: {
text: "Sintetizas la sabiduría de líneas temporales infinitas, convirtiéndote en el mayor maestro en todas las realidades.",
isEnding: true
},
ending_multiversal_helper: {
text: "Usas tu conocimiento de todas las líneas temporales para ayudar a los seres a través del multiverso a alcanzar su potencial.",
isEnding: true
},
ending_stability_teacher: {
text: "Enseñas a otros a resistir el caos temporal, convirtiéndote en el ancla que mantiene estable la realidad.",
isEnding: true
},
ending_beyond_time: {
text: "Trasciendes el tiempo mismo, explorando dimensiones y realidades que existen más allá de los conceptos temporales.",
isEnding: true
},
ending_temporal_healer: {
text: "Usas tormentas temporales para sanar heridas en el tiempo mismo, reparando líneas temporales rotas e historias perdidas.",
isEnding: true
},
ending_chaos_weaver: {
text: "Dominas el arte de crear orden del caos, construyendo nuevas realidades a partir de fragmentos temporales.",
isEnding: true
},
ending_sanctuary_keeper: {
text: "Tu santuario se convierte en un faro de esperanza para todos los desplazados por el tiempo, ofreciendo refugio y nuevos comienzos.",
isEnding: true
},
ending_timeless_founder: {
text: "Construyes una comunidad que existe fuera del tiempo, donde seres de todas las eras viven juntos en armonía.",
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: 140,
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
try {
storage.storyProgress = {
currentNode: currentStoryNode,
history: storyHistory,
visitedNodes: visitedNodes
};
} catch (e) {
console.log("Storage error:", e);
}
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 = 1200;
var spacing = 250;
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(); /****
* 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: 60,
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: 65,
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 > 1600) {
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 > 1600 && 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
try {
if (!storage.storyProgress) {
storage.storyProgress = {
currentNode: "intro",
history: [],
visitedNodes: 0
};
}
} catch (e) {
// Fallback if storage is not available
storage = {
storyProgress: {
currentNode: "intro",
history: [],
visitedNodes: 0
},
language: "en"
};
}
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"
}, {
text: "Ask about the treacherous path",
next: "shadow_realm"
}]
},
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"
}, {
text: "Search for a magical grove",
next: "magical_grove"
}, {
text: "Look for crystal caves",
next: "crystal_caves"
}]
},
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
},
// New extended story paths
magical_grove: {
text: "You discover a hidden grove where time moves differently. Ancient trees whisper secrets of past and future.",
choices: [{
text: "Listen to the whispers",
next: "time_whispers"
}, {
text: "Plant a new tree",
next: "plant_tree"
}, {
text: "Meditate in the center",
next: "grove_meditation"
}, {
text: "Touch the temporal nexus",
next: "temporal_nexus"
}]
},
temporal_nexus: {
text: "You touch a swirling portal of temporal energy. Reality fractures around you as you see all possible timelines at once.",
choices: [{
text: "Try to control the timelines",
next: "timeline_master"
}, {
text: "Let yourself drift through time",
next: "time_wanderer"
}, {
text: "Anchor yourself to the present",
next: "present_anchor"
}]
},
timeline_master: {
text: "You grasp the threads of time itself. With great concentration, you learn to weave destiny and reshape reality.",
choices: [{
text: "Become the architect of fate",
next: "fate_architect"
}, {
text: "Create a perfect timeline",
next: "perfect_timeline"
}, {
text: "Restore the natural order",
next: "time_guardian"
}]
},
time_wanderer: {
text: "You drift through countless timelines, experiencing infinite lives and possibilities. Each journey teaches you something new.",
choices: [{
text: "Choose to settle in a peaceful timeline",
next: "peaceful_timeline"
}, {
text: "Continue wandering eternally",
next: "eternal_drifter"
}, {
text: "Gather fragments of all timelines",
next: "timeline_collector"
}]
},
present_anchor: {
text: "You fight against the temporal currents, anchoring yourself to your original timeline. The effort transforms you.",
choices: [{
text: "Become immune to time magic",
next: "time_immune"
}, {
text: "Gain power over temporal storms",
next: "storm_controller"
}, {
text: "Create a safe haven from time",
next: "temporal_sanctuary"
}]
},
fate_architect: {
text: "As master of destiny, you reshape the world according to your vision. Every choice creates ripples across reality.",
choices: [{
text: "Design a world without suffering",
next: "ending_world_designer"
}, {
text: "Create challenges to strengthen souls",
next: "ending_soul_forger"
}]
},
perfect_timeline: {
text: "You craft a timeline where every choice leads to the best possible outcome for everyone.",
choices: [{
text: "Oversee your perfect creation",
next: "ending_perfect_overseer"
}, {
text: "Step back and let it evolve",
next: "ending_humble_creator"
}]
},
time_guardian: {
text: "You become the protector of temporal balance, ensuring no one else disrupts the natural flow of time.",
choices: [{
text: "Guard time eternally",
next: "ending_eternal_sentinel"
}, {
text: "Train others to share the burden",
next: "ending_time_academy"
}]
},
peaceful_timeline: {
text: "You find a timeline of eternal peace and harmony, where conflicts are resolved through understanding.",
choices: [{
text: "Become an ambassador of peace",
next: "ending_peace_ambassador"
}, {
text: "Protect this peaceful world",
next: "ending_peace_guardian"
}]
},
eternal_drifter: {
text: "You choose to wander through time forever, becoming a legend whispered across all timelines.",
choices: [{
text: "Guide lost souls across time",
next: "ending_temporal_guide"
}, {
text: "Record the stories of all timelines",
next: "ending_infinite_chronicler"
}]
},
timeline_collector: {
text: "You gather the best aspects from every timeline, creating a unique perspective on existence.",
choices: [{
text: "Share these collected wisdoms",
next: "ending_wisdom_synthesizer"
}, {
text: "Use the knowledge to help others",
next: "ending_multiversal_helper"
}]
},
time_immune: {
text: "Your immunity to temporal effects makes you a beacon of stability in an ever-changing universe.",
choices: [{
text: "Help others resist time magic",
next: "ending_stability_teacher"
}, {
text: "Explore realms beyond time",
next: "ending_beyond_time"
}]
},
storm_controller: {
text: "You command the chaotic forces that tear through time, directing them with precision and wisdom.",
choices: [{
text: "Use storms to heal temporal wounds",
next: "ending_temporal_healer"
}, {
text: "Create new realities from chaos",
next: "ending_chaos_weaver"
}]
},
temporal_sanctuary: {
text: "Your sanctuary becomes a refuge for those displaced by temporal accidents and time magic.",
choices: [{
text: "Welcome all temporal refugees",
next: "ending_sanctuary_keeper"
}, {
text: "Build a community outside time",
next: "ending_timeless_founder"
}]
},
time_whispers: {
text: "The whispers reveal visions of possible futures. You see yourself in different roles across time.",
choices: [{
text: "Choose the path of the healer",
next: "ending_healer"
}, {
text: "Choose the path of the inventor",
next: "ending_inventor"
}, {
text: "Choose to remain a wanderer",
next: "ending_eternal_wanderer"
}]
},
plant_tree: {
text: "Your planted tree grows instantly, creating a bridge between realms. You become its caretaker.",
choices: [{
text: "Tend the bridge tree",
next: "ending_bridge_keeper"
}, {
text: "Travel between realms",
next: "ending_realm_traveler"
}]
},
grove_meditation: {
text: "Deep meditation reveals your true purpose. You understand the balance of all things.",
choices: [{
text: "Become a balance keeper",
next: "ending_balance_keeper"
}, {
text: "Share this wisdom",
next: "ending_wisdom_spreader"
}]
},
crystal_caves: {
text: "You find crystalline caves that sing with harmonic frequencies. Each crystal holds memories.",
choices: [{
text: "Touch the memory crystals",
next: "memory_crystals"
}, {
text: "Create new harmonies",
next: "crystal_music"
}, {
text: "Take a crystal as companion",
next: "crystal_companion"
}]
},
memory_crystals: {
text: "The crystals show you memories of all who came before. You understand the cycle of life.",
choices: [{
text: "Preserve these memories",
next: "ending_memory_keeper"
}, {
text: "Add your own memories",
next: "ending_legacy_weaver"
}]
},
crystal_music: {
text: "Your music with the crystals creates beautiful melodies that heal hearts across the land.",
choices: [{
text: "Become a crystal musician",
next: "ending_crystal_bard"
}, {
text: "Teach others this music",
next: "ending_harmony_teacher"
}]
},
crystal_companion: {
text: "The crystal becomes your lifelong companion, guiding you on adventures across many worlds.",
choices: [{
text: "Explore new worlds together",
next: "ending_world_explorer"
}, {
text: "Return home with wisdom",
next: "ending_transformed_return"
}]
},
shadow_realm: {
text: "You slip into a realm of shadows where your fears take physical form, but so does your courage.",
choices: [{
text: "Face your fears directly",
next: "confront_fears"
}, {
text: "Befriend the shadows",
next: "shadow_alliance"
}, {
text: "Use courage to light the way",
next: "courage_light"
}]
},
confront_fears: {
text: "By facing your fears, you transform them into strengths. You become fearless.",
choices: [{
text: "Help others face their fears",
next: "ending_fear_helper"
}, {
text: "Become a shadow warrior",
next: "ending_shadow_warrior"
}]
},
shadow_alliance: {
text: "The shadows become your allies, teaching you to see truth hidden in darkness.",
choices: [{
text: "Become a truth seeker",
next: "ending_truth_seeker"
}, {
text: "Master shadow magic",
next: "ending_shadow_mage"
}]
},
courage_light: {
text: "Your courage creates light that banishes the shadow realm's darkness forever.",
choices: [{
text: "Become a light bringer",
next: "ending_light_bringer"
}, {
text: "Guard against future darkness",
next: "ending_darkness_sentinel"
}]
},
// New endings
ending_healer: {
text: "You become a legendary healer, using time magic to cure ailments across all ages.",
isEnding: true
},
ending_inventor: {
text: "Your inventions, inspired by time's wisdom, revolutionize the world and solve great problems.",
isEnding: true
},
ending_eternal_wanderer: {
text: "You choose the path of eternal wandering, experiencing infinite adventures across time.",
isEnding: true
},
ending_bridge_keeper: {
text: "As keeper of the bridge tree, you maintain peace between different realms forever.",
isEnding: true
},
ending_realm_traveler: {
text: "You become an interdimensional traveler, bringing knowledge and hope to countless worlds.",
isEnding: true
},
ending_balance_keeper: {
text: "You maintain the cosmic balance, ensuring harmony between all forces of nature.",
isEnding: true
},
ending_wisdom_spreader: {
text: "You travel the world sharing the grove's wisdom, enlightening all who listen.",
isEnding: true
},
ending_memory_keeper: {
text: "You become the eternal keeper of memories, preserving the stories of all living beings.",
isEnding: true
},
ending_legacy_weaver: {
text: "You weave new stories into the crystal memories, ensuring future generations learn from the past.",
isEnding: true
},
ending_crystal_bard: {
text: "Your crystal music becomes legendary, healing hearts and inspiring love wherever you go.",
isEnding: true
},
ending_harmony_teacher: {
text: "You establish a school of crystal harmony, teaching others to heal the world through music.",
isEnding: true
},
ending_world_explorer: {
text: "With your crystal companion, you discover infinite worlds and become a multiversal adventurer.",
isEnding: true
},
ending_transformed_return: {
text: "You return home transformed, using your crystal's wisdom to improve your original world.",
isEnding: true
},
ending_fear_helper: {
text: "You dedicate your life to helping others overcome their fears, becoming a beacon of courage.",
isEnding: true
},
ending_shadow_warrior: {
text: "You become a warrior who fights darkness wherever it threatens innocent lives.",
isEnding: true
},
ending_truth_seeker: {
text: "You devote yourself to uncovering hidden truths, exposing lies and bringing justice.",
isEnding: true
},
ending_shadow_mage: {
text: "You master shadow magic, using it to protect the innocent and maintain cosmic balance.",
isEnding: true
},
ending_light_bringer: {
text: "You become a bringer of light, illuminating dark places and bringing hope to the hopeless.",
isEnding: true
},
ending_darkness_sentinel: {
text: "You stand eternal guard against darkness, ensuring shadow realms never threaten the world again.",
isEnding: true
},
// Chapter 5 endings - Time and Multiverse
ending_world_designer: {
text: "You become the architect of reality itself, designing worlds where every being can find happiness and purpose.",
isEnding: true
},
ending_soul_forger: {
text: "You create meaningful challenges that help souls grow stronger, becoming the ultimate teacher through experience.",
isEnding: true
},
ending_perfect_overseer: {
text: "You watch over your perfect timeline, making subtle adjustments to maintain eternal harmony.",
isEnding: true
},
ending_humble_creator: {
text: "Your perfect creation evolves beyond your imagination, proving that the best art comes from letting go.",
isEnding: true
},
ending_eternal_sentinel: {
text: "You become the eternal guardian of time itself, ensuring the natural flow of cause and effect.",
isEnding: true
},
ending_time_academy: {
text: "You establish an academy that trains temporal guardians, ensuring time will always be protected.",
isEnding: true
},
ending_peace_ambassador: {
text: "You become a legendary peacemaker, traveling between timelines to resolve conflicts with wisdom.",
isEnding: true
},
ending_peace_guardian: {
text: "You dedicate yourself to protecting the peaceful timeline, ensuring it remains a sanctuary for all.",
isEnding: true
},
ending_temporal_guide: {
text: "You become a legendary guide who helps lost souls find their way through the maze of time.",
isEnding: true
},
ending_infinite_chronicler: {
text: "You record the infinite stories of all timelines, becoming the ultimate keeper of universal history.",
isEnding: true
},
ending_wisdom_synthesizer: {
text: "You synthesize the wisdom of infinite timelines, becoming the greatest teacher in all realities.",
isEnding: true
},
ending_multiversal_helper: {
text: "You use your knowledge of all timelines to help beings across the multiverse achieve their potential.",
isEnding: true
},
ending_stability_teacher: {
text: "You teach others to resist temporal chaos, becoming the anchor that keeps reality stable.",
isEnding: true
},
ending_beyond_time: {
text: "You transcend time itself, exploring dimensions and realities that exist beyond temporal concepts.",
isEnding: true
},
ending_temporal_healer: {
text: "You use temporal storms to heal wounds in time itself, mending broken timelines and lost histories.",
isEnding: true
},
ending_chaos_weaver: {
text: "You master the art of creating order from chaos, building new realities from temporal fragments.",
isEnding: true
},
ending_sanctuary_keeper: {
text: "Your sanctuary becomes a beacon of hope for all displaced by time, offering shelter and new beginnings.",
isEnding: true
},
ending_timeless_founder: {
text: "You build a community that exists outside time, where beings from all eras live together in harmony.",
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"
}, {
text: "Preguntar sobre el camino traicionero",
next: "shadow_realm"
}]
},
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"
}, {
text: "Buscar un bosque mágico",
next: "magical_grove"
}, {
text: "Buscar cuevas de cristal",
next: "crystal_caves"
}]
},
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
},
// Nuevos caminos de historia extendidos
magical_grove: {
text: "Descubres un bosque oculto donde el tiempo se mueve diferente. Árboles antiguos susurran secretos del pasado y futuro.",
choices: [{
text: "Escuchar los susurros",
next: "time_whispers"
}, {
text: "Plantar un nuevo árbol",
next: "plant_tree"
}, {
text: "Meditar en el centro",
next: "grove_meditation"
}, {
text: "Tocar el nexo temporal",
next: "temporal_nexus"
}]
},
temporal_nexus: {
text: "Tocas un portal giratorio de energía temporal. La realidad se fractura a tu alrededor mientras ves todas las líneas temporales posibles a la vez.",
choices: [{
text: "Intentar controlar las líneas temporales",
next: "timeline_master"
}, {
text: "Dejarte llevar a través del tiempo",
next: "time_wanderer"
}, {
text: "Anclarte al presente",
next: "present_anchor"
}]
},
timeline_master: {
text: "Capturas los hilos del tiempo mismo. Con gran concentración, aprendes a tejer el destino y remodelar la realidad.",
choices: [{
text: "Convertirte en el arquitecto del destino",
next: "fate_architect"
}, {
text: "Crear una línea temporal perfecta",
next: "perfect_timeline"
}, {
text: "Restaurar el orden natural",
next: "time_guardian"
}]
},
time_wanderer: {
text: "Derivas a través de innumerables líneas temporales, experimentando vidas infinitas y posibilidades. Cada viaje te enseña algo nuevo.",
choices: [{
text: "Elegir establecerte en una línea temporal pacífica",
next: "peaceful_timeline"
}, {
text: "Continuar vagando eternamente",
next: "eternal_drifter"
}, {
text: "Reunir fragmentos de todas las líneas temporales",
next: "timeline_collector"
}]
},
present_anchor: {
text: "Luchas contra las corrientes temporales, anclándote a tu línea temporal original. El esfuerzo te transforma.",
choices: [{
text: "Volverte inmune a la magia del tiempo",
next: "time_immune"
}, {
text: "Ganar poder sobre las tormentas temporales",
next: "storm_controller"
}, {
text: "Crear un refugio seguro del tiempo",
next: "temporal_sanctuary"
}]
},
fate_architect: {
text: "Como maestro del destino, remoldeas el mundo según tu visión. Cada elección crea ondas a través de la realidad.",
choices: [{
text: "Diseñar un mundo sin sufrimiento",
next: "ending_world_designer"
}, {
text: "Crear desafíos para fortalecer las almas",
next: "ending_soul_forger"
}]
},
perfect_timeline: {
text: "Creas una línea temporal donde cada elección lleva al mejor resultado posible para todos.",
choices: [{
text: "Supervisar tu creación perfecta",
next: "ending_perfect_overseer"
}, {
text: "Retroceder y dejar que evolucione",
next: "ending_humble_creator"
}]
},
time_guardian: {
text: "Te conviertes en el protector del equilibrio temporal, asegurando que nadie más perturbe el flujo natural del tiempo.",
choices: [{
text: "Guardar el tiempo eternamente",
next: "ending_eternal_sentinel"
}, {
text: "Entrenar a otros para compartir la carga",
next: "ending_time_academy"
}]
},
peaceful_timeline: {
text: "Encuentras una línea temporal de paz eterna y armonía, donde los conflictos se resuelven a través del entendimiento.",
choices: [{
text: "Convertirte en un embajador de la paz",
next: "ending_peace_ambassador"
}, {
text: "Proteger este mundo pacífico",
next: "ending_peace_guardian"
}]
},
eternal_drifter: {
text: "Eliges vagar por el tiempo para siempre, convirtiéndote en una leyenda susurrada a través de todas las líneas temporales.",
choices: [{
text: "Guiar almas perdidas a través del tiempo",
next: "ending_temporal_guide"
}, {
text: "Registrar las historias de todas las líneas temporales",
next: "ending_infinite_chronicler"
}]
},
timeline_collector: {
text: "Reúnes los mejores aspectos de cada línea temporal, creando una perspectiva única sobre la existencia.",
choices: [{
text: "Compartir estas sabidurías recolectadas",
next: "ending_wisdom_synthesizer"
}, {
text: "Usar el conocimiento para ayudar a otros",
next: "ending_multiversal_helper"
}]
},
time_immune: {
text: "Tu inmunidad a los efectos temporales te convierte en un faro de estabilidad en un universo en constante cambio.",
choices: [{
text: "Ayudar a otros a resistir la magia del tiempo",
next: "ending_stability_teacher"
}, {
text: "Explorar reinos más allá del tiempo",
next: "ending_beyond_time"
}]
},
storm_controller: {
text: "Comandas las fuerzas caóticas que desgarran el tiempo, dirigiéndolas con precisión y sabiduría.",
choices: [{
text: "Usar tormentas para sanar heridas temporales",
next: "ending_temporal_healer"
}, {
text: "Crear nuevas realidades del caos",
next: "ending_chaos_weaver"
}]
},
temporal_sanctuary: {
text: "Tu santuario se convierte en un refugio para aquellos desplazados por accidentes temporales y magia del tiempo.",
choices: [{
text: "Dar la bienvenida a todos los refugiados temporales",
next: "ending_sanctuary_keeper"
}, {
text: "Construir una comunidad fuera del tiempo",
next: "ending_timeless_founder"
}]
},
time_whispers: {
text: "Los susurros revelan visiones de futuros posibles. Te ves a ti mismo en diferentes roles a través del tiempo.",
choices: [{
text: "Elegir el camino del curandero",
next: "ending_healer"
}, {
text: "Elegir el camino del inventor",
next: "ending_inventor"
}, {
text: "Elegir seguir siendo un vagabundo",
next: "ending_eternal_wanderer"
}]
},
plant_tree: {
text: "Tu árbol plantado crece instantáneamente, creando un puente entre reinos. Te conviertes en su cuidador.",
choices: [{
text: "Cuidar el árbol puente",
next: "ending_bridge_keeper"
}, {
text: "Viajar entre reinos",
next: "ending_realm_traveler"
}]
},
grove_meditation: {
text: "La meditación profunda revela tu verdadero propósito. Entiendes el equilibrio de todas las cosas.",
choices: [{
text: "Convertirse en guardián del equilibrio",
next: "ending_balance_keeper"
}, {
text: "Compartir esta sabiduría",
next: "ending_wisdom_spreader"
}]
},
crystal_caves: {
text: "Encuentras cuevas cristalinas que cantan con frecuencias armónicas. Cada cristal guarda memorias.",
choices: [{
text: "Tocar los cristales de memoria",
next: "memory_crystals"
}, {
text: "Crear nuevas armonías",
next: "crystal_music"
}, {
text: "Tomar un cristal como compañero",
next: "crystal_companion"
}]
},
memory_crystals: {
text: "Los cristales te muestran memorias de todos los que vinieron antes. Entiendes el ciclo de la vida.",
choices: [{
text: "Preservar estas memorias",
next: "ending_memory_keeper"
}, {
text: "Añadir tus propias memorias",
next: "ending_legacy_weaver"
}]
},
crystal_music: {
text: "Tu música con los cristales crea melodías hermosas que sanan corazones a través de la tierra.",
choices: [{
text: "Convertirse en músico de cristal",
next: "ending_crystal_bard"
}, {
text: "Enseñar esta música a otros",
next: "ending_harmony_teacher"
}]
},
crystal_companion: {
text: "El cristal se convierte en tu compañero de vida, guiándote en aventuras a través de muchos mundos.",
choices: [{
text: "Explorar nuevos mundos juntos",
next: "ending_world_explorer"
}, {
text: "Regresar a casa con sabiduría",
next: "ending_transformed_return"
}]
},
shadow_realm: {
text: "Te deslizas a un reino de sombras donde tus miedos toman forma física, pero también tu valor.",
choices: [{
text: "Enfrentar tus miedos directamente",
next: "confront_fears"
}, {
text: "Hacer amistad con las sombras",
next: "shadow_alliance"
}, {
text: "Usar valor para iluminar el camino",
next: "courage_light"
}]
},
confront_fears: {
text: "Al enfrentar tus miedos, los transformas en fortalezas. Te vuelves intrépido.",
choices: [{
text: "Ayudar a otros a enfrentar sus miedos",
next: "ending_fear_helper"
}, {
text: "Convertirse en guerrero de las sombras",
next: "ending_shadow_warrior"
}]
},
shadow_alliance: {
text: "Las sombras se vuelven tus aliadas, enseñándote a ver la verdad oculta en la oscuridad.",
choices: [{
text: "Convertirse en buscador de la verdad",
next: "ending_truth_seeker"
}, {
text: "Dominar la magia de las sombras",
next: "ending_shadow_mage"
}]
},
courage_light: {
text: "Tu valor crea luz que destierra la oscuridad del reino de las sombras para siempre.",
choices: [{
text: "Convertirse en portador de luz",
next: "ending_light_bringer"
}, {
text: "Proteger contra futuras oscuridades",
next: "ending_darkness_sentinel"
}]
},
// Nuevos finales
ending_healer: {
text: "Te conviertes en un curandero legendario, usando magia del tiempo para curar dolencias en todas las edades.",
isEnding: true
},
ending_inventor: {
text: "Tus inventos, inspirados por la sabiduría del tiempo, revolucionan el mundo y resuelven grandes problemas.",
isEnding: true
},
ending_eternal_wanderer: {
text: "Eliges el camino del vagabundeo eterno, experimentando aventuras infinitas a través del tiempo.",
isEnding: true
},
ending_bridge_keeper: {
text: "Como guardián del árbol puente, mantienes la paz entre diferentes reinos para siempre.",
isEnding: true
},
ending_realm_traveler: {
text: "Te conviertes en un viajero interdimensional, llevando conocimiento y esperanza a mundos incontables.",
isEnding: true
},
ending_balance_keeper: {
text: "Mantienes el equilibrio cósmico, asegurando armonía entre todas las fuerzas de la naturaleza.",
isEnding: true
},
ending_wisdom_spreader: {
text: "Viajas por el mundo compartiendo la sabiduría del bosque, iluminando a todos los que escuchan.",
isEnding: true
},
ending_memory_keeper: {
text: "Te conviertes en el guardián eterno de memorias, preservando las historias de todos los seres vivos.",
isEnding: true
},
ending_legacy_weaver: {
text: "Tejes nuevas historias en las memorias de cristal, asegurando que futuras generaciones aprendan del pasado.",
isEnding: true
},
ending_crystal_bard: {
text: "Tu música de cristal se vuelve legendaria, sanando corazones e inspirando amor dondequiera que vayas.",
isEnding: true
},
ending_harmony_teacher: {
text: "Estableces una escuela de armonía cristalina, enseñando a otros a sanar el mundo a través de la música.",
isEnding: true
},
ending_world_explorer: {
text: "Con tu compañero de cristal, descubres mundos infinitos y te conviertes en un aventurero multiversal.",
isEnding: true
},
ending_transformed_return: {
text: "Regresas a casa transformado, usando la sabiduría de tu cristal para mejorar tu mundo original.",
isEnding: true
},
ending_fear_helper: {
text: "Dedicas tu vida a ayudar a otros a superar sus miedos, convirtiéndote en un faro de valor.",
isEnding: true
},
ending_shadow_warrior: {
text: "Te conviertes en un guerrero que lucha contra la oscuridad dondequiera que amenace vidas inocentes.",
isEnding: true
},
ending_truth_seeker: {
text: "Te dedicas a descubrir verdades ocultas, exponiendo mentiras y trayendo justicia.",
isEnding: true
},
ending_shadow_mage: {
text: "Dominas la magia de las sombras, usándola para proteger a los inocentes y mantener el equilibrio cósmico.",
isEnding: true
},
ending_light_bringer: {
text: "Te conviertes en un portador de luz, iluminando lugares oscuros y trayendo esperanza a los sin esperanza.",
isEnding: true
},
ending_darkness_sentinel: {
text: "Te conviertes en guardián eterno contra la oscuridad, asegurando que los reinos sombríos nunca amenacen el mundo otra vez.",
isEnding: true
},
// Finales del Capítulo 5 - Tiempo y Multiverso
ending_world_designer: {
text: "Te conviertes en el arquitecto de la realidad misma, diseñando mundos donde cada ser puede encontrar felicidad y propósito.",
isEnding: true
},
ending_soul_forger: {
text: "Creas desafíos significativos que ayudan a las almas a crecer más fuertes, convirtiéndote en el maestro definitivo a través de la experiencia.",
isEnding: true
},
ending_perfect_overseer: {
text: "Vigilas tu línea temporal perfecta, haciendo ajustes sutiles para mantener la armonía eterna.",
isEnding: true
},
ending_humble_creator: {
text: "Tu creación perfecta evoluciona más allá de tu imaginación, demostrando que el mejor arte viene de soltar el control.",
isEnding: true
},
ending_eternal_sentinel: {
text: "Te conviertes en el guardián eterno del tiempo mismo, asegurando el flujo natural de causa y efecto.",
isEnding: true
},
ending_time_academy: {
text: "Estableces una academia que entrena guardianes temporales, asegurando que el tiempo siempre esté protegido.",
isEnding: true
},
ending_peace_ambassador: {
text: "Te conviertes en un pacificador legendario, viajando entre líneas temporales para resolver conflictos con sabiduría.",
isEnding: true
},
ending_peace_guardian: {
text: "Te dedicas a proteger la línea temporal pacífica, asegurando que permanezca como un santuario para todos.",
isEnding: true
},
ending_temporal_guide: {
text: "Te conviertes en un guía legendario que ayuda a las almas perdidas a encontrar su camino a través del laberinto del tiempo.",
isEnding: true
},
ending_infinite_chronicler: {
text: "Registras las historias infinitas de todas las líneas temporales, convirtiéndote en el guardián definitivo de la historia universal.",
isEnding: true
},
ending_wisdom_synthesizer: {
text: "Sintetizas la sabiduría de líneas temporales infinitas, convirtiéndote en el mayor maestro en todas las realidades.",
isEnding: true
},
ending_multiversal_helper: {
text: "Usas tu conocimiento de todas las líneas temporales para ayudar a los seres a través del multiverso a alcanzar su potencial.",
isEnding: true
},
ending_stability_teacher: {
text: "Enseñas a otros a resistir el caos temporal, convirtiéndote en el ancla que mantiene estable la realidad.",
isEnding: true
},
ending_beyond_time: {
text: "Trasciendes el tiempo mismo, explorando dimensiones y realidades que existen más allá de los conceptos temporales.",
isEnding: true
},
ending_temporal_healer: {
text: "Usas tormentas temporales para sanar heridas en el tiempo mismo, reparando líneas temporales rotas e historias perdidas.",
isEnding: true
},
ending_chaos_weaver: {
text: "Dominas el arte de crear orden del caos, construyendo nuevas realidades a partir de fragmentos temporales.",
isEnding: true
},
ending_sanctuary_keeper: {
text: "Tu santuario se convierte en un faro de esperanza para todos los desplazados por el tiempo, ofreciendo refugio y nuevos comienzos.",
isEnding: true
},
ending_timeless_founder: {
text: "Construyes una comunidad que existe fuera del tiempo, donde seres de todas las eras viven juntos en armonía.",
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: 140,
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
try {
storage.storyProgress = {
currentNode: currentStoryNode,
history: storyHistory,
visitedNodes: visitedNodes
};
} catch (e) {
console.log("Storage error:", e);
}
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 = 1200;
var spacing = 250;
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();