User prompt
Ocak ve tezgahı çok azıcık yukarı yükselt.
User prompt
Ocak ve fırını 3.ekrandaki tazgah gibi büyük yap.
User prompt
İlk ekranda yeni tarlayı açamıyorum. Onu düzelt
User prompt
3.cü ekrandada tezgah, müşteriler ve pişen mısır sayısı dışında her şeyi sil.
User prompt
1. ekranda tarla ve tarla açma yeri dışındaki her şeyi sil.
User prompt
Birinci ve üçüncü ekranda bir yerde 0 yazıyor onu sil.
User prompt
Cook asetini ve cook ile olsan yazıları tamamen sil.
User prompt
Cook 1. Ve 3. Ekranda gözüküyor bunu sil.
User prompt
Hayla cooked gözülüyor 1. Ve 3. Ekranda
User prompt
İlk ve son ekranda 2.ekran gözüküyor bunu düzelt.
User prompt
2.ekranda tencere,ocak ve box dışındaki her şeyi sil.
User prompt
Pişen mısırları 2.ekranda gösteren yazıları sil.
User prompt
Boxa basıldığında tencereye teker teker mısır gelsin ve hepsi tencerenin farklı yerlerinde dursun.
User prompt
Cook asetine ve pişen mısır sayısına dokunamayalım.
User prompt
Cook aseti 2.ekranda tekrar gözüksün.
User prompt
Cook asetini tekrar ekle.
User prompt
3.ekranda pişen mısırların sayısını yazan bir kutu ekle
User prompt
Boxun altındaki cook asetinden kalan yazılar var onları sil.
User prompt
Cook yazıları hayla duruyor onlarıda sil 2.ekranda
User prompt
Cook asetini direkt yok et.
User prompt
Cook asetini sil. Onun yerine 2.ekrandaki box tuşuna basınca eğer mısır varsa mısırlar tencerenin içine düşünler ve pişmeye başlasınlar.
User prompt
Tencere ve ocağa yeni asetler ekle. Bütün asetler kendi asetleri olsun.
User prompt
Tencere ve ocak boyutunu büyüt.
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'addCorn')' in or related to this line: 'game.orderArea.addCorn(1);' Line Number: 120
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'getGlobalCenter')' in or related to this line: 'var orderPos = game.orderArea.getGlobalCenter();' Line Number: 100
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ // CookArea: Cooks raw corn, can be tapped to cook, then send to order area var CookArea = Container.expand(function () { var self = Container.call(this); var cookAsset = self.attachAsset('cook', { anchorX: 0.5, anchorY: 0.5 }); cookAsset.width = 220; cookAsset.height = 220; self.rawCorn = 0; self.cookedCorn = 0; // Cooked corn icon var cookedAsset = self.attachAsset('cooked', { anchorX: 0.5, anchorY: 0.5, alpha: 0 }); cookedAsset.width = 120; cookedAsset.height = 120; // Texts var rawTxt = new Text2('0', { size: 60, fill: "#fff" }); rawTxt.anchor.set(0.5, 0.2); self.addChild(rawTxt); var cookedTxt = new Text2('0', { size: 60, fill: 0xFFB347 }); cookedTxt.anchor.set(0.5, 0.8); self.addChild(cookedTxt); self.addRawCorn = function (n) { self.rawCorn += n; rawTxt.setText(self.rawCorn); LK.effects.flashObject(cookAsset, 0xffff00, 200); }; self.removeRawCorn = function (n) { if (self.rawCorn >= n) { self.rawCorn -= n; rawTxt.setText(self.rawCorn); return true; } return false; }; self.addCookedCorn = function (n) { self.cookedCorn += n; cookedTxt.setText(self.cookedCorn); cookedAsset.alpha = 1; LK.effects.flashObject(cookedAsset, 0xffb347, 200); }; self.removeCookedCorn = function (n) { if (self.cookedCorn >= n) { self.cookedCorn -= n; cookedTxt.setText(self.cookedCorn); if (self.cookedCorn === 0) cookedAsset.alpha = 0; return true; } return false; }; self.down = function (x, y, obj) { if (self.rawCorn > 0) { // Cook one corn (takes time) self.removeRawCorn(1); LK.effects.flashObject(cookAsset, 0xffb347, 200); LK.setTimeout(function () { self.addCookedCorn(1); }, game.cookTime); } else if (self.cookedCorn > 0) { // Send cooked corn to order area var globalCook = self.toGlobal({ x: 0, y: 0 }); var orderPos = game.cookArea.getGlobalCenter(); var flyingCorn = LK.getAsset('cooked', { anchorX: 0.5, anchorY: 0.5, x: globalCook.x, y: globalCook.y, width: 100, height: 100 }); game.addChild(flyingCorn); tween(flyingCorn, { x: orderPos.x, y: orderPos.y, alpha: 0.2 }, { duration: 500, easing: tween.cubicOut, onFinish: function onFinish() { flyingCorn.destroy(); if (self.removeCookedCorn(1)) { game.orderArea.addCorn(1); } } }); } }; self.getGlobalCenter = function () { var pos = self.toGlobal({ x: 0, y: 0 }); return { x: pos.x, y: pos.y }; }; self.reset = function () { self.rawCorn = 0; self.cookedCorn = 0; rawTxt.setText('0'); cookedTxt.setText('0'); cookedAsset.alpha = 0; }; // Add containsPoint method to CookArea self.containsPoint = function (point) { // Convert global point to local coordinates of the CookArea var localX = point.x - self.x; var localY = point.y - self.y; // cookAsset is centered at (0,0) with anchor 0.5,0.5 var w = cookAsset.width; var h = cookAsset.height; // Check if localX, localY is inside cookAsset bounds return localX >= -w / 2 && localX <= w / 2 && localY >= -h / 2 && localY <= h / 2; }; return self; }); // CornBox: Stores harvested corn, can be tapped to send to cook area var CornBox = Container.expand(function () { var self = Container.call(this); var boxAsset = self.attachAsset('box', { anchorX: 0.5, anchorY: 0.5 }); boxAsset.width = 220; boxAsset.height = 220; self.cornCount = 0; // Corn count text var cornTxt = new Text2('0', { size: 80, fill: 0xFFF700 }); cornTxt.anchor.set(0.5, 0.5); self.addChild(cornTxt); self.addCorn = function (n) { self.cornCount += n; cornTxt.setText(self.cornCount); LK.effects.flashObject(boxAsset, 0xffff00, 200); }; self.removeCorn = function (n) { if (self.cornCount >= n) { self.cornCount -= n; cornTxt.setText(self.cornCount); return true; } return false; }; self.down = function (x, y, obj) { if (self.cornCount > 0) { // Animate corn to cook area var globalBox = self.toGlobal({ x: 0, y: 0 }); var cookPos = game.cookArea.getGlobalCenter(); var flyingCorn = LK.getAsset('corn', { anchorX: 0.5, anchorY: 0.5, x: globalBox.x, y: globalBox.y, width: 100, height: 100 }); game.addChild(flyingCorn); tween(flyingCorn, { x: cookPos.x, y: cookPos.y, alpha: 0.2 }, { duration: 500, easing: tween.cubicOut, onFinish: function onFinish() { flyingCorn.destroy(); if (self.removeCorn(1)) { game.cookArea.addRawCorn(1); } } }); } }; self.getGlobalCenter = function () { var pos = self.toGlobal({ x: 0, y: 0 }); return { x: pos.x, y: pos.y }; }; self.reset = function () { self.cornCount = 0; cornTxt.setText('0'); }; // Add containsPoint method to CornBox self.containsPoint = function (point) { // Convert global point to local coordinates of the CornBox var localX = point.x - self.x; var localY = point.y - self.y; // boxAsset is centered at (0,0) with anchor 0.5,0.5 var w = boxAsset.width; var h = boxAsset.height; // Check if localX, localY is inside boxAsset bounds return localX >= -w / 2 && localX <= w / 2 && localY >= -h / 2 && localY <= h / 2; }; return self; }); // CornField: Represents a single field where corn can be planted, grown, and harvested var CornField = Container.expand(function () { var self = Container.call(this); // States: 'empty', 'growing', 'ready' self.state = 'empty'; self.index = 0; // set by game self.cornType = null; // for future upgrades // Field asset var fieldAsset = self.attachAsset('field', { anchorX: 0.5, anchorY: 0.5 }); fieldAsset.width = 320; fieldAsset.height = 320; // Corn asset (hidden unless growing/ready) var cornAsset = self.attachAsset('corn', { anchorX: 0.5, anchorY: 0.5, alpha: 0 }); cornAsset.width = 180; cornAsset.height = 180; // Grow time/ready text above corn var growTxt = new Text2('', { size: 60, fill: "#fff" }); growTxt.anchor.set(0.5, 1); growTxt.x = 0; growTxt.y = -120; self.addChild(growTxt); // Cooldown text above field (for replant cooldown) var cooldownTxt = new Text2('', { size: 60, fill: 0xFF4444 }); cooldownTxt.anchor.set(0.5, 1); cooldownTxt.x = 0; cooldownTxt.y = -180; self.addChild(cooldownTxt); // Track grow start time for countdown self._growStart = null; self._growEnd = null; // Show field as locked if not unlocked var lockAsset = self.attachAsset('lock', { anchorX: 0.5, anchorY: 0.5, alpha: 0 }); lockAsset.width = 120; lockAsset.height = 120; // Track how many times this field has been planted self.plantCount = 0; // Plant corn if field is empty self.down = function (x, y, obj) { if (self.state === 'empty' && !self.locked) { if (self._replantCooldown) { // Show cooldown visually LK.effects.flashObject(fieldAsset, 0xff0000, 200); return; } // Only allow planting if there are seeds left if (typeof game.seeds === "undefined" || game.seeds <= 0) { LK.effects.flashObject(fieldAsset, 0xff0000, 300); return; } // Decrement seed count and update display game.seeds--; if (typeof game.updateSeeds === "function") game.updateSeeds(); self.plant(); } else if (self.locked) { // Try to unlock if enough coins if (game.coins >= game.unlockCost) { game.coins -= game.unlockCost; self.unlock(); game.updateCoins(); } else { LK.effects.flashObject(lockAsset, 0xff0000, 500); } } else if (self.state === 'ready') { self.harvest(); } }; self.plant = function () { self.state = 'growing'; cornAsset.alpha = 1; cornAsset.scaleX = 0.5; cornAsset.scaleY = 0.5; tween(cornAsset, { scaleX: 1, scaleY: 1 }, { duration: 400, easing: tween.easeOut }); // Calculate grow time: 5s for first, +1s for each subsequent plant if (typeof self.plantCount !== "number") self.plantCount = 0; var growTime = 5000 + self.plantCount * 1000; self.plantCount++; // Start grow timer self._growStart = Date.now(); self._growEnd = self._growStart + growTime; growTxt.setText(Math.ceil(growTime / 1000)); self.growTimeout = LK.setTimeout(function () { self.state = 'ready'; self._growStart = null; self._growEnd = null; growTxt.setText('ready'); LK.effects.flashObject(cornAsset, 0xffff00, 400); }, growTime); }; self.harvest = function () { if (self.state !== 'ready') return; self.state = 'empty'; cornAsset.alpha = 0; growTxt.setText(''); self._growStart = null; self._growEnd = null; // Animate corn flying to box var globalCorn = self.toGlobal({ x: 0, y: 0 }); var boxPos = game.cornBox.getGlobalCenter(); var flyingCorn = LK.getAsset('corn', { anchorX: 0.5, anchorY: 0.5, x: globalCorn.x, y: globalCorn.y, width: 120, height: 120 }); game.addChild(flyingCorn); tween(flyingCorn, { x: boxPos.x, y: boxPos.y, alpha: 0.2 }, { duration: 600, easing: tween.cubicOut, onFinish: function onFinish() { flyingCorn.destroy(); game.cornBox.addCorn(1); } }); // Start replant cooldown: prevent planting for 5 seconds self._replantCooldown = true; cooldownTxt.setText('5'); var cooldownLeft = 5; self._replantCooldownTimer = LK.setInterval(function () { cooldownLeft--; if (cooldownLeft > 0) { cooldownTxt.setText('' + cooldownLeft); } else { LK.clearInterval(self._replantCooldownTimer); self._replantCooldown = false; cooldownTxt.setText(''); } }, 1000); }; self.locked = false; self.lock = function () { self.locked = true; lockAsset.alpha = 1; fieldAsset.alpha = 0.4; cornAsset.alpha = 0; self.state = 'empty'; }; self.unlock = function () { self.locked = false; lockAsset.alpha = 0; fieldAsset.alpha = 1; }; self.setLocked = function (locked) { if (locked) { self.lock(); fieldAsset.alpha = 0.4; } else { self.unlock(); fieldAsset.alpha = 1; } }; self.reset = function () { self.state = 'empty'; cornAsset.alpha = 0; if (self.growTimeout) LK.clearTimeout(self.growTimeout); growTxt.setText(''); self._growStart = null; self._growEnd = null; self.plantCount = 0; if (self._replantCooldownTimer) LK.clearInterval(self._replantCooldownTimer); self._replantCooldown = false; cooldownTxt.setText(''); }; // Update method for grow/ready text self.update = function () { if (self.state === 'growing' && self._growStart && self._growEnd) { var now = Date.now(); var remain = Math.max(0, Math.ceil((self._growEnd - now) / 1000)); if (remain > 0) { growTxt.setText(remain); } else { growTxt.setText('ready'); } } else if (self.state === 'ready') { growTxt.setText('ready'); } else { growTxt.setText(''); } // Show/hide cooldown text depending on replant cooldown if (self._replantCooldown) { // cooldownTxt is already updated in the interval cooldownTxt.visible = true; } else { cooldownTxt.visible = false; } }; // Add containsPoint method to CornField self.containsPoint = function (point) { // Convert global point to local coordinates of the field var localX = point.x - self.x; var localY = point.y - self.y; // fieldAsset is centered at (0,0) with anchor 0.5,0.5 var w = fieldAsset.width; var h = fieldAsset.height; // Check if localX, localY is inside fieldAsset bounds return localX >= -w / 2 && localX <= w / 2 && localY >= -h / 2 && localY <= h / 2; }; return self; }); // Customer: Represents a customer standing in front of the tezgah (counter) var Customer = Container.expand(function () { var self = Container.call(this); // Body (ellipse) var body = self.attachAsset('cooked', { anchorX: 0.5, anchorY: 1, y: 0, width: 180, height: 220, alpha: 1 }); // Head (unique customer head) var head = self.attachAsset('customerHead', { anchorX: 0.5, anchorY: 1, y: -180, width: 120, height: 120, alpha: 1 }); // Left hand (ellipse) var leftHand = self.attachAsset('cook', { anchorX: 0.5, anchorY: 1, x: -60, y: -60, width: 60, height: 60, alpha: 1 }); // Right hand (ellipse) var rightHand = self.attachAsset('cook', { anchorX: 0.5, anchorY: 1, x: 60, y: -60, width: 60, height: 60, alpha: 1 }); // Optionally, randomize color or add more features for variety // For future: self.order = {...} return self; }); // OrderArea: Handles customer orders, sauces, and delivery var OrderArea = Container.expand(function () { var self = Container.call(this); var orderAsset = self.attachAsset('order', { anchorX: 0.5, anchorY: 0.5 }); orderAsset.width = 260; orderAsset.height = 260; self.cornCount = 0; self.currentOrder = null; self.sauces = ['ketchup', 'mayonnaise', 'cheese']; self.selectedSauces = []; // Corn icon var cornAsset = self.attachAsset('cooked', { anchorX: 0.5, anchorY: 0.5, alpha: 0 }); cornAsset.width = 120; cornAsset.height = 120; // Order text var orderTxt = new Text2('', { size: 50, fill: "#fff" }); orderTxt.anchor.set(0.5, 0.1); self.addChild(orderTxt); // Sauce icons self.sauceIcons = []; for (var i = 0; i < self.sauces.length; i++) { var s = self.sauces[i]; var icon = self.attachAsset(s, { anchorX: 0.5, anchorY: 0.5, x: -60 + i * 60, y: 80, alpha: 0.5 }); icon.width = 60; icon.height = 60; icon.sauce = s; // Add containsPoint method to each sauce icon icon.containsPoint = function (point) { // point is relative to OrderArea, icon.x/y is relative to OrderArea var localX = point.x - icon.x; var localY = point.y - icon.y; var w = icon.width, h = icon.height; return localX >= -w / 2 && localX <= w / 2 && localY >= -h / 2 && localY <= h / 2; }; self.sauceIcons.push(icon); } // Delivery button var deliverBtn = self.attachAsset('deliver', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 120, alpha: 0.7 }); deliverBtn.width = 100; deliverBtn.height = 60; // Add containsPoint method to deliverBtn for hit testing deliverBtn.containsPoint = function (point) { var localX = point.x - deliverBtn.x; var localY = point.y - deliverBtn.y; var w = deliverBtn.width; var h = deliverBtn.height; return localX >= -w / 2 && localX <= w / 2 && localY >= -h / 2 && localY <= h / 2; }; // Add corn to order area self.addCorn = function (n) { self.cornCount += n; cornAsset.alpha = 1; LK.effects.flashObject(cornAsset, 0xffb347, 200); self.updateOrderText(); }; self.removeCorn = function (n) { if (self.cornCount >= n) { self.cornCount -= n; if (self.cornCount === 0) cornAsset.alpha = 0; self.updateOrderText(); return true; } return false; }; self.updateOrderText = function () { if (!self.currentOrder) { orderTxt.setText(''); return; } var txt = 'Sipariş: '; for (var i = 0; i < self.currentOrder.sauces.length; i++) { txt += self.currentOrder.sauces[i]; if (i < self.currentOrder.sauces.length - 1) txt += ', '; } orderTxt.setText(txt); }; self.newOrder = function () { // Random sauces (1-3) var n = 1 + Math.floor(Math.random() * self.sauces.length); var sauces = []; var used = {}; while (sauces.length < n) { var idx = Math.floor(Math.random() * self.sauces.length); var s = self.sauces[idx]; if (!used[s]) { sauces.push(s); used[s] = true; } } self.currentOrder = { sauces: sauces }; self.selectedSauces = []; self.updateOrderText(); for (var i = 0; i < self.sauceIcons.length; i++) { self.sauceIcons[i].alpha = 0.5; } }; // Sauce selection self.sauceDown = function (sauce) { if (!self.currentOrder) return; if (self.selectedSauces.length >= self.currentOrder.sauces.length) return; if (self.selectedSauces.indexOf(sauce) !== -1) return; self.selectedSauces.push(sauce); for (var i = 0; i < self.sauceIcons.length; i++) { if (self.sauceIcons[i].sauce === sauce) { self.sauceIcons[i].alpha = 1; } } }; // Deliver order self.deliver = function () { if (!self.currentOrder) return; if (self.cornCount < 1) return; // Check sauces var ok = true; for (var i = 0; i < self.currentOrder.sauces.length; i++) { if (self.selectedSauces.indexOf(self.currentOrder.sauces[i]) === -1) { ok = false; break; } } if (ok && self.selectedSauces.length === self.currentOrder.sauces.length) { // Success self.removeCorn(1); LK.effects.flashObject(orderAsset, 0x00ff00, 400); game.coins += game.orderReward; game.updateCoins(); self.currentOrder = null; self.selectedSauces = []; LK.setTimeout(function () { self.newOrder(); }, 800); } else { // Wrong sauces LK.effects.flashObject(orderAsset, 0xff0000, 400); self.selectedSauces = []; for (var i = 0; i < self.sauceIcons.length; i++) { self.sauceIcons[i].alpha = 0.5; } } }; // Event handling self.down = function (x, y, obj) { // Check if sauce icon tapped for (var i = 0; i < self.sauceIcons.length; i++) { var icon = self.sauceIcons[i]; if (icon.containsPoint({ x: x - self.x, y: y - self.y })) { self.sauceDown(icon.sauce); return; } } // Check if deliver button tapped if (deliverBtn.containsPoint({ x: x - self.x, y: y - self.y })) { self.deliver(); return; } }; self.getGlobalCenter = function () { var pos = self.toGlobal({ x: 0, y: 0 }); return { x: pos.x, y: pos.y }; }; self.reset = function () { self.cornCount = 0; self.currentOrder = null; self.selectedSauces = []; cornAsset.alpha = 0; self.updateOrderText(); for (var i = 0; i < self.sauceIcons.length; i++) { self.sauceIcons[i].alpha = 0.5; } }; // Add containsPoint method to OrderArea self.containsPoint = function (point) { // Convert global point to local coordinates of the OrderArea var localX = point.x - self.x; var localY = point.y - self.y; // orderAsset is centered at (0,0) with anchor 0.5,0.5 var w = orderAsset.width; var h = orderAsset.height; // Check if localX, localY is inside orderAsset bounds return localX >= -w / 2 && localX <= w / 2 && localY >= -h / 2 && localY <= h / 2; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2e7d32 }); /**** * Game Code ****/ // --- Game constants --- game.cornGrowTime = 5000; // ms game.cookTime = 2000; // ms game.orderReward = 5; game.unlockCost = 20; game.maxFields = 8; // --- Game state --- game.coins = storage.coins || 20; game.unlockedFields = 4; game.seeds = 4; // Başlangıçta 4 tohumumuz var // --- UI: Seeds display (only on field screen) --- var seedsTxt = new Text2('Tohum: ' + game.seeds, { size: 80, fill: 0xFFF700 }); seedsTxt.anchor.set(0.5, 0); // Move seedsTxt down to avoid the top menu (at least 100px from top), and center horizontally seedsTxt.x = 2048 / 2; seedsTxt.y = 140; LK.gui.top.addChild(seedsTxt); // Always show on field screen, hide otherwise (handled in updateScreenVisibility) seedsTxt.visible = game.currentScreen === 0; // --- UI: Coins display --- var coinsTxt = new Text2(game.coins + '₺', { size: 90, fill: 0xFFFDE7 }); coinsTxt.anchor.set(0.5, 0); LK.gui.top.addChild(coinsTxt); // Bring seedsTxt and coinsTxt to the very front in the GUI overlay if (typeof LK.gui.top.setChildIndex === "function") { LK.gui.top.setChildIndex(seedsTxt, LK.gui.top.children.length - 1); LK.gui.top.setChildIndex(coinsTxt, LK.gui.top.children.length - 1); } // Update seeds display game.updateSeeds = function () { seedsTxt.setText('Tohum: ' + game.seeds); }; game.updateCoins = function () { coinsTxt.setText(game.coins + '₺'); storage.coins = game.coins; storage.unlockedFields = game.unlockedFields; }; // --- Screen management --- game.screens = ['field', 'boxcook', 'order']; game.currentScreen = 0; // 0: field, 1: box/cook, 2: order // --- Field grid --- game.fields = []; var fieldRows = 2; var fieldCols = 2; var fieldSpacing = 340; var fieldStartX = 400; var fieldStartY = 600; function updateFieldGrid() { // Determine grid size based on unlocked fields var n = game.unlockedFields; if (n <= 4) { fieldRows = 2; fieldCols = 2; } else if (n <= 9) { fieldRows = 3; fieldCols = 3; } else { fieldRows = 4; fieldCols = 4; } } function layoutFields() { updateFieldGrid(); // Calculate how many fields are visible per "page" vertically var maxVisibleRows = Math.floor((2048 - fieldStartY) / fieldSpacing); // fit as many as possible var maxVisibleCols = Math.floor((2048 - fieldStartX) / fieldSpacing); // For our game, let's allow 2 rows before scrolling horizontally var fieldsPerCol = 2; var fieldsPerRow = 4; // up to 4 columns before scrolling horizontally // Calculate how many "pages" horizontally var pageSize = fieldsPerCol * fieldsPerRow; var pageCount = Math.ceil(game.unlockedFields / pageSize); // Find which page is currently active (always show the last unlocked page) var currentPage = Math.floor((game.unlockedFields - 1) / pageSize); // Calculate horizontal offset for scrolling var scrollX = currentPage * (fieldsPerRow * fieldSpacing + 100); // 100px gap between pages for (var i = 0; i < game.maxFields; i++) { // Which page does this field belong to? var page = Math.floor(i / pageSize); var pageIndex = i % pageSize; var row = Math.floor(pageIndex / fieldsPerRow); var col = pageIndex % fieldsPerRow; // If not unlocked, keep offscreen if (i >= game.unlockedFields) { game.fields[i].x = -1000; game.fields[i].y = -1000; continue; } // Place fields in a grid, scrolling horizontally after 2 rows var x = fieldStartX + col * fieldSpacing - scrollX; var y = fieldStartY + row * fieldSpacing; game.fields[i].x = x; game.fields[i].y = y; } } // Create fields for (var i = 0; i < game.maxFields; i++) { var field = new CornField(); field.index = i; game.addChild(field); game.fields.push(field); } function updateFieldLocks() { for (var i = 0; i < game.maxFields; i++) { if (i < game.unlockedFields) { game.fields[i].setLocked(false); if (game.fields[i].fieldAsset) game.fields[i].fieldAsset.alpha = 1; } else { game.fields[i].setLocked(true); if (game.fields[i].fieldAsset) game.fields[i].fieldAsset.alpha = 0.4; } } } updateFieldLocks(); layoutFields(); // --- Corn Box --- game.cornBox = new CornBox(); game.cornBox.x = 2048 - 300; game.cornBox.y = 700; game.addChild(game.cornBox); // --- Stove & Pot for Cooking Screen --- game.stove = new Container(); game.stove.x = 2048 / 2; game.stove.y = 1200; game.addChild(game.stove); // Stove asset (rectangle) - increased size var stoveAsset = LK.getAsset('box', { anchorX: 0.5, anchorY: 0.5, width: 700, height: 160, y: 120 }); game.stove.addChild(stoveAsset); // Pot asset (ellipse, centered on stove) - increased size var potAsset = LK.getAsset('cook', { anchorX: 0.5, anchorY: 0.5, width: 400, height: 320, y: 0 }); game.stove.addChild(potAsset); // Pot "lid" (for visual effect) - increased size var potLid = LK.getAsset('cooked', { anchorX: 0.5, anchorY: 0.5, width: 320, height: 70, y: -120, alpha: 0.7 }); game.stove.addChild(potLid); // Corns in pot (array of {asset, startTime}) game.potCorns = []; // Pot timer text game.potTimerTxt = new Text2('', { size: 70, fill: "#fff" }); game.potTimerTxt.anchor.set(0.5, 0.5); game.potTimerTxt.x = 0; game.potTimerTxt.y = 0; game.stove.addChild(game.potTimerTxt); // --- Cook Area (for legacy, still used for quick cook) --- game.cookArea = new CookArea(); game.cookArea.x = 2048 - 300; game.cookArea.y = 1100; game.addChild(game.cookArea); // --- Order Area --- // Order area removed as per request // Minimal OrderArea to prevent undefined error for addCorn game.orderArea = { addCorn: function addCorn(n) { // No-op: order area is removed, but prevent error } }; // --- Tezgah (Counter) for Customer Screen --- // Make the tezgah (counter) very large and at the very bottom of the screen, spanning almost the full width game.counterAsset = LK.getAsset('box', { anchorX: 0.5, anchorY: 1, width: 2048 - 20, // leave only 10px margin on each side for a bigger counter height: 420, // make it even taller alpha: 0.95 }); game.counterAsset.x = 2048 / 2; game.counterAsset.y = 2732; // anchorY:1 puts bottom at y=2732 game.addChild(game.counterAsset); // --- Customers in front of tezgah (only on customer screen) --- game.customers = []; var customerCount = 3; var spacing = 420; var startX = 2048 / 2 - spacing; var y = 2732 - 420; // Stand just above the tezgah for (var i = 0; i < customerCount; i++) { var cust = new Customer(); cust.x = startX + i * spacing; cust.y = y; cust.visible = false; // Only show on customer screen game.addChild(cust); game.customers.push(cust); } // --- Unlock 4 Fields Button --- // Place a new button below the 4 fields to unlock 4 more fields at once for 20 coins var unlock4BtnContainer = new Container(); var unlock4Btn = LK.getAsset('unlock', { anchorX: 0.5, anchorY: 0.5, width: 320, height: 120, alpha: 0.9 }); unlock4BtnContainer.addChild(unlock4Btn); game.addChild(unlock4BtnContainer); var unlock4Txt = new Text2('4 Tarla Aç (20₺)', { size: 60, fill: "#fff" }); unlock4Txt.anchor.set(0.5, 0.5); game.addChild(unlock4Txt); // Add containsPoint method to unlock4BtnContainer unlock4BtnContainer.containsPoint = function (point) { var localX = point.x - unlock4BtnContainer.x; var localY = point.y - unlock4BtnContainer.y; var w = unlock4Btn.width; var h = unlock4Btn.height; return localX >= -w / 2 && localX <= w / 2 && localY >= -h / 2 && localY <= h / 2; }; // Update unlock4 button position and text function updateUnlockBtn() { // Only show if exactly 4 fields are unlocked and maxFields not reached and seeds > 0 if (game.unlockedFields !== 4 || game.unlockedFields >= game.maxFields || game.seeds <= 0) { unlock4Btn.alpha = 0.3; unlock4BtnContainer.visible = false; unlock4Txt.visible = false; return; } // Place below the last unlocked field (index game.unlockedFields-1) var lastField = game.fields[game.unlockedFields - 1]; unlock4BtnContainer.x = lastField.x; unlock4BtnContainer.y = lastField.y + 260; unlock4Txt.x = unlock4BtnContainer.x; unlock4Txt.y = unlock4BtnContainer.y; unlock4BtnContainer.visible = true; unlock4Txt.visible = true; unlock4Btn.alpha = 0.9; unlock4Txt.setText('4 Tarla Aç (20₺)'); } updateUnlockBtn(); // --- Screen navigation buttons --- var leftBtn = LK.getAsset('unlock', { anchorX: 0.5, anchorY: 0.5, width: 120, height: 120, x: 120, y: 2732 / 2, alpha: 0.7 }); var rightBtn = LK.getAsset('unlock', { anchorX: 0.5, anchorY: 0.5, width: 120, height: 120, x: 2048 - 120, y: 2732 / 2, alpha: 0.7 }); game.addChild(leftBtn); game.addChild(rightBtn); // Add containsPoint for nav buttons leftBtn.containsPoint = function (point) { var localX = point.x - leftBtn.x; var localY = point.y - leftBtn.y; var w = leftBtn.width, h = leftBtn.height; return localX >= -w / 2 && localX <= w / 2 && localY >= -h / 2 && localY <= h / 2; }; rightBtn.containsPoint = function (point) { var localX = point.x - rightBtn.x; var localY = point.y - rightBtn.y; var w = rightBtn.width, h = rightBtn.height; return localX >= -w / 2 && localX <= w / 2 && localY >= -h / 2 && localY <= h / 2; }; // Nav button text var leftTxt = new Text2('<', { size: 90, fill: "#fff" }); leftTxt.anchor.set(0.5, 0.5); leftTxt.x = leftBtn.x; leftTxt.y = leftBtn.y; game.addChild(leftTxt); var rightTxt = new Text2('>', { size: 90, fill: "#fff" }); rightTxt.anchor.set(0.5, 0.5); rightTxt.x = rightBtn.x; rightTxt.y = rightBtn.y; game.addChild(rightTxt); // --- Screen show/hide logic --- function updateScreenVisibility() { // 0: field, 1: boxcook, 2: order var showField = game.currentScreen === 0; var showBoxCook = game.currentScreen === 1; var showOrder = game.currentScreen === 2; // Fields for (var i = 0; i < game.fields.length; i++) { game.fields[i].visible = showField; } unlock4BtnContainer.visible = showField; unlock4Txt.visible = showField; // Box & Cook game.cornBox.visible = showBoxCook; game.cookArea.visible = showBoxCook; if (game.stove) game.stove.visible = showBoxCook; // Order // game.orderArea.visible = showOrder; // Removed order area if (game.counterAsset) game.counterAsset.visible = showOrder; // Customers visible only on customer screen if (game.customers) { for (var i = 0; i < game.customers.length; i++) { game.customers[i].visible = showOrder; } } // Nav buttons always visible leftBtn.visible = true; rightBtn.visible = true; leftTxt.visible = true; rightTxt.visible = true; // Show seeds count only on field screen if (typeof seedsTxt !== "undefined") { seedsTxt.visible = showField; if (showField && typeof game.updateSeeds === "function") { game.updateSeeds(); } } } updateScreenVisibility(); // --- Touch handling --- game.down = function (x, y, obj) { // Navigation buttons if (leftBtn.containsPoint({ x: x, y: y })) { game.currentScreen = (game.currentScreen + 2) % 3; updateScreenVisibility(); return; } if (rightBtn.containsPoint({ x: x, y: y })) { game.currentScreen = (game.currentScreen + 1) % 3; updateScreenVisibility(); return; } // Per-screen input if (game.currentScreen === 0) { // Field screen if (unlock4BtnContainer.visible && unlock4BtnContainer.containsPoint({ x: x, y: y })) { if (game.seeds <= 0) { LK.effects.flashObject(unlock4Btn, 0xff0000, 400); return; } if (game.coins >= 20 && game.unlockedFields === 4 && game.unlockedFields < game.maxFields) { game.coins -= 20; // Unlock 4 more fields, but do not exceed maxFields var toUnlock = Math.min(4, game.maxFields - game.unlockedFields); game.unlockedFields += toUnlock; game.updateCoins(); updateFieldLocks(); layoutFields(); updateUnlockBtn(); } else { LK.effects.flashObject(unlock4Btn, 0xff0000, 400); } return; } for (var i = 0; i < game.fields.length; i++) { var f = game.fields[i]; if (f.visible && f.containsPoint({ x: x, y: y })) { f.down(x - f.x, y - f.y, obj); return; } } } else if (game.currentScreen === 1) { // Box & Cook screen if (game.cornBox.visible && game.cornBox.containsPoint({ x: x, y: y })) { game.cornBox.down(x - game.cornBox.x, y - game.cornBox.y, obj); return; } // Drop corn into pot if possible // Check if tap is inside pot var localPotX = x - game.stove.x; var localPotY = y - game.stove.y; var potW = potAsset.width, potH = potAsset.height; if (localPotX >= -potW / 2 && localPotX <= potW / 2 && localPotY >= -potH / 2 && localPotY <= potH / 2) { // Try to add corn from box to pot (if any) if (game.cornBox.cornCount > 0) { // Remove from box if (game.cornBox.removeCorn(1)) { // Add a corn asset to pot var cornInPot = LK.getAsset('corn', { anchorX: 0.5, anchorY: 0.5, width: 80, height: 80, x: 0, y: 0 }); game.stove.addChild(cornInPot); // Start cook timer (30s) var cookStart = Date.now(); game.potCorns.push({ asset: cornInPot, startTime: cookStart, done: false }); // Flash pot LK.effects.flashObject(potAsset, 0xffff00, 200); } } return; } // Collect cooked corn from pot (tap on cooked corn) for (var i = 0; i < game.potCorns.length; i++) { var c = game.potCorns[i]; if (c.done) { // Check if tap is on this corn var cx = c.asset.x, cy = c.asset.y; var tapDist = Math.sqrt(Math.pow(localPotX - cx, 2) + Math.pow(localPotY - cy, 2)); if (tapDist < 60) { // Remove from pot, add to cookArea c.asset.destroy(); game.potCorns.splice(i, 1); game.cookArea.addCookedCorn(1); LK.effects.flashObject(potAsset, 0x05c49c, 200); return; } } } if (game.cookArea.visible && game.cookArea.containsPoint({ x: x, y: y })) { game.cookArea.down(x - game.cookArea.x, y - game.cookArea.y, obj); return; } } else if (game.currentScreen === 2) { // Order screen // Order area removed } }; // --- Game update --- game.update = function () { // Update all fields for grow/ready text for (var i = 0; i < game.fields.length; i++) { if (game.fields[i].visible) { if (typeof game.fields[i].update === "function") { game.fields[i].update(); } } } // No automatic planting: Corn only grows when planted by the player // --- Pot cooking logic --- if (game.stove && game.potCorns) { var minTimeLeft = null; for (var i = 0; i < game.potCorns.length; i++) { var c = game.potCorns[i]; if (!c.done) { var elapsed = Date.now() - c.startTime; var left = 30000 - elapsed; if (left <= 0) { // Done cooking c.done = true; c.asset.alpha = 1; c.asset.tint = 0x05c49c; // cooked color LK.effects.flashObject(c.asset, 0x05c49c, 300); left = 0; } else { c.asset.alpha = 0.7; c.asset.tint = 0xb8b031; // raw color } if (minTimeLeft === null || left < minTimeLeft) minTimeLeft = left; } } // Show timer for the first uncooked corn if (minTimeLeft !== null && minTimeLeft > 0) { var sec = Math.ceil(minTimeLeft / 1000); game.potTimerTxt.setText(sec + " sn"); game.potTimerTxt.visible = true; } else { game.potTimerTxt.setText(''); game.potTimerTxt.visible = false; } } }; // --- Reset function for new game --- game.resetGame = function () { game.coins = 20; game.unlockedFields = 4; game.seeds = 4; if (typeof game.updateSeeds === "function") game.updateSeeds(); game.updateCoins(); updateFieldLocks(); layoutFields(); updateUnlockBtn(); for (var i = 0; i < game.fields.length; i++) { game.fields[i].reset(); } game.cornBox.reset(); game.cookArea.reset(); // Reset stove/pot if (game.potCorns) { for (var i = 0; i < game.potCorns.length; i++) { if (game.potCorns[i].asset) game.potCorns[i].asset.destroy(); } game.potCorns = []; } if (game.potTimerTxt) game.potTimerTxt.setText(''); // game.orderArea.reset(); // game.orderArea.newOrder(); // Reset to first screen and update visibility game.currentScreen = 0; updateScreenVisibility(); }; // --- Asset definitions (for static analysis) --- // These are not real code, but LK will auto-create these assets as used above: // field: green box, corn: yellow ellipse, lock: gray lock, box: brown box, cook: pot, cooked: orange ellipse, order: tray, ketchup/mayonnaise/cheese: colored circles, deliver: blue button, unlock: green button // --- End of code ---
===================================================================
--- original.js
+++ change.js
@@ -863,33 +863,33 @@
game.stove = new Container();
game.stove.x = 2048 / 2;
game.stove.y = 1200;
game.addChild(game.stove);
-// Stove asset (rectangle)
+// Stove asset (rectangle) - increased size
var stoveAsset = LK.getAsset('box', {
anchorX: 0.5,
anchorY: 0.5,
- width: 420,
- height: 80,
+ width: 700,
+ height: 160,
y: 120
});
game.stove.addChild(stoveAsset);
-// Pot asset (ellipse, centered on stove)
+// Pot asset (ellipse, centered on stove) - increased size
var potAsset = LK.getAsset('cook', {
anchorX: 0.5,
anchorY: 0.5,
- width: 220,
- height: 180,
+ width: 400,
+ height: 320,
y: 0
});
game.stove.addChild(potAsset);
-// Pot "lid" (for visual effect)
+// Pot "lid" (for visual effect) - increased size
var potLid = LK.getAsset('cooked', {
anchorX: 0.5,
anchorY: 0.5,
- width: 180,
- height: 40,
- y: -70,
+ width: 320,
+ height: 70,
+ y: -120,
alpha: 0.7
});
game.stove.addChild(potLid);
// Corns in pot (array of {asset, startTime})
Mısır. In-Game asset. 2d. High contrast. No shadows
Arkaplanı sil
Arkaplanı sil
Arkaplanı olmasın.
Arkaplanı sil
Tahta arkaplan. In-Game asset. 2d. High contrast. No shadows
Arkaplanı sil
Cadde arka planı. In-Game asset. 2d. High contrast. No shadows
Konuşma balonu. In-Game asset. 2d. High contrast. No shadows
Ketçap kutusu. In-Game asset. 2d. High contrast. No shadows
Mayonez kutusu. In-Game asset. 2d. High contrast. No shadows
Dökülmüş ketçap. In-Game asset. 2d. High contrast. No shadows
Dökülmüş mayonez. In-Game asset. 2d. High contrast. No shadows
Delete hand
Türkiye bayrağı. In-Game asset. 2d. High contrast. No shadows
İngiliz bayrağı. In-Game asset. 2d. High contrast. No shadows
Fransa bayrağı. In-Game asset. 2d. High contrast. No shadows