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 Customer = Container.expand(function () {
var self = Container.call(this);
var customerGraphics = self.attachAsset('customer', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1 + Math.random() * 2;
self.targetShelf = null;
self.state = 'browsing'; // browsing, shopping, leaving
self.patience = 300 + Math.random() * 200;
self.maxPatience = self.patience;
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';
}
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;
} 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) {
var earnings = self.targetShelf.sellProduct();
money += earnings;
updateUI();
LK.getSound('cashRegister').play();
self.state = 'leaving';
} else {
self.state = 'browsing';
self.targetShelf = null;
}
} 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 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;
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 = 400 + 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 storeSize = storage.storeSize || 1;
// 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 = 600;
// 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(800, 400);
createShelf(1000, 400);
createShelf(1200, 400);
createShelf(800, 600);
createShelf(1000, 600);
createShelf(1200, 600);
// Expand store button
var expandButton = game.addChild(LK.getAsset('expandButton', {
anchorX: 0.5,
anchorY: 0.5
}));
expandButton.x = 1600;
expandButton.y = 400;
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 = 400 + (storeSize - 1) * 150;
createShelf(1400, newShelfY);
createShelf(1600, 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 = 1600;
stockButton.y = 500;
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 store manager
if (storeManager.update) {
storeManager.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
@@ -1,6 +1,298 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var Customer = Container.expand(function () {
+ var self = Container.call(this);
+ var customerGraphics = self.attachAsset('customer', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 1 + Math.random() * 2;
+ self.targetShelf = null;
+ self.state = 'browsing'; // browsing, shopping, leaving
+ self.patience = 300 + Math.random() * 200;
+ self.maxPatience = self.patience;
+ 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';
+ }
+ 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;
+ } 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) {
+ var earnings = self.targetShelf.sellProduct();
+ money += earnings;
+ updateUI();
+ LK.getSound('cashRegister').play();
+ self.state = 'leaving';
+ } else {
+ self.state = 'browsing';
+ self.targetShelf = null;
+ }
+ } 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 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;
+ 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 = 400 + 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: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+// Game variables
+var money = storage.money || 500;
+var level = storage.level || 1;
+var shelves = [];
+var customers = [];
+var storeSize = storage.storeSize || 1;
+// 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 = 600;
+// 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(800, 400);
+createShelf(1000, 400);
+createShelf(1200, 400);
+createShelf(800, 600);
+createShelf(1000, 600);
+createShelf(1200, 600);
+// Expand store button
+var expandButton = game.addChild(LK.getAsset('expandButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+}));
+expandButton.x = 1600;
+expandButton.y = 400;
+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 = 400 + (storeSize - 1) * 150;
+ createShelf(1400, newShelfY);
+ createShelf(1600, 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 = 1600;
+stockButton.y = 500;
+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 store manager
+ if (storeManager.update) {
+ storeManager.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();
\ No newline at end of file