User prompt
Paranın sol tarafına basınca Yeni bir sayfaya geçecek Yatırım butonu oluştur.
User prompt
Coin fiyatının değişme hızı %95 oranda yavaşlasın.
User prompt
Coin panelinde bulunan bütün coinlerin fiyatı rastgele %50 oranda otomatik yükseliş ve düşüş sağlasın.
User prompt
Sol alt tarafa bir panel oluştur. En popüler 10 coin alım satımı butonu ekle. Bu coinler başlangıç fiyatından %50 oranlarında rastgele yükseliş ve düşüş göstersin.
User prompt
Bakiye yetersiz dedikten sonra teklifi yenile.
User prompt
Bakiye yetersiz süresini 2 saniyeden 5 saniyeye çıkart.
User prompt
Eğer elimizde ürün bakiye yoksa buton kırmızı yansın. Buton üzerinde Bakiye yetersiz uyarısı 2 saniye belirsin sonra kaybolsun.
User prompt
Alış ve satış teklif süreleri maksimum 2 dakika olarak güncelle.
User prompt
Alış ve satış Bütün teklif süreleri rastgele gelsin ama maksimum 5 dakika olsun.
User prompt
Yeni teklif süreleri 5 dk olsun.
User prompt
Toplu satış ve İnternet Teklif süreleri 5 dakika olsun.
User prompt
Teklif süreleri 20 dakika olsun. Tamamlanan ve kabul edilen teklif olunca süre dolması beklensin.
User prompt
Tekliflerin tamamlanma süresi olsun. Her 1 dakikada yeni teklif gelsin.
User prompt
Her İnternet teklifi tamamlanmadan diğer teklife geçmesin. Ayrıca onun altına aynı panelden bir panel oluştur. Oradan da toplu ürün satış teklifleri de gelsin.
User prompt
Ekranın sol orta tarafında bir panel oluştur. O panelde İnternet üzerinden rastgele miktarda ürün almak için teklifler gelsin.
User prompt
Başlangıç parası 2000 olsun
User prompt
Maden ve Mağazalarda bulunan Oto Üret satın alındıktan sonra, Oto Üret kapalı konuma getirilmesin.
User prompt
Üret panellerinin arasında ince bir boşluk olsun
Code edit (1 edits merged)
Please save this source code
User prompt
CPU parça ismini Mouse olarak değiştir.
User prompt
Madenlerin Oto üret açıldığı zaman kapatılmasın.
User prompt
Fabrika açış maliyetini %50 artır
User prompt
Borç Yanına Borç Öde butonu olsun tamamını ödeyelim.
User prompt
Geri Ödeme Süresi 10 Dakika olarak güncelle.
User prompt
Banka geri ödeme süresini borcun altına ekle. Geri ödeme süresi 1 dakikada bir yenilensin.
/**** * 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; // Production time in frames (default 30, halves every 5 levels, min 5) self.getProductionTime = function () { // Each 5 levels halves the time, min 5 frames var base = 30; var speedup = Math.floor((self.level - 1) / 5); var prodTime = Math.floor(base / Math.pow(2, speedup)); if (prodTime < 5) { prodTime = 5; } return prodTime; }; 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 * 3.5); levelTxt.setText('Lv.' + self.level); updateMoneyText(); // Reset autoTick so production interval is not skipped after upgrade self.autoTick = 0; // --- Reduce production time by 10% after each upgrade, if customProductionTime is present --- if (typeof self.customProductionTime === "number") { self.customProductionTime = Math.max(Math.floor(self.customProductionTime * 0.9), 60); // min 1s (60 frames) } // Update production time text if present if (self._prodTimeTxt) { var prodTime = self.getProductionTime ? self.getProductionTime() : 30; var prodTimeSec = (prodTime / 60).toFixed(2); self._prodTimeTxt.setText("Üretim: " + prodTimeSec + " sn"); } } }; 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 * 2.975); levelTxt.setText('Lv.' + self.level); updateMoneyText(); } }; self.update = function () { self.timer++; // No automatic production }; 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 * 3.85); levelTxt.setText('Lv.' + self.level); updateMoneyText(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x181818 }); /**** * Game Code ****/ // --- Coin Panel (Bottom Left) --- var coinNames = ["BTC", "ETH", "BNB", "SOL", "XRP", "DOGE", "ADA", "AVAX", "TRX", "LINK"]; var coinBasePrices = [1000000, 60000, 8000, 4000, 20, 10, 8, 6, 2, 500]; // Each coin starts at base price, can fluctuate ±50% var coinPrices = []; var coinMinPrices = []; var coinMaxPrices = []; for (var i = 0; i < coinNames.length; i++) { coinPrices[i] = coinBasePrices[i]; coinMinPrices[i] = Math.floor(coinBasePrices[i] * 0.5); coinMaxPrices[i] = Math.floor(coinBasePrices[i] * 1.5); } // Panel background var coinPanel = LK.getAsset('button', { anchorX: 0, anchorY: 1, width: 520, height: 900, x: 0, y: 2732 }); game.addChild(coinPanel); // Title var coinTitle = new Text2('COIN AL/SAT', { size: 38, fill: '#fff' }); coinTitle.anchor.set(0, 0.5); coinTitle.x = coinPanel.x + 30; coinTitle.y = coinPanel.y - 860; game.addChild(coinTitle); // Coin rows var coinRowHeight = 80; var coinBtnsBuy = []; var coinBtnsSell = []; var coinPriceTxts = []; var coinAmount = []; for (var i = 0; i < coinNames.length; i++) { coinAmount[i] = 0; // Coin name var nameTxt = new Text2(coinNames[i], { size: 32, fill: '#bff' }); nameTxt.anchor.set(0, 0.5); nameTxt.x = coinPanel.x + 30; nameTxt.y = coinPanel.y - 780 + i * coinRowHeight; game.addChild(nameTxt); // Price text var priceTxt = new Text2('₺' + coinPrices[i], { size: 32, fill: '#fff' }); priceTxt.anchor.set(0, 0.5); priceTxt.x = coinPanel.x + 130; priceTxt.y = nameTxt.y; game.addChild(priceTxt); coinPriceTxts.push(priceTxt); // Buy button var buyBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 90, height: 54 }); buyBtn.x = coinPanel.x + 320; buyBtn.y = nameTxt.y; game.addChild(buyBtn); var buyTxt = new Text2('Al', { size: 28, fill: '#fff' }); buyTxt.anchor.set(0.5, 0.5); buyTxt.x = buyBtn.x; buyTxt.y = buyBtn.y; game.addChild(buyTxt); // Sell button var sellBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 90, height: 54 }); sellBtn.x = coinPanel.x + 430; sellBtn.y = nameTxt.y; game.addChild(sellBtn); var sellTxt = new Text2('Sat', { size: 28, fill: '#fff' }); sellTxt.anchor.set(0.5, 0.5); sellTxt.x = sellBtn.x; sellTxt.y = sellBtn.y; game.addChild(sellTxt); // Amount owned text var ownedTxt = new Text2('0', { size: 28, fill: '#ffb' }); ownedTxt.anchor.set(0, 0.5); ownedTxt.x = coinPanel.x + 30; ownedTxt.y = nameTxt.y + 32; game.addChild(ownedTxt); // Buy logic (function (idx, buyBtn, buyTxt, ownedTxt) { buyBtn.down = function (x, y, obj) { var price = coinPrices[idx]; if (money >= price) { money -= price; coinAmount[idx]++; updateMoneyText(); ownedTxt.setText(coinAmount[idx]); // Animate buyBtn tween(buyBtn, { scaleX: 1.12, scaleY: 1.12 }, { duration: 80, onFinish: function onFinish() { tween(buyBtn, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); } else { // Not enough money, flash red and show warning buyTxt.setText('Yetersiz'); tween(buyBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(buyBtn, { tint: 0x222222 }, { duration: 120 }); } }); LK.setTimeout(function () { buyTxt.setText('Al'); }, 120); } }; })(i, buyBtn, buyTxt, ownedTxt); // Sell logic (function (idx, sellBtn, sellTxt, ownedTxt) { sellBtn.down = function (x, y, obj) { if (coinAmount[idx] > 0) { money += coinPrices[idx]; coinAmount[idx]--; updateMoneyText(); ownedTxt.setText(coinAmount[idx]); // Animate sellBtn tween(sellBtn, { scaleX: 1.12, scaleY: 1.12 }, { duration: 80, onFinish: function onFinish() { tween(sellBtn, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); } else { // No coin to sell, flash red and show warning sellTxt.setText('Yok'); tween(sellBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(sellBtn, { tint: 0x222222 }, { duration: 120 }); } }); LK.setTimeout(function () { sellTxt.setText('Sat'); }, 120); } }; })(i, sellBtn, sellTxt, ownedTxt); coinBtnsBuy.push(buyBtn); coinBtnsSell.push(sellBtn); } // --- Coin Price Fluctuation Logic --- function updateCoinPrices() { for (var i = 0; i < coinNames.length; i++) { // Randomly move price up or down by up to ±50% of base price var base = coinBasePrices[i]; var min = coinMinPrices[i]; var max = coinMaxPrices[i]; // Randomly pick a new price between min and max (simulate full random walk within ±50%) var newPrice = min + Math.floor(Math.random() * (max - min + 1)); coinPrices[i] = newPrice; coinPriceTxts[i].setText('₺' + coinPrices[i]); } } // Update every 40 seconds (2400 frames) to slow down price changes by 95% LK.setInterval(updateCoinPrices, 2400); // Computer parts (10 types) // Raw materials (3 types) // Factory, Store, Mine icons // Customer // Button // Create a factory class for each part type var partTypes = ['mouse', 'gpu', 'ram', 'ssd', 'psu', 'mb', 'case', 'fan', 'hdd', 'cooler']; var oreTypes = ['copper', 'silicon', 'iron']; var FactoryClasses = {}; // Üretim süreleri sırası ile 2, 4, 6, ... 20 saniye (2 ve katları, 60fps) olacak şekilde ayarlanır var partProductionTimes = []; for (var i = 0; i < partTypes.length; i++) { partProductionTimes[i] = (i + 1) * 2 * 60; // 2,4,6,...,20 saniye (frame cinsinden) } for (var i = 0; i < partTypes.length; i++) { (function (type, idx) { FactoryClasses[type] = Container.expand(function () { var self = BaseFactory.call(this); self.setPartType(type); // Override getProductionTime to use diversified 1-3-5-7s pattern // Store a custom production time for this factory instance self.customProductionTime = partProductionTimes[idx]; self.getProductionTime = function () { // Use the customProductionTime, which is reduced by 10% on each upgrade var prodTime = self.customProductionTime; // Each 5 levels halves the time, min 1s (60 frames) var speedup = Math.floor((self.level - 1) / 5); prodTime = Math.floor(prodTime / Math.pow(2, speedup)); if (prodTime < 60) { prodTime = 60; } return prodTime; }; return self; }); })(partTypes[i], 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 = 2000; // UI Texts var moneyTxt = new Text2('₺' + money, { size: 50, fill: '#fff' }); moneyTxt.anchor.set(0.5, 0); LK.gui.top.addChild(moneyTxt); // --- Yatırım Button --- var yatirimBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 180, height: 70 }); yatirimBtn.x = moneyTxt.x - 220; yatirimBtn.y = 40; LK.gui.top.addChild(yatirimBtn); var yatirimBtnTxt = new Text2('Yatırım', { size: 36, fill: '#fff' }); yatirimBtnTxt.anchor.set(0.5, 0.5); yatirimBtnTxt.x = yatirimBtn.x; yatirimBtnTxt.y = yatirimBtn.y; LK.gui.top.addChild(yatirimBtnTxt); // Yatırım butonuna basınca yeni bir sayfaya geç (örnek: LK.showPage fonksiyonu ile) yatirimBtn.down = function (x, y, obj) { // Burada yeni bir sayfa açmak için örnek bir fonksiyon çağrısı: if (typeof LK.showPage === "function") { LK.showPage("yatirim"); } else { // Eğer showPage yoksa, ekrana basit bir uyarı gösterebiliriz yatirimBtnTxt.setText("Sayfa yok"); tween(yatirimBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(yatirimBtn, { tint: 0x222222 }, { duration: 120 }); yatirimBtnTxt.setText("Yatırım"); } }); } }; // --- Banka Button & Borç Logic --- var bankBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 180, height: 70 }); bankBtn.x = moneyTxt.x + 220; bankBtn.y = 40; LK.gui.top.addChild(bankBtn); var bankBtnTxt = new Text2('Banka', { size: 36, fill: '#fff' }); bankBtnTxt.anchor.set(0.5, 0.5); bankBtnTxt.x = bankBtn.x; bankBtnTxt.y = bankBtn.y; LK.gui.top.addChild(bankBtnTxt); var borc = 0; var borcTxt = new Text2('', { size: 32, fill: '#ffb' }); borcTxt.anchor.set(0.5, 0); borcTxt.x = moneyTxt.x + 420; borcTxt.y = 10; LK.gui.top.addChild(borcTxt); // Borç Öde button var borcOdeBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 140, height: 54 }); borcOdeBtn.x = borcTxt.x + 180; borcOdeBtn.y = borcTxt.y + 28; LK.gui.top.addChild(borcOdeBtn); var borcOdeBtnTxt = new Text2('Borç Öde', { size: 28, fill: '#fff' }); borcOdeBtnTxt.anchor.set(0.5, 0.5); borcOdeBtnTxt.x = borcOdeBtn.x; borcOdeBtnTxt.y = borcOdeBtn.y; LK.gui.top.addChild(borcOdeBtnTxt); borcOdeBtn.down = function (x, y, obj) { if (borc > 0) { var odeme = Math.min(money, borc); if (odeme > 0) { money -= odeme; borc -= odeme; if (borc < 0) { borc = 0; } updateMoneyText(); updateBorcText(); } // If borç is now 0, clear timers if (borc <= 0) { borc = 0; updateBorcText(); if (typeof borcOdemeTimer !== "undefined" && borcOdemeTimer) { LK.clearInterval(borcOdemeTimer); borcOdemeTimer = null; } if (typeof borcOdemeTimeTimer !== "undefined" && borcOdemeTimeTimer) { LK.clearInterval(borcOdemeTimeTimer); borcOdemeTimeTimer = null; } } } else { // Flash button red if no debt tween(borcOdeBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(borcOdeBtn, { tint: 0x222222 }, { duration: 120 }); } }); } }; // Repayment time text var borcTimeTxt = new Text2('', { size: 28, fill: '#ffb' }); borcTimeTxt.anchor.set(0.5, 0); borcTimeTxt.x = borcTxt.x; borcTimeTxt.y = borcTxt.y + 38; LK.gui.top.addChild(borcTimeTxt); var borcOdemeKalan = 0; // seconds left to next repayment var borcOdemeTimeTimer = null; function updateBorcText() { if (borc > 0) { borcTxt.setText('Borç: ₺' + borc); if (borcOdemeKalan > 0) { var min = Math.floor(borcOdemeKalan / 60); var sec = borcOdemeKalan % 60; var timeStr = min > 0 ? min + " dk " + (sec < 10 ? "0" : "") + sec + " sn" : sec + " sn"; borcTimeTxt.setText("Geri ödeme: " + timeStr); } else { borcTimeTxt.setText(''); } } else { borcTxt.setText(''); borcTimeTxt.setText(''); } } updateBorcText(); var borcOdemeTimer = null; bankBtn.down = function (x, y, obj) { // Only allow one active loan at a time if (borc > 0) { // Flash button red to indicate already borrowed tween(bankBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(bankBtn, { tint: 0x222222 }, { duration: 120 }); } }); return; } borc = 1000; money += 1000; updateMoneyText(); updateBorcText(); // Start repayment every 10 minutes (600s = 36000 frames) if (borcOdemeTimer) { LK.clearInterval(borcOdemeTimer); } if (borcOdemeTimeTimer) { LK.clearInterval(borcOdemeTimeTimer); } borcOdemeKalan = 600; // seconds to next repayment (10 minutes) updateBorcText(); // Repayment time countdown, updates every 1 second borcOdemeTimeTimer = LK.setInterval(function () { if (borc > 0) { borcOdemeKalan--; if (borcOdemeKalan < 0) { borcOdemeKalan = 0; } updateBorcText(); } else { borcOdemeKalan = 0; updateBorcText(); if (borcOdemeTimeTimer) { LK.clearInterval(borcOdemeTimeTimer); borcOdemeTimeTimer = null; } } }, 60); // 1 second at 60fps borcOdemeTimer = LK.setInterval(function () { if (borc > 0) { var odeme = Math.ceil(borc * 0.25); if (money >= odeme) { money -= odeme; borc -= odeme; if (borc < 0) { borc = 0; } updateMoneyText(); updateBorcText(); } else { // Not enough money, take all money and reduce borc accordingly borc -= money; money = 0; if (borc < 0) { borc = 0; } updateMoneyText(); updateBorcText(); } if (borc <= 0) { borc = 0; updateBorcText(); if (borcOdemeTimer) { LK.clearInterval(borcOdemeTimer); borcOdemeTimer = null; } if (borcOdemeTimeTimer) { LK.clearInterval(borcOdemeTimeTimer); borcOdemeTimeTimer = null; } } borcOdemeKalan = 600; // reset repayment time for next cycle (10 minutes) updateBorcText(); } }, 36000); // 10 minutes at 60fps }; function updateMoneyText() { moneyTxt.setText('₺' + money); updateBorcText(); } 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 += (i === 0 ? "MOUSE" : partTypes[i].toUpperCase()) + ':' + parts[partTypes[i]] + ' '; } partsTxt.setText(s); } updatePartsText(); // --- Mines --- var mines = []; var mineAutoProduce = [false, false, false]; // Track auto-produce state for each mine var mineAutoBtns = []; var mineAutoTxts = []; 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); // Add auto-produce toggle button var autoBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); // Move auto-produce button further down autoBtn.x = mine.x; autoBtn.y = mine.y + 480; game.addChild(autoBtn); var autoMineCost = (i + 1) * 500; // 500, 1000, 1500 for each mine var autoTxt = new Text2('Oto Üret: Kapalı', { size: 36, fill: '#fff' }); autoTxt.anchor.set(0.5, 0.5); autoTxt.x = autoBtn.x; autoTxt.y = autoBtn.y; game.addChild(autoTxt); autoBtn.mineIndex = i; autoBtn.down = function (x, y, obj) { var idx = this.mineIndex; var autoMineCost = (idx + 1) * 500; if (!mineAutoProduce[idx]) { if (money >= autoMineCost) { money -= autoMineCost; updateMoneyText(); mineAutoProduce[idx] = true; mineAutoTxts[idx].setText('Oto Üret: Açık'); } else { // Not enough money, flash button red tween(this, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(autoBtn, { tint: 0x222222 }, { duration: 120 }); } }); } } else { // Oto Üret kapatılmasın: Satın alındıktan sonra kapatmaya izin verme // Artık kapatma işlemi yapılmıyor, buton işlevsiz. } }; mineAutoBtns.push(autoBtn); mineAutoTxts.push(autoTxt); // Set initial text autoTxt.setText('Oto Üret: Kapalı\n₺' + autoMineCost); } // --- Factories for each part --- var factories = []; var factoryUnlocks = []; var factoryUnlockCosts = [0, 350, 525, 700, 875, 1050, 1225, 1400, 1575, 1750]; // Apply 50% price increase to all except the first (CPU) for (var i = 1; i < factoryUnlockCosts.length; i++) { factoryUnlockCosts[i] = Math.floor(factoryUnlockCosts[i] * 1.5); } var factoryAutoProduce = []; var factoryAutoBtns = []; var factoryAutoTxts = []; 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); // Add vertical spacing (gap) between factory panels var factoryPanelGap = 24; f.x = 500 + col * 300 + col * factoryPanelGap; // Move MB, CASE, FAN, HDD, COOLER (indices 5,6,7,8,9) further down // Move the whole factories panel lower by +200px if (i >= 5) { // Increase the offset for the second row and move these factories further down f.y = 1300 + row * 420 + 320; } else { f.y = 1300 + row * 420; } game.addChild(f); factories.push(f); // Add production time text under the part icon var prodTime = f.getProductionTime ? f.getProductionTime() : 30; var prodTimeSec = (prodTime / 60).toFixed(2); // Add a panel image behind the production time text var prodTimePanel = LK.getAsset('button', { anchorX: 0.5, anchorY: 0, width: 220, height: 54, x: f.x, y: f.y - 60 + 60 * 0.7 + 28, // 10px higher to allow for text padding scaleX: 0.8, scaleY: 0.7 }); // Add horizontal gap to prodTimePanel to match factory panel gap prodTimePanel.x = f.x; game.addChild(prodTimePanel); var prodTimeTxt = new Text2("Üretim: " + prodTimeSec + " sn", { size: 32, fill: "#fff" }); prodTimeTxt.anchor.set(0.5, 0); // Place under the part icon (which is at y: -60, scale 0.7, so about -60+60*0.7+10) prodTimeTxt.x = f.x; prodTimeTxt.y = f.y - 60 + 60 * 0.7 + 38; game.addChild(prodTimeTxt); // Store reference for later update on upgrade f._prodTimeTxt = prodTimeTxt; // Unlock state: CPU (i==0) is always unlocked, others locked factoryUnlocks.push(i === 0 ? true : false); // Add auto-produce toggle button for each factory factoryAutoProduce.push(false); var autoBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); autoBtn.x = f.x; // Move auto-produce button further down // Add horizontal gap to autoBtn to match factory panel gap autoBtn.x = f.x; if (i >= 5) { autoBtn.y = f.y + 530 + 80; } else { autoBtn.y = f.y + 530; } game.addChild(autoBtn); var autoTxt = new Text2('Oto Üret: Kapalı', { size: 36, fill: '#fff' }); autoTxt.anchor.set(0.5, 0.5); autoTxt.x = autoBtn.x; autoTxt.y = autoBtn.y; game.addChild(autoTxt); autoBtn.factoryIndex = i; autoBtn.down = function (x, y, obj) { var idx = this.factoryIndex; if (!factoryAutoProduce[idx]) { // Cost to enable auto-produce for factory: 1000 var autoFactoryCost = (idx + 1) * 1000; if (money >= autoFactoryCost) { money -= autoFactoryCost; updateMoneyText(); factoryAutoProduce[idx] = true; factoryAutoTxts[idx].setText('Oto Üret: Açık'); } else { // Not enough money, flash button red tween(this, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(autoBtn, { tint: 0x222222 }, { duration: 120 }); } }); } } else { // Oto Üret kapatılmasın: Satın alındıktan sonra kapatmaya izin verme // Artık kapatma işlemi yapılmıyor, buton işlevsiz. } }; factoryAutoBtns.push(autoBtn); factoryAutoTxts.push(autoTxt); // Set initial text var autoFactoryCost = (i + 1) * 1000; autoTxt.setText('Oto Üret: Kapalı\n₺' + autoFactoryCost); } // --- 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 - 80; // Move left to make space for produce button btn.y = mines[i].y + 200; game.addChild(btn); var txt = new Text2('Maden Yükselt\n₺' + mines[i].upgradeCost, { size: 44, fill: '#fff' }); txt.anchor.set(0.5, 0.5); txt.y = btn.y + 20; 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); // Add ÜRET (Produce) button next to upgrade var prodBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); prodBtn.x = mines[i].x + 80; // Place to the right of upgrade button prodBtn.y = mines[i].y + 320; // moved even lower game.addChild(prodBtn); var prodTxt = new Text2('ÜRET', { size: 44, fill: '#fff' }); prodTxt.anchor.set(0.5, 0.5); prodTxt.x = prodBtn.x; prodTxt.y = prodBtn.y + 10; // moved higher game.addChild(prodTxt); prodBtn.mineIndex = i; prodBtn.down = function (x, y, obj) { var idx = this.mineIndex; var m = mines[idx]; // Instantly produce one batch of raw material for this mine rawMaterials[m.type] += m.production; updateRawText(); // Animate mine for feedback tween(m, { scaleX: 1.1, scaleY: 1.1 }, { duration: 120, easing: tween.easeOut, onFinish: function onFinish() { tween(m, { scaleX: 1, scaleY: 1 }, { duration: 120 }); } }); }; } // Factory upgrade buttons for each part var factoryBtns = []; var factoryUnlockBtns = []; for (var i = 0; i < factories.length; i++) { var f = factories[i]; // If factory is locked (except CPU), show unlock button instead of upgrade if (!factoryUnlocks[i]) { var unlockBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); unlockBtn.x = f.x; // Add horizontal gap to unlock buttons to match factory panel gap unlockBtn.x = f.x; if (i >= 5) { unlockBtn.y = f.y + 200 + 80; } else { unlockBtn.y = f.y + 200; } game.addChild(unlockBtn); var unlockTxt = new Text2((i === 0 ? "MOUSE" : partTypes[i].toUpperCase()) + " Aç\n₺" + factoryUnlockCosts[i], { size: 44, fill: '#fff' }); unlockTxt.anchor.set(0.5, 0.5); unlockTxt.x = unlockBtn.x; unlockTxt.y = unlockBtn.y + 20; game.addChild(unlockTxt); unlockBtn.factoryIndex = i; unlockBtn.txt = unlockTxt; unlockBtn.down = function (x, y, obj) { var idx = this.factoryIndex; if (!factoryUnlocks[idx] && money >= factoryUnlockCosts[idx]) { money -= factoryUnlockCosts[idx]; updateMoneyText(); factoryUnlocks[idx] = true; // Remove unlock button and text this.destroy(); this.txt.destroy(); // Show upgrade button for this factory showFactoryUpgradeButton(idx); } }; factoryUnlockBtns.push(unlockBtn); // Don't show upgrade button for locked factories continue; } // Show upgrade button for unlocked factories var btn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); btn.x = f.x; // Add horizontal gap to upgrade/unlock/production buttons to match factory panel gap 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((i === 0 ? "MOUSE" : partTypes[i].toUpperCase()) + " Yükselt\n₺" + f.upgradeCost, { size: 44, fill: '#fff' }); txt.anchor.set(0.5, 0.5); txt.x = btn.x; txt.y = btn.y + 20; 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((idx === 0 ? "MOUSE" : partTypes[idx].toUpperCase()) + " Yükselt\n₺" + f.upgradeCost); } }; factoryBtns.push(btn); } // Helper to show upgrade button after unlock function showFactoryUpgradeButton(idx) { var f = factories[idx]; var btn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5 }); btn.x = f.x; // Add horizontal gap to upgrade button after unlock to match factory panel gap btn.x = f.x; if (idx >= 5) { btn.y = f.y + 200 + 80; } else { btn.y = f.y + 200; } game.addChild(btn); var txt = new Text2((idx === 0 ? "MOUSE" : partTypes[idx].toUpperCase()) + " Yükselt\n₺" + f.upgradeCost, { size: 44, fill: '#fff' }); txt.anchor.set(0.5, 0.5); txt.x = btn.x; txt.y = btn.y + 20; game.addChild(txt); btn.factoryIndex = idx; 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((idx === 0 ? "MOUSE" : partTypes[idx].toUpperCase()) + " Yükselt\n₺" + f.upgradeCost); } }; factoryBtns[idx] = 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: 44, fill: '#fff' }); storeBtnTxt.anchor.set(0.5, 0.5); storeBtnTxt.x = storeBtn.x; storeBtnTxt.y = storeBtn.y + 20; 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; // Add horizontal gap to production buttons to match factory panel gap 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: 36, 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; // Only allow production if factory is unlocked if (!factoryUnlocks[idx]) { // Optionally, flash or shake to indicate locked tween(factories[idx], { scaleX: 1.15, scaleY: 1.15 }, { duration: 80, onFinish: function onFinish() { tween(factories[idx], { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); return; } 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 // Calculate production cost as 50% of the sale price (which is 30~49, so use 40 as avg, or use 30 + Math.floor(Math.random()*20)/2 for dynamic) var salePrice = 30 + Math.floor(Math.random() * 20); var productionCost = Math.floor(salePrice * 0.5); if (rawMaterials.copper >= 2 && rawMaterials.silicon >= 1 && rawMaterials.iron >= 1 && money >= productionCost) { rawMaterials.copper -= 2; rawMaterials.silicon -= 1; rawMaterials.iron -= 1; money -= productionCost; updateMoneyText(); 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() { // Only allow customer for parts that have been produced at least once var availableParts = []; for (var i = 0; i < partTypes.length; i++) { if (parts[partTypes[i]] > 0) { availableParts.push(partTypes[i]); } } if (availableParts.length === 0) { // No available parts, do not spawn customer return; } var c = new Customer(); c.x = store.x - 300; c.y = store.y + 120; // Pick a random available part type to buy var idx = Math.floor(Math.random() * availableParts.length); var part = availableParts[idx]; c.setPart(part); c.partType = part; game.addChild(c); customers.push(c); // Animate customer moving to store (slower) tween(c, { x: store.x }, { duration: 1200, // doubled duration for slower movement 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 (slower) tween(c, { x: store.x + 300 }, { duration: 800, // doubled duration for slower movement 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(); // Auto-produce for mine if enabled if (mineAutoProduce[i]) { // Produce every 30 frames (~0.5s) if (!mines[i].autoTick) { mines[i].autoTick = 0; } mines[i].autoTick++; if (mines[i].autoTick >= 30) { rawMaterials[mines[i].type] += mines[i].production; updateRawText(); // Animate mine for feedback tween(mines[i], { scaleX: 1.1, scaleY: 1.1 }, { duration: 120, easing: tween.easeOut, onFinish: function onFinish() { tween(this.target, { scaleX: 1, scaleY: 1 }, { duration: 120 }); }.bind({ target: mines[i] }) }); mines[i].autoTick = 0; } } } // Auto-produce for factories for (var i = 0; i < factories.length; i++) { if (factoryAutoProduce[i] && factoryUnlocks[i]) { if (!factories[i].autoTick) { factories[i].autoTick = 0; } factories[i].autoTick++; // Use per-factory production time (speed up with level) var prodTime = factories[i].getProductionTime ? factories[i].getProductionTime() : 30; if (factories[i].autoTick >= prodTime) { var f = factories[i]; var part = partTypes[i]; var produced = 0; for (var j = 0; j < f.production; j++) { // Each part needs: copper:2, silicon:1, iron:1 // Calculate production cost as 50% of the sale price (which is 30~49, so use 40 as avg, or use 30 + Math.floor(Math.random()*20)/2 for dynamic) var salePrice = 30 + Math.floor(Math.random() * 20); var productionCost = Math.floor(salePrice * 0.5); if (rawMaterials.copper >= 2 && rawMaterials.silicon >= 1 && rawMaterials.iron >= 1 && money >= productionCost) { rawMaterials.copper -= 2; rawMaterials.silicon -= 1; rawMaterials.iron -= 1; money -= productionCost; updateMoneyText(); 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(this.target, { scaleX: 1, scaleY: 1 }, { duration: 120 }); }.bind({ target: f }) }); } factories[i].autoTick = 0; } } } // 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 }; // --- Internet Offer Panel --- // Panel variables var offerPanel = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 420, height: 340, x: 120, y: 1366 // center of 2732 }); game.addChild(offerPanel); var offerTitle = new Text2('İNTERNET TEKLİFİ', { size: 38, fill: '#fff' }); offerTitle.anchor.set(0.5, 0); offerTitle.x = offerPanel.x; offerTitle.y = offerPanel.y - 140; game.addChild(offerTitle); var offerPartTxt = new Text2('', { size: 36, fill: '#bff' }); offerPartTxt.anchor.set(0.5, 0); offerPartTxt.x = offerPanel.x; offerPartTxt.y = offerPanel.y - 60; game.addChild(offerPartTxt); var offerAmountTxt = new Text2('', { size: 36, fill: '#fff' }); offerAmountTxt.anchor.set(0.5, 0); offerAmountTxt.x = offerPanel.x; offerAmountTxt.y = offerPanel.y - 10; game.addChild(offerAmountTxt); var offerPriceTxt = new Text2('', { size: 36, fill: '#ffb' }); offerPriceTxt.anchor.set(0.5, 0); offerPriceTxt.x = offerPanel.x; offerPriceTxt.y = offerPanel.y + 40; game.addChild(offerPriceTxt); var offerBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 220, height: 70, x: offerPanel.x, y: offerPanel.y + 120 }); game.addChild(offerBtn); var offerBtnTxt = new Text2('Satın Al', { size: 36, fill: '#fff' }); offerBtnTxt.anchor.set(0.5, 0.5); offerBtnTxt.x = offerBtn.x; offerBtnTxt.y = offerBtn.y; game.addChild(offerBtnTxt); // Offer state var currentOffer = { part: null, amount: 0, price: 0, active: false // yeni teklif aktif mi }; // Helper to generate a new offer var offerTimeLeft = 0; var offerTimerInterval = null; var offerTimeTxt = new Text2('', { size: 32, fill: '#ffb' }); offerTimeTxt.anchor.set(0.5, 0); offerTimeTxt.x = offerPanel.x; offerTimeTxt.y = offerPanel.y + 90; game.addChild(offerTimeTxt); function updateOfferTimeTxt() { if (offerTimeLeft > 0) { var min = Math.floor(offerTimeLeft / 60); var sec = offerTimeLeft % 60; var timeStr = min > 0 ? min + " dk " + (sec < 10 ? "0" : "") + sec + " sn" : sec + " sn"; offerTimeTxt.setText("Yeni teklif: " + timeStr); } else { offerTimeTxt.setText(''); } } function generateInternetOffer() { // Pick a random part type var idx = Math.floor(Math.random() * partTypes.length); var part = partTypes[idx]; // Random amount: 2-8 var amount = 2 + Math.floor(Math.random() * 7); // Random price per item: 18-32 var pricePer = 18 + Math.floor(Math.random() * 15); var totalPrice = pricePer * amount; currentOffer.part = part; currentOffer.amount = amount; currentOffer.price = totalPrice; currentOffer.active = true; // Update UI offerPartTxt.setText(idx === 0 ? "MOUSE" : part.toUpperCase()); offerAmountTxt.setText("Adet: " + amount); offerPriceTxt.setText("Toplam: ₺" + totalPrice); offerBtn.visible = true; offerBtnTxt.visible = true; // Rastgele 1-2 dakika (60-120 saniye) arası süre belirle offerTimeLeft = (60 + Math.floor(Math.random() * 61)) * 60; updateOfferTimeTxt(); // Start timer for next offer if (offerTimerInterval) { LK.clearInterval(offerTimerInterval); offerTimerInterval = null; } offerTimerInterval = LK.setInterval(function () { if (!currentOffer.active) { LK.clearInterval(offerTimerInterval); offerTimerInterval = null; return; } offerTimeLeft--; updateOfferTimeTxt(); if (offerTimeLeft <= 0) { // Süre doldu, yeni teklif gelsin currentOffer.active = false; offerBtn.visible = false; offerBtnTxt.visible = false; offerPartTxt.setText("Süre doldu!"); offerAmountTxt.setText(""); offerPriceTxt.setText(""); updateOfferTimeTxt(); LK.clearInterval(offerTimerInterval); offerTimerInterval = null; LK.setTimeout(function () { generateInternetOffer(); }, 60); // 1 frame sonra yeni teklif gelsin } }, 60); // 1 saniye } generateInternetOffer(); // Button logic offerBtn.down = function (x, y, obj) { if (!currentOffer.active) return; if (money >= currentOffer.price) { money -= currentOffer.price; parts[currentOffer.part] += currentOffer.amount; updateMoneyText(); updatePartsText(); // Animate panel for feedback tween(offerPanel, { scaleX: 1.08, scaleY: 1.08 }, { duration: 120, onFinish: function onFinish() { tween(offerPanel, { scaleX: 1, scaleY: 1 }, { duration: 120 }); } }); // Teklif tamamlandı, yeni teklif gelene kadar butonu kapat currentOffer.active = false; offerBtn.visible = false; offerBtnTxt.visible = false; offerPartTxt.setText("Teklif tamamlandı!"); offerAmountTxt.setText(""); offerPriceTxt.setText(""); offerTimeLeft = 1200; updateOfferTimeTxt(); if (offerTimerInterval) { LK.clearInterval(offerTimerInterval); offerTimerInterval = null; } // Yeni teklif rastgele 1-2 dakika sonra gelsin var nextOfferDelay = (60 + Math.floor(Math.random() * 61)) * 60; LK.setTimeout(function () { generateInternetOffer(); }, nextOfferDelay); } else { // Not enough money, flash button red tween(offerBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(offerBtn, { tint: 0x222222 }, { duration: 120 }); } }); } }; // --- Toplu Satış Paneli --- var sellPanel = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 420, height: 340, x: 120, y: 1366 + 400 // offerPanel.y + 400 px altına }); game.addChild(sellPanel); var sellTitle = new Text2('TOPLU SATIŞ TEKLİFİ', { size: 38, fill: '#fff' }); sellTitle.anchor.set(0.5, 0); sellTitle.x = sellPanel.x; sellTitle.y = sellPanel.y - 140; game.addChild(sellTitle); var sellPartTxt = new Text2('', { size: 36, fill: '#bff' }); sellPartTxt.anchor.set(0.5, 0); sellPartTxt.x = sellPanel.x; sellPartTxt.y = sellPanel.y - 60; game.addChild(sellPartTxt); var sellAmountTxt = new Text2('', { size: 36, fill: '#fff' }); sellAmountTxt.anchor.set(0.5, 0); sellAmountTxt.x = sellPanel.x; sellAmountTxt.y = sellPanel.y - 10; game.addChild(sellAmountTxt); var sellPriceTxt = new Text2('', { size: 36, fill: '#ffb' }); sellPriceTxt.anchor.set(0.5, 0); sellPriceTxt.x = sellPanel.x; sellPriceTxt.y = sellPanel.y + 40; game.addChild(sellPriceTxt); var sellBtn = LK.getAsset('button', { anchorX: 0.5, anchorY: 0.5, width: 220, height: 70, x: sellPanel.x, y: sellPanel.y + 120 }); game.addChild(sellBtn); var sellBtnTxt = new Text2('Sat', { size: 36, fill: '#fff' }); sellBtnTxt.anchor.set(0.5, 0.5); sellBtnTxt.x = sellBtn.x; sellBtnTxt.y = sellBtn.y; game.addChild(sellBtnTxt); // Satış teklifi state var currentSellOffer = { part: null, amount: 0, price: 0, active: false }; // Helper to generate a new sell offer var sellOfferTimeLeft = 0; var sellOfferTimerInterval = null; var sellOfferTimeTxt = new Text2('', { size: 32, fill: '#ffb' }); sellOfferTimeTxt.anchor.set(0.5, 0); sellOfferTimeTxt.x = sellPanel.x; sellOfferTimeTxt.y = sellPanel.y + 90; game.addChild(sellOfferTimeTxt); function updateSellOfferTimeTxt() { if (sellOfferTimeLeft > 0) { var min = Math.floor(sellOfferTimeLeft / 60); var sec = sellOfferTimeLeft % 60; var timeStr = min > 0 ? min + " dk " + (sec < 10 ? "0" : "") + sec + " sn" : sec + " sn"; sellOfferTimeTxt.setText("Yeni teklif: " + timeStr); } else { sellOfferTimeTxt.setText(''); } } // Helper to generate a new sell offer function generateSellOffer() { // Sadece stoğunda en az 2 olanlardan rastgele seç var available = []; for (var i = 0; i < partTypes.length; i++) { if (parts[partTypes[i]] >= 2) available.push(partTypes[i]); } if (available.length === 0) { currentSellOffer.part = null; currentSellOffer.amount = 0; currentSellOffer.price = 0; currentSellOffer.active = false; sellPartTxt.setText("Yeterli ürün yok"); sellAmountTxt.setText(""); sellPriceTxt.setText(""); sellBtn.visible = false; sellBtnTxt.visible = false; return; } var idx = Math.floor(Math.random() * available.length); var part = available[idx]; // Satış miktarı: 2-8, ama stoğundan fazla olamaz var maxAmount = Math.min(parts[part], 8); var amount = 2 + Math.floor(Math.random() * (maxAmount - 1)); // Satış fiyatı: 28-45 arası birim fiyat var pricePer = 28 + Math.floor(Math.random() * 18); var totalPrice = pricePer * amount; currentSellOffer.part = part; currentSellOffer.amount = amount; currentSellOffer.price = totalPrice; currentSellOffer.active = true; sellPartTxt.setText(idx === 0 ? "MOUSE" : part.toUpperCase()); sellAmountTxt.setText("Adet: " + amount); sellPriceTxt.setText("Toplam: ₺" + totalPrice); sellBtn.visible = true; sellBtnTxt.visible = true; // Süreyi rastgele 1-2 dakika (60-120 saniye) arası belirle sellOfferTimeLeft = (60 + Math.floor(Math.random() * 61)) * 60; updateSellOfferTimeTxt(); // Timer varsa temizle if (sellOfferTimerInterval) { LK.clearInterval(sellOfferTimerInterval); sellOfferTimerInterval = null; } sellOfferTimerInterval = LK.setInterval(function () { if (!currentSellOffer.active) { LK.clearInterval(sellOfferTimerInterval); sellOfferTimerInterval = null; return; } sellOfferTimeLeft--; updateSellOfferTimeTxt(); if (sellOfferTimeLeft <= 0) { // Süre doldu, yeni teklif gelsin currentSellOffer.active = false; sellBtn.visible = false; sellBtnTxt.visible = false; sellPartTxt.setText("Süre doldu!"); sellAmountTxt.setText(""); sellPriceTxt.setText(""); updateSellOfferTimeTxt(); LK.clearInterval(sellOfferTimerInterval); sellOfferTimerInterval = null; LK.setTimeout(function () { generateSellOffer(); }, 60); // 1 frame sonra yeni teklif gelsin } }, 60); // 1 saniye } generateSellOffer(); // Satış butonu logic sellBtn.down = function (x, y, obj) { if (!currentSellOffer.active) return; if (parts[currentSellOffer.part] >= currentSellOffer.amount) { parts[currentSellOffer.part] -= currentSellOffer.amount; money += currentSellOffer.price; updateMoneyText(); updatePartsText(); // Panel animasyonu tween(sellPanel, { scaleX: 1.08, scaleY: 1.08 }, { duration: 120, onFinish: function onFinish() { tween(sellPanel, { scaleX: 1, scaleY: 1 }, { duration: 120 }); } }); // Teklif tamamlandı, yeni teklif gelene kadar butonu kapat currentSellOffer.active = false; sellBtn.visible = false; sellBtnTxt.visible = false; sellPartTxt.setText("Teklif tamamlandı!"); sellAmountTxt.setText(""); sellPriceTxt.setText(""); // Yeni teklif rastgele 1-2 dakika sonra gelsin var nextSellOfferDelay = (60 + Math.floor(Math.random() * 61)) * 60; LK.setTimeout(function () { generateSellOffer(); }, nextSellOfferDelay); } else { // Yeterli ürün yok, kırmızıya boya ve uyarı göster tween(sellBtn, { tint: 0xff2222 }, { duration: 120, onFinish: function onFinish() { tween(sellBtn, { tint: 0x222222 }, { duration: 120 }); } }); // 'Bakiye yetersiz' uyarısı göster sellBtnTxt.setText('Bakiye yetersiz'); LK.setTimeout(function () { // Eğer buton hala görünürse eski haline döndür if (sellBtn.visible) { sellBtnTxt.setText('Sat'); } // Teklifi yenile generateSellOffer(); }, 300); // 5 saniye = 300 frame } }; // Satış teklifi her rastgele 1-5 dakikada bir yenilensin (eğer aktif değilse) function scheduleNextSellOfferInterval() { var interval = (60 + Math.floor(Math.random() * 61)) * 60; LK.setTimeout(function () { if (!currentSellOffer.active) generateSellOffer(); scheduleNextSellOfferInterval(); }, interval); } scheduleNextSellOfferInterval();
===================================================================
--- original.js
+++ change.js
@@ -470,8 +470,49 @@
fill: '#fff'
});
moneyTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(moneyTxt);
+// --- Yatırım Button ---
+var yatirimBtn = LK.getAsset('button', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: 180,
+ height: 70
+});
+yatirimBtn.x = moneyTxt.x - 220;
+yatirimBtn.y = 40;
+LK.gui.top.addChild(yatirimBtn);
+var yatirimBtnTxt = new Text2('Yatırım', {
+ size: 36,
+ fill: '#fff'
+});
+yatirimBtnTxt.anchor.set(0.5, 0.5);
+yatirimBtnTxt.x = yatirimBtn.x;
+yatirimBtnTxt.y = yatirimBtn.y;
+LK.gui.top.addChild(yatirimBtnTxt);
+// Yatırım butonuna basınca yeni bir sayfaya geç (örnek: LK.showPage fonksiyonu ile)
+yatirimBtn.down = function (x, y, obj) {
+ // Burada yeni bir sayfa açmak için örnek bir fonksiyon çağrısı:
+ if (typeof LK.showPage === "function") {
+ LK.showPage("yatirim");
+ } else {
+ // Eğer showPage yoksa, ekrana basit bir uyarı gösterebiliriz
+ yatirimBtnTxt.setText("Sayfa yok");
+ tween(yatirimBtn, {
+ tint: 0xff2222
+ }, {
+ duration: 120,
+ onFinish: function onFinish() {
+ tween(yatirimBtn, {
+ tint: 0x222222
+ }, {
+ duration: 120
+ });
+ yatirimBtnTxt.setText("Yatırım");
+ }
+ });
+ }
+};
// --- Banka Button & Borç Logic ---
var bankBtn = LK.getAsset('button', {
anchorX: 0.5,
anchorY: 0.5,
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