User prompt
Müşteriler daha yavaş hareket etsinler.
User prompt
Fabrikalar bütün panelini biraz aşağı indir.
User prompt
Madenlerin üret yazısını biraz yukarı çıkar.
User prompt
Madenlerin üret butonunu biraz alta indir.
User prompt
Madenlerin üret butonunu biraz alta indir.
User prompt
Madenlerin üret butonunu biraz alta indir.
User prompt
Madenin Yükseltme Fiyatının yanına üret butonu ekle.
User prompt
Yükselt ve Aç yazılarını biraz büyüt.
User prompt
Yükselt ve Aç yazılarını biraz alta indir
User prompt
Bütün yazı boyutunu biraz küçült.
User prompt
Açma ve yükseltme yazılarını büyüt.
User prompt
Maden, Fabrikaların ve mağazanın olduğu Yazıların boyutunu biraz büyüt.
User prompt
Üretilmeyen ürünün müşterisi gelmesin.
User prompt
CPU fabrikası hariç diğer fabrikaları üretime açmak için belli ücret ödeyelim.
User prompt
MB, CASE, FAN, HDD, COOLER fabrikalarını biraz aşağı indir.
User prompt
MB, CASE, FAN, HDD, COOLER fabrikalarını biraz aşağı indir.
User prompt
Fabrika boşluklarını alta doğru biraz aç.
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'length')' in or related to this line: 'for (var i = 0; i < partTypes.length; i++) {' Line Number: 220
User prompt
Her ürünün farklı fabrikası olsun.
Code edit (1 edits merged)
Please save this source code
User prompt
Bilgisayar Parçası Otomasyon: Mağaza ve Fabrika Yönetimi
Initial prompt
Idle otomasyon üretim ve mağaza yönetim oyunu. 10 bilgisayar parçası olan bir otomasyon oyunu. Müşteriler mağazadan ürün almak için geliyorlar. Her şeyin yükseltme maliyeti olacak. Fabrikada üret butonu olsun. Ek olarak 3 adet maden olsun. Bu ürünleri üretmek için 3 madenden ürün üretelim.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Factory class: base for all part factories var BaseFactory = Container.expand(function () { var self = Container.call(this); self.level = 1; self.production = 1; // per click self.upgradeCost = 100; self.partType = null; self.attachAsset('factory', { anchorX: 0.5, anchorY: 0.5 }); // Part icon var partIcon = null; if (self.partType) { partIcon = self.attachAsset('part_' + self.partType, { anchorX: 0.5, anchorY: 0.5, y: -60, scaleX: 0.7, scaleY: 0.7 }); } // Level text var levelTxt = new Text2('Lv.' + self.level, { size: 40, fill: '#fff' }); levelTxt.anchor.set(0.5, 0); levelTxt.y = 90; self.addChild(levelTxt); self.upgrade = function () { if (money >= self.upgradeCost) { money -= self.upgradeCost; self.level += 1; self.production += 1; self.upgradeCost = Math.floor(self.upgradeCost * 2); levelTxt.setText('Lv.' + self.level); updateMoneyText(); } }; self.setPartType = function (type) { self.partType = type; if (partIcon) partIcon.destroy(); partIcon = self.attachAsset('part_' + type, { anchorX: 0.5, anchorY: 0.5, y: -60, scaleX: 0.7, scaleY: 0.7 }); }; return self; }); // Create a factory class for each part type // Customer class: comes to store and buys a part var Customer = Container.expand(function () { var self = Container.call(this); self.partType = null; self.attachAsset('customer', { anchorX: 0.5, anchorY: 0.5 }); var partIcon = null; self.setPart = function (type) { self.partType = type; if (partIcon) partIcon.destroy(); partIcon = self.attachAsset('part_' + type, { anchorX: 0.5, anchorY: 0.5, y: 60, scaleX: 0.5, scaleY: 0.5 }); }; return self; }); // Mine class: produces raw materials over time var Mine = Container.expand(function () { var self = Container.call(this); self.level = 1; self.type = 'copper'; // 'copper', 'silicon', 'iron' self.production = 1; // per tick self.timer = 0; self.upgradeCost = 50; self.attachAsset('mine', { anchorX: 0.5, anchorY: 0.5 }); // Ore icon var oreIcon = self.attachAsset('ore_' + self.type, { anchorX: 0.5, anchorY: 0.5, y: 60, scaleX: 0.7, scaleY: 0.7 }); // Level text var levelTxt = new Text2('Lv.' + self.level, { size: 40, fill: '#fff' }); levelTxt.anchor.set(0.5, 0); levelTxt.y = 90; self.addChild(levelTxt); self.setType = function (type) { self.type = type; oreIcon.destroy(); var newOre = self.attachAsset('ore_' + type, { anchorX: 0.5, anchorY: 0.5, y: 60, scaleX: 0.7, scaleY: 0.7 }); }; self.upgrade = function () { if (money >= self.upgradeCost) { money -= self.upgradeCost; self.level += 1; self.production += 1; self.upgradeCost = Math.floor(self.upgradeCost * 1.7); levelTxt.setText('Lv.' + self.level); updateMoneyText(); } }; self.update = function () { self.timer++; if (self.timer >= 60) { // produce every second self.timer = 0; rawMaterials[self.type] += self.production; updateRawText(); } }; return self; }); // Store class: sells computer parts to customers var Store = Container.expand(function () { var self = Container.call(this); self.level = 1; self.sellSpeed = 1; // customers per 2s self.upgradeCost = 120; self.attachAsset('store', { anchorX: 0.5, anchorY: 0.5 }); // Level text var levelTxt = new Text2('Lv.' + self.level, { size: 40, fill: '#fff' }); levelTxt.anchor.set(0.5, 0); levelTxt.y = 90; self.addChild(levelTxt); self.upgrade = function () { if (money >= self.upgradeCost) { money -= self.upgradeCost; self.level += 1; self.sellSpeed += 1; self.upgradeCost = Math.floor(self.upgradeCost * 2.2); levelTxt.setText('Lv.' + self.level); updateMoneyText(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x181818 }); /**** * Game Code ****/ // Create a factory class for each part type // Button // Customer // Factory, Store, Mine icons // Raw materials (3 types) // Computer parts (10 types) // --- Global State --- var partTypes = ['cpu', 'gpu', 'ram', 'ssd', 'psu', 'mb', 'case', 'fan', 'hdd', 'cooler']; var oreTypes = ['copper', 'silicon', 'iron']; var FactoryClasses = {}; for (var i = 0; i < partTypes.length; i++) { (function (type) { FactoryClasses[type] = Container.expand(function () { var self = BaseFactory.call(this); self.setPartType(type); return self; }); })(partTypes[i]); } // Inventory var rawMaterials = { copper: 10, silicon: 10, iron: 10 }; var parts = {}; for (var i = 0; i < partTypes.length; i++) parts[partTypes[i]] = 0; // Money var money = 100; // UI Texts var moneyTxt = new Text2('₺' + money, { size: 70, fill: '#fff' }); moneyTxt.anchor.set(0.5, 0); LK.gui.top.addChild(moneyTxt); function updateMoneyText() { moneyTxt.setText('₺' + money); } var rawTxt = new Text2('', { size: 40, fill: '#ffb' }); rawTxt.anchor.set(0.5, 0); rawTxt.y = 80; LK.gui.top.addChild(rawTxt); function updateRawText() { rawTxt.setText('Bakır: ' + rawMaterials.copper + ' Silikon: ' + rawMaterials.silicon + ' Demir: ' + rawMaterials.iron); } updateRawText(); var partsTxt = new Text2('', { size: 40, fill: '#bff' }); partsTxt.anchor.set(0.5, 0); partsTxt.y = 140; LK.gui.top.addChild(partsTxt); function updatePartsText() { var s = ''; for (var i = 0; i < partTypes.length; i++) { s += partTypes[i].toUpperCase() + ':' + parts[partTypes[i]] + ' '; } partsTxt.setText(s); } updatePartsText(); // --- Mines --- var mines = []; for (var i = 0; i < 3; i++) { var mine = new Mine(); mine.x = 300 + i * 350; mine.y = 600; mine.setType(oreTypes[i]); game.addChild(mine); mines.push(mine); } // --- Factories for each part --- var factories = []; for (var i = 0; i < partTypes.length; i++) { var FactoryClass = FactoryClasses[partTypes[i]]; var f = new FactoryClass(); // Arrange factories in two rows of 5, with extra vertical spacing between rows var col = i % 5; var row = Math.floor(i / 5); f.x = 500 + col * 300; // Move MB, CASE, FAN, HDD, COOLER (indices 5,6,7,8,9) further down if (i >= 5) { f.y = 1100 + row * 420 + 80; } else { f.y = 1100 + row * 420; } game.addChild(f); factories.push(f); } // --- Store --- var store = new Store(); store.x = 1700; store.y = 600; game.addChild(store); // --- Upgrade Buttons --- var mineBtns = []; for (var i = 0; i < 3; i++) { var btn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); btn.x = mines[i].x; btn.y = mines[i].y + 200; game.addChild(btn); var txt = new Text2('Maden Yükselt\n₺' + mines[i].upgradeCost, { size: 32, fill: '#fff' }); txt.anchor.set(0.5, 0.5); txt.y = btn.y - 30; txt.x = btn.x; game.addChild(txt); btn.mineIndex = i; btn.txt = txt; btn.down = function (x, y, obj) { var idx = this.mineIndex; var m = mines[idx]; if (money >= m.upgradeCost) { m.upgrade(); this.txt.setText('Maden Yükselt\n₺' + m.upgradeCost); } }; mineBtns.push(btn); } // Factory upgrade buttons for each part var factoryBtns = []; for (var i = 0; i < factories.length; i++) { var f = factories[i]; var btn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); btn.x = f.x; // Move MB, CASE, FAN, HDD, COOLER (indices 5,6,7,8,9) buttons further down if (i >= 5) { btn.y = f.y + 200 + 80; } else { btn.y = f.y + 200; } game.addChild(btn); var txt = new Text2(partTypes[i].toUpperCase() + " Yükselt\n₺" + f.upgradeCost, { size: 32, fill: '#fff' }); txt.anchor.set(0.5, 0.5); txt.x = btn.x; txt.y = btn.y - 30; game.addChild(txt); btn.factoryIndex = i; btn.txt = txt; btn.down = function (x, y, obj) { var idx = this.factoryIndex; var f = factories[idx]; if (money >= f.upgradeCost) { f.upgrade(); this.txt.setText(partTypes[idx].toUpperCase() + " Yükselt\n₺" + f.upgradeCost); } }; factoryBtns.push(btn); } // Store upgrade button var storeBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); storeBtn.x = store.x; storeBtn.y = store.y + 200; game.addChild(storeBtn); var storeBtnTxt = new Text2('Mağaza Yükselt\n₺' + store.upgradeCost, { size: 32, fill: '#fff' }); storeBtnTxt.anchor.set(0.5, 0.5); storeBtnTxt.x = storeBtn.x; storeBtnTxt.y = storeBtn.y - 30; game.addChild(storeBtnTxt); storeBtn.down = function (x, y, obj) { if (money >= store.upgradeCost) { store.upgrade(); storeBtnTxt.setText('Mağaza Yükselt\n₺' + store.upgradeCost); } }; // --- Production Buttons and Logic for each factory --- var prodBtns = []; for (var i = 0; i < factories.length; i++) { (function (idx) { var f = factories[idx]; var btn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); btn.x = f.x; // Move MB, CASE, FAN, HDD, COOLER (indices 5,6,7,8,9) production buttons further down if (idx >= 5) { btn.y = f.y + 350 + 80; } else { btn.y = f.y + 350; } game.addChild(btn); var txt = new Text2('ÜRET', { size: 50, fill: '#fff' }); txt.anchor.set(0.5, 0.5); txt.x = btn.x; txt.y = btn.y; game.addChild(txt); btn.factoryIndex = idx; btn.down = function (x, y, obj) { var idx = this.factoryIndex; var f = factories[idx]; var part = partTypes[idx]; var produced = 0; for (var j = 0; j < f.production; j++) { // Each part needs: copper:2, silicon:1, iron:1 if (rawMaterials.copper >= 2 && rawMaterials.silicon >= 1 && rawMaterials.iron >= 1) { rawMaterials.copper -= 2; rawMaterials.silicon -= 1; rawMaterials.iron -= 1; parts[part] += 1; produced++; } } if (produced > 0) { updateRawText(); updatePartsText(); // Animate factory tween(f, { scaleX: 1.1, scaleY: 1.1 }, { duration: 120, easing: tween.easeOut, onFinish: function onFinish() { tween(f, { scaleX: 1, scaleY: 1 }, { duration: 120 }); } }); } }; prodBtns.push(btn); })(i); } // --- Customer/Store Logic --- var customers = []; var customerTimer = 0; var customerInterval = 120; // 2s function spawnCustomer() { var c = new Customer(); c.x = store.x - 300; c.y = store.y + 120; // Pick a random part type to buy var idx = Math.floor(Math.random() * partTypes.length); var part = partTypes[idx]; c.setPart(part); c.partType = part; game.addChild(c); customers.push(c); // Animate customer moving to store tween(c, { x: store.x }, { duration: 600, easing: tween.cubicOut }); } function processCustomers() { for (var i = customers.length - 1; i >= 0; i--) { var c = customers[i]; // If at store, try to sell if (Math.abs(c.x - store.x) < 10) { var part = c.partType; if (parts[part] > 0) { parts[part] -= 1; var price = 30 + Math.floor(Math.random() * 20); money += price; updateMoneyText(); updatePartsText(); // Animate customer leaving tween(c, { x: store.x + 300 }, { duration: 400, onFinish: function onFinish() { c.destroy(); } }); customers.splice(i, 1); } } } } // --- Game Update --- game.update = function () { // Update mines for (var i = 0; i < mines.length; i++) { mines[i].update(); } // Customer spawn logic customerTimer++; if (customerTimer >= customerInterval / store.sellSpeed) { customerTimer = 0; spawnCustomer(); } processCustomers(); }; // --- Dragging (for fun, not required) --- var dragNode = null; game.down = function (x, y, obj) { // No drag for now }; game.move = function (x, y, obj) { // No drag for now }; game.up = function (x, y, obj) { // No drag for now };
===================================================================
--- original.js
+++ change.js
@@ -266,9 +266,14 @@
// Arrange factories in two rows of 5, with extra vertical spacing between rows
var col = i % 5;
var row = Math.floor(i / 5);
f.x = 500 + col * 300;
- f.y = 1100 + row * 420; // Increased from 350 to 420 for more space between rows
+ // Move MB, CASE, FAN, HDD, COOLER (indices 5,6,7,8,9) further down
+ if (i >= 5) {
+ f.y = 1100 + row * 420 + 80;
+ } else {
+ f.y = 1100 + row * 420;
+ }
game.addChild(f);
factories.push(f);
}
// --- Store ---
@@ -314,9 +319,14 @@
anchorX: 0.5,
anchorY: 0.5
});
btn.x = f.x;
- btn.y = f.y + 200;
+ // Move MB, CASE, FAN, HDD, COOLER (indices 5,6,7,8,9) buttons further down
+ if (i >= 5) {
+ btn.y = f.y + 200 + 80;
+ } else {
+ btn.y = f.y + 200;
+ }
game.addChild(btn);
var txt = new Text2(partTypes[i].toUpperCase() + " Yükselt\n₺" + f.upgradeCost, {
size: 32,
fill: '#fff'
@@ -368,9 +378,14 @@
anchorX: 0.5,
anchorY: 0.5
});
btn.x = f.x;
- btn.y = f.y + 350;
+ // Move MB, CASE, FAN, HDD, COOLER (indices 5,6,7,8,9) production buttons further down
+ if (idx >= 5) {
+ btn.y = f.y + 350 + 80;
+ } else {
+ btn.y = f.y + 350;
+ }
game.addChild(btn);
var txt = new Text2('ÜRET', {
size: 50,
fill: '#fff'
Factory. In-Game asset. 2d. High contrast. No shadows
Copper. In-Game asset. 2d. High contrast. No shadows
Müşteri. In-Game asset. 2d. High contrast. No shadows
Iron. In-Game asset. 2d. High contrast. No shadows
Silicon. In-Game asset. 2d. High contrast. No shadows
Store. In-Game asset. 2d. High contrast. No shadows
CPU. In-Game asset. 2d. High contrast. No shadows
PC Case. In-Game asset. 2d. High contrast. No shadows
PC GPU. In-Game asset. 2d. High contrast. No shadows
PC RAM. In-Game asset. 2d. High contrast. No shadows
PC Klavye. In-Game asset. 2d. High contrast. No shadows
PC Monitör. In-Game asset. 2d. High contrast. No shadows
City. In-Game asset. 2d. High contrast. No shadows
Bilgisayar teknikeri personel. In-Game asset. 2d. High contrast. No shadows
Mavi gömlekli bilgisayar teknikeri personeli. In-Game asset. 2d. High contrast. No shadows
Silver madeni. In-Game asset. 2d. High contrast. No shadows
Altın cevheri. In-Game asset. 2d. High contrast. No shadows
Nikel cevheri. In-Game asset. 2d. High contrast. No shadows
SSD bilgisayar Parçası. In-Game asset. 2d. High contrast. No shadows
PSU bilgisayar Parçası. In-Game asset. 2d. High contrast. No shadows
ANAKART Bilgisayar Parçası. In-Game asset. 2d. High contrast. No shadows
Maden girişi. In-Game asset. 2d. High contrast. No shadows
2000 sayısı ve Buy butonu. In-Game asset. 2d. High contrast. No shadows