User prompt
Please fix the bug: 'Timeout.tick error: resultText.setTextColor is not a function' in or related to this line: 'resultText.setTextColor("#00FF00");' Line Number: 166
User prompt
make every half hour, you get 50 dollars
User prompt
Please fix the bug: 'Timeout.tick error: Cannot set properties of undefined (setting 'fill')' in or related to this line: 'resultText.style.fill = "#00FF00";' Line Number: 166
User prompt
make when the AI project percent is >10 without any player support, then the boss fires you and you can either become jobless or get a new job (do random names for the companies)
User prompt
make another sprite and the text on it is YOU GOT FIRED
User prompt
when its past 10%, make a YOU GOT FIRED SCREEN and all of the company options are added and each business has 2% less salary and every half hour you get 50 Dollars
User prompt
make each minute in game add 1% to the AI Project
User prompt
add different workers working on the ai project with you, and so each minute in game, 1% Is added but if you didn't contribute before the AI% is more than 10%, you get fired and have a chance to get new jobs, such as Meow Meow Motors, Toyoda Motors, and DevelopingAI,
User prompt
alright here's the fixed version: make it so every hour you get paid by the evil boss, and make the AI Project, when clicked, hide everything else and you can click on, video or upload and each button gives the ai project 1%
Code edit (1 edits merged)
Please save this source code
User prompt
Life Shift: Shop, Gamble, Repeat
Initial prompt
make a casino Esque game, where you work at a shop via swiping and each minute is one hour in game, and you can click buy drugs (medicine) and at 5pm your shift is done and you start work at 5 am, and you can gamble your money, and you work on a AI Project, and the casino is a 50/50 chance Title
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { money: 100, health: 100, aiProgress: 0, day: 1 }); /**** * Classes ****/ var CoinFlipGame = Container.expand(function () { var self = Container.call(this); var background = self.attachAsset('shopBackground', { anchorX: 0.5, anchorY: 0.5, width: 800, height: 600, tint: 0x222222 }); var coin = self.attachAsset('coinHeads', { anchorX: 0.5, anchorY: 0.5, y: -100, scaleX: 2, scaleY: 2 }); var titleText = new Text2("50/50 Gambling", { size: 50, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.y = -200; self.addChild(titleText); var betText = new Text2("Bet Amount: $10", { size: 30, fill: 0xFFFFFF }); betText.anchor.set(0.5, 0.5); betText.y = 50; self.addChild(betText); var resultText = new Text2("", { size: 40, fill: 0xFFFFFF }); resultText.anchor.set(0.5, 0.5); resultText.y = 150; self.addChild(resultText); self.visible = false; self.betAmount = 10; self.isFlipping = false; // Create buttons var headsButton = new MenuButton("Bet on Heads", function () { self.flipCoin("heads"); }); headsButton.x = -150; headsButton.y = 100; self.addChild(headsButton); var tailsButton = new MenuButton("Bet on Tails", function () { self.flipCoin("tails"); }); tailsButton.x = 150; tailsButton.y = 100; self.addChild(tailsButton); var closeButton = new MenuButton("Close", function () { self.hide(); }); closeButton.x = 0; closeButton.y = 220; self.addChild(closeButton); // Bet amount buttons var decreaseBetButton = new MenuButton("-", function () { if (self.betAmount > 10) { self.betAmount -= 10; betText.setText("Bet Amount: $" + self.betAmount); } }); decreaseBetButton.x = -100; decreaseBetButton.y = 50; self.addChild(decreaseBetButton); var increaseBetButton = new MenuButton("+", function () { self.betAmount += 10; betText.setText("Bet Amount: $" + self.betAmount); }); increaseBetButton.x = 100; increaseBetButton.y = 50; self.addChild(increaseBetButton); self.show = function () { self.visible = true; resultText.setText(""); coin.texture = LK.getAsset('coinHeads', {}).texture; }; self.hide = function () { self.visible = false; }; self.flipCoin = function (userChoice) { if (self.isFlipping) { return; } // Check if player has enough money if (storage.money < self.betAmount) { resultText.setText("Not enough money!"); LK.getSound('error').play(); return; } self.isFlipping = true; LK.getSound('coinFlip').play(); // Animation for coin flip var flipCount = 0; var maxFlips = 10; var flipTimer = LK.setInterval(function () { flipCount++; // Toggle between heads and tails if (flipCount % 2 === 0) { coin.texture = LK.getAsset('coinHeads', {}).texture; } else { coin.texture = LK.getAsset('coinTails', {}).texture; } // Scaling animation if (flipCount <= maxFlips / 2) { coin.scaleX = 2 - flipCount * 0.2; } else { coin.scaleX = 1 + (flipCount - maxFlips / 2) * 0.2; } // End of animation if (flipCount >= maxFlips) { LK.clearInterval(flipTimer); // Determine result (50/50 chance) var result = Math.random() < 0.5 ? "heads" : "tails"; // Set final coin face coin.texture = LK.getAsset(result === "heads" ? 'coinHeads' : 'coinTails', {}).texture; // Check if player won if (result === userChoice) { // Player won resultText.setText("You Won $" + self.betAmount + "!"); resultText.style.fill = "#00FF00"; storage.money += self.betAmount; } else { // Player lost resultText.setText("You Lost $" + self.betAmount); resultText.style.fill = "#FF0000"; storage.money -= self.betAmount; } self.emit('gamblingComplete', { result: result === userChoice ? "win" : "loss", amount: self.betAmount }); self.isFlipping = false; } }, 100); }; self.on = function (event, callback) { if (!self._events) { self._events = {}; } if (!self._events[event]) { self._events[event] = []; } self._events[event].push(callback); }; self.emit = function (event, data) { if (self._events && self._events[event]) { self._events[event].forEach(function (callback) { callback(data); }); } }; return self; }); var Customer = Container.expand(function () { var self = Container.call(this); var customerGraphic = self.attachAsset('customer', { anchorX: 0.5, anchorY: 0.5 }); var productGraphic = self.attachAsset('productItem', { anchorX: 0.5, anchorY: 0.5, y: -120 }); self.itemValue = 0; self.serveTime = 0; self.active = true; self.reset = function () { self.itemValue = Math.floor(Math.random() * 20) + 10; self.serveTime = Math.floor(Math.random() * 5) + 3; self.active = true; var valueText = new Text2(self.itemValue + '$', { size: 40, fill: 0xFFFFFF }); valueText.anchor.set(0.5, 0.5); productGraphic.addChild(valueText); }; self.down = function (x, y, obj) { if (self.active) { self.startDragX = x; self.startDragY = y; self.isDragging = true; } }; self.up = function (x, y, obj) { if (self.isDragging) { var dragDistanceX = x - self.startDragX; if (Math.abs(dragDistanceX) > 200) { // Successful swipe self.active = false; LK.getSound('swipe').play(); // Move customer off screen var direction = dragDistanceX > 0 ? 2500 : -500; tween(self, { x: direction }, { duration: 500, onFinish: function onFinish() { self.emit('customerServed', self.itemValue); } }); } self.isDragging = false; } }; self.move = function (x, y, obj) { if (self.isDragging) { var dragDistanceX = x - self.startDragX; if (Math.abs(dragDistanceX) < 300) { self.x = self.originalX + dragDistanceX; } } }; self.reset(); return self; }); var DayNightCycle = Container.expand(function () { var self = Container.call(this); var sunMoon = self.attachAsset('dayNightCycle', { anchorX: 0.5, anchorY: 0.5 }); var timeText = new Text2("5:00 AM", { size: 50, fill: 0x000000 }); timeText.anchor.set(0.5, 0.5); timeText.y = 70; self.addChild(timeText); var dayText = new Text2("Day 1", { size: 30, fill: 0x000000 }); dayText.anchor.set(0.5, 0.5); dayText.y = -70; self.addChild(dayText); self.currentHour = 5; // 5 AM start self.currentMinute = 0; self.day = 1; self.isAM = true; self.updateDay = function (newDay) { self.day = newDay; dayText.setText("Day " + self.day); }; self.updateTime = function () { self.currentMinute++; if (self.currentMinute >= 60) { self.currentMinute = 0; self.currentHour++; if (self.currentHour == 12) { self.isAM = !self.isAM; } else if (self.currentHour > 12) { self.currentHour = 1; } // Update sun/moon position and color based on time var timeOfDay = (self.currentHour + (self.isAM ? 0 : 12)) % 24; var angle = timeOfDay / 24 * 2 * Math.PI - Math.PI / 2; // Calculate position on a circular path var radius = 50; var cycleX = Math.cos(angle) * radius; var cycleY = Math.sin(angle) * radius; sunMoon.x = cycleX; sunMoon.y = cycleY; // Change color based on time (yellow for day, silver for night) if (timeOfDay >= 6 && timeOfDay < 18) { sunMoon.tint = 0xFFD700; // day - yellow } else { sunMoon.tint = 0xC0C0C0; // night - silver } self.emit('hourChanged', { hour: self.currentHour, isAM: self.isAM }); // Pay the player every hour if (shopOpen) { storage.money += 10; // Pay $10 every hour self.emit('hourlyPayment', { amount: 10 }); } } var displayHour = self.currentHour; var displayMinute = self.currentMinute.toString().padStart(2, '0'); var ampm = self.isAM ? "AM" : "PM"; timeText.setText(displayHour + ":" + displayMinute + " " + ampm); }; self.reset = function () { self.currentHour = 5; self.currentMinute = 0; self.isAM = true; self.updateTime(); }; self.on = function (event, callback) { if (!self._events) { self._events = {}; } if (!self._events[event]) { self._events[event] = []; } self._events[event].push(callback); }; self.emit = function (event, data) { if (self._events && self._events[event]) { self._events[event].forEach(function (callback) { callback(data); }); } }; return self; }); var MenuButton = Container.expand(function (text, callback) { var self = Container.call(this); var button = self.attachAsset('menuButton', { anchorX: 0.5, anchorY: 0.5 }); var buttonText = new Text2(text, { size: 30, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.down = function () { button.tint = 0x3468A0; // Darker blue when pressed self.isPressed = true; }; self.up = function () { if (self.isPressed) { button.tint = 0x4682B4; // Reset to original color if (callback) { callback(); } self.isPressed = false; } }; return self; }); var ShopInterface = Container.expand(function () { var self = Container.call(this); // Shop background var background = self.attachAsset('shopBackground', { anchorX: 0.5, anchorY: 0, x: 1024, y: 400 }); // Counter var counter = self.attachAsset('counterTop', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1100 }); // Cash register var register = self.attachAsset('cashRegister', { anchorX: 0.5, anchorY: 0.5, x: 1500, y: 1020 }); // Computer for AI project var computer = self.attachAsset('computerScreen', { anchorX: 0.5, anchorY: 0.5, x: 700, y: 1020 }); // Text display for computer var computerText = new Text2("AI PROJECT", { size: 30, fill: 0x00FF00 }); computerText.anchor.set(0.5, 0.5); computer.addChild(computerText); self.on = function (event, callback) { if (!self._events) { self._events = {}; } if (!self._events[event]) { self._events[event] = []; } self._events[event].push(callback); }; self.emit = function (event, data) { if (self._events && self._events[event]) { self._events[event].forEach(function (callback) { callback(data); }); } }; // Computer click handler computer.interactive = true; computer.down = function () { self.emit('workOnAI'); // Hide other elements and show AI options shopInterface.visible = false; statusBars.visible = false; dayNightCycle.visible = false; // Create AI interaction interface var aiInterface = new Container(); var videoButton = new MenuButton("Video", function () { aiProgress += 1; statusBars.updateAIProgress(aiProgress); aiInterface.visible = false; shopInterface.visible = true; statusBars.visible = true; dayNightCycle.visible = true; }); videoButton.x = 1024; videoButton.y = 800; aiInterface.addChild(videoButton); var uploadButton = new MenuButton("Upload", function () { aiProgress += 1; statusBars.updateAIProgress(aiProgress); aiInterface.visible = false; shopInterface.visible = true; statusBars.visible = true; dayNightCycle.visible = true; }); uploadButton.x = 1024; uploadButton.y = 1000; aiInterface.addChild(uploadButton); game.addChild(aiInterface); }; return self; }); var StatusBars = Container.expand(function () { var self = Container.call(this); // Health bar background var healthBg = self.attachAsset('healthBarBackground', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); // Health bar var healthBar = self.attachAsset('healthBar', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: 500 // Full width initially }); // Health label var healthText = new Text2("Health", { size: 30, fill: 0x000000 }); healthText.x = 10; healthText.y = -5; self.addChild(healthText); // AI Progress bar background var aiProgressBg = self.attachAsset('aiProgressBarBackground', { anchorX: 0, anchorY: 0, x: 0, y: 50 }); // AI Progress bar var aiProgressBar = self.attachAsset('aiProgressBar', { anchorX: 0, anchorY: 0, x: 0, y: 50, width: 0 // Start at 0 progress }); // AI Progress label var aiProgressText = new Text2("AI Project: 0%", { size: 30, fill: 0x000000 }); aiProgressText.x = 10; aiProgressText.y = 45; self.addChild(aiProgressText); // Money display var moneyText = new Text2("$100", { size: 40, fill: 0x008000 }); moneyText.x = 250; moneyText.y = -50; self.addChild(moneyText); self.updateHealth = function (health) { var barWidth = health / 100 * 500; healthBar.width = barWidth; // Change color based on health level if (health > 70) { healthBar.tint = 0x00FF00; // Green } else if (health > 30) { healthBar.tint = 0xFFFF00; // Yellow } else { healthBar.tint = 0xFF0000; // Red } }; self.updateAIProgress = function (progress) { var barWidth = progress / 100 * 500; aiProgressBar.width = barWidth; aiProgressText.setText("AI Project: " + Math.floor(progress) + "%"); }; self.updateMoney = function (amount) { moneyText.setText("$" + amount); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ function offerNewJobs() { // Create job options interface var jobInterface = new Container(); var meowMeowMotorsButton = new MenuButton("Meow Meow Motors", function () { // Logic for accepting job at Meow Meow Motors fired = false; aiProgress = 0; aiWorkers = 0; jobInterface.visible = false; shopInterface.visible = true; statusBars.visible = true; dayNightCycle.visible = true; // Adjust salary for new job paymentData.amount -= paymentData.amount * 0.02; }); meowMeowMotorsButton.x = 1024; meowMeowMotorsButton.y = 800; jobInterface.addChild(meowMeowMotorsButton); var toyodaMotorsButton = new MenuButton("Toyoda Motors", function () { // Logic for accepting job at Toyoda Motors fired = false; aiProgress = 0; aiWorkers = 0; jobInterface.visible = false; shopInterface.visible = true; statusBars.visible = true; dayNightCycle.visible = true; // Adjust salary for new job paymentData.amount -= paymentData.amount * 0.02; }); toyodaMotorsButton.x = 1024; toyodaMotorsButton.y = 1000; jobInterface.addChild(toyodaMotorsButton); var developingAIButton = new MenuButton("DevelopingAI", function () { // Logic for accepting job at DevelopingAI fired = false; aiProgress = 0; aiWorkers = 0; jobInterface.visible = false; shopInterface.visible = true; statusBars.visible = true; dayNightCycle.visible = true; // Adjust salary for new job paymentData.amount -= paymentData.amount * 0.02; }); developingAIButton.x = 1024; developingAIButton.y = 1200; jobInterface.addChild(developingAIButton); game.addChild(jobInterface); } // Global game variables var money = storage.money; var health = storage.health; var aiProgress = storage.aiProgress; var currentDay = storage.day; var shopOpen = false; var gameRunning = true; var workOnAITime = 0; var aiWorkers = 0; // Number of workers contributing to AI project var fired = false; // Track if player is fired var customerWaitingTime = 0; var timeToNextCustomer = 3; var activeCustomers = []; var medicinePrice = 30; // Interface elements var shopInterface = new ShopInterface(); shopInterface.x = 0; shopInterface.y = 0; game.addChild(shopInterface); // Status display var statusBars = new StatusBars(); statusBars.x = 50; statusBars.y = 150; game.addChild(statusBars); // Update initial status displays statusBars.updateHealth(health); statusBars.updateAIProgress(aiProgress); statusBars.updateMoney(money); // Time display var dayNightCycle = new DayNightCycle(); dayNightCycle.x = 1800; dayNightCycle.y = 150; dayNightCycle.updateDay(currentDay); game.addChild(dayNightCycle); // Menu buttons var takeMedicineButton = new MenuButton("Take Medicine ($" + medicinePrice + ")", function () { if (money >= medicinePrice && health < 100) { money -= medicinePrice; health = Math.min(100, health + 30); statusBars.updateHealth(health); statusBars.updateMoney(money); LK.getSound('pillTaken').play(); } else if (health >= 100) { // Already at full health LK.getSound('error').play(); } else { // Not enough money LK.getSound('error').play(); } }); takeMedicineButton.x = 1650; takeMedicineButton.y = 250; game.addChild(takeMedicineButton); var gamblingButton = new MenuButton("Try Gambling", function () { coinFlipGame.show(); }); gamblingButton.x = 1650; gamblingButton.y = 350; game.addChild(gamblingButton); // Create gambling mini-game var coinFlipGame = new CoinFlipGame(); coinFlipGame.x = 1024; coinFlipGame.y = 1300; game.addChild(coinFlipGame); // Event handlers shopInterface.on('workOnAI', function () { if (!shopOpen) { return; } // Simulate working on AI project workOnAITime = 60; // Work for 1 hour (60 minutes) LK.getSound('typing').play(); // Flash the computer screen var computer = shopInterface.children[3]; // The computer screen tween(computer, { tint: 0x00FF00 }, { duration: 200, onFinish: function onFinish() { tween(computer, { tint: 0x000080 }, { duration: 200 }); } }); }); coinFlipGame.on('gamblingComplete', function (result) { statusBars.updateMoney(money); }); dayNightCycle.on('hourChanged', function (timeData) { // Check if it's time to open or close the shop if (timeData.hour === 5 && !timeData.isAM) { // 5 PM - Closing time shopOpen = false; endDay(); } else if (timeData.hour === 5 && timeData.isAM) { // 5 AM - Opening time shopOpen = true; startDay(); } // Decrease health over time (more when working) if (shopOpen) { health -= 0.5; health = Math.max(0, health); statusBars.updateHealth(health); // Check if health is critically low if (health <= 0) { LK.showGameOver(); } } }); dayNightCycle.on('hourlyPayment', function (paymentData) { if (fired) { money += 50; // Adjusted payment after being fired } else { money += paymentData.amount; } statusBars.updateMoney(money); }); // Handle customer creation and management function createCustomer() { if (!shopOpen || activeCustomers.length >= 3) { return; } var customer = new Customer(); customer.x = 1024; // Center X customer.y = 750; // Position Y customer.originalX = customer.x; // Offset each customer to prevent overlap if (activeCustomers.length > 0) { var offset = activeCustomers.length * 300 - 300; customer.x += offset; customer.originalX = customer.x; } // Handle customer served event customer.on = function (event, callback) { if (!customer._events) { customer._events = {}; } if (!customer._events[event]) { customer._events[event] = []; } customer._events[event].push(callback); }; customer.emit = function (event, data) { if (customer._events && customer._events[event]) { customer._events[event].forEach(function (callback) { callback(data); }); } }; customer.on('customerServed', function (value) { // Remove from active customers var index = activeCustomers.indexOf(customer); if (index !== -1) { activeCustomers.splice(index, 1); } // Add money money += value; statusBars.updateMoney(money); LK.getSound('cashRegister').play(); // Rearrange remaining customers rearrangeCustomers(); // Remove from game game.removeChild(customer); }); // Add to game and track activeCustomers.push(customer); game.addChild(customer); // Reset timer for next customer timeToNextCustomer = Math.floor(Math.random() * 3) + 2; } function rearrangeCustomers() { for (var i = 0; i < activeCustomers.length; i++) { var targetX = 1024 + i * 300 - 300; tween(activeCustomers[i], { x: targetX }, { duration: 300 }); activeCustomers[i].originalX = targetX; } } function startDay() { // Reset daily variables shopOpen = true; timeToNextCustomer = 3; // Ensure health display is updated statusBars.updateHealth(health); } function endDay() { // Save game state storage.money = money; storage.health = health; storage.aiProgress = aiProgress; storage.day = currentDay + 1; // Clear active customers for (var i = activeCustomers.length - 1; i >= 0; i--) { game.removeChild(activeCustomers[i]); } activeCustomers = []; // Update display currentDay++; dayNightCycle.updateDay(currentDay); // Victory condition check if (aiProgress >= 100) { LK.showYouWin(); } } // Main game update loop game.update = function () { if (!gameRunning) { return; } // Update time (1 real-time second = 1 minute in game) if (LK.ticks % 60 === 0) { dayNightCycle.updateTime(); aiProgress += 1; // Add 1% to the AI Project every in-game minute statusBars.updateAIProgress(aiProgress); // Process AI work time if (workOnAITime > 0) { workOnAITime--; // Progress AI project aiProgress += 0.5 + aiWorkers; // Workers contribute to AI progress // Check if player should be fired if (aiProgress > 10 && workOnAITime === 0 && !fired) { fired = true; LK.showGameOver(); // Player is fired // Show 'YOU GOT FIRED' screen var firedScreen = new Container(); var firedText = new Text2("YOU GOT FIRED", { size: 100, fill: 0xFF0000 }); firedText.anchor.set(0.5, 0.5); firedText.x = 1024; firedText.y = 600; firedScreen.addChild(firedText); game.addChild(firedScreen); // Offer new job options offerNewJobs(); } if (aiProgress >= 100) { aiProgress = 100; // Victory achieved } statusBars.updateAIProgress(aiProgress); } // Process customer waiting time if (shopOpen) { customerWaitingTime++; if (customerWaitingTime >= timeToNextCustomer) { customerWaitingTime = 0; createCustomer(); } } } }; // Start game music LK.playMusic('shopMusic');
===================================================================
--- original.js
+++ change.js
@@ -544,8 +544,10 @@
jobInterface.visible = false;
shopInterface.visible = true;
statusBars.visible = true;
dayNightCycle.visible = true;
+ // Adjust salary for new job
+ paymentData.amount -= paymentData.amount * 0.02;
});
meowMeowMotorsButton.x = 1024;
meowMeowMotorsButton.y = 800;
jobInterface.addChild(meowMeowMotorsButton);
@@ -557,8 +559,10 @@
jobInterface.visible = false;
shopInterface.visible = true;
statusBars.visible = true;
dayNightCycle.visible = true;
+ // Adjust salary for new job
+ paymentData.amount -= paymentData.amount * 0.02;
});
toyodaMotorsButton.x = 1024;
toyodaMotorsButton.y = 1000;
jobInterface.addChild(toyodaMotorsButton);
@@ -570,8 +574,10 @@
jobInterface.visible = false;
shopInterface.visible = true;
statusBars.visible = true;
dayNightCycle.visible = true;
+ // Adjust salary for new job
+ paymentData.amount -= paymentData.amount * 0.02;
});
developingAIButton.x = 1024;
developingAIButton.y = 1200;
jobInterface.addChild(developingAIButton);
@@ -689,9 +695,13 @@
}
}
});
dayNightCycle.on('hourlyPayment', function (paymentData) {
- money += paymentData.amount;
+ if (fired) {
+ money += 50; // Adjusted payment after being fired
+ } else {
+ money += paymentData.amount;
+ }
statusBars.updateMoney(money);
});
// Handle customer creation and management
function createCustomer() {
@@ -801,8 +811,19 @@
// Check if player should be fired
if (aiProgress > 10 && workOnAITime === 0 && !fired) {
fired = true;
LK.showGameOver(); // Player is fired
+ // Show 'YOU GOT FIRED' screen
+ var firedScreen = new Container();
+ var firedText = new Text2("YOU GOT FIRED", {
+ size: 100,
+ fill: 0xFF0000
+ });
+ firedText.anchor.set(0.5, 0.5);
+ firedText.x = 1024;
+ firedText.y = 600;
+ firedScreen.addChild(firedText);
+ game.addChild(firedScreen);
// Offer new job options
offerNewJobs();
}
if (aiProgress >= 100) {