User prompt
kesinti oldugunda -2 buy products yazsın
User prompt
her 10 saniyede 2 dolar azalsın ürün olmadığında
User prompt
ve ürün olmadıgında her dakika 5 dolar kaybedelim ve ekranda lütfen ürün satın alın uyarısı gelsin
User prompt
markette ürün olmadıgında gelen npcler şikayet etsin
User prompt
kasiyer ücretini 215 yap
User prompt
expand butonunun ücretini 150 olarak ayarla restock ücretini ise 175 olarak düzenle
User prompt
daha fazla para kazanabilmek için daha fazla para kazandıran kasiyer ekleme butonu yap ücret 250
User prompt
yeni açılan kasaları dükkanın içine diğer kasaların yanına koy
User prompt
extra kasa açarken yeni açılan kasayı diğer kasalara paralel ve hizalı şekilde konumlandır
User prompt
kapıları en kenarlara koy
User prompt
dükkana giriş ve çıkış kapısı yap
User prompt
biraz daha yukarı çıkart ve büyült
User prompt
biraz daha yukarı çıkar
User prompt
yukarı çıkar butonları
User prompt
butonları aşagıda ortala
User prompt
butonları biraz sağa kaydır
User prompt
butonları daha buyuk yap
User prompt
butonları marketin dışına koy
User prompt
kasiyeri istediğim gibi konumlandır
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'then')' in or related to this line: 'tween(self.bodyParts.rightArm, {' Line Number: 74
User prompt
ekrana sığdır oyunu
User prompt
biz para kazanınca efekt olsun efektte para çıksın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
insanları ve kasaları daha gerçekçi yap
Code edit (1 edits merged)
Please save this source code
User prompt
Market Empire 3D
/****
* 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
}, 300).then(function () {
tween(self.bodyParts.rightArm, {
rotation: 0
}, 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.findNearestShelf = function () {
var nearestShelf = null;
var minDistance = Infinity;
shelves.forEach(function (shelf) {
if (shelf.products.length > 0) {
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;
}
}
});
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 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') {
self.x += self.speed;
self.y -= self.speed * 0.5;
if (self.x > 2048 + 50 || self.y < -50) {
self.destroy();
customers.splice(customers.indexOf(self), 1);
}
}
};
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 = -50;
customer.y = 500 + Math.random() * 400;
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 = storage.money || 500;
var level = storage.level || 1;
var shelves = [];
var customers = [];
var cashiers = [];
var moneyEffects = [];
var storeSize = storage.storeSize || 1;
// 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;
}
// 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);
}
}
// 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;
// Stock with initial products
for (var i = 0; i < 3; i++) {
shelf.addProduct();
}
shelves.push(shelf);
game.addChild(shelf);
return shelf;
}
// Create initial store layout
createShelf(600, 500);
createShelf(800, 500);
createShelf(1000, 500);
createShelf(600, 700);
createShelf(800, 700);
createShelf(1000, 700);
// Create initial cashier
var cashier = new Cashier();
cashier.x = 400;
cashier.y = 600;
cashiers.push(cashier);
game.addChild(cashier);
// Expand store button
var expandButton = game.addChild(LK.getAsset('expandButton', {
anchorX: 0.5,
anchorY: 0.5
}));
expandButton.x = 1400;
expandButton.y = 500;
var expandText = new Text2('Expand\n$200', {
size: 20,
fill: 0xFFFFFF
});
expandText.anchor.set(0.5, 0.5);
expandButton.addChild(expandText);
expandButton.down = function (x, y, obj) {
if (money >= 200) {
money -= 200;
storeSize++;
// Add new shelves
var newShelfY = 500 + (storeSize - 1) * 150;
createShelf(1200, newShelfY);
createShelf(1400, newShelfY);
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 = 1400;
stockButton.y = 600;
var stockText = new Text2('Restock\n$50', {
size: 20,
fill: 0xFFFFFF
});
stockText.anchor.set(0.5, 0.5);
stockButton.addChild(stockText);
stockButton.down = function (x, y, obj) {
if (money >= 50) {
money -= 50;
// 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);
}
};
// 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);
}
// 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 money effects
for (var i = moneyEffects.length - 1; i >= 0; i--) {
var effect = moneyEffects[i];
if (effect.update) {
effect.update();
}
}
// Check win condition
if (money >= 10000) {
LK.showYouWin();
}
// 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
@@ -310,9 +310,9 @@
self.spawnCustomer = function () {
if (customers.length < 8) {
var customer = new Customer();
customer.x = -50;
- customer.y = 400 + Math.random() * 400;
+ customer.y = 500 + Math.random() * 400;
customers.push(customer);
game.addChild(customer);
}
};
@@ -401,9 +401,9 @@
anchorX: 0.5,
anchorY: 0.5
}));
storeFloor.x = 1024;
-storeFloor.y = 600;
+storeFloor.y = 866;
// Initial shelves
function createShelf(x, y) {
var shelf = new Shelf();
shelf.x = x;
@@ -416,27 +416,27 @@
game.addChild(shelf);
return shelf;
}
// Create initial store layout
-createShelf(800, 400);
-createShelf(1000, 400);
-createShelf(1200, 400);
-createShelf(800, 600);
-createShelf(1000, 600);
-createShelf(1200, 600);
+createShelf(600, 500);
+createShelf(800, 500);
+createShelf(1000, 500);
+createShelf(600, 700);
+createShelf(800, 700);
+createShelf(1000, 700);
// Create initial cashier
var cashier = new Cashier();
-cashier.x = 500;
-cashier.y = 500;
+cashier.x = 400;
+cashier.y = 600;
cashiers.push(cashier);
game.addChild(cashier);
// Expand store button
var expandButton = game.addChild(LK.getAsset('expandButton', {
anchorX: 0.5,
anchorY: 0.5
}));
-expandButton.x = 1600;
-expandButton.y = 400;
+expandButton.x = 1400;
+expandButton.y = 500;
var expandText = new Text2('Expand\n$200', {
size: 20,
fill: 0xFFFFFF
});
@@ -446,11 +446,11 @@
if (money >= 200) {
money -= 200;
storeSize++;
// Add new shelves
- var newShelfY = 400 + (storeSize - 1) * 150;
+ var newShelfY = 500 + (storeSize - 1) * 150;
+ createShelf(1200, newShelfY);
createShelf(1400, newShelfY);
- createShelf(1600, newShelfY);
updateUI();
LK.getSound('expand').play();
LK.effects.flashObject(expandButton, 0x00FF00, 500);
} else {
@@ -461,10 +461,10 @@
var stockButton = game.addChild(LK.getAsset('stockButton', {
anchorX: 0.5,
anchorY: 0.5
}));
-stockButton.x = 1600;
-stockButton.y = 500;
+stockButton.x = 1400;
+stockButton.y = 600;
var stockText = new Text2('Restock\n$50', {
size: 20,
fill: 0xFFFFFF
});