User prompt
Has un menuĚ principal donde puedas elegir de espanĚol y ingleĚ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 maĚ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 ****/ // Game state variables 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"; // Job data var availableJobs = [{ name: "Fast Food Worker", salary: 1200, requirements: "None", happiness: -5 }, { name: "Retail Associate", salary: 1400, requirements: "None", happiness: -3 }, { name: "Office Assistant", salary: 2000, requirements: "High School", happiness: 0 }, { name: "Bank Teller", salary: 2800, requirements: "Some Experience", happiness: 5 }, { name: "Software Developer", salary: 5000, requirements: "College Degree", happiness: 15 }, { name: "Manager", salary: 4200, requirements: "Leadership Experience", happiness: 10 }]; var relationships = [{ name: "Coffee Shop Regular", status: "Stranger", happiness: 5 }, { name: "Gym Partner", status: "Acquaintance", happiness: 8 }, { name: "Coworker", status: "Friend", happiness: 12 }]; // 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", { 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)); moneyDisplay.x = 224; moneyDisplay.y = 250; var jobDisplay = game.addChild(new StatDisplay("Job", playerJob, 0x8e44ad)); jobDisplay.x = 224; jobDisplay.y = 350; jobDisplay.updateValue(playerJob, ""); var happinessDisplay = game.addChild(new StatDisplay("Happiness", playerHappiness + "%", 0xf39c12)); happinessDisplay.x = 224; happinessDisplay.y = 450; happinessDisplay.updateValue(playerHappiness + "%", ""); var relationshipDisplay = game.addChild(new StatDisplay("Relationship", playerRelationship, 0xe91e63)); relationshipDisplay.x = 224; relationshipDisplay.y = 550; relationshipDisplay.updateValue(playerRelationship, ""); // 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?", { 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 updateStats() { moneyDisplay.updateValue(playerMoney); jobDisplay.updateValue(playerJob, ""); happinessDisplay.updateValue(playerHappiness + "%", ""); relationshipDisplay.updateValue(playerRelationship, ""); } 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!"); 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!"); clearChoices(); LK.getSound('success').play(); LK.setTimeout(function () { LK.showYouWin(); }, 2000); return true; } return false; } function showMainMenu() { currentScene = "main"; eventText.setText("Day " + dayCounter + ": What would you like to do today?"); clearChoices(); addChoice("Look for a job", function () { showJobSearch(); }); addChoice("Go on a date", function () { showDating(); }); addChoice("Rest at home (+10 happiness)", function () { playerHappiness = Math.min(100, playerHappiness + 10); playerMoney -= 50; // Daily expenses advanceDay(); }); addChoice("Work extra hours (+money)", function () { if (playerJob === "Unemployed") { eventText.setText("You need a job first!"); return; } playerMoney += Math.floor(playerSalary * 0.3); playerHappiness = Math.max(0, playerHappiness - 5); playerMoney -= 50; // Daily expenses advanceDay(); }); } function showJobSearch() { currentScene = "jobs"; eventText.setText("Available job opportunities:"); 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 () { applyForJob(jobData); }); })(job); } addChoice("Go back", function () { showMainMenu(); }); } function applyForJob(job) { var chance = Math.random(); if (chance > 0.3) { playerJob = job.name; playerSalary = job.salary; playerHappiness += job.happiness; monthsUnemployed = 0; eventText.setText("Congratulations! You got the job as " + job.name + "!"); LK.getSound('success').play(); } else { eventText.setText("Sorry, you didn't get the job. Better luck next time!"); LK.getSound('failure').play(); } clearChoices(); addChoice("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!"); clearChoices(); addChoice("Ask them out ($100)", function () { if (playerMoney < 100) { eventText.setText("You don't have enough money for a proper date!"); clearChoices(); addChoice("Go back", 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!"); LK.getSound('success').play(); } else { playerHappiness -= 5; eventText.setText("The date didn't go well. Maybe next time!"); LK.getSound('failure').play(); } clearChoices(); addChoice("Continue", function () { playerMoney -= 50; // Daily expenses advanceDay(); }); }); addChoice("Just be friends", function () { playerHappiness += 3; eventText.setText("You had a nice friendly conversation!"); clearChoices(); addChoice("Continue", function () { playerMoney -= 50; // Daily expenses advanceDay(); }); }); addChoice("Go back", function () { showMainMenu(); }); } function advanceDay() { dayCounter++; // Monthly salary if (dayCounter % 30 === 0 && playerJob !== "Unemployed") { playerMoney += playerSalary; eventText.setText("Payday! You received $" + playerSalary + " from your job as " + playerJob); clearChoices(); addChoice("Continue", function () { checkDailyEvents(); }); return; } // Track unemployment if (playerJob === "Unemployed") { monthsUnemployed++; } // Random events if (Math.random() < 0.1) { showRandomEvent(); } else { checkDailyEvents(); } } function showRandomEvent() { var events = [{ text: "You found $50 on the street!", money: 50, happiness: 5 }, { text: "Your car broke down. Repair costs $300.", money: -300, happiness: -10 }, { text: "You won a small lottery prize of $200!", money: 200, happiness: 15 }, { text: "You got sick and had to pay $150 for medicine.", 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); clearChoices(); addChoice("Continue", function () { checkDailyEvents(); }); } function checkDailyEvents() { updateStats(); if (checkGameOver()) { return; } showMainMenu(); } // Initialize the game showMainMenu();
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,383 @@
-/****
+/****
+* 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: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x1a252f
+});
+
+/****
+* Game Code
+****/
+// Game state variables
+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";
+// Job data
+var availableJobs = [{
+ name: "Fast Food Worker",
+ salary: 1200,
+ requirements: "None",
+ happiness: -5
+}, {
+ name: "Retail Associate",
+ salary: 1400,
+ requirements: "None",
+ happiness: -3
+}, {
+ name: "Office Assistant",
+ salary: 2000,
+ requirements: "High School",
+ happiness: 0
+}, {
+ name: "Bank Teller",
+ salary: 2800,
+ requirements: "Some Experience",
+ happiness: 5
+}, {
+ name: "Software Developer",
+ salary: 5000,
+ requirements: "College Degree",
+ happiness: 15
+}, {
+ name: "Manager",
+ salary: 4200,
+ requirements: "Leadership Experience",
+ happiness: 10
+}];
+var relationships = [{
+ name: "Coffee Shop Regular",
+ status: "Stranger",
+ happiness: 5
+}, {
+ name: "Gym Partner",
+ status: "Acquaintance",
+ happiness: 8
+}, {
+ name: "Coworker",
+ status: "Friend",
+ happiness: 12
+}];
+// 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", {
+ 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));
+moneyDisplay.x = 224;
+moneyDisplay.y = 250;
+var jobDisplay = game.addChild(new StatDisplay("Job", playerJob, 0x8e44ad));
+jobDisplay.x = 224;
+jobDisplay.y = 350;
+jobDisplay.updateValue(playerJob, "");
+var happinessDisplay = game.addChild(new StatDisplay("Happiness", playerHappiness + "%", 0xf39c12));
+happinessDisplay.x = 224;
+happinessDisplay.y = 450;
+happinessDisplay.updateValue(playerHappiness + "%", "");
+var relationshipDisplay = game.addChild(new StatDisplay("Relationship", playerRelationship, 0xe91e63));
+relationshipDisplay.x = 224;
+relationshipDisplay.y = 550;
+relationshipDisplay.updateValue(playerRelationship, "");
+// 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?", {
+ 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 updateStats() {
+ moneyDisplay.updateValue(playerMoney);
+ jobDisplay.updateValue(playerJob, "");
+ happinessDisplay.updateValue(playerHappiness + "%", "");
+ relationshipDisplay.updateValue(playerRelationship, "");
+}
+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!");
+ 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!");
+ clearChoices();
+ LK.getSound('success').play();
+ LK.setTimeout(function () {
+ LK.showYouWin();
+ }, 2000);
+ return true;
+ }
+ return false;
+}
+function showMainMenu() {
+ currentScene = "main";
+ eventText.setText("Day " + dayCounter + ": What would you like to do today?");
+ clearChoices();
+ addChoice("Look for a job", function () {
+ showJobSearch();
+ });
+ addChoice("Go on a date", function () {
+ showDating();
+ });
+ addChoice("Rest at home (+10 happiness)", function () {
+ playerHappiness = Math.min(100, playerHappiness + 10);
+ playerMoney -= 50; // Daily expenses
+ advanceDay();
+ });
+ addChoice("Work extra hours (+money)", function () {
+ if (playerJob === "Unemployed") {
+ eventText.setText("You need a job first!");
+ return;
+ }
+ playerMoney += Math.floor(playerSalary * 0.3);
+ playerHappiness = Math.max(0, playerHappiness - 5);
+ playerMoney -= 50; // Daily expenses
+ advanceDay();
+ });
+}
+function showJobSearch() {
+ currentScene = "jobs";
+ eventText.setText("Available job opportunities:");
+ 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 () {
+ applyForJob(jobData);
+ });
+ })(job);
+ }
+ addChoice("Go back", function () {
+ showMainMenu();
+ });
+}
+function applyForJob(job) {
+ var chance = Math.random();
+ if (chance > 0.3) {
+ playerJob = job.name;
+ playerSalary = job.salary;
+ playerHappiness += job.happiness;
+ monthsUnemployed = 0;
+ eventText.setText("Congratulations! You got the job as " + job.name + "!");
+ LK.getSound('success').play();
+ } else {
+ eventText.setText("Sorry, you didn't get the job. Better luck next time!");
+ LK.getSound('failure').play();
+ }
+ clearChoices();
+ addChoice("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!");
+ clearChoices();
+ addChoice("Ask them out ($100)", function () {
+ if (playerMoney < 100) {
+ eventText.setText("You don't have enough money for a proper date!");
+ clearChoices();
+ addChoice("Go back", 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!");
+ LK.getSound('success').play();
+ } else {
+ playerHappiness -= 5;
+ eventText.setText("The date didn't go well. Maybe next time!");
+ LK.getSound('failure').play();
+ }
+ clearChoices();
+ addChoice("Continue", function () {
+ playerMoney -= 50; // Daily expenses
+ advanceDay();
+ });
+ });
+ addChoice("Just be friends", function () {
+ playerHappiness += 3;
+ eventText.setText("You had a nice friendly conversation!");
+ clearChoices();
+ addChoice("Continue", function () {
+ playerMoney -= 50; // Daily expenses
+ advanceDay();
+ });
+ });
+ addChoice("Go back", function () {
+ showMainMenu();
+ });
+}
+function advanceDay() {
+ dayCounter++;
+ // Monthly salary
+ if (dayCounter % 30 === 0 && playerJob !== "Unemployed") {
+ playerMoney += playerSalary;
+ eventText.setText("Payday! You received $" + playerSalary + " from your job as " + playerJob);
+ clearChoices();
+ addChoice("Continue", function () {
+ checkDailyEvents();
+ });
+ return;
+ }
+ // Track unemployment
+ if (playerJob === "Unemployed") {
+ monthsUnemployed++;
+ }
+ // Random events
+ if (Math.random() < 0.1) {
+ showRandomEvent();
+ } else {
+ checkDailyEvents();
+ }
+}
+function showRandomEvent() {
+ var events = [{
+ text: "You found $50 on the street!",
+ money: 50,
+ happiness: 5
+ }, {
+ text: "Your car broke down. Repair costs $300.",
+ money: -300,
+ happiness: -10
+ }, {
+ text: "You won a small lottery prize of $200!",
+ money: 200,
+ happiness: 15
+ }, {
+ text: "You got sick and had to pay $150 for medicine.",
+ 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);
+ clearChoices();
+ addChoice("Continue", function () {
+ checkDailyEvents();
+ });
+}
+function checkDailyEvents() {
+ updateStats();
+ if (checkGameOver()) {
+ return;
+ }
+ showMainMenu();
+}
+// Initialize the game
+showMainMenu();
\ No newline at end of file
Personaje artiĚstica viendo a la caĚmara pixel art. In-Game asset. 2d. High contrast. No shadows
Hombre atleĚtico mirando a la caĚmara pixel art. In-Game asset. 2d. High contrast. No shadows
Hombre trabajador mirando a la caĚmara pixel art. In-Game asset. 2d. High contrast. No shadows
Hombre ejecutivo mirando a la caĚmara pixel art. In-Game asset. 2d. High contrast. No shadows
Personaje hombre casual mirando a la caĚmara pixel art. In-Game asset. 2d. High contrast. No shadows