User prompt
Has un menú principal donde puedas elegir de español y inglés
Code edit (1 edits merged)
Please save this source code
User prompt
Life Simulator: Rise to Success
Initial prompt
Hasme un juego de texto interactivo donde tengas que trabajar tengas opciones de que trabajo tener perder por no tener dinero y ganar dinero tener novia y más
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var ChoiceButton = Container.expand(function (text, action) {
var self = Container.call(this);
var buttonBg = self.attachAsset('choiceButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2(text, {
size: 45,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.action = action;
self.down = function (x, y, obj) {
LK.getSound('buttonClick').play();
tween(buttonBg, {
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 100
});
if (self.action) {
self.action();
}
};
self.up = function (x, y, obj) {
tween(buttonBg, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
};
return self;
});
var StatDisplay = Container.expand(function (label, value, color) {
var self = Container.call(this);
var statBg = self.attachAsset('statBar', {
anchorX: 0,
anchorY: 0
});
statBg.tint = color || 0x34495e;
var labelText = new Text2(label + ": $" + value, {
size: 40,
fill: 0xFFFFFF
});
labelText.anchor.set(0, 0.5);
labelText.x = 20;
labelText.y = 40;
self.addChild(labelText);
self.updateValue = function (newValue, prefix) {
labelText.setText(label + ": " + (prefix || "$") + newValue);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a252f
});
/****
* Game Code
****/
// Language and game state variables
var currentLanguage = storage.get('language') || 'english';
var showingLanguageMenu = true;
var playerMoney = 1000;
var playerJob = "Unemployed";
var playerSalary = 0;
var playerHappiness = 50;
var playerRelationship = "Single";
var playerAge = 22;
var monthsUnemployed = 0;
var dayCounter = 1;
var currentScene = "main";
// Translations
var translations = {
english: {
title: "Life Simulator: Rise to Success",
selectLanguage: "Select Language / Seleccionar Idioma",
english: "English",
spanish: "Español",
money: "Money",
job: "Job",
happiness: "Happiness",
relationship: "Relationship",
unemployed: "Unemployed",
single: "Single",
welcome: "Welcome to your adult life! You're starting with $1000. What's your first move?",
dayText: "Day",
whatToDo: ": What would you like to do today?",
lookForJob: "Look for a job",
goOnDate: "Go on a date",
restAtHome: "Rest at home (+10 happiness)",
workExtra: "Work extra hours (+money)",
availableJobs: "Available job opportunities:",
goBack: "Go back",
congratsJob: "Congratulations! You got the job as ",
noJob: "Sorry, you didn't get the job. Better luck next time!",
needJobFirst: "You need a job first!",
"continue": "Continue",
askOut: "Ask them out ($100)",
justFriends: "Just be friends",
notEnoughMoney: "You don't have enough money for a proper date!",
wonderfulTime: "Great! You had a wonderful time together!",
dateNotWell: "The date didn't go well. Maybe next time!",
friendlyChat: "You had a nice friendly conversation!",
payday: "Payday! You received $",
gameOver: "You've run out of money and can't find work. You're forced to move back with your parents. Game Over!",
youWin: "Congratulations! You've achieved financial stability, happiness, and love. You've won at life!",
dating: "Dating "
},
spanish: {
title: "Simulador de Vida: Camino al Éxito",
selectLanguage: "Select Language / Seleccionar Idioma",
english: "English",
spanish: "Español",
money: "Dinero",
job: "Trabajo",
happiness: "Felicidad",
relationship: "Relación",
unemployed: "Desempleado",
single: "Soltero",
welcome: "¡Bienvenido a tu vida adulta! Empiezas con $1000. ¿Cuál es tu primer movimiento?",
dayText: "Día",
whatToDo: ": ¿Qué te gustaría hacer hoy?",
lookForJob: "Buscar trabajo",
goOnDate: "Ir a una cita",
restAtHome: "Descansar en casa (+10 felicidad)",
workExtra: "Trabajar horas extra (+dinero)",
availableJobs: "Oportunidades de trabajo disponibles:",
goBack: "Volver",
congratsJob: "¡Felicidades! Conseguiste el trabajo como ",
noJob: "Lo siento, no conseguiste el trabajo. ¡Mejor suerte la próxima vez!",
needJobFirst: "¡Necesitas un trabajo primero!",
"continue": "Continuar",
askOut: "Invitarla/o a salir ($100)",
justFriends: "Solo ser amigos",
notEnoughMoney: "¡No tienes suficiente dinero para una cita apropiada!",
wonderfulTime: "¡Genial! ¡Pasaron un tiempo maravilloso juntos!",
dateNotWell: "La cita no fue bien. ¡Tal vez la próxima vez!",
friendlyChat: "¡Tuviste una conversación amistosa agradable!",
payday: "¡Día de pago! Recibiste $",
gameOver: "Te quedaste sin dinero y no puedes encontrar trabajo. Te ves obligado a regresar con tus padres. ¡Fin del juego!",
youWin: "¡Felicidades! Has logrado estabilidad financiera, felicidad y amor. ¡Has ganado en la vida!",
dating: "Saliendo con "
}
};
function getText(key) {
return translations[currentLanguage][key] || key;
}
// Job data with translations
var availableJobs = [{
nameEn: "Fast Food Worker",
nameEs: "Trabajador de Comida Rápida",
salary: 1200,
requirements: "None",
happiness: -5
}, {
nameEn: "Retail Associate",
nameEs: "Asociado de Ventas",
salary: 1400,
requirements: "None",
happiness: -3
}, {
nameEn: "Office Assistant",
nameEs: "Asistente de Oficina",
salary: 2000,
requirements: "High School",
happiness: 0
}, {
nameEn: "Bank Teller",
nameEs: "Cajero de Banco",
salary: 2800,
requirements: "Some Experience",
happiness: 5
}, {
nameEn: "Software Developer",
nameEs: "Desarrollador de Software",
salary: 5000,
requirements: "College Degree",
happiness: 15
}, {
nameEn: "Manager",
nameEs: "Gerente",
salary: 4200,
requirements: "Leadership Experience",
happiness: 10
}];
function getJobName(job) {
return currentLanguage === 'spanish' ? job.nameEs : job.nameEn;
}
var relationships = [{
nameEn: "Coffee Shop Regular",
nameEs: "Cliente Habitual del Café",
status: "Stranger",
happiness: 5
}, {
nameEn: "Gym Partner",
nameEs: "Compañero de Gimnasio",
status: "Acquaintance",
happiness: 8
}, {
nameEn: "Coworker",
nameEs: "Compañero de Trabajo",
status: "Friend",
happiness: 12
}];
function getPersonName(person) {
return currentLanguage === 'spanish' ? person.nameEs : person.nameEn;
}
// UI Elements
var backgroundPanel = game.addChild(LK.getAsset('backgroundPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
}));
var titleText = new Text2(getText('selectLanguage'), {
size: 60,
fill: 0xE74C3C
});
titleText.anchor.set(0.5, 0);
titleText.x = 1024;
titleText.y = 150;
game.addChild(titleText);
// Stats display
var moneyDisplay = game.addChild(new StatDisplay(getText('money'), playerMoney, 0x27ae60));
moneyDisplay.x = 224;
moneyDisplay.y = 250;
var jobDisplay = game.addChild(new StatDisplay(getText('job'), getText('unemployed'), 0x8e44ad));
jobDisplay.x = 224;
jobDisplay.y = 350;
jobDisplay.updateValue(getText('unemployed'), "");
var happinessDisplay = game.addChild(new StatDisplay(getText('happiness'), playerHappiness + "%", 0xf39c12));
happinessDisplay.x = 224;
happinessDisplay.y = 450;
happinessDisplay.updateValue(playerHappiness + "%", "");
var relationshipDisplay = game.addChild(new StatDisplay(getText('relationship'), getText('single'), 0xe91e63));
relationshipDisplay.x = 224;
relationshipDisplay.y = 550;
relationshipDisplay.updateValue(getText('single'), "");
// Event panel
var eventPanel = game.addChild(LK.getAsset('eventPanel', {
anchorX: 0.5,
anchorY: 0,
x: 1024,
y: 700
}));
var eventText = new Text2(getText('selectLanguage'), {
size: 42,
fill: 0xFFFFFF
});
eventText.anchor.set(0.5, 0);
eventText.x = 1024;
eventText.y = 750;
game.addChild(eventText);
// Choice buttons
var choiceButtons = [];
function clearChoices() {
for (var i = 0; i < choiceButtons.length; i++) {
choiceButtons[i].destroy();
}
choiceButtons = [];
}
function addChoice(text, action) {
var button = new ChoiceButton(text, action);
button.x = 1024;
button.y = 1200 + choiceButtons.length * 140;
game.addChild(button);
choiceButtons.push(button);
}
function showLanguageMenu() {
titleText.setText(getText('selectLanguage'));
eventText.setText(getText('selectLanguage'));
clearChoices();
addChoice(getText('english'), function () {
currentLanguage = 'english';
storage.set('language', 'english');
showingLanguageMenu = false;
updateUILanguage();
showMainMenu();
});
addChoice(getText('spanish'), function () {
currentLanguage = 'spanish';
storage.set('language', 'spanish');
showingLanguageMenu = false;
updateUILanguage();
showMainMenu();
});
}
function updateUILanguage() {
titleText.setText(getText('title'));
moneyDisplay.labelText.setText(getText('money') + ": $" + playerMoney);
jobDisplay.labelText.setText(getText('job') + ": " + (playerJob === "Unemployed" ? getText('unemployed') : playerJob));
happinessDisplay.labelText.setText(getText('happiness') + ": " + playerHappiness + "%");
relationshipDisplay.labelText.setText(getText('relationship') + ": " + (playerRelationship === "Single" ? getText('single') : playerRelationship));
}
function updateStats() {
moneyDisplay.updateValue(playerMoney);
var jobText = playerJob === "Unemployed" ? getText('unemployed') : playerJob;
jobDisplay.updateValue(jobText, "");
happinessDisplay.updateValue(playerHappiness + "%", "");
var relationshipText = playerRelationship === "Single" ? getText('single') : playerRelationship;
relationshipDisplay.updateValue(relationshipText, "");
}
function checkGameOver() {
if (playerMoney <= 0 && monthsUnemployed >= 3) {
eventText.setText(getText('gameOver'));
clearChoices();
LK.getSound('failure').play();
LK.setTimeout(function () {
LK.showGameOver();
}, 2000);
return true;
}
if (playerMoney >= 10000 && playerHappiness >= 80 && playerRelationship !== getText('single')) {
eventText.setText(getText('youWin'));
clearChoices();
LK.getSound('success').play();
LK.setTimeout(function () {
LK.showYouWin();
}, 2000);
return true;
}
return false;
}
function showMainMenu() {
currentScene = "main";
eventText.setText(getText('dayText') + " " + dayCounter + getText('whatToDo'));
clearChoices();
addChoice(getText('lookForJob'), function () {
showJobSearch();
});
addChoice(getText('goOnDate'), function () {
showDating();
});
addChoice(getText('restAtHome'), function () {
playerHappiness = Math.min(100, playerHappiness + 10);
playerMoney -= 50; // Daily expenses
advanceDay();
});
addChoice(getText('workExtra'), function () {
if (playerJob === "Unemployed") {
eventText.setText(getText('needJobFirst'));
return;
}
playerMoney += Math.floor(playerSalary * 0.3);
playerHappiness = Math.max(0, playerHappiness - 5);
playerMoney -= 50; // Daily expenses
advanceDay();
});
}
function showJobSearch() {
currentScene = "jobs";
eventText.setText(getText('availableJobs'));
clearChoices();
for (var i = 0; i < Math.min(3, availableJobs.length); i++) {
var job = availableJobs[i];
(function (jobData) {
addChoice(getJobName(jobData) + " ($" + jobData.salary + "/month)", function () {
applyForJob(jobData);
});
})(job);
}
addChoice(getText('goBack'), function () {
showMainMenu();
});
}
function applyForJob(job) {
var chance = Math.random();
if (chance > 0.3) {
playerJob = getJobName(job);
playerSalary = job.salary;
playerHappiness += job.happiness;
monthsUnemployed = 0;
eventText.setText(getText('congratsJob') + getJobName(job) + "!");
LK.getSound('success').play();
} else {
eventText.setText(getText('noJob'));
LK.getSound('failure').play();
}
clearChoices();
addChoice(getText('continue'), function () {
playerMoney -= 50; // Daily expenses
advanceDay();
});
}
function showDating() {
currentScene = "dating";
var person = relationships[Math.floor(Math.random() * relationships.length)];
eventText.setText(currentLanguage === 'spanish' ? "Conoces a " + getPersonName(person) + " en un café local. ¡Parece interesante!" : "You meet " + getPersonName(person) + " at a local cafe. They seem interesting!");
clearChoices();
addChoice(getText('askOut'), function () {
if (playerMoney < 100) {
eventText.setText(getText('notEnoughMoney'));
clearChoices();
addChoice(getText('goBack'), function () {
showMainMenu();
});
return;
}
playerMoney -= 100;
var success = Math.random() > 0.4;
if (success) {
playerHappiness += person.happiness;
playerRelationship = getText('dating') + getPersonName(person);
eventText.setText(getText('wonderfulTime'));
LK.getSound('success').play();
} else {
playerHappiness -= 5;
eventText.setText(getText('dateNotWell'));
LK.getSound('failure').play();
}
clearChoices();
addChoice(getText('continue'), function () {
playerMoney -= 50; // Daily expenses
advanceDay();
});
});
addChoice(getText('justFriends'), function () {
playerHappiness += 3;
eventText.setText(getText('friendlyChat'));
clearChoices();
addChoice(getText('continue'), function () {
playerMoney -= 50; // Daily expenses
advanceDay();
});
});
addChoice(getText('goBack'), function () {
showMainMenu();
});
}
function advanceDay() {
dayCounter++;
// Monthly salary
if (dayCounter % 30 === 0 && playerJob !== getText('unemployed')) {
playerMoney += playerSalary;
eventText.setText(getText('payday') + playerSalary + (currentLanguage === 'spanish' ? " de tu trabajo como " + playerJob : " from your job as " + playerJob));
clearChoices();
addChoice(getText('continue'), function () {
checkDailyEvents();
});
return;
}
// Track unemployment
if (playerJob === "Unemployed") {
monthsUnemployed++;
}
// Random events
if (Math.random() < 0.1) {
showRandomEvent();
} else {
checkDailyEvents();
}
}
function showRandomEvent() {
var events = [{
textEn: "You found $50 on the street!",
textEs: "¡Encontraste $50 en la calle!",
money: 50,
happiness: 5
}, {
textEn: "Your car broke down. Repair costs $300.",
textEs: "Tu auto se descompuso. Los costos de reparación son $300.",
money: -300,
happiness: -10
}, {
textEn: "You won a small lottery prize of $200!",
textEs: "¡Ganaste un pequeño premio de lotería de $200!",
money: 200,
happiness: 15
}, {
textEn: "You got sick and had to pay $150 for medicine.",
textEs: "Te enfermaste y tuviste que pagar $150 por medicina.",
money: -150,
happiness: -5
}];
var event = events[Math.floor(Math.random() * events.length)];
playerMoney = Math.max(0, playerMoney + event.money);
playerHappiness = Math.max(0, Math.min(100, playerHappiness + event.happiness));
eventText.setText(currentLanguage === 'spanish' ? event.textEs : event.textEn);
clearChoices();
addChoice(getText('continue'), function () {
checkDailyEvents();
});
}
function checkDailyEvents() {
updateStats();
if (checkGameOver()) {
return;
}
showMainMenu();
}
// Initialize the game
if (showingLanguageMenu) {
showLanguageMenu();
} else {
updateUILanguage();
showMainMenu();
} ===================================================================
--- original.js
+++ change.js
@@ -72,9 +72,11 @@
/****
* Game Code
****/
-// Game state variables
+// Language and game state variables
+var currentLanguage = storage.get('language') || 'english';
+var showingLanguageMenu = true;
var playerMoney = 1000;
var playerJob = "Unemployed";
var playerSalary = 0;
var playerHappiness = 50;
@@ -82,92 +84,183 @@
var playerAge = 22;
var monthsUnemployed = 0;
var dayCounter = 1;
var currentScene = "main";
-// Job data
+// Translations
+var translations = {
+ english: {
+ title: "Life Simulator: Rise to Success",
+ selectLanguage: "Select Language / Seleccionar Idioma",
+ english: "English",
+ spanish: "Español",
+ money: "Money",
+ job: "Job",
+ happiness: "Happiness",
+ relationship: "Relationship",
+ unemployed: "Unemployed",
+ single: "Single",
+ welcome: "Welcome to your adult life! You're starting with $1000. What's your first move?",
+ dayText: "Day",
+ whatToDo: ": What would you like to do today?",
+ lookForJob: "Look for a job",
+ goOnDate: "Go on a date",
+ restAtHome: "Rest at home (+10 happiness)",
+ workExtra: "Work extra hours (+money)",
+ availableJobs: "Available job opportunities:",
+ goBack: "Go back",
+ congratsJob: "Congratulations! You got the job as ",
+ noJob: "Sorry, you didn't get the job. Better luck next time!",
+ needJobFirst: "You need a job first!",
+ "continue": "Continue",
+ askOut: "Ask them out ($100)",
+ justFriends: "Just be friends",
+ notEnoughMoney: "You don't have enough money for a proper date!",
+ wonderfulTime: "Great! You had a wonderful time together!",
+ dateNotWell: "The date didn't go well. Maybe next time!",
+ friendlyChat: "You had a nice friendly conversation!",
+ payday: "Payday! You received $",
+ gameOver: "You've run out of money and can't find work. You're forced to move back with your parents. Game Over!",
+ youWin: "Congratulations! You've achieved financial stability, happiness, and love. You've won at life!",
+ dating: "Dating "
+ },
+ spanish: {
+ title: "Simulador de Vida: Camino al Éxito",
+ selectLanguage: "Select Language / Seleccionar Idioma",
+ english: "English",
+ spanish: "Español",
+ money: "Dinero",
+ job: "Trabajo",
+ happiness: "Felicidad",
+ relationship: "Relación",
+ unemployed: "Desempleado",
+ single: "Soltero",
+ welcome: "¡Bienvenido a tu vida adulta! Empiezas con $1000. ¿Cuál es tu primer movimiento?",
+ dayText: "Día",
+ whatToDo: ": ¿Qué te gustaría hacer hoy?",
+ lookForJob: "Buscar trabajo",
+ goOnDate: "Ir a una cita",
+ restAtHome: "Descansar en casa (+10 felicidad)",
+ workExtra: "Trabajar horas extra (+dinero)",
+ availableJobs: "Oportunidades de trabajo disponibles:",
+ goBack: "Volver",
+ congratsJob: "¡Felicidades! Conseguiste el trabajo como ",
+ noJob: "Lo siento, no conseguiste el trabajo. ¡Mejor suerte la próxima vez!",
+ needJobFirst: "¡Necesitas un trabajo primero!",
+ "continue": "Continuar",
+ askOut: "Invitarla/o a salir ($100)",
+ justFriends: "Solo ser amigos",
+ notEnoughMoney: "¡No tienes suficiente dinero para una cita apropiada!",
+ wonderfulTime: "¡Genial! ¡Pasaron un tiempo maravilloso juntos!",
+ dateNotWell: "La cita no fue bien. ¡Tal vez la próxima vez!",
+ friendlyChat: "¡Tuviste una conversación amistosa agradable!",
+ payday: "¡Día de pago! Recibiste $",
+ gameOver: "Te quedaste sin dinero y no puedes encontrar trabajo. Te ves obligado a regresar con tus padres. ¡Fin del juego!",
+ youWin: "¡Felicidades! Has logrado estabilidad financiera, felicidad y amor. ¡Has ganado en la vida!",
+ dating: "Saliendo con "
+ }
+};
+function getText(key) {
+ return translations[currentLanguage][key] || key;
+}
+// Job data with translations
var availableJobs = [{
- name: "Fast Food Worker",
+ nameEn: "Fast Food Worker",
+ nameEs: "Trabajador de Comida Rápida",
salary: 1200,
requirements: "None",
happiness: -5
}, {
- name: "Retail Associate",
+ nameEn: "Retail Associate",
+ nameEs: "Asociado de Ventas",
salary: 1400,
requirements: "None",
happiness: -3
}, {
- name: "Office Assistant",
+ nameEn: "Office Assistant",
+ nameEs: "Asistente de Oficina",
salary: 2000,
requirements: "High School",
happiness: 0
}, {
- name: "Bank Teller",
+ nameEn: "Bank Teller",
+ nameEs: "Cajero de Banco",
salary: 2800,
requirements: "Some Experience",
happiness: 5
}, {
- name: "Software Developer",
+ nameEn: "Software Developer",
+ nameEs: "Desarrollador de Software",
salary: 5000,
requirements: "College Degree",
happiness: 15
}, {
- name: "Manager",
+ nameEn: "Manager",
+ nameEs: "Gerente",
salary: 4200,
requirements: "Leadership Experience",
happiness: 10
}];
+function getJobName(job) {
+ return currentLanguage === 'spanish' ? job.nameEs : job.nameEn;
+}
var relationships = [{
- name: "Coffee Shop Regular",
+ nameEn: "Coffee Shop Regular",
+ nameEs: "Cliente Habitual del Café",
status: "Stranger",
happiness: 5
}, {
- name: "Gym Partner",
+ nameEn: "Gym Partner",
+ nameEs: "Compañero de Gimnasio",
status: "Acquaintance",
happiness: 8
}, {
- name: "Coworker",
+ nameEn: "Coworker",
+ nameEs: "Compañero de Trabajo",
status: "Friend",
happiness: 12
}];
+function getPersonName(person) {
+ return currentLanguage === 'spanish' ? person.nameEs : person.nameEn;
+}
// UI Elements
var backgroundPanel = game.addChild(LK.getAsset('backgroundPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
}));
-var titleText = new Text2("Life Simulator: Rise to Success", {
+var titleText = new Text2(getText('selectLanguage'), {
size: 60,
fill: 0xE74C3C
});
titleText.anchor.set(0.5, 0);
titleText.x = 1024;
titleText.y = 150;
game.addChild(titleText);
// Stats display
-var moneyDisplay = game.addChild(new StatDisplay("Money", playerMoney, 0x27ae60));
+var moneyDisplay = game.addChild(new StatDisplay(getText('money'), playerMoney, 0x27ae60));
moneyDisplay.x = 224;
moneyDisplay.y = 250;
-var jobDisplay = game.addChild(new StatDisplay("Job", playerJob, 0x8e44ad));
+var jobDisplay = game.addChild(new StatDisplay(getText('job'), getText('unemployed'), 0x8e44ad));
jobDisplay.x = 224;
jobDisplay.y = 350;
-jobDisplay.updateValue(playerJob, "");
-var happinessDisplay = game.addChild(new StatDisplay("Happiness", playerHappiness + "%", 0xf39c12));
+jobDisplay.updateValue(getText('unemployed'), "");
+var happinessDisplay = game.addChild(new StatDisplay(getText('happiness'), playerHappiness + "%", 0xf39c12));
happinessDisplay.x = 224;
happinessDisplay.y = 450;
happinessDisplay.updateValue(playerHappiness + "%", "");
-var relationshipDisplay = game.addChild(new StatDisplay("Relationship", playerRelationship, 0xe91e63));
+var relationshipDisplay = game.addChild(new StatDisplay(getText('relationship'), getText('single'), 0xe91e63));
relationshipDisplay.x = 224;
relationshipDisplay.y = 550;
-relationshipDisplay.updateValue(playerRelationship, "");
+relationshipDisplay.updateValue(getText('single'), "");
// Event panel
var eventPanel = game.addChild(LK.getAsset('eventPanel', {
anchorX: 0.5,
anchorY: 0,
x: 1024,
y: 700
}));
-var eventText = new Text2("Welcome to your adult life! You're starting with $1000. What's your first move?", {
+var eventText = new Text2(getText('selectLanguage'), {
size: 42,
fill: 0xFFFFFF
});
eventText.anchor.set(0.5, 0);
@@ -188,26 +281,54 @@
button.y = 1200 + choiceButtons.length * 140;
game.addChild(button);
choiceButtons.push(button);
}
+function showLanguageMenu() {
+ titleText.setText(getText('selectLanguage'));
+ eventText.setText(getText('selectLanguage'));
+ clearChoices();
+ addChoice(getText('english'), function () {
+ currentLanguage = 'english';
+ storage.set('language', 'english');
+ showingLanguageMenu = false;
+ updateUILanguage();
+ showMainMenu();
+ });
+ addChoice(getText('spanish'), function () {
+ currentLanguage = 'spanish';
+ storage.set('language', 'spanish');
+ showingLanguageMenu = false;
+ updateUILanguage();
+ showMainMenu();
+ });
+}
+function updateUILanguage() {
+ titleText.setText(getText('title'));
+ moneyDisplay.labelText.setText(getText('money') + ": $" + playerMoney);
+ jobDisplay.labelText.setText(getText('job') + ": " + (playerJob === "Unemployed" ? getText('unemployed') : playerJob));
+ happinessDisplay.labelText.setText(getText('happiness') + ": " + playerHappiness + "%");
+ relationshipDisplay.labelText.setText(getText('relationship') + ": " + (playerRelationship === "Single" ? getText('single') : playerRelationship));
+}
function updateStats() {
moneyDisplay.updateValue(playerMoney);
- jobDisplay.updateValue(playerJob, "");
+ var jobText = playerJob === "Unemployed" ? getText('unemployed') : playerJob;
+ jobDisplay.updateValue(jobText, "");
happinessDisplay.updateValue(playerHappiness + "%", "");
- relationshipDisplay.updateValue(playerRelationship, "");
+ var relationshipText = playerRelationship === "Single" ? getText('single') : playerRelationship;
+ relationshipDisplay.updateValue(relationshipText, "");
}
function checkGameOver() {
if (playerMoney <= 0 && monthsUnemployed >= 3) {
- eventText.setText("You've run out of money and can't find work. You're forced to move back with your parents. Game Over!");
+ eventText.setText(getText('gameOver'));
clearChoices();
LK.getSound('failure').play();
LK.setTimeout(function () {
LK.showGameOver();
}, 2000);
return true;
}
- if (playerMoney >= 10000 && playerHappiness >= 80 && playerRelationship !== "Single") {
- eventText.setText("Congratulations! You've achieved financial stability, happiness, and love. You've won at life!");
+ if (playerMoney >= 10000 && playerHappiness >= 80 && playerRelationship !== getText('single')) {
+ eventText.setText(getText('youWin'));
clearChoices();
LK.getSound('success').play();
LK.setTimeout(function () {
LK.showYouWin();
@@ -217,24 +338,24 @@
return false;
}
function showMainMenu() {
currentScene = "main";
- eventText.setText("Day " + dayCounter + ": What would you like to do today?");
+ eventText.setText(getText('dayText') + " " + dayCounter + getText('whatToDo'));
clearChoices();
- addChoice("Look for a job", function () {
+ addChoice(getText('lookForJob'), function () {
showJobSearch();
});
- addChoice("Go on a date", function () {
+ addChoice(getText('goOnDate'), function () {
showDating();
});
- addChoice("Rest at home (+10 happiness)", function () {
+ addChoice(getText('restAtHome'), function () {
playerHappiness = Math.min(100, playerHappiness + 10);
playerMoney -= 50; // Daily expenses
advanceDay();
});
- addChoice("Work extra hours (+money)", function () {
+ addChoice(getText('workExtra'), function () {
if (playerJob === "Unemployed") {
- eventText.setText("You need a job first!");
+ eventText.setText(getText('needJobFirst'));
return;
}
playerMoney += Math.floor(playerSalary * 0.3);
playerHappiness = Math.max(0, playerHappiness - 5);
@@ -243,94 +364,94 @@
});
}
function showJobSearch() {
currentScene = "jobs";
- eventText.setText("Available job opportunities:");
+ eventText.setText(getText('availableJobs'));
clearChoices();
for (var i = 0; i < Math.min(3, availableJobs.length); i++) {
var job = availableJobs[i];
(function (jobData) {
- addChoice(jobData.name + " ($" + jobData.salary + "/month)", function () {
+ addChoice(getJobName(jobData) + " ($" + jobData.salary + "/month)", function () {
applyForJob(jobData);
});
})(job);
}
- addChoice("Go back", function () {
+ addChoice(getText('goBack'), function () {
showMainMenu();
});
}
function applyForJob(job) {
var chance = Math.random();
if (chance > 0.3) {
- playerJob = job.name;
+ playerJob = getJobName(job);
playerSalary = job.salary;
playerHappiness += job.happiness;
monthsUnemployed = 0;
- eventText.setText("Congratulations! You got the job as " + job.name + "!");
+ eventText.setText(getText('congratsJob') + getJobName(job) + "!");
LK.getSound('success').play();
} else {
- eventText.setText("Sorry, you didn't get the job. Better luck next time!");
+ eventText.setText(getText('noJob'));
LK.getSound('failure').play();
}
clearChoices();
- addChoice("Continue", function () {
+ addChoice(getText('continue'), function () {
playerMoney -= 50; // Daily expenses
advanceDay();
});
}
function showDating() {
currentScene = "dating";
var person = relationships[Math.floor(Math.random() * relationships.length)];
- eventText.setText("You meet " + person.name + " at a local cafe. They seem interesting!");
+ eventText.setText(currentLanguage === 'spanish' ? "Conoces a " + getPersonName(person) + " en un café local. ¡Parece interesante!" : "You meet " + getPersonName(person) + " at a local cafe. They seem interesting!");
clearChoices();
- addChoice("Ask them out ($100)", function () {
+ addChoice(getText('askOut'), function () {
if (playerMoney < 100) {
- eventText.setText("You don't have enough money for a proper date!");
+ eventText.setText(getText('notEnoughMoney'));
clearChoices();
- addChoice("Go back", function () {
+ addChoice(getText('goBack'), function () {
showMainMenu();
});
return;
}
playerMoney -= 100;
var success = Math.random() > 0.4;
if (success) {
playerHappiness += person.happiness;
- playerRelationship = "Dating " + person.name;
- eventText.setText("Great! You had a wonderful time together!");
+ playerRelationship = getText('dating') + getPersonName(person);
+ eventText.setText(getText('wonderfulTime'));
LK.getSound('success').play();
} else {
playerHappiness -= 5;
- eventText.setText("The date didn't go well. Maybe next time!");
+ eventText.setText(getText('dateNotWell'));
LK.getSound('failure').play();
}
clearChoices();
- addChoice("Continue", function () {
+ addChoice(getText('continue'), function () {
playerMoney -= 50; // Daily expenses
advanceDay();
});
});
- addChoice("Just be friends", function () {
+ addChoice(getText('justFriends'), function () {
playerHappiness += 3;
- eventText.setText("You had a nice friendly conversation!");
+ eventText.setText(getText('friendlyChat'));
clearChoices();
- addChoice("Continue", function () {
+ addChoice(getText('continue'), function () {
playerMoney -= 50; // Daily expenses
advanceDay();
});
});
- addChoice("Go back", function () {
+ addChoice(getText('goBack'), function () {
showMainMenu();
});
}
function advanceDay() {
dayCounter++;
// Monthly salary
- if (dayCounter % 30 === 0 && playerJob !== "Unemployed") {
+ if (dayCounter % 30 === 0 && playerJob !== getText('unemployed')) {
playerMoney += playerSalary;
- eventText.setText("Payday! You received $" + playerSalary + " from your job as " + playerJob);
+ eventText.setText(getText('payday') + playerSalary + (currentLanguage === 'spanish' ? " de tu trabajo como " + playerJob : " from your job as " + playerJob));
clearChoices();
- addChoice("Continue", function () {
+ addChoice(getText('continue'), function () {
checkDailyEvents();
});
return;
}
@@ -346,30 +467,34 @@
}
}
function showRandomEvent() {
var events = [{
- text: "You found $50 on the street!",
+ textEn: "You found $50 on the street!",
+ textEs: "¡Encontraste $50 en la calle!",
money: 50,
happiness: 5
}, {
- text: "Your car broke down. Repair costs $300.",
+ textEn: "Your car broke down. Repair costs $300.",
+ textEs: "Tu auto se descompuso. Los costos de reparación son $300.",
money: -300,
happiness: -10
}, {
- text: "You won a small lottery prize of $200!",
+ textEn: "You won a small lottery prize of $200!",
+ textEs: "¡Ganaste un pequeño premio de lotería de $200!",
money: 200,
happiness: 15
}, {
- text: "You got sick and had to pay $150 for medicine.",
+ textEn: "You got sick and had to pay $150 for medicine.",
+ textEs: "Te enfermaste y tuviste que pagar $150 por medicina.",
money: -150,
happiness: -5
}];
var event = events[Math.floor(Math.random() * events.length)];
playerMoney = Math.max(0, playerMoney + event.money);
playerHappiness = Math.max(0, Math.min(100, playerHappiness + event.happiness));
- eventText.setText(event.text);
+ eventText.setText(currentLanguage === 'spanish' ? event.textEs : event.textEn);
clearChoices();
- addChoice("Continue", function () {
+ addChoice(getText('continue'), function () {
checkDailyEvents();
});
}
function checkDailyEvents() {
@@ -379,5 +504,10 @@
}
showMainMenu();
}
// Initialize the game
-showMainMenu();
\ No newline at end of file
+if (showingLanguageMenu) {
+ showLanguageMenu();
+} else {
+ updateUILanguage();
+ showMainMenu();
+}
\ No newline at end of file
Personaje artística viendo a la cámara pixel art. In-Game asset. 2d. High contrast. No shadows
Hombre atlético mirando a la cámara pixel art. In-Game asset. 2d. High contrast. No shadows
Hombre trabajador mirando a la cámara pixel art. In-Game asset. 2d. High contrast. No shadows
Hombre ejecutivo mirando a la cámara pixel art. In-Game asset. 2d. High contrast. No shadows
Personaje hombre casual mirando a la cámara pixel art. In-Game asset. 2d. High contrast. No shadows