User prompt
Let the selling price of the fish be 110 and the selling price of strawberries is 40 but there is a 25% chance that it will be 50
User prompt
add fish to the game
User prompt
Change appearance of "fish"
User prompt
Add fish to assets and buy these fish from the fish shop
User prompt
Add "fish" to assets
User prompt
Add fish asset
User prompt
Add a new button next to gear shop "fish shop" and when we click on it, a screen will appear in front of us and we can buy fish from there. A normal fish is 100$ and the sales price is 120 but the fish grow very slowly Fish grow in 55 seconds
User prompt
Let's not plant fruits in water
User prompt
add water to assets
User prompt
add water to assets and put water in the bottom 16 soil
User prompt
Make the 16 soils at the bottom of the screen water and add fish to them instead of fruit.
User prompt
put another 32 lands at the bottom of the screen
User prompt
put the lands in the middle of the screen
User prompt
Let's start the game with 32 lands
User prompt
clear soil addition counter
User prompt
clear soil addition counter Let's start with 32 soil instead of weed
User prompt
add soil addition counter in the bottom left corner of the screen and add 1 soil every 1 minute
User prompt
If we plant bananas, do not add soil and if we plant dragon fruit, do not add soil
User prompt
adding soil when we plant bananas and adding soil when we plant dragon fruit
User prompt
When we plant dragon fruit, put all the lands that come in the middle of the screen
User prompt
When you plant dragon fruit, the soil that comes out of the screen is fixed.
User prompt
If we plant dragon fruit, move the lands to the left of the screen and add 12 more lands
User prompt
delete land purchase button Instead, let's start the game with 6 lands and if we plant 1 banana, the lands will be 12 lands. If you plant a dragon fruit, the soil should be 18 soils.
User prompt
If you take the 15th land, move all the lands to the left and put 15 more lands to the right
User prompt
If there is a total of 15 soils, take 15 soils to the left and if we take soil from here, add 3 soils to the right.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var AdvancedSprinkler = Container.expand(function (x, y) { var self = Container.call(this); self.x = x; self.y = y; self.type = 'advanced'; var sprinklerGraphics = self.attachAsset('sprinkler', { anchorX: 0.5, anchorY: 0.5, tint: 0x00ff00 }); // Add enhanced pulsing animation for advanced sprinkler function animateAdvancedSprinkler() { tween(sprinklerGraphics, { scaleX: 1.4, scaleY: 1.4, alpha: 0.6 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { tween(sprinklerGraphics, { scaleX: 1.0, scaleY: 1.0, alpha: 1.0 }, { duration: 800, easing: tween.easeInOut, onFinish: animateAdvancedSprinkler }); } }); } animateAdvancedSprinkler(); return self; }); var Button = Container.expand(function (text, onClick) { var self = Container.call(this); var buttonBg = self.attachAsset('button', { anchorX: 0.5, anchorY: 0.5 }); var buttonText = new Text2(text, { size: 30, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.down = function () { if (onClick) onClick(); }; return self; }); var GearShop = Container.expand(function () { var self = Container.call(this); var background = self.attachAsset('seedShopBg', { anchorX: 0.5, anchorY: 0.5 }); var titleText = new Text2('GEAR SHOP', { size: 80, fill: 0x000000 }); titleText.anchor.set(0.5, 0.5); titleText.y = -600; self.addChild(titleText); // Sprinkler item var sprinklerButton = new Container(); sprinklerButton.x = 0; sprinklerButton.y = -200; var sprinklerIcon = LK.getAsset('sprinkler', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); sprinklerIcon.x = -300; sprinklerButton.addChild(sprinklerIcon); var nameText = new Text2('Sprinkler', { size: 70, fill: 0x000000 }); nameText.anchor.set(0, 0.5); nameText.x = -200; sprinklerButton.addChild(nameText); var priceText = new Text2('$35', { size: 70, fill: 0xFFFF00 }); priceText.anchor.set(1, 0.5); priceText.x = 300; sprinklerButton.addChild(priceText); var descText = new Text2('2x growth speed in 3x3 area', { size: 40, fill: 0x666666 }); descText.anchor.set(0.5, 0); descText.y = 50; sprinklerButton.addChild(descText); sprinklerButton.down = function () { if (money >= 35) { selectedSprinkler = 'regular'; self.visible = false; LK.getSound('Buy').play(); } }; self.addChild(sprinklerButton); // Advanced Sprinkler item var advancedSprinklerButton = new Container(); advancedSprinklerButton.x = 0; advancedSprinklerButton.y = 50; var advancedSprinklerIcon = LK.getAsset('sprinkler', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5, tint: 0x00ff00 }); advancedSprinklerIcon.x = -300; advancedSprinklerButton.addChild(advancedSprinklerIcon); var advancedNameText = new Text2('Advanced Sprinkler', { size: 70, fill: 0x000000 }); advancedNameText.anchor.set(0, 0.5); advancedNameText.x = -200; advancedSprinklerButton.addChild(advancedNameText); var advancedPriceText = new Text2('$150', { size: 70, fill: 0xFFFF00 }); advancedPriceText.anchor.set(1, 0.5); advancedPriceText.x = 300; advancedSprinklerButton.addChild(advancedPriceText); var advancedDescText = new Text2('4x growth speed in 5x5 area', { size: 40, fill: 0x666666 }); advancedDescText.anchor.set(0.5, 0); advancedDescText.y = 50; advancedSprinklerButton.addChild(advancedDescText); advancedSprinklerButton.down = function () { if (money >= 150) { selectedSprinkler = 'advanced'; self.visible = false; LK.getSound('Buy').play(); } }; self.addChild(advancedSprinklerButton); var closeButton = new Button('CLOSE', function () { self.visible = false; }); closeButton.y = 500; self.addChild(closeButton); return self; }); var PlantSpot = Container.expand(function (x, y) { var self = Container.call(this); self.x = x; self.y = y; self.planted = false; self.plantType = null; self.plantTime = 0; self.grown = false; self.regrowTime = 0; var dirtGraphics = self.attachAsset('dirt', { anchorX: 0.5, anchorY: 0.5 }); // Move dirt graphics to the back layer self.setChildIndex(dirtGraphics, 0); var plantGraphics = null; self.plantSeed = function (seedType) { if (self.planted) return false; self.planted = true; self.plantType = seedType; self.plantTime = LK.ticks; self.grown = false; self.isColorful = false; // 5% chance for colorful fruit (3x price) if (Math.random() < 0.05) { self.isColorful = true; self.plantType = 'colorful_' + seedType; } var finalScale = 1.0; plantGraphics = self.attachAsset(self.plantType, { anchorX: 0.5, anchorY: 0.5, alpha: 0.5, scaleX: 0.3, scaleY: 0.3 }); // Ensure plant graphics appear above soil, especially for giant fruits self.setChildIndex(plantGraphics, self.children.length - 1); // Animate plant growth over 5 seconds tween(plantGraphics, { scaleX: finalScale, scaleY: finalScale }, { duration: 5000, easing: tween.easeOut }); // Add rainbow tint animation for colorful fruits if (self.isColorful) { var colorfulAnimation = function colorfulAnimation() { var colors = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff, 0x00ffff]; var currentColor = 0; var _animateColor = function animateColor() { if (plantGraphics) { tween(plantGraphics, { tint: colors[currentColor] }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { currentColor = (currentColor + 1) % colors.length; _animateColor(); } }); } }; _animateColor(); }; // Start colorful animation after growth completes LK.setTimeout(colorfulAnimation, 5000); } LK.getSound('plant').play(); return true; }; self.harvest = function () { if (!self.grown) return null; var harvestedType = self.plantType; var isColorfulHarvest = self.isColorful; // Check if this is a regrowing fruit (banana, dragon fruit, or coconut) var isBanana = harvestedType === 'banana' || harvestedType === 'colorful_banana'; var isDragonFruit = harvestedType === 'dragonfruit' || harvestedType === 'colorful_dragonfruit'; var isCoconut = harvestedType === 'coconut' || harvestedType === 'colorful_coconut'; if (isBanana || isDragonFruit || isCoconut) { // Hide the plant graphics with animation for regrowing fruits if (plantGraphics) { tween(plantGraphics, { alpha: 0.3, scaleX: 0.5, scaleY: 0.5 }, { duration: 500, easing: tween.easeIn }); } self.grown = false; self.regrowTime = LK.ticks; } else { // For carrots and strawberries, reset the plant completely if (plantGraphics) { plantGraphics.destroy(); plantGraphics = null; } self.planted = false; self.plantType = null; self.plantTime = 0; self.grown = false; self.isColorful = false; self.regrowTime = 0; } LK.getSound('harvest').play(); return { type: harvestedType, colorful: isColorfulHarvest }; }; self.update = function () { if (self.planted && !self.grown) { // Check if this spot is affected by a sprinkler var speedMultiplier = 1; for (var i = 0; i < sprinklers.length; i++) { var sprinkler = sprinklers[i]; var distanceX = Math.abs(self.x - sprinkler.x); var distanceY = Math.abs(self.y - sprinkler.y); if (sprinkler.type === 'advanced') { // Advanced sprinkler: 4x speed in 5x5 area (1100px = 5 * 220px spacing) if (distanceX <= 1100 && distanceY <= 1100) { speedMultiplier = 4; break; } } else { // Regular sprinkler: 2x speed in 3x3 area (660px = 3 * 220px spacing) if (distanceX <= 660 && distanceY <= 660) { speedMultiplier = 2; break; } } } // Check if it's time to regrow after harvest (for bananas, dragon fruit, and coconut) if (self.regrowTime > 0) { var isBanana = self.plantType === 'banana' || self.plantType === 'colorful_banana'; var isDragonFruit = self.plantType === 'dragonfruit' || self.plantType === 'colorful_dragonfruit'; var isCoconut = self.plantType === 'coconut' || self.plantType === 'colorful_coconut'; var regrowReady = false; if (isBanana && LK.ticks - self.regrowTime > 1140 / speedMultiplier) { // 19 seconds at 60fps for banana regrow (halved with sprinkler) regrowReady = true; } else if ((isDragonFruit || isCoconut) && LK.ticks - self.regrowTime > 1320 / speedMultiplier) { // 22 seconds at 60fps for dragon fruit and coconut regrow (halved with sprinkler) regrowReady = true; } if (regrowReady) { self.grown = true; self.regrowTime = 0; if (plantGraphics) { var regrowScale = 1.0; tween(plantGraphics, { alpha: 1.0, scaleX: regrowScale, scaleY: regrowScale }, { duration: 1000, easing: tween.easeOut }); } } } else if (self.regrowTime === 0 && LK.ticks - self.plantTime > 300 / speedMultiplier) { // 5 seconds at 60fps for initial growth (halved with sprinkler) self.grown = true; if (plantGraphics) { plantGraphics.alpha = 1.0; } } } }; self.down = function () { if (self.grown) { var harvested = self.harvest(); if (harvested) { var harvestType = harvested.type; if (harvested.colorful) { // Store colorful fruits separately for 3x price var baseType = harvestType.replace('colorful_', ''); inventory['colorful_' + baseType] = (inventory['colorful_' + baseType] || 0) + 1; } else { inventory[harvestType] = (inventory[harvestType] || 0) + 1; } updateInventoryDisplay(); } } else if (!self.planted && selectedSprinkler) { // Place sprinkler var sprinklerCost = selectedSprinkler === 'advanced' ? 150 : 35; if (money >= sprinklerCost) { var sprinkler; if (selectedSprinkler === 'advanced') { sprinkler = new AdvancedSprinkler(self.x, self.y); } else { sprinkler = new Sprinkler(self.x, self.y); } sprinklers.push(sprinkler); game.addChild(sprinkler); money -= sprinklerCost; updateMoneyDisplay(); selectedSprinkler = false; gearShop.visible = false; } } else if (!self.planted && selectedSeed && money >= seedPrices[selectedSeed]) { if (self.plantSeed(selectedSeed)) { money -= seedPrices[selectedSeed]; updateMoneyDisplay(); selectedSeed = null; seedShop.visible = false; } } }; return self; }); var SeedShop = Container.expand(function () { var self = Container.call(this); var background = self.attachAsset('seedShopBg', { anchorX: 0.5, anchorY: 0.5 }); var titleText = new Text2('SEED SHOP', { size: 80, fill: 0x000000 }); titleText.anchor.set(0.5, 0.5); titleText.y = -600; self.addChild(titleText); var seedTypes = ['carrot', 'strawberry', 'banana', 'coconut', 'dragonfruit']; var seedNames = ['Carrot', 'Strawberry', 'Banana', 'Coconut', 'Dragon Fruit']; // Use uniform medium size for all seeds in shop var uniformScale = 0.5; // Medium size for all seeds for (var i = 0; i < seedTypes.length; i++) { var seedButton = new Container(); seedButton.x = 0; seedButton.y = -400 + i * 150; // Use uniform scale for all seed icons var seedIcon = LK.getAsset(seedTypes[i], { anchorX: 0.5, anchorY: 0.5, scaleX: uniformScale, scaleY: uniformScale }); seedIcon.x = -300; seedButton.addChild(seedIcon); var nameText = new Text2(seedNames[i], { size: 70, fill: 0x000000 }); nameText.anchor.set(0, 0.5); nameText.x = -250; seedButton.addChild(nameText); var priceText = new Text2('$' + seedPrices[seedTypes[i]], { size: 70, fill: 0xFFFF00 }); priceText.anchor.set(1, 0.5); priceText.x = 300; seedButton.addChild(priceText); seedButton.seedType = seedTypes[i]; seedButton.down = function () { if (money >= seedPrices[this.seedType]) { selectedSeed = this.seedType; self.visible = false; LK.getSound('Buy').play(); } }; self.addChild(seedButton); } var closeButton = new Button('CLOSE', function () { self.visible = false; }); closeButton.y = 500; self.addChild(closeButton); return self; }); var Sprinkler = Container.expand(function (x, y) { var self = Container.call(this); self.x = x; self.y = y; self.type = 'regular'; var sprinklerGraphics = self.attachAsset('sprinkler', { anchorX: 0.5, anchorY: 0.5 }); // Add pulsing animation to show it's active function animateSprinkler() { tween(sprinklerGraphics, { scaleX: 1.2, scaleY: 1.2, alpha: 0.7 }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { tween(sprinklerGraphics, { scaleX: 1.0, scaleY: 1.0, alpha: 1.0 }, { duration: 1000, easing: tween.easeInOut, onFinish: animateSprinkler }); } }); } animateSprinkler(); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x228B22 }); /**** * Game Code ****/ // Add grass background var grassBackground = game.attachAsset('grass_bg', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); var money = 0; var inventory = {}; var selectedSeed = null; var selectedSprinkler = false; var sprinklers = []; var soilPrice = 50; var seedPrices = { carrot: 10, strawberry: 50, banana: 80, coconut: 160, dragonfruit: 250 }; var sellPrices = { carrot: 15, strawberry: 35, banana: 60, coconut: 135, dragonfruit: 200, colorful_carrot: 45, colorful_strawberry: 105, colorful_banana: 180, colorful_coconut: 405, colorful_dragonfruit: 600 }; // Create plant spots in a grid var plantSpots = []; var gridCols = 3; var gridRows = 1; var startX = 800; var startY = 1366; var spacing = 220; for (var row = 0; row < gridRows; row++) { for (var col = 0; col < gridCols; col++) { var spot = new PlantSpot(startX + col * spacing, startY + row * spacing); plantSpots.push(spot); game.addChild(spot); } } // Plant initial carrots plantSpots[0].plantSeed('carrot'); plantSpots[1].plantSeed('carrot'); // UI Elements var moneyText = new Text2('Money: $0', { size: 50, fill: 0x000000 }); moneyText.anchor.set(0, 0); moneyText.x = 150; moneyText.y = 50; LK.gui.topLeft.addChild(moneyText); var inventoryText = new Text2('Inventory: Empty', { size: 50, fill: 0x000000 }); inventoryText.anchor.set(0, 1); inventoryText.x = 100; inventoryText.y = -100; LK.gui.bottomLeft.addChild(inventoryText); // Make inventory alive with pulsing animation function animateInventory() { tween(inventoryText, { scaleX: 1.1, scaleY: 1.1 }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { tween(inventoryText, { scaleX: 1.0, scaleY: 1.0 }, { duration: 1000, easing: tween.easeInOut, onFinish: animateInventory }); } }); } animateInventory(); var sellButton = new Button('SELL ALL', function () { var totalSale = 0; // Check if we get the 10% price boost (30% chance) var priceBoost = Math.random() < 0.3 ? 1.1 : 1.0; for (var itemType in inventory) { if (inventory[itemType] > 0) { var basePrice = sellPrices[itemType] * priceBoost; totalSale += inventory[itemType] * basePrice; inventory[itemType] = 0; } } if (totalSale > 0) { money += totalSale; updateMoneyDisplay(); updateInventoryDisplay(); LK.getSound('sell').play(); } }); sellButton.x = 600; sellButton.y = 100; sellButton.scaleX = 1.3; sellButton.scaleY = 1.3; LK.gui.topLeft.addChild(sellButton); var seedButton = new Button('SEEDS', function () { seedShop.visible = true; }); seedButton.x = 900; seedButton.y = 100; seedButton.scaleX = 1.3; seedButton.scaleY = 1.3; LK.gui.topLeft.addChild(seedButton); var freeCoinsButton = new Button('FREE COINS', function () { money += 500; updateMoneyDisplay(); }); freeCoinsButton.x = 1200; freeCoinsButton.y = 100; freeCoinsButton.scaleX = 1.3; freeCoinsButton.scaleY = 1.3; LK.gui.topLeft.addChild(freeCoinsButton); var gearButton = new Button('GEAR SHOP', function () { gearShop.visible = true; }); gearButton.x = 600; gearButton.y = 250; gearButton.scaleX = 1.3; gearButton.scaleY = 1.3; LK.gui.topLeft.addChild(gearButton); var newSoilButton = new Button('NEW SOIL $' + soilPrice, function () { if (money >= soilPrice) { // Purchase new soil money -= soilPrice; var newSpot; if (plantSpots.length >= 15) { // When we have 15 or more soils, add 3 soils to the right var rightStartX = startX + 15 * spacing; // Position to the right of the 15 left soils var rightStartY = 800; var rightIndex = plantSpots.length - 15; // Index within the right section var newSpotX = rightStartX + rightIndex % 3 * spacing; // 3 columns on the right var newSpotY = rightStartY + Math.floor(rightIndex / 3) * spacing; // Add rows going down newSpot = new PlantSpot(newSpotX, newSpotY); } else if (plantSpots.length >= 6) { // When we have 6-14 soils, arrange them vertically to the left (5 rows of 3) var leftStartY = 800; var newSpotX = startX + plantSpots.length % 3 * spacing; // Keep 3 columns var newSpotY = leftStartY + Math.floor(plantSpots.length / 3) * spacing; // Add rows going down newSpot = new PlantSpot(newSpotX, newSpotY); } else { // For first 6 soils, use original horizontal layout var newSpotX = startX + plantSpots.length * spacing; newSpot = new PlantSpot(newSpotX, startY); } plantSpots.push(newSpot); game.addChild(newSpot); // When we reach exactly 6 soils, rearrange all existing spots to vertical layout if (plantSpots.length === 6) { var topStartY = 800; for (var i = 0; i < plantSpots.length; i++) { var spot = plantSpots[i]; var newX = startX + i % 3 * spacing; var newY = topStartY + Math.floor(i / 3) * spacing; tween(spot, { x: newX, y: newY }, { duration: 1000, easing: tween.easeInOut }); } } // When we reach exactly 15 soils, rearrange all existing spots to final left layout if (plantSpots.length === 15) { var leftStartY = 800; for (var i = 0; i < plantSpots.length; i++) { var spot = plantSpots[i]; var newX = startX + i % 3 * spacing; var newY = leftStartY + Math.floor(i / 3) * spacing; tween(spot, { x: newX, y: newY }, { duration: 1000, easing: tween.easeInOut }); } } // Increase soil price by $25 soilPrice += 25; newSoilButton.children[1].setText('NEW SOIL $' + soilPrice); // Update button text updateMoneyDisplay(); LK.getSound('Buy').play(); } }); newSoilButton.x = 900; newSoilButton.y = 250; newSoilButton.scaleX = 1.3; newSoilButton.scaleY = 1.3; LK.gui.topLeft.addChild(newSoilButton); var seedShop = new SeedShop(); seedShop.x = 1024; seedShop.y = 1366; seedShop.visible = false; game.addChild(seedShop); var gearShop = new GearShop(); gearShop.x = 1024; gearShop.y = 1366; gearShop.visible = false; game.addChild(gearShop); // Button sliding variables var topButtons = [sellButton, seedButton, freeCoinsButton, gearButton, newSoilButton]; var buttonBasePositions = [600, 900, 1200, 600, 900]; var slideOffset = 0; var maxSlideOffset = 400; // Maximum pixels to slide // Sliding functions function slideButtonsLeft() { slideOffset = Math.min(slideOffset + 100, maxSlideOffset); updateButtonPositions(); } function slideButtonsRight() { slideOffset = Math.max(slideOffset - 100, -maxSlideOffset); updateButtonPositions(); } function updateButtonPositions() { for (var i = 0; i < topButtons.length; i++) { tween(topButtons[i], { x: buttonBasePositions[i] + slideOffset }, { duration: 300, easing: tween.easeOut }); } } function updateMoneyDisplay() { moneyText.setText('Money: $' + money); } function updateInventoryDisplay() { var inventoryStr = 'Inventory: '; var hasItems = false; for (var itemType in inventory) { if (inventory[itemType] > 0) { if (hasItems) inventoryStr += ', '; inventoryStr += itemType + ' x' + inventory[itemType]; hasItems = true; } } if (!hasItems) { inventoryStr += 'Empty'; } inventoryText.setText(inventoryStr); } // Play background music LK.playMusic('Music'); // Touch controls for sliding buttons var touchStartX = 0; var isDraggingButtons = false; game.down = function (x, y, obj) { // Check if touch is in the top button area if (y < 200) { touchStartX = x; isDraggingButtons = true; } }; game.up = function (x, y, obj) { if (isDraggingButtons) { var deltaX = x - touchStartX; if (Math.abs(deltaX) > 50) { // Minimum swipe distance if (deltaX > 0) { slideButtonsLeft(); } else { slideButtonsRight(); } } isDraggingButtons = false; } }; game.update = function () { // Plant spots update automatically through their update methods };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var AdvancedSprinkler = Container.expand(function (x, y) {
var self = Container.call(this);
self.x = x;
self.y = y;
self.type = 'advanced';
var sprinklerGraphics = self.attachAsset('sprinkler', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x00ff00
});
// Add enhanced pulsing animation for advanced sprinkler
function animateAdvancedSprinkler() {
tween(sprinklerGraphics, {
scaleX: 1.4,
scaleY: 1.4,
alpha: 0.6
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(sprinklerGraphics, {
scaleX: 1.0,
scaleY: 1.0,
alpha: 1.0
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: animateAdvancedSprinkler
});
}
});
}
animateAdvancedSprinkler();
return self;
});
var Button = Container.expand(function (text, onClick) {
var self = Container.call(this);
var buttonBg = self.attachAsset('button', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2(text, {
size: 30,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function () {
if (onClick) onClick();
};
return self;
});
var GearShop = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('seedShopBg', {
anchorX: 0.5,
anchorY: 0.5
});
var titleText = new Text2('GEAR SHOP', {
size: 80,
fill: 0x000000
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -600;
self.addChild(titleText);
// Sprinkler item
var sprinklerButton = new Container();
sprinklerButton.x = 0;
sprinklerButton.y = -200;
var sprinklerIcon = LK.getAsset('sprinkler', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
sprinklerIcon.x = -300;
sprinklerButton.addChild(sprinklerIcon);
var nameText = new Text2('Sprinkler', {
size: 70,
fill: 0x000000
});
nameText.anchor.set(0, 0.5);
nameText.x = -200;
sprinklerButton.addChild(nameText);
var priceText = new Text2('$35', {
size: 70,
fill: 0xFFFF00
});
priceText.anchor.set(1, 0.5);
priceText.x = 300;
sprinklerButton.addChild(priceText);
var descText = new Text2('2x growth speed in 3x3 area', {
size: 40,
fill: 0x666666
});
descText.anchor.set(0.5, 0);
descText.y = 50;
sprinklerButton.addChild(descText);
sprinklerButton.down = function () {
if (money >= 35) {
selectedSprinkler = 'regular';
self.visible = false;
LK.getSound('Buy').play();
}
};
self.addChild(sprinklerButton);
// Advanced Sprinkler item
var advancedSprinklerButton = new Container();
advancedSprinklerButton.x = 0;
advancedSprinklerButton.y = 50;
var advancedSprinklerIcon = LK.getAsset('sprinkler', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5,
tint: 0x00ff00
});
advancedSprinklerIcon.x = -300;
advancedSprinklerButton.addChild(advancedSprinklerIcon);
var advancedNameText = new Text2('Advanced Sprinkler', {
size: 70,
fill: 0x000000
});
advancedNameText.anchor.set(0, 0.5);
advancedNameText.x = -200;
advancedSprinklerButton.addChild(advancedNameText);
var advancedPriceText = new Text2('$150', {
size: 70,
fill: 0xFFFF00
});
advancedPriceText.anchor.set(1, 0.5);
advancedPriceText.x = 300;
advancedSprinklerButton.addChild(advancedPriceText);
var advancedDescText = new Text2('4x growth speed in 5x5 area', {
size: 40,
fill: 0x666666
});
advancedDescText.anchor.set(0.5, 0);
advancedDescText.y = 50;
advancedSprinklerButton.addChild(advancedDescText);
advancedSprinklerButton.down = function () {
if (money >= 150) {
selectedSprinkler = 'advanced';
self.visible = false;
LK.getSound('Buy').play();
}
};
self.addChild(advancedSprinklerButton);
var closeButton = new Button('CLOSE', function () {
self.visible = false;
});
closeButton.y = 500;
self.addChild(closeButton);
return self;
});
var PlantSpot = Container.expand(function (x, y) {
var self = Container.call(this);
self.x = x;
self.y = y;
self.planted = false;
self.plantType = null;
self.plantTime = 0;
self.grown = false;
self.regrowTime = 0;
var dirtGraphics = self.attachAsset('dirt', {
anchorX: 0.5,
anchorY: 0.5
});
// Move dirt graphics to the back layer
self.setChildIndex(dirtGraphics, 0);
var plantGraphics = null;
self.plantSeed = function (seedType) {
if (self.planted) return false;
self.planted = true;
self.plantType = seedType;
self.plantTime = LK.ticks;
self.grown = false;
self.isColorful = false;
// 5% chance for colorful fruit (3x price)
if (Math.random() < 0.05) {
self.isColorful = true;
self.plantType = 'colorful_' + seedType;
}
var finalScale = 1.0;
plantGraphics = self.attachAsset(self.plantType, {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
// Ensure plant graphics appear above soil, especially for giant fruits
self.setChildIndex(plantGraphics, self.children.length - 1);
// Animate plant growth over 5 seconds
tween(plantGraphics, {
scaleX: finalScale,
scaleY: finalScale
}, {
duration: 5000,
easing: tween.easeOut
});
// Add rainbow tint animation for colorful fruits
if (self.isColorful) {
var colorfulAnimation = function colorfulAnimation() {
var colors = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff, 0x00ffff];
var currentColor = 0;
var _animateColor = function animateColor() {
if (plantGraphics) {
tween(plantGraphics, {
tint: colors[currentColor]
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
currentColor = (currentColor + 1) % colors.length;
_animateColor();
}
});
}
};
_animateColor();
};
// Start colorful animation after growth completes
LK.setTimeout(colorfulAnimation, 5000);
}
LK.getSound('plant').play();
return true;
};
self.harvest = function () {
if (!self.grown) return null;
var harvestedType = self.plantType;
var isColorfulHarvest = self.isColorful;
// Check if this is a regrowing fruit (banana, dragon fruit, or coconut)
var isBanana = harvestedType === 'banana' || harvestedType === 'colorful_banana';
var isDragonFruit = harvestedType === 'dragonfruit' || harvestedType === 'colorful_dragonfruit';
var isCoconut = harvestedType === 'coconut' || harvestedType === 'colorful_coconut';
if (isBanana || isDragonFruit || isCoconut) {
// Hide the plant graphics with animation for regrowing fruits
if (plantGraphics) {
tween(plantGraphics, {
alpha: 0.3,
scaleX: 0.5,
scaleY: 0.5
}, {
duration: 500,
easing: tween.easeIn
});
}
self.grown = false;
self.regrowTime = LK.ticks;
} else {
// For carrots and strawberries, reset the plant completely
if (plantGraphics) {
plantGraphics.destroy();
plantGraphics = null;
}
self.planted = false;
self.plantType = null;
self.plantTime = 0;
self.grown = false;
self.isColorful = false;
self.regrowTime = 0;
}
LK.getSound('harvest').play();
return {
type: harvestedType,
colorful: isColorfulHarvest
};
};
self.update = function () {
if (self.planted && !self.grown) {
// Check if this spot is affected by a sprinkler
var speedMultiplier = 1;
for (var i = 0; i < sprinklers.length; i++) {
var sprinkler = sprinklers[i];
var distanceX = Math.abs(self.x - sprinkler.x);
var distanceY = Math.abs(self.y - sprinkler.y);
if (sprinkler.type === 'advanced') {
// Advanced sprinkler: 4x speed in 5x5 area (1100px = 5 * 220px spacing)
if (distanceX <= 1100 && distanceY <= 1100) {
speedMultiplier = 4;
break;
}
} else {
// Regular sprinkler: 2x speed in 3x3 area (660px = 3 * 220px spacing)
if (distanceX <= 660 && distanceY <= 660) {
speedMultiplier = 2;
break;
}
}
}
// Check if it's time to regrow after harvest (for bananas, dragon fruit, and coconut)
if (self.regrowTime > 0) {
var isBanana = self.plantType === 'banana' || self.plantType === 'colorful_banana';
var isDragonFruit = self.plantType === 'dragonfruit' || self.plantType === 'colorful_dragonfruit';
var isCoconut = self.plantType === 'coconut' || self.plantType === 'colorful_coconut';
var regrowReady = false;
if (isBanana && LK.ticks - self.regrowTime > 1140 / speedMultiplier) {
// 19 seconds at 60fps for banana regrow (halved with sprinkler)
regrowReady = true;
} else if ((isDragonFruit || isCoconut) && LK.ticks - self.regrowTime > 1320 / speedMultiplier) {
// 22 seconds at 60fps for dragon fruit and coconut regrow (halved with sprinkler)
regrowReady = true;
}
if (regrowReady) {
self.grown = true;
self.regrowTime = 0;
if (plantGraphics) {
var regrowScale = 1.0;
tween(plantGraphics, {
alpha: 1.0,
scaleX: regrowScale,
scaleY: regrowScale
}, {
duration: 1000,
easing: tween.easeOut
});
}
}
} else if (self.regrowTime === 0 && LK.ticks - self.plantTime > 300 / speedMultiplier) {
// 5 seconds at 60fps for initial growth (halved with sprinkler)
self.grown = true;
if (plantGraphics) {
plantGraphics.alpha = 1.0;
}
}
}
};
self.down = function () {
if (self.grown) {
var harvested = self.harvest();
if (harvested) {
var harvestType = harvested.type;
if (harvested.colorful) {
// Store colorful fruits separately for 3x price
var baseType = harvestType.replace('colorful_', '');
inventory['colorful_' + baseType] = (inventory['colorful_' + baseType] || 0) + 1;
} else {
inventory[harvestType] = (inventory[harvestType] || 0) + 1;
}
updateInventoryDisplay();
}
} else if (!self.planted && selectedSprinkler) {
// Place sprinkler
var sprinklerCost = selectedSprinkler === 'advanced' ? 150 : 35;
if (money >= sprinklerCost) {
var sprinkler;
if (selectedSprinkler === 'advanced') {
sprinkler = new AdvancedSprinkler(self.x, self.y);
} else {
sprinkler = new Sprinkler(self.x, self.y);
}
sprinklers.push(sprinkler);
game.addChild(sprinkler);
money -= sprinklerCost;
updateMoneyDisplay();
selectedSprinkler = false;
gearShop.visible = false;
}
} else if (!self.planted && selectedSeed && money >= seedPrices[selectedSeed]) {
if (self.plantSeed(selectedSeed)) {
money -= seedPrices[selectedSeed];
updateMoneyDisplay();
selectedSeed = null;
seedShop.visible = false;
}
}
};
return self;
});
var SeedShop = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('seedShopBg', {
anchorX: 0.5,
anchorY: 0.5
});
var titleText = new Text2('SEED SHOP', {
size: 80,
fill: 0x000000
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -600;
self.addChild(titleText);
var seedTypes = ['carrot', 'strawberry', 'banana', 'coconut', 'dragonfruit'];
var seedNames = ['Carrot', 'Strawberry', 'Banana', 'Coconut', 'Dragon Fruit'];
// Use uniform medium size for all seeds in shop
var uniformScale = 0.5; // Medium size for all seeds
for (var i = 0; i < seedTypes.length; i++) {
var seedButton = new Container();
seedButton.x = 0;
seedButton.y = -400 + i * 150;
// Use uniform scale for all seed icons
var seedIcon = LK.getAsset(seedTypes[i], {
anchorX: 0.5,
anchorY: 0.5,
scaleX: uniformScale,
scaleY: uniformScale
});
seedIcon.x = -300;
seedButton.addChild(seedIcon);
var nameText = new Text2(seedNames[i], {
size: 70,
fill: 0x000000
});
nameText.anchor.set(0, 0.5);
nameText.x = -250;
seedButton.addChild(nameText);
var priceText = new Text2('$' + seedPrices[seedTypes[i]], {
size: 70,
fill: 0xFFFF00
});
priceText.anchor.set(1, 0.5);
priceText.x = 300;
seedButton.addChild(priceText);
seedButton.seedType = seedTypes[i];
seedButton.down = function () {
if (money >= seedPrices[this.seedType]) {
selectedSeed = this.seedType;
self.visible = false;
LK.getSound('Buy').play();
}
};
self.addChild(seedButton);
}
var closeButton = new Button('CLOSE', function () {
self.visible = false;
});
closeButton.y = 500;
self.addChild(closeButton);
return self;
});
var Sprinkler = Container.expand(function (x, y) {
var self = Container.call(this);
self.x = x;
self.y = y;
self.type = 'regular';
var sprinklerGraphics = self.attachAsset('sprinkler', {
anchorX: 0.5,
anchorY: 0.5
});
// Add pulsing animation to show it's active
function animateSprinkler() {
tween(sprinklerGraphics, {
scaleX: 1.2,
scaleY: 1.2,
alpha: 0.7
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(sprinklerGraphics, {
scaleX: 1.0,
scaleY: 1.0,
alpha: 1.0
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: animateSprinkler
});
}
});
}
animateSprinkler();
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x228B22
});
/****
* Game Code
****/
// Add grass background
var grassBackground = game.attachAsset('grass_bg', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
var money = 0;
var inventory = {};
var selectedSeed = null;
var selectedSprinkler = false;
var sprinklers = [];
var soilPrice = 50;
var seedPrices = {
carrot: 10,
strawberry: 50,
banana: 80,
coconut: 160,
dragonfruit: 250
};
var sellPrices = {
carrot: 15,
strawberry: 35,
banana: 60,
coconut: 135,
dragonfruit: 200,
colorful_carrot: 45,
colorful_strawberry: 105,
colorful_banana: 180,
colorful_coconut: 405,
colorful_dragonfruit: 600
};
// Create plant spots in a grid
var plantSpots = [];
var gridCols = 3;
var gridRows = 1;
var startX = 800;
var startY = 1366;
var spacing = 220;
for (var row = 0; row < gridRows; row++) {
for (var col = 0; col < gridCols; col++) {
var spot = new PlantSpot(startX + col * spacing, startY + row * spacing);
plantSpots.push(spot);
game.addChild(spot);
}
}
// Plant initial carrots
plantSpots[0].plantSeed('carrot');
plantSpots[1].plantSeed('carrot');
// UI Elements
var moneyText = new Text2('Money: $0', {
size: 50,
fill: 0x000000
});
moneyText.anchor.set(0, 0);
moneyText.x = 150;
moneyText.y = 50;
LK.gui.topLeft.addChild(moneyText);
var inventoryText = new Text2('Inventory: Empty', {
size: 50,
fill: 0x000000
});
inventoryText.anchor.set(0, 1);
inventoryText.x = 100;
inventoryText.y = -100;
LK.gui.bottomLeft.addChild(inventoryText);
// Make inventory alive with pulsing animation
function animateInventory() {
tween(inventoryText, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(inventoryText, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: animateInventory
});
}
});
}
animateInventory();
var sellButton = new Button('SELL ALL', function () {
var totalSale = 0;
// Check if we get the 10% price boost (30% chance)
var priceBoost = Math.random() < 0.3 ? 1.1 : 1.0;
for (var itemType in inventory) {
if (inventory[itemType] > 0) {
var basePrice = sellPrices[itemType] * priceBoost;
totalSale += inventory[itemType] * basePrice;
inventory[itemType] = 0;
}
}
if (totalSale > 0) {
money += totalSale;
updateMoneyDisplay();
updateInventoryDisplay();
LK.getSound('sell').play();
}
});
sellButton.x = 600;
sellButton.y = 100;
sellButton.scaleX = 1.3;
sellButton.scaleY = 1.3;
LK.gui.topLeft.addChild(sellButton);
var seedButton = new Button('SEEDS', function () {
seedShop.visible = true;
});
seedButton.x = 900;
seedButton.y = 100;
seedButton.scaleX = 1.3;
seedButton.scaleY = 1.3;
LK.gui.topLeft.addChild(seedButton);
var freeCoinsButton = new Button('FREE COINS', function () {
money += 500;
updateMoneyDisplay();
});
freeCoinsButton.x = 1200;
freeCoinsButton.y = 100;
freeCoinsButton.scaleX = 1.3;
freeCoinsButton.scaleY = 1.3;
LK.gui.topLeft.addChild(freeCoinsButton);
var gearButton = new Button('GEAR SHOP', function () {
gearShop.visible = true;
});
gearButton.x = 600;
gearButton.y = 250;
gearButton.scaleX = 1.3;
gearButton.scaleY = 1.3;
LK.gui.topLeft.addChild(gearButton);
var newSoilButton = new Button('NEW SOIL $' + soilPrice, function () {
if (money >= soilPrice) {
// Purchase new soil
money -= soilPrice;
var newSpot;
if (plantSpots.length >= 15) {
// When we have 15 or more soils, add 3 soils to the right
var rightStartX = startX + 15 * spacing; // Position to the right of the 15 left soils
var rightStartY = 800;
var rightIndex = plantSpots.length - 15; // Index within the right section
var newSpotX = rightStartX + rightIndex % 3 * spacing; // 3 columns on the right
var newSpotY = rightStartY + Math.floor(rightIndex / 3) * spacing; // Add rows going down
newSpot = new PlantSpot(newSpotX, newSpotY);
} else if (plantSpots.length >= 6) {
// When we have 6-14 soils, arrange them vertically to the left (5 rows of 3)
var leftStartY = 800;
var newSpotX = startX + plantSpots.length % 3 * spacing; // Keep 3 columns
var newSpotY = leftStartY + Math.floor(plantSpots.length / 3) * spacing; // Add rows going down
newSpot = new PlantSpot(newSpotX, newSpotY);
} else {
// For first 6 soils, use original horizontal layout
var newSpotX = startX + plantSpots.length * spacing;
newSpot = new PlantSpot(newSpotX, startY);
}
plantSpots.push(newSpot);
game.addChild(newSpot);
// When we reach exactly 6 soils, rearrange all existing spots to vertical layout
if (plantSpots.length === 6) {
var topStartY = 800;
for (var i = 0; i < plantSpots.length; i++) {
var spot = plantSpots[i];
var newX = startX + i % 3 * spacing;
var newY = topStartY + Math.floor(i / 3) * spacing;
tween(spot, {
x: newX,
y: newY
}, {
duration: 1000,
easing: tween.easeInOut
});
}
}
// When we reach exactly 15 soils, rearrange all existing spots to final left layout
if (plantSpots.length === 15) {
var leftStartY = 800;
for (var i = 0; i < plantSpots.length; i++) {
var spot = plantSpots[i];
var newX = startX + i % 3 * spacing;
var newY = leftStartY + Math.floor(i / 3) * spacing;
tween(spot, {
x: newX,
y: newY
}, {
duration: 1000,
easing: tween.easeInOut
});
}
}
// Increase soil price by $25
soilPrice += 25;
newSoilButton.children[1].setText('NEW SOIL $' + soilPrice); // Update button text
updateMoneyDisplay();
LK.getSound('Buy').play();
}
});
newSoilButton.x = 900;
newSoilButton.y = 250;
newSoilButton.scaleX = 1.3;
newSoilButton.scaleY = 1.3;
LK.gui.topLeft.addChild(newSoilButton);
var seedShop = new SeedShop();
seedShop.x = 1024;
seedShop.y = 1366;
seedShop.visible = false;
game.addChild(seedShop);
var gearShop = new GearShop();
gearShop.x = 1024;
gearShop.y = 1366;
gearShop.visible = false;
game.addChild(gearShop);
// Button sliding variables
var topButtons = [sellButton, seedButton, freeCoinsButton, gearButton, newSoilButton];
var buttonBasePositions = [600, 900, 1200, 600, 900];
var slideOffset = 0;
var maxSlideOffset = 400; // Maximum pixels to slide
// Sliding functions
function slideButtonsLeft() {
slideOffset = Math.min(slideOffset + 100, maxSlideOffset);
updateButtonPositions();
}
function slideButtonsRight() {
slideOffset = Math.max(slideOffset - 100, -maxSlideOffset);
updateButtonPositions();
}
function updateButtonPositions() {
for (var i = 0; i < topButtons.length; i++) {
tween(topButtons[i], {
x: buttonBasePositions[i] + slideOffset
}, {
duration: 300,
easing: tween.easeOut
});
}
}
function updateMoneyDisplay() {
moneyText.setText('Money: $' + money);
}
function updateInventoryDisplay() {
var inventoryStr = 'Inventory: ';
var hasItems = false;
for (var itemType in inventory) {
if (inventory[itemType] > 0) {
if (hasItems) inventoryStr += ', ';
inventoryStr += itemType + ' x' + inventory[itemType];
hasItems = true;
}
}
if (!hasItems) {
inventoryStr += 'Empty';
}
inventoryText.setText(inventoryStr);
}
// Play background music
LK.playMusic('Music');
// Touch controls for sliding buttons
var touchStartX = 0;
var isDraggingButtons = false;
game.down = function (x, y, obj) {
// Check if touch is in the top button area
if (y < 200) {
touchStartX = x;
isDraggingButtons = true;
}
};
game.up = function (x, y, obj) {
if (isDraggingButtons) {
var deltaX = x - touchStartX;
if (Math.abs(deltaX) > 50) {
// Minimum swipe distance
if (deltaX > 0) {
slideButtonsLeft();
} else {
slideButtonsRight();
}
}
isDraggingButtons = false;
}
};
game.update = function () {
// Plant spots update automatically through their update methods
};
8 bit dragon fruit tree. In-Game asset. 2d. High contrast. No shadows
8 bit carrot. In-Game asset. 2d. High contrast. No shadows
background grass 8 bit. In-Game asset. 2d. High contrast. No shadows
8 bit Straw berry. In-Game asset. 2d. High contrast. No shadows
8 bit banana tree. In-Game asset. 2d. High contrast. No shadows
8 bit coconut tree. In-Game asset. 2d. High contrast. No shadows
Neon
Neon
Neon
Neon
Neon
Stone 8 bit. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
8 bit fish. In-Game asset. 2d. High contrast. No shadows
Neon
8 bit orange. In-Game asset. 2d. High contrast. No shadows
Neon
Apple tree 8 bit. In-Game asset. 2d. High contrast. No shadows
Choco
Choco but all parts of the carrot are visible and only the carrot is painted brown
Neon
different color