User prompt
markete BAM adını ver
User prompt
kasiyeri çıkışa doğru yaklaştır
User prompt
gelen müşterilerin yüzde 53ü satın alım yapsın
User prompt
oyunda raflara tıklayınca satmak olmasın
User prompt
duraklatma menüsüne sıfırlama seçeneği koy
User prompt
paneldeki yazıları büyült daha fazla
User prompt
hepsini birbirrinden ayır uzaklaştır yazıları
User prompt
yazıyı yukarı çek
User prompt
paneli daha okunaklı hale getirene kadar büyült
User prompt
panelde üst üste gelen ögeleri düzenleyin
User prompt
Magaza özelleştirmeyi biraz detaylandırın
User prompt
baslangıçta raf sayısını 5 yap
User prompt
restock 50 dolar yap
User prompt
dükkanı özelleştirme paneli ekle
User prompt
maskot satın alındığında 2 kat müşteri gelsin ve 1,5 kat daha fazla para gelsin
User prompt
10. seviyede daha çok müşteri gelmesi için bir reklam maskotu olsun bu maskotu almak için 10. seviyede maskot alma butonu çıksın ücreti 670 olsun
User prompt
1000 dolar ekleyen buton ekle
User prompt
seviye 10da ürünün fiyatlarını belirlemek 15-85 dolar arasında
User prompt
her kasa veya raf alındığında level atla
User prompt
get düğmesini kaldır
User prompt
magazayı genişlet dügmesii kaldır
User prompt
her bastıgımda 1000 verecek buton ekle
User prompt
mağazada yeni eklenen raflar ve kasalar sığmazsa alt kısımlara doğru ekle
User prompt
her 20 dk da vergi al ekrana uyarı yazıp vergiyi 110 alın
User prompt
başlangıçta dükkan küçük olsun
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Cashier = Container.expand(function () {
var self = Container.call(this);
// Create cashier counter
var counter = self.addChild(LK.getAsset('cashierCounter', {
anchorX: 0.5,
anchorY: 0.5
}));
// Create human-like cashier
var head = self.addChild(LK.getAsset('cashierHead', {
anchorX: 0.5,
anchorY: 0.5
}));
head.y = -35;
var body = self.addChild(LK.getAsset('cashierBody', {
anchorX: 0.5,
anchorY: 0.5
}));
body.y = -15;
var leftArm = self.addChild(LK.getAsset('cashierArm', {
anchorX: 0.5,
anchorY: 0
}));
leftArm.x = -12;
leftArm.y = -22;
var rightArm = self.addChild(LK.getAsset('cashierArm', {
anchorX: 0.5,
anchorY: 0
}));
rightArm.x = 12;
rightArm.y = -22;
self.bodyParts = {
head: head,
body: body,
leftArm: leftArm,
rightArm: rightArm
};
self.isProcessing = false;
self.processingTimer = 0;
self.processCustomer = function (customer) {
if (!self.isProcessing) {
self.isProcessing = true;
self.processingTimer = 60; // 1 second processing time
// Animate cashier working
tween(self.bodyParts.rightArm, {
rotation: -0.5
}, {
duration: 300,
onComplete: function onComplete() {
tween(self.bodyParts.rightArm, {
rotation: 0
}, {
duration: 300
});
}
});
}
};
self.update = function () {
if (self.isProcessing) {
self.processingTimer--;
if (self.processingTimer <= 0) {
self.isProcessing = false;
}
// Slight head bob while processing
self.bodyParts.head.y = -35 + Math.sin(LK.ticks * 0.3) * 1;
} else {
self.bodyParts.head.y = -35;
}
};
return self;
});
var Customer = Container.expand(function () {
var self = Container.call(this);
// Create human-like customer with body parts
var head = self.addChild(LK.getAsset('customerHead', {
anchorX: 0.5,
anchorY: 0.5
}));
head.y = -20;
var body = self.addChild(LK.getAsset('customerBody', {
anchorX: 0.5,
anchorY: 0.5
}));
body.y = 0;
var leftArm = self.addChild(LK.getAsset('customerArm', {
anchorX: 0.5,
anchorY: 0
}));
leftArm.x = -15;
leftArm.y = -8;
var rightArm = self.addChild(LK.getAsset('customerArm', {
anchorX: 0.5,
anchorY: 0
}));
rightArm.x = 15;
rightArm.y = -8;
var leftLeg = self.addChild(LK.getAsset('customerLeg', {
anchorX: 0.5,
anchorY: 0
}));
leftLeg.x = -8;
leftLeg.y = 16;
var rightLeg = self.addChild(LK.getAsset('customerLeg', {
anchorX: 0.5,
anchorY: 0
}));
rightLeg.x = 8;
rightLeg.y = 16;
// Store body parts for animation
self.bodyParts = {
head: head,
body: body,
leftArm: leftArm,
rightArm: rightArm,
leftLeg: leftLeg,
rightLeg: rightLeg
};
self.speed = 1 + Math.random() * 2;
self.targetShelf = null;
self.state = 'browsing'; // browsing, shopping, checkout, leaving
self.patience = 300 + Math.random() * 200;
self.maxPatience = self.patience;
self.walkCycle = 0;
self.shoppingCart = [];
self.hasComplained = false;
self.complain = function () {
// Visual complaint effect - flash red
LK.effects.flashObject(self, 0xff0000, 800);
// Create complaint text above customer
var complaintText = new Text2('No products!', {
size: 20,
fill: 0xff0000
});
complaintText.anchor.set(0.5, 1);
complaintText.x = self.x;
complaintText.y = self.y - 40;
game.addChild(complaintText);
// Animate complaint text
tween(complaintText, {
y: complaintText.y - 30,
alpha: 0
}, {
duration: 1500,
onComplete: function onComplete() {
complaintText.destroy();
}
});
// Reduce customer patience significantly
self.patience = Math.min(self.patience, 30);
};
self.findNearestShelf = function () {
var nearestShelf = null;
var minDistance = Infinity;
var hasProductsAvailable = false;
shelves.forEach(function (shelf) {
if (shelf.products.length > 0) {
hasProductsAvailable = true;
var distance = Math.sqrt(Math.pow(self.x - shelf.x, 2) + Math.pow(self.y - shelf.y, 2));
if (distance < minDistance) {
minDistance = distance;
nearestShelf = shelf;
}
}
});
// If no products available, customer complains
if (!hasProductsAvailable && !self.hasComplained) {
self.hasComplained = true;
self.complain();
}
return nearestShelf;
};
self.update = function () {
self.patience--;
if (self.patience <= 0) {
self.state = 'leaving';
}
// Walking animation
self.walkCycle += 0.2;
if (self.state === 'browsing' || self.state === 'checkout') {
self.bodyParts.leftLeg.rotation = Math.sin(self.walkCycle) * 0.3;
self.bodyParts.rightLeg.rotation = Math.sin(self.walkCycle + Math.PI) * 0.3;
self.bodyParts.leftArm.rotation = Math.sin(self.walkCycle + Math.PI) * 0.2;
self.bodyParts.rightArm.rotation = Math.sin(self.walkCycle) * 0.2;
self.bodyParts.body.y = Math.sin(self.walkCycle * 2) * 1;
}
if (self.state === 'browsing') {
if (!self.targetShelf) {
self.targetShelf = self.findNearestShelf();
}
if (self.targetShelf) {
var dx = self.targetShelf.x - self.x;
var dy = self.targetShelf.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 60) {
self.state = 'shopping';
self.patience = 60;
// Stop walking animation
self.bodyParts.leftLeg.rotation = 0;
self.bodyParts.rightLeg.rotation = 0;
self.bodyParts.leftArm.rotation = 0;
self.bodyParts.rightArm.rotation = 0;
} else {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
} else {
// No shelves with products available, customer becomes impatient
if (!self.hasComplained) {
self.hasComplained = true;
self.complain();
}
self.state = 'leaving';
}
} else if (self.state === 'shopping') {
if (self.targetShelf && self.targetShelf.products.length > 0) {
// Add item to shopping cart instead of direct purchase
self.shoppingCart.push({
item: self.targetShelf.productType,
price: self.targetShelf.price
});
self.targetShelf.sellProduct();
// Move to checkout
self.state = 'checkout';
self.targetShelf = null;
} else {
self.state = 'browsing';
self.targetShelf = null;
}
} else if (self.state === 'checkout') {
// Move to cashier
var cashier = findNearestCashier();
if (cashier) {
var dx = cashier.x - self.x;
var dy = cashier.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 80) {
// Process purchase at cashier
var total = 0;
self.shoppingCart.forEach(function (item) {
total += item.price;
});
money += total;
cashier.processCustomer(self);
createMoneyEffect(cashier.x, cashier.y - 50, total);
updateUI();
LK.getSound('cashRegister').play();
self.state = 'leaving';
} else {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
} else {
self.state = 'leaving';
}
} else if (self.state === 'leaving') {
// Move towards exit door
var dx = 1800 - self.x;
var dy = 600 - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 20) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
} else {
// Customer reached exit, remove them
self.destroy();
customers.splice(customers.indexOf(self), 1);
}
}
};
return self;
});
var Door = Container.expand(function () {
var self = Container.call(this);
// Create door frame
var frame = self.addChild(LK.getAsset('doorFrame', {
anchorX: 0.5,
anchorY: 0.5
}));
// Create door
var door = self.addChild(LK.getAsset('entranceDoor', {
anchorX: 0.5,
anchorY: 0.5
}));
self.doorType = 'entrance'; // 'entrance' or 'exit'
self.isOpen = false;
self.openTimer = 0;
self.setDoorType = function (type) {
self.doorType = type;
if (type === 'exit') {
door.destroy();
door = self.addChild(LK.getAsset('exitDoor', {
anchorX: 0.5,
anchorY: 0.5
}));
}
};
self.openDoor = function () {
if (!self.isOpen) {
self.isOpen = true;
self.openTimer = 60; // Keep door open for 1 second
// Animate door opening
tween(door, {
scaleX: 0.3,
alpha: 0.7
}, {
duration: 300
});
}
};
self.closeDoor = function () {
if (self.isOpen) {
self.isOpen = false;
// Animate door closing
tween(door, {
scaleX: 1,
alpha: 1
}, {
duration: 300
});
}
};
self.update = function () {
if (self.isOpen) {
self.openTimer--;
if (self.openTimer <= 0) {
self.closeDoor();
}
}
// Check for nearby customers to open door
var nearbyCustomer = false;
customers.forEach(function (customer) {
var distance = Math.sqrt(Math.pow(customer.x - self.x, 2) + Math.pow(customer.y - self.y, 2));
if (distance < 100) {
nearbyCustomer = true;
}
});
if (nearbyCustomer && !self.isOpen) {
self.openDoor();
}
};
return self;
});
var MoneyEffect = Container.expand(function () {
var self = Container.call(this);
var moneyIcon = self.attachAsset('money', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocity = {
x: (Math.random() - 0.5) * 4,
y: -2 - Math.random() * 2
};
self.lifetime = 120; // 2 seconds at 60fps
self.age = 0;
self.update = function () {
self.age++;
// Move upward and slightly sideways
self.x += self.velocity.x;
self.y += self.velocity.y;
// Fade out over time
self.alpha = 1 - self.age / self.lifetime;
// Scale effect
var scale = 1 + self.age / self.lifetime * 0.5;
self.scaleX = scale;
self.scaleY = scale;
// Remove when lifetime expires
if (self.age >= self.lifetime) {
self.destroy();
var index = moneyEffects.indexOf(self);
if (index > -1) {
moneyEffects.splice(index, 1);
}
}
};
return self;
});
var Shelf = Container.expand(function () {
var self = Container.call(this);
var shelfGraphics = self.attachAsset('shelf', {
anchorX: 0.5,
anchorY: 0.5
});
self.products = [];
self.maxProducts = 5;
self.productType = 'basic';
self.price = 10;
self.addProduct = function () {
if (self.products.length < self.maxProducts) {
var product = self.addChild(LK.getAsset('product', {
anchorX: 0.5,
anchorY: 0.5
}));
product.x = (self.products.length - 2) * 20;
product.y = -25;
self.products.push(product);
}
};
self.sellProduct = function () {
if (self.products.length > 0) {
var product = self.products.pop();
product.destroy();
return self.price;
}
return 0;
};
self.down = function (x, y, obj) {
if (self.products.length > 0) {
var earnings = self.sellProduct();
money += earnings;
createMoneyEffect(self.x, self.y - 50, earnings);
updateUI();
LK.getSound('purchase').play();
// Visual feedback
LK.effects.flashObject(self, 0x00FF00, 300);
}
};
return self;
});
var StoreManager = Container.expand(function () {
var self = Container.call(this);
self.customerSpawnTimer = 0;
self.customerSpawnRate = 120; // spawn every 2 seconds at 60fps
self.spawnCustomer = function () {
if (customers.length < 8) {
var customer = new Customer();
customer.x = 250; // Near entrance door
customer.y = 600 + (Math.random() - 0.5) * 100;
customers.push(customer);
game.addChild(customer);
}
};
self.update = function () {
self.customerSpawnTimer++;
if (self.customerSpawnTimer >= self.customerSpawnRate) {
self.customerSpawnTimer = 0;
self.spawnCustomer();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Game variables
var money = 20;
var level = 1;
var shelves = [];
var customers = [];
var cashiers = [];
var moneyEffects = [];
var storeSize = storage.storeSize || 1;
var emptyShelfPenaltyTimer = 0;
var warningText = null;
var taxTimer = 0;
var taxInterval = 72000; // 20 minutes at 60fps (20 * 60 * 60)
// Helper function to find nearest cashier
function findNearestCashier() {
if (cashiers.length === 0) return null;
var nearestCashier = cashiers[0];
var minDistance = Infinity;
cashiers.forEach(function (cashier) {
var distance = Math.sqrt(Math.pow(cashier.x, 2) + Math.pow(cashier.y, 2));
if (distance < minDistance && !cashier.isProcessing) {
minDistance = distance;
nearestCashier = cashier;
}
});
return nearestCashier;
}
// Helper function to check if all shelves are empty
function areAllShelvesEmpty() {
return shelves.every(function (shelf) {
return shelf.products.length === 0;
});
}
// Function to show warning message
function showWarningMessage() {
if (warningText) {
warningText.destroy();
}
warningText = new Text2('Please buy products!', {
size: 80,
fill: 0xff0000
});
warningText.anchor.set(0.5, 0.5);
warningText.x = 1024;
warningText.y = 1366;
game.addChild(warningText);
// Flash the warning text
LK.effects.flashObject(warningText, 0xffff00, 1000);
}
// Function to show penalty message
function showPenaltyMessage() {
if (warningText) {
warningText.destroy();
}
warningText = new Text2('Buy products -$2', {
size: 80,
fill: 0xff0000
});
warningText.anchor.set(0.5, 0.5);
warningText.x = 1024;
warningText.y = 1366;
game.addChild(warningText);
// Flash the penalty text
LK.effects.flashObject(warningText, 0xffff00, 1000);
// Create penalty indicator next to money display
var penaltyIndicator = new Text2('-$2', {
size: 60,
fill: 0xff0000
});
penaltyIndicator.anchor.set(0, 0);
penaltyIndicator.x = moneyText.x + 100;
penaltyIndicator.y = moneyText.y;
LK.gui.top.addChild(penaltyIndicator);
// Animate penalty indicator
tween(penaltyIndicator, {
y: penaltyIndicator.y - 30,
alpha: 0
}, {
duration: 2000,
onComplete: function onComplete() {
penaltyIndicator.destroy();
}
});
}
// Function to hide warning message
function hideWarningMessage() {
if (warningText) {
warningText.destroy();
warningText = null;
}
}
// Function to collect tax
function collectTax() {
// Show tax warning message
if (warningText) {
warningText.destroy();
}
warningText = new Text2('Tax Time! -$110', {
size: 80,
fill: 0xff0000
});
warningText.anchor.set(0.5, 0.5);
warningText.x = 1024;
warningText.y = 1366;
game.addChild(warningText);
// Flash the tax warning
LK.effects.flashObject(warningText, 0xffff00, 2000);
// Deduct tax amount
money -= 110;
updateUI();
// Flash screen red for tax collection
LK.effects.flashScreen(0xff0000, 1000);
// Create tax penalty indicator
var taxIndicator = new Text2('-$110 TAX', {
size: 60,
fill: 0xff0000
});
taxIndicator.anchor.set(0, 0);
taxIndicator.x = moneyText.x + 100;
taxIndicator.y = moneyText.y;
LK.gui.top.addChild(taxIndicator);
// Animate tax indicator
tween(taxIndicator, {
y: taxIndicator.y - 50,
alpha: 0
}, {
duration: 3000,
onComplete: function onComplete() {
taxIndicator.destroy();
}
});
}
// Function to create money effect at position
function createMoneyEffect(x, y, amount) {
// Create multiple money icons based on amount
var numEffects = Math.min(Math.floor(amount / 10) + 1, 5);
for (var i = 0; i < numEffects; i++) {
var effect = new MoneyEffect();
effect.x = x + (Math.random() - 0.5) * 40;
effect.y = y + (Math.random() - 0.5) * 20;
// Add slight delay between effects
var delay = i * 100;
if (delay > 0) {
effect.alpha = 0;
tween(effect, {
alpha: 1
}, {
duration: 200,
delay: delay
});
}
moneyEffects.push(effect);
game.addChild(effect);
}
}
// Function to show price setting interface
function showPriceSettingInterface() {
// Create semi-transparent overlay
var overlay = game.addChild(LK.getAsset('storeFloor', {
anchorX: 0.5,
anchorY: 0.5
}));
overlay.x = 1024;
overlay.y = 1366;
overlay.alpha = 0.8;
overlay.tint = 0x000000;
// Create price setting panel
var panel = game.addChild(LK.getAsset('expandButton', {
anchorX: 0.5,
anchorY: 0.5
}));
panel.x = 1024;
panel.y = 1366;
panel.scaleX = 4;
panel.scaleY = 3;
panel.tint = 0xffffff;
// Title text
var titleText = new Text2('Set Product Price ($15-$85)', {
size: 50,
fill: 0x000000
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 1200;
game.addChild(titleText);
// Current price display
var currentPriceText = new Text2('Current: $' + shelves[0].price, {
size: 40,
fill: 0x000000
});
currentPriceText.anchor.set(0.5, 0.5);
currentPriceText.x = 1024;
currentPriceText.y = 1280;
game.addChild(currentPriceText);
// Price input buttons
var priceButtons = [];
var prices = [15, 25, 35, 45, 55, 65, 75, 85];
for (var i = 0; i < prices.length; i++) {
var priceButton = game.addChild(LK.getAsset('stockButton', {
anchorX: 0.5,
anchorY: 0.5
}));
priceButton.x = 724 + i % 4 * 150;
priceButton.y = 1380 + Math.floor(i / 4) * 100;
priceButton.scaleX = 0.8;
priceButton.scaleY = 0.8;
priceButton.price = prices[i];
priceButtons.push(priceButton);
var buttonText = new Text2('$' + prices[i], {
size: 30,
fill: 0xffffff
});
buttonText.anchor.set(0.5, 0.5);
priceButton.addChild(buttonText);
priceButton.down = function (x, y, obj) {
var selectedPrice = obj.price;
// Update all shelf prices
shelves.forEach(function (shelf) {
shelf.price = selectedPrice;
});
currentPriceText.setText('Current: $' + selectedPrice);
LK.effects.flashObject(obj, 0x00FF00, 300);
LK.getSound('purchase').play();
};
}
// Close button
var closeButton = game.addChild(LK.getAsset('hireCashierButton', {
anchorX: 0.5,
anchorY: 0.5
}));
closeButton.x = 1024;
closeButton.y = 1600;
closeButton.scaleX = 1.2;
closeButton.scaleY = 0.8;
var closeText = new Text2('Close', {
size: 35,
fill: 0xffffff
});
closeText.anchor.set(0.5, 0.5);
closeButton.addChild(closeText);
closeButton.down = function (x, y, obj) {
// Remove all UI elements
overlay.destroy();
panel.destroy();
titleText.destroy();
currentPriceText.destroy();
priceButtons.forEach(function (button) {
button.destroy();
});
closeButton.destroy();
LK.getSound('cashRegister').play();
};
}
// UI Elements
var moneyText = new Text2('$' + money, {
size: 60,
fill: 0x000000
});
moneyText.anchor.set(0.5, 0);
LK.gui.top.addChild(moneyText);
var levelText = new Text2('Level ' + level, {
size: 40,
fill: 0x000000
});
levelText.anchor.set(0, 0);
levelText.x = 50;
levelText.y = 50;
LK.gui.topLeft.addChild(levelText);
// Store floor
var storeFloor = game.addChild(LK.getAsset('storeFloor', {
anchorX: 0.5,
anchorY: 0.5
}));
storeFloor.x = 1024;
storeFloor.y = 866;
// Initial shelves
function createShelf(x, y) {
var shelf = new Shelf();
shelf.x = x;
shelf.y = y;
// Set price based on current level
shelf.price = Math.floor(10 * Math.pow(1.5, level - 1));
// Stock with initial products
for (var i = 0; i < 3; i++) {
shelf.addProduct();
}
shelves.push(shelf);
game.addChild(shelf);
return shelf;
}
// Create entrance and exit doors
var entranceDoor = new Door();
entranceDoor.x = 200; // Far left edge of store
entranceDoor.y = 600; // Middle height
entranceDoor.setDoorType('entrance');
game.addChild(entranceDoor);
var exitDoor = new Door();
exitDoor.x = 1800; // Far right edge of store
exitDoor.y = 600; // Middle height
exitDoor.setDoorType('exit');
game.addChild(exitDoor);
// Create initial store layout
createShelf(600, 500);
createShelf(800, 500);
createShelf(600, 700);
createShelf(800, 700);
// Create initial cashiers - positioned at front of store for easy customer access
for (var i = 0; i < 1; i++) {
var cashier = new Cashier();
cashier.x = 600 + i * 200; // Space cashiers 200 pixels apart
cashier.y = 400; // Front of store for easy access
cashiers.push(cashier);
game.addChild(cashier);
}
// Expand store button
var expandButton = game.addChild(LK.getAsset('expandButton', {
anchorX: 0.5,
anchorY: 0.5
}));
expandButton.x = 1024;
expandButton.y = 1700;
expandButton.scaleX = 1.3;
expandButton.scaleY = 1.3;
var expandText = new Text2('Expand\n$150', {
size: 30,
fill: 0xFFFFFF
});
expandText.anchor.set(0.5, 0.5);
expandButton.addChild(expandText);
expandButton.down = function (x, y, obj) {
var expandCost = Math.floor(150 * Math.pow(1.5, level - 1));
if (money >= expandCost) {
money -= expandCost;
storeSize++;
// Find the rightmost shelf position
var rightmostX = 0;
shelves.forEach(function (shelf) {
if (shelf.x > rightmostX) {
rightmostX = shelf.x;
}
});
// Check if we can fit horizontally (within store bounds)
var newShelfX = rightmostX + 200; // 200 pixels spacing between shelves
var maxStoreWidth = 1800; // Store width limit
if (newShelfX <= maxStoreWidth) {
// Add new shelves next to existing ones horizontally
createShelf(newShelfX, 500);
createShelf(newShelfX, 700);
} else {
// Find bottom-most shelf position to stack vertically
var bottommostY = 0;
shelves.forEach(function (shelf) {
if (shelf.y > bottommostY) {
bottommostY = shelf.y;
}
});
// Add new shelves below existing ones
var newShelfY = bottommostY + 200; // 200 pixels spacing between shelf rows
createShelf(600, newShelfY); // Start new row at initial X position
createShelf(800, newShelfY);
}
// Level up when expanding store (buying shelves)
level++;
levelText.setText('Level ' + level);
LK.effects.flashScreen(0x00FF00, 1000);
updateUI();
LK.getSound('expand').play();
LK.effects.flashObject(expandButton, 0x00FF00, 500);
} else {
LK.effects.flashObject(expandButton, 0xFF0000, 500);
}
};
// Restock button
var stockButton = game.addChild(LK.getAsset('stockButton', {
anchorX: 0.5,
anchorY: 0.5
}));
stockButton.x = 1024;
stockButton.y = 1820;
stockButton.scaleX = 1.3;
stockButton.scaleY = 1.3;
var stockText = new Text2('Restock\n$100', {
size: 30,
fill: 0xFFFFFF
});
stockText.anchor.set(0.5, 0.5);
stockButton.addChild(stockText);
stockButton.down = function (x, y, obj) {
var stockCost = Math.floor(100 * Math.pow(1.5, level - 1));
if (money >= stockCost) {
money -= stockCost;
// Restock all shelves
shelves.forEach(function (shelf) {
while (shelf.products.length < shelf.maxProducts) {
shelf.addProduct();
}
});
updateUI();
LK.getSound('purchase').play();
LK.effects.flashObject(stockButton, 0x00FF00, 500);
} else {
LK.effects.flashObject(stockButton, 0xFF0000, 500);
}
};
// Hire cashier button
var hireCashierButton = game.addChild(LK.getAsset('hireCashierButton', {
anchorX: 0.5,
anchorY: 0.5
}));
hireCashierButton.x = 1024;
hireCashierButton.y = 1940;
hireCashierButton.scaleX = 1.3;
hireCashierButton.scaleY = 1.3;
var hireCashierText = new Text2('Hire\nCashier\n$175', {
size: 26,
fill: 0xFFFFFF
});
hireCashierText.anchor.set(0.5, 0.5);
hireCashierButton.addChild(hireCashierText);
hireCashierButton.down = function (x, y, obj) {
var hireCost = Math.floor(175 * Math.pow(1.5, level - 1));
if (money >= hireCost) {
money -= hireCost;
// Create new cashier
var newCashier = new Cashier();
// Position new cashier next to existing cashiers
var cashierX = 600 + cashiers.length * 200;
var cashierY = 400;
var maxStoreWidth = 1800; // Store width limit
// If cashier would go beyond store width, stack vertically
if (cashierX > maxStoreWidth) {
// Find how many cashiers fit horizontally
var cashiersPerRow = Math.floor((maxStoreWidth - 600) / 200) + 1;
var row = Math.floor(cashiers.length / cashiersPerRow);
var col = cashiers.length % cashiersPerRow;
cashierX = 600 + col * 200;
cashierY = 400 + row * 150; // Stack with 150 pixel spacing vertically
}
newCashier.x = cashierX;
newCashier.y = cashierY;
cashiers.push(newCashier);
game.addChild(newCashier);
// Level up when hiring cashier
level++;
levelText.setText('Level ' + level);
LK.effects.flashScreen(0x00FF00, 1000);
updateUI();
LK.getSound('cashRegister').play();
LK.effects.flashObject(hireCashierButton, 0x00FF00, 500);
} else {
LK.effects.flashObject(hireCashierButton, 0xFF0000, 500);
}
};
// Get $1000 button
var moneyButton = game.addChild(LK.getAsset('hireCashierButton', {
anchorX: 0.5,
anchorY: 0.5
}));
moneyButton.x = 1024;
moneyButton.y = 2060;
moneyButton.scaleX = 1.3;
moneyButton.scaleY = 1.3;
var moneyButtonText = new Text2('Get\n$1000', {
size: 30,
fill: 0xFFFFFF
});
moneyButtonText.anchor.set(0.5, 0.5);
moneyButton.addChild(moneyButtonText);
moneyButton.down = function (x, y, obj) {
money += 1000;
updateUI();
LK.effects.flashObject(moneyButton, 0x00FF00, 500);
LK.getSound('purchase').play();
};
// Price setting button (only visible at level 10+)
var priceButton = game.addChild(LK.getAsset('stockButton', {
anchorX: 0.5,
anchorY: 0.5
}));
priceButton.x = 1024;
priceButton.y = 2180;
priceButton.scaleX = 1.3;
priceButton.scaleY = 1.3;
priceButton.visible = false; // Hidden initially
var priceButtonText = new Text2('Set\nPrices', {
size: 30,
fill: 0xFFFFFF
});
priceButtonText.anchor.set(0.5, 0.5);
priceButton.addChild(priceButtonText);
priceButton.down = function (x, y, obj) {
if (level >= 10) {
showPriceSettingInterface();
} else {
LK.effects.flashObject(priceButton, 0xFF0000, 500);
}
};
// Store manager
var storeManager = new StoreManager();
game.addChild(storeManager);
function updateUI() {
moneyText.setText('$' + money);
// Level up system
if (money >= level * 1000) {
level++;
levelText.setText('Level ' + level);
LK.effects.flashScreen(0x00FF00, 1000);
}
// Show price setting button at level 10
if (level >= 10) {
priceButton.visible = true;
} else {
priceButton.visible = false;
}
// Save progress
storage.money = money;
storage.level = level;
storage.storeSize = storeSize;
}
// Game loop
game.update = function () {
// Update customers
for (var i = customers.length - 1; i >= 0; i--) {
var customer = customers[i];
if (customer.update) {
customer.update();
}
}
// Update cashiers
for (var i = 0; i < cashiers.length; i++) {
var cashier = cashiers[i];
if (cashier.update) {
cashier.update();
}
}
// Update store manager
if (storeManager.update) {
storeManager.update();
}
// Update doors
if (entranceDoor.update) {
entranceDoor.update();
}
if (exitDoor.update) {
exitDoor.update();
}
// Update money effects
for (var i = moneyEffects.length - 1; i >= 0; i--) {
var effect = moneyEffects[i];
if (effect.update) {
effect.update();
}
}
// Check for empty shelves penalty
if (areAllShelvesEmpty()) {
emptyShelfPenaltyTimer++;
// Show warning message
showWarningMessage();
// Apply penalty every 10 seconds (600 ticks at 60fps)
if (emptyShelfPenaltyTimer >= 600) {
money -= 2;
emptyShelfPenaltyTimer = 0;
updateUI();
// Show penalty message
showPenaltyMessage();
// Flash screen red for penalty
LK.effects.flashScreen(0xff0000, 500);
}
} else {
emptyShelfPenaltyTimer = 0;
hideWarningMessage();
}
// Check win condition
if (money >= 10000) {
LK.showYouWin();
}
// Tax collection every 20 minutes
taxTimer++;
if (taxTimer >= taxInterval) {
collectTax();
taxTimer = 0; // Reset timer
}
// Check lose condition (bankruptcy)
if (money < 0 && shelves.every(function (shelf) {
return shelf.products.length === 0;
})) {
LK.showGameOver();
}
};
// Initialize UI
updateUI(); ===================================================================
--- original.js
+++ change.js
@@ -909,15 +909,36 @@
} else {
LK.effects.flashObject(hireCashierButton, 0xFF0000, 500);
}
};
+// Get $1000 button
+var moneyButton = game.addChild(LK.getAsset('hireCashierButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+}));
+moneyButton.x = 1024;
+moneyButton.y = 2060;
+moneyButton.scaleX = 1.3;
+moneyButton.scaleY = 1.3;
+var moneyButtonText = new Text2('Get\n$1000', {
+ size: 30,
+ fill: 0xFFFFFF
+});
+moneyButtonText.anchor.set(0.5, 0.5);
+moneyButton.addChild(moneyButtonText);
+moneyButton.down = function (x, y, obj) {
+ money += 1000;
+ updateUI();
+ LK.effects.flashObject(moneyButton, 0x00FF00, 500);
+ LK.getSound('purchase').play();
+};
// Price setting button (only visible at level 10+)
var priceButton = game.addChild(LK.getAsset('stockButton', {
anchorX: 0.5,
anchorY: 0.5
}));
priceButton.x = 1024;
-priceButton.y = 2060;
+priceButton.y = 2180;
priceButton.scaleX = 1.3;
priceButton.scaleY = 1.3;
priceButton.visible = false; // Hidden initially
var priceButtonText = new Text2('Set\nPrices', {