User prompt
Gelincigin hareketlerini gif olarak yap
User prompt
Çiftçiye yürüme efekti ekle
User prompt
Tıkladığım yere Gelincik koşma efekti ile gitsin.
User prompt
Gelincik koşarken koşar gibi hareket etsin
User prompt
Skorda her yumurta için 10 puan kullan
User prompt
Skor olarak 0/8 kullanma
User prompt
Farmer stop
User prompt
Farmer stop
User prompt
Yumartaların hepsini topladiktan sonra oyun bitmesin ve yumurtalar yenilenmiş oyun devam etsin.
User prompt
Yumurtaların hepsini topladıktan sonra oyun devam etsin.
User prompt
The game will not end when you collect all the eggs and the chickens will start laying eggs again.
User prompt
After taked all egss dont finish
User prompt
Save Best score ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
When i taked all egss dont finish the game
User prompt
when i taked all eggs dont finish the game
User prompt
Please fix the bug: 'Uncaught TypeError: storage.showTextInput is not a function' in or related to this line: 'storage.showTextInput({' Line Number: 194
User prompt
Please fix the bug: 'Uncaught TypeError: LK.showTextInput is not a function' in or related to this line: 'LK.showTextInput({' Line Number: 194
User prompt
enter a nick name and playing game
User prompt
Before playing game, player enter nick name.
User prompt
Require name entry before playing game
User prompt
before play game add user name
User prompt
After you get all the eggs, let the eggs come again
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Chicken = Container.expand(function () { var self = Container.call(this); var chickenGraphics = self.attachAsset('chicken', { anchorX: 0.5, anchorY: 0.5 }); self.hasEgg = true; self.egg = null; // Add method to show egg regeneration animation self.regenerateEgg = function () { if (!self.hasEgg && self.egg) { self.hasEgg = true; // Visual feedback when egg regenerates var originalY = self.y; tween(self, { y: self.y - 20 }, { duration: 300, complete: function complete() { tween(self, { y: originalY }, { duration: 300 }); } }); } }; return self; }); var Egg = Container.expand(function () { var self = Container.call(this); var eggGraphics = self.attachAsset('egg', { anchorX: 0.5, anchorY: 0.5 }); self.isCollected = false; self.isDelivered = false; self.underChicken = null; return self; }); var Farmer = Container.expand(function () { var self = Container.call(this); var farmerGraphics = self.attachAsset('farmer', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.direction = 1; self.patrolPoints = []; self.currentPoint = 0; self.lastX = 0; self.lastY = 0; self.update = function () { // Store last position self.lastX = self.x; self.lastY = self.y; // Check if weasel has an egg and if farmer should chase if (weasel && weasel.hasEgg) { // Chase the weasel at a faster speed var chaseSpeed = self.speed * 1.5; var dx = weasel.x - self.x; var dy = weasel.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > chaseSpeed) { self.x += dx / distance * chaseSpeed; self.y += dy / distance * chaseSpeed; } } else if (self.patrolPoints.length > 0) { var targetPoint = self.patrolPoints[self.currentPoint]; // Move toward target point var dx = targetPoint.x - self.x; var dy = targetPoint.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > self.speed) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } else { // Point reached, move to next point self.currentPoint = (self.currentPoint + 1) % self.patrolPoints.length; } // Randomly change direction occasionally if (Math.random() < 0.005) { self.currentPoint = Math.floor(Math.random() * self.patrolPoints.length); } } }; return self; }); var NicknameScreen = Container.expand(function () { var self = Container.call(this); // Create semi-transparent background var bg = self.attachAsset('coop', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, alpha: 0.8 }); bg.width = 2048; bg.height = 2732; // Title text var titleText = new Text2('ENTER YOUR NICKNAME', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 2732 / 3; self.addChild(titleText); // Nickname display text self.nicknameText = new Text2('', { size: 70, fill: 0xFFFFFF }); self.nicknameText.anchor.set(0.5, 0.5); self.nicknameText.x = 2048 / 2; self.nicknameText.y = 2732 / 2; self.addChild(self.nicknameText); // Placeholder text self.placeholderText = new Text2('Touch here to enter your name', { size: 50, fill: 0xAAAAAA }); self.placeholderText.anchor.set(0.5, 0.5); self.placeholderText.x = 2048 / 2; self.placeholderText.y = 2732 / 2; self.addChild(self.placeholderText); // Start button self.startButton = new Container(); var startButtonBg = self.startButton.attachAsset('coop', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0, width: 400, height: 100 }); startButtonBg.tint = 0x43A047; var startButtonText = new Text2('START GAME', { size: 50, fill: 0xFFFFFF }); startButtonText.anchor.set(0.5, 0.5); self.startButton.addChild(startButtonText); self.startButton.x = 2048 / 2; self.startButton.y = 2732 / 1.5; self.startButton.alpha = 0.5; // Start disabled self.addChild(self.startButton); // Input field behavior self.isEditing = false; self.nickname = ''; self.down = function (x, y, obj) { // Check if clicking on text field area var textFieldBounds = { x: self.nicknameText.x - 300, y: self.nicknameText.y - 50, width: 600, height: 100 }; if (x >= textFieldBounds.x && x <= textFieldBounds.x + textFieldBounds.width && y >= textFieldBounds.y && y <= textFieldBounds.y + textFieldBounds.height) { self.activateInput(); } // Check if clicking on start button and name is entered if (self.nickname.length > 0 && self.startButton.x - 200 <= x && x <= self.startButton.x + 200 && self.startButton.y - 50 <= y && y <= self.startButton.y + 50) { self.startGame(); } }; self.activateInput = function () { self.isEditing = true; LK.textInput({ title: "Enter Your Nickname", text: self.nickname, onAccept: function onAccept(text) { self.updateNickname(text); self.isEditing = false; }, onCancel: function onCancel() { self.isEditing = false; } }); }; self.updateNickname = function (text) { self.nickname = text.trim(); if (self.nickname.length > 0) { self.nicknameText.setText(self.nickname); self.placeholderText.visible = false; self.startButton.alpha = 1.0; // Enable button // Save nickname to storage storage.playerNickname = self.nickname; } else { self.nicknameText.setText(''); self.placeholderText.visible = true; self.startButton.alpha = 0.5; // Disable button } }; self.startGame = function () { if (self.nickname.length > 0) { // Remove nickname screen if (self.parent) { self.parent.removeChild(self); } // Start the actual game gameStarted = true; initializeGameElements(); } }; // Check if we have a saved nickname if (storage.playerNickname) { self.updateNickname(storage.playerNickname); } return self; }); // Set farm background color var Weasel = Container.expand(function () { var self = Container.call(this); var weaselGraphics = self.attachAsset('weasel', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; // Increased from 5 to 10 for faster movement self.hasEgg = false; self.carryingEgg = null; self.targetX = undefined; self.targetY = undefined; self.lastX = 0; self.lastY = 0; self.update = function () { self.lastX = self.x; self.lastY = self.y; // Follow mouse click target if it exists if (self.targetX !== undefined && self.targetY !== undefined) { var dx = self.targetX - self.x; var dy = self.targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); // If we're close enough to the target, stop moving if (distance < self.speed) { self.x = self.targetX; self.y = self.targetY; // Clear the target once reached self.targetX = undefined; self.targetY = undefined; } else { // Move toward the target self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } // Update egg position if carrying one if (self.hasEgg && self.carryingEgg) { self.carryingEgg.x = self.x; self.carryingEgg.y = self.y - 30; } } // Alert nearby chickens and farmer when near eggs if (eggs && chickens) { for (var i = 0; i < eggs.length; i++) { var egg = eggs[i]; if (!egg.isCollected && egg.underChicken) { // Calculate distance to egg var dx = self.x - egg.x; var dy = self.y - egg.y; var distance = Math.sqrt(dx * dx + dy * dy); // If close to an egg, make the chicken flutter if (distance < 150 && egg.underChicken) { // Make chicken flutter by adding a slight movement var chicken = egg.underChicken; if (LK.ticks % 10 === 0) { chicken.x += (Math.random() - 0.5) * 5; chicken.y += (Math.random() - 0.5) * 5; } } } } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Set farm background color game.setBackgroundColor(0x7CFC00); // Game variables var gameWidth = 2048; var gameHeight = 2732; var score = 0; var bestScore = storage.bestScore || 0; var weasel; var farmer; var chickens = []; var eggs = []; var coop; var exit; var dragNode = null; var isGameOver = false; var lastIntersectingFarmer = false; var totalEggs = 8; var eggsDelivered = 0; var lastEggCollectionTime = storage.lastEggCollectionTime || 0; var eggRegenerationTime = 2 * 60 * 1000; // 2 minutes in milliseconds var collectedEggIds = storage.collectedEggIds || []; var gameStarted = false; var nicknameScreen; // Function to initialize game elements function initializeGameElements() { // Create chicken coop area coop = game.addChild(LK.getAsset('coop', { anchorX: 0.5, anchorY: 0.5, x: gameWidth / 2, y: gameHeight / 2, alpha: 0.3 })); // Create exit at bottom of screen exit = game.addChild(LK.getAsset('exit', { anchorX: 0.5, anchorY: 0.5, x: gameWidth / 2, y: gameHeight - 100 })); // Create score text var scoreTxt = new Text2('Eggs: 0/' + totalEggs, { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create best score text var bestScoreTxt = new Text2('Best: ' + bestScore, { size: 60, fill: 0xFFD700 }); bestScoreTxt.anchor.set(0.5, 0); bestScoreTxt.y = 100; LK.gui.top.addChild(bestScoreTxt); // Add nickname display var nicknameTxt = new Text2('Player: ' + (storage.playerNickname || ''), { size: 50, fill: 0xFFFFFF }); nicknameTxt.anchor.set(0.5, 0); nicknameTxt.y = 160; LK.gui.top.addChild(nicknameTxt); // Create the player character (weasel) weasel = new Weasel(); weasel.x = gameWidth / 2; weasel.y = gameHeight - 200; weasel.lastX = weasel.x; weasel.lastY = weasel.y; game.addChild(weasel); // Create the farmer farmer = new Farmer(); farmer.x = gameWidth / 4; farmer.y = gameHeight / 3; farmer.lastX = farmer.x; farmer.lastY = farmer.y; game.addChild(farmer); // Set up farmer patrol points farmer.patrolPoints = [{ x: gameWidth / 4, y: gameHeight / 3 }, { x: 3 * gameWidth / 4, y: gameHeight / 3 }, { x: 3 * gameWidth / 4, y: 2 * gameHeight / 3 }, { x: gameWidth / 4, y: 2 * gameHeight / 3 }]; // Create chickens and eggs for (var i = 0; i < totalEggs; i++) { var chicken = new Chicken(); // Position chickens in a grid-like pattern var row = Math.floor(i / 4); var col = i % 4; chicken.x = (col + 1) * (gameWidth / 5); chicken.y = (row + 1) * (gameHeight / 4); game.addChild(chicken); chickens.push(chicken); // Create egg under chicken var egg = new Egg(); egg.x = chicken.x; egg.y = chicken.y; egg.underChicken = chicken; chicken.egg = egg; // Add egg to the game so it's visible game.addChild(egg); eggs.push(egg); } // Start background music LK.playMusic('Weale'); } // Show nickname screen first nicknameScreen = new NicknameScreen(); game.addChild(nicknameScreen); // Drag handling functions function handleMove(x, y, obj) { if (dragNode && !isGameOver) { dragNode.x = x; dragNode.y = y; // Check if weasel is carrying an egg if (weasel.hasEgg && weasel.carryingEgg) { weasel.carryingEgg.x = weasel.x; weasel.carryingEgg.y = weasel.y - 30; } } } // We don't need move handler since we're following clicks game.move = function (x, y, obj) {}; game.down = function (x, y, obj) { if (gameStarted && !isGameOver) { // Instead of setting dragNode, set a target position for the weasel to follow weasel.targetX = x; weasel.targetY = y; } }; game.up = function (x, y, obj) { dragNode = null; }; // Main game update logic game.update = function () { // Skip updates if game is not started yet if (!gameStarted) return; // Skip updates if game is over if (isGameOver) return; // Update farmer and weasel positions farmer.update(); weasel.update(); // Check for farmer collision var intersectingFarmer = weasel.intersects(farmer); if (!lastIntersectingFarmer && intersectingFarmer) { // Weasel got caught by farmer isGameOver = true; LK.getSound('caught').play(); LK.effects.flashScreen(0xFF0000, 1000); LK.showGameOver(); } lastIntersectingFarmer = intersectingFarmer; // Check for egg pickup for (var i = 0; i < eggs.length; i++) { var egg = eggs[i]; if (!egg.isCollected && egg.underChicken && weasel.intersects(egg.underChicken)) { // Weasel is near a chicken with an egg if (!weasel.hasEgg) { // Pick up the egg egg.isCollected = true; egg.underChicken.hasEgg = false; weasel.hasEgg = true; weasel.carryingEgg = egg; game.addChild(egg); // Move egg to top layer LK.getSound('pickup').play(); // Track collected egg with its index if (!collectedEggIds.includes(i)) { collectedEggIds.push(i); } // Store current time as last collection time lastEggCollectionTime = Date.now(); // Save to storage storage.lastEggCollectionTime = lastEggCollectionTime; storage.collectedEggIds = collectedEggIds; // When egg is taken, immediately alert the farmer by increasing his speed temporarily var oldSpeed = farmer.speed; farmer.speed = farmer.speed * 2; LK.setTimeout(function () { farmer.speed = oldSpeed; }, 3000); } } } // Check for egg delivery if (weasel.hasEgg && weasel.carryingEgg && weasel.intersects(exit)) { // Deliver the egg weasel.carryingEgg.isDelivered = true; weasel.hasEgg = false; // Remove the delivered egg if (weasel.carryingEgg.parent) { weasel.carryingEgg.parent.removeChild(weasel.carryingEgg); } eggsDelivered++; score += 10; LK.setScore(score); scoreTxt.setText("Eggs: " + eggsDelivered + "/" + totalEggs); // Check if we've beaten the best score if (score > bestScore) { bestScore = score; storage.bestScore = bestScore; bestScoreTxt.setText('Best: ' + bestScore); } LK.getSound('success').play(); // Update scores when delivering all eggs, but don't end the game if (eggsDelivered >= totalEggs) { // Update best score if current score is higher if (score > bestScore) { bestScore = score; storage.bestScore = bestScore; bestScoreTxt.setText('Best: ' + bestScore); } LK.effects.flashScreen(0x00FF00, 1000); // Reset eggs delivered counter so player can continue collecting eggsDelivered = 0; scoreTxt.setText("Eggs: " + eggsDelivered + "/" + totalEggs); } weasel.carryingEgg = null; } // Check if eggs should regenerate (after eggRegenerationTime has passed or all eggs collected) var currentTime = Date.now(); var allEggsCollected = true; // Check if all eggs are collected for (var i = 0; i < eggs.length; i++) { if (!eggs[i].isCollected && !eggs[i].isDelivered) { allEggsCollected = false; break; } } // Regenerate eggs if time passed or all eggs collected if (lastEggCollectionTime > 0 && currentTime - lastEggCollectionTime >= eggRegenerationTime || allEggsCollected) { // Regenerate all collected eggs for (var i = 0; i < collectedEggIds.length; i++) { var eggId = collectedEggIds[i]; if (eggId < eggs.length && eggs[eggId]) { var egg = eggs[eggId]; var chicken = egg.underChicken; if (chicken) { // Reset egg and chicken states egg.isCollected = false; egg.isDelivered = false; chicken.hasEgg = true; // Call chicken regenerate method for animation chicken.regenerateEgg(); // Visually emphasize egg regeneration with a tween effect egg.alpha = 0; game.addChild(egg); tween(egg, { alpha: 1 }, { duration: 1000 }); } } } // Reset collection tracking collectedEggIds = []; lastEggCollectionTime = 0; storage.collectedEggIds = collectedEggIds; storage.lastEggCollectionTime = lastEggCollectionTime; } // Make chickens occasionally look around (random movement) if (LK.ticks % 60 === 0) { for (var j = 0; j < chickens.length; j++) { if (Math.random() < 0.3) { var chicken = chickens[j]; var randomOffsetX = (Math.random() - 0.5) * 20; var randomOffsetY = (Math.random() - 0.5) * 20; tween(chicken, { x: chicken.x + randomOffsetX, y: chicken.y + randomOffsetY }, { duration: 500 }); } } } };
===================================================================
--- original.js
+++ change.js
@@ -176,9 +176,9 @@
}
};
self.activateInput = function () {
self.isEditing = true;
- storage.showTextInput({
+ LK.textInput({
title: "Enter Your Nickname",
text: self.nickname,
onAccept: function onAccept(text) {
self.updateNickname(text);
its a chicken. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
egg. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
angry farmer with all body. In-Game asset. 2d. High contrast. No shadows
without egg
hole. In-Game asset. 2d. High contrast. No shadows
Çit. In-Game asset. 2d. High contrast. No shadows