User prompt
Remove the weather button
User prompt
Add the close button to the upgrade panel
User prompt
Add it to the market panel
User prompt
The menu can't be closed
User prompt
I can't close the menu pls add the close button to all menus
User prompt
Move the close button to the bottom left
User prompt
There is no close button in the upgrades menu
User prompt
Add the clos button to the upgrades menu
User prompt
Can't close the upgrades and market menu
User prompt
When the menu is open and the same button that is used to open the menu when clicked will close the menu and remove the weather button
User prompt
Make a close button for every menu
User prompt
Make the seasons effect the crops
User prompt
Add sunny, winter, rainy, thunderstorm, spring
User prompt
The money counter is gone
User prompt
The text is overlaping when restarted
User prompt
Restart button with upgrades like oven blender and fishing rod ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Give the player $15
User prompt
Give the player 10 dollars to start the game ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add upgrades to the market and a animal pen
User prompt
Make the market
User prompt
It will take more time like 35 seconds to be grown fully
User prompt
Move the seed water and harvest buttons to the bottom right
Code edit (1 edits merged)
Please save this source code
User prompt
Harvest Tycoon: Farm & Grow
Initial prompt
Farming simulator
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { money: 50, cropsSold: 0, fieldsUnlocked: 9 }); /**** * Classes ****/ var CropButton = Container.expand(function (cropType) { var self = Container.call(this); self.cropType = cropType; var cropInfo = CropType.getInfo(cropType); var button = self.attachAsset(cropInfo.shape, { anchorX: 0.5, anchorY: 0.5, scaleX: 0.6, scaleY: 0.6 }); var priceTag = new Text2("$" + cropInfo.seedCost, { size: 25, fill: 0xFFFFFF }); priceTag.anchor.set(0.5, 0); priceTag.y = 40; self.addChild(priceTag); self.down = function (x, y, obj) { tween(self, { alpha: 0.7 }, { duration: 100 }); }; self.up = function (x, y, obj) { tween(self, { alpha: 1 }, { duration: 100 }); // Select crop type selectedCropType = self.cropType; selectedTool = 'seed'; updateToolButtons(); // Close selection cropSelectionPanel.visible = false; }; return self; }); var MarketButton = Container.expand(function () { var self = Container.call(this); var button = self.attachAsset('marketButton', { anchorX: 0.5, anchorY: 0.5 }); var label = new Text2("Market", { size: 50, fill: 0xFFFFFF }); label.anchor.set(0.5); self.addChild(label); self.down = function (x, y, obj) { tween(self, { alpha: 0.7 }, { duration: 100 }); }; self.up = function (x, y, obj) { tween(self, { alpha: 1 }, { duration: 100 }); // Sell all ready crops var cropsSold = 0; var moneyEarned = 0; plots.forEach(function (plot) { if (plot.state === PlotState.READY) { moneyEarned += CropType.getInfo(plot.cropType).sellPrice; cropsSold++; plot.reset(); } }); if (cropsSold > 0) { money += moneyEarned; storage.cropsSold += cropsSold; updateMoneyDisplay(); // Show feedback var sellMessage = new Text2("Sold " + cropsSold + " crops for $" + moneyEarned + "!", { size: 60, fill: 0xFFFF00 }); sellMessage.anchor.set(0.5); sellMessage.x = 2048 / 2; sellMessage.y = 2732 / 2; game.addChild(sellMessage); // Animate and remove tween(sellMessage, { alpha: 0, y: sellMessage.y - 100 }, { duration: 2000, onFinish: function onFinish() { sellMessage.destroy(); } }); LK.getSound('sell').play(); } }; return self; }); var Plot = Container.expand(function () { var self = Container.call(this); self.state = PlotState.EMPTY; self.cropType = CropType.NONE; self.growthProgress = 0; self.growthTotal = 0; self.needsWater = false; self.isWet = false; // Create soil var soil = self.attachAsset('soil', { anchorX: 0.5, anchorY: 0.5 }); self.soil = soil; // Growth indicator (invisible initially) var seedling = self.attachAsset('seedling', { anchorX: 0.5, anchorY: 1.0, y: 50, visible: false }); self.seedling = seedling; self.plant = function (cropType) { if (self.state !== PlotState.EMPTY || money < CropType.getInfo(cropType).seedCost) { return false; } money -= CropType.getInfo(cropType).seedCost; updateMoneyDisplay(); self.cropType = cropType; self.state = PlotState.SEEDED; self.growthProgress = 0; self.growthTotal = CropType.getInfo(cropType).growthTime * 60; // Convert to frames self.needsWater = true; self.seedling.visible = true; self.seedling.height = 30; // Small at first LK.getSound('plant').play(); return true; }; self.water = function () { if (self.state !== PlotState.SEEDED && self.state !== PlotState.GROWING) { return false; } self.isWet = true; self.needsWater = false; self.soil.texture = LK.getAsset('wetSoil', {}).texture; // Reset drying timeout self.dryTimer = LK.setTimeout(function () { self.isWet = false; self.needsWater = true; self.soil.texture = LK.getAsset('soil', {}).texture; }, 5000); // Soil stays wet for 5 seconds LK.getSound('water').play(); return true; }; self.harvest = function () { if (self.state !== PlotState.READY) { return false; } money += CropType.getInfo(self.cropType).sellPrice; storage.cropsSold++; updateMoneyDisplay(); self.reset(); LK.getSound('harvest').play(); return true; }; self.reset = function () { self.state = PlotState.EMPTY; self.cropType = CropType.NONE; self.growthProgress = 0; self.growthTotal = 0; self.needsWater = false; self.isWet = false; self.soil.texture = LK.getAsset('soil', {}).texture; self.seedling.visible = false; if (self.dryTimer) { LK.clearTimeout(self.dryTimer); } }; self.update = function () { // Only grow if it's watered if ((self.state === PlotState.SEEDED || self.state === PlotState.GROWING) && self.isWet) { self.growthProgress++; // Update crop appearance based on growth progress var growthPercentage = self.growthProgress / self.growthTotal; if (growthPercentage < 0.3) { self.state = PlotState.SEEDED; self.seedling.height = 30 + growthPercentage * 100; } else if (growthPercentage < 1) { self.state = PlotState.GROWING; // If we just entered growing state, change the shape if (self.seedling.texture !== LK.getAsset(CropType.getInfo(self.cropType).shape, {}).texture) { self.seedling.texture = LK.getAsset(CropType.getInfo(self.cropType).shape, {}).texture; self.seedling.width = LK.getAsset(CropType.getInfo(self.cropType).shape, {}).width; self.seedling.height = LK.getAsset(CropType.getInfo(self.cropType).shape, {}).height * growthPercentage; } else { self.seedling.height = LK.getAsset(CropType.getInfo(self.cropType).shape, {}).height * growthPercentage; } } else { // Fully grown self.state = PlotState.READY; self.seedling.height = LK.getAsset(CropType.getInfo(self.cropType).shape, {}).height; // Make it bounce a little to show it's ready tween(self.seedling, { y: 45 }, { duration: 500, easing: tween.easeInOut, onFinish: function onFinish() { tween(self.seedling, { y: 50 }, { duration: 500, easing: tween.easeInOut }); } }); } } }; // Handle interaction self.down = function (x, y, obj) { // Selection effect tween(self, { alpha: 0.7 }, { duration: 100 }); }; self.up = function (x, y, obj) { tween(self, { alpha: 1 }, { duration: 100 }); if (selectedTool === 'seed') { if (selectedCropType !== CropType.NONE) { self.plant(selectedCropType); } } else if (selectedTool === 'water') { self.water(); } else if (selectedTool === 'harvest') { self.harvest(); } }; return self; }); var ToolButton = Container.expand(function (toolType, shape) { var self = Container.call(this); self.toolType = toolType; var button = self.attachAsset(shape, { anchorX: 0.5, anchorY: 0.5 }); var label = new Text2(toolType.charAt(0).toUpperCase() + toolType.slice(1), { size: 30, fill: 0xFFFFFF }); label.anchor.set(0.5); self.addChild(label); self.setSelected = function (isSelected) { button.alpha = isSelected ? 1.0 : 0.7; if (isSelected) { tween(self, { scaleX: 1.1, scaleY: 1.1 }, { duration: 200 }); } else { tween(self, { scaleX: 1.0, scaleY: 1.0 }, { duration: 200 }); } }; self.down = function (x, y, obj) { tween(self, { alpha: 0.7 }, { duration: 100 }); }; self.up = function (x, y, obj) { tween(self, { alpha: 1 }, { duration: 100 }); // Update selected tool if (self.toolType === 'seed') { openCropSelection(); } else { selectedTool = self.toolType; selectedCropType = CropType.NONE; updateToolButtons(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game variables var PlotState = { EMPTY: 0, SEEDED: 1, GROWING: 2, READY: 3 }; var CropType = { NONE: 0, CARROT: 1, CORN: 2, TOMATO: 3, getInfo: function getInfo(type) { switch (type) { case CropType.CARROT: return { name: "Carrot", growthTime: 5, // in seconds for demo seedCost: 5, sellPrice: 10, shape: 'carrot' }; case CropType.CORN: return { name: "Corn", growthTime: 10, // in seconds for demo seedCost: 10, sellPrice: 25, shape: 'corn' }; case CropType.TOMATO: return { name: "Tomato", growthTime: 15, // in seconds for demo seedCost: 15, sellPrice: 40, shape: 'tomato' }; default: return { name: "None", growthTime: 0, seedCost: 0, sellPrice: 0, shape: null }; } } }; var plots = []; var toolButtons = {}; var cropSelectionPanel; var moneyDisplay; var money = storage.money; var selectedTool = 'seed'; var selectedCropType = CropType.NONE; // Initialize the farm layout function initializeFarm() { var plotSize = 220; // Size of each plot including margin var gridSize = 3; // 3x3 grid var startX = (2048 - plotSize * gridSize) / 2 + plotSize / 2; var startY = 600; // Start plots below the top UI area // Create plots in a grid for (var row = 0; row < gridSize; row++) { for (var col = 0; col < gridSize; col++) { var plot = new Plot(); plot.x = startX + col * plotSize; plot.y = startY + row * plotSize; // Check if unlocked if (row * gridSize + col < storage.fieldsUnlocked) { game.addChild(plot); plots.push(plot); } } } } // Create UI function createUI() { // Money display moneyDisplay = new Text2("$" + money, { size: 70, fill: 0xFFFF00 }); moneyDisplay.anchor.set(0, 0); moneyDisplay.x = 150; moneyDisplay.y = 50; LK.gui.addChild(moneyDisplay); // Title var titleText = new Text2("Harvest Tycoon", { size: 100, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 2048 / 2; titleText.y = 50; LK.gui.addChild(titleText); // Create tool buttons var buttonSize = 120; var buttonSpacing = buttonSize * 1.2; var buttonStartX = 2048 - buttonSize - 50; // Right side of screen with some margin var buttonY = 2732 - buttonSize - 50; // Bottom of screen with some margin // Harvest button (rightmost) toolButtons.harvest = new ToolButton('harvest', 'harvestButton'); toolButtons.harvest.x = buttonStartX; toolButtons.harvest.y = buttonY; game.addChild(toolButtons.harvest); // Water button (middle) toolButtons.water = new ToolButton('water', 'waterButton'); toolButtons.water.x = buttonStartX - buttonSpacing; toolButtons.water.y = buttonY; game.addChild(toolButtons.water); // Seed button (leftmost of the three) toolButtons.seed = new ToolButton('seed', 'seedButton'); toolButtons.seed.x = buttonStartX - buttonSpacing * 2; toolButtons.seed.y = buttonY; game.addChild(toolButtons.seed); // Market button (to sell all ready crops) var marketButton = new MarketButton(); marketButton.x = 2048 - 200; marketButton.y = 200; game.addChild(marketButton); // Create crop selection panel (initially hidden) cropSelectionPanel = new Container(); cropSelectionPanel.visible = false; game.addChild(cropSelectionPanel); // Panel background var panelBg = LK.getAsset('soil', { width: 500, height: 200, anchorX: 0.5, anchorY: 0.5 }); panelBg.alpha = 0.8; cropSelectionPanel.addChild(panelBg); // Add crop buttons var cropButtonX = -150; var cropButtonY = 0; var cropButtonSpacing = 150; var carrotButton = new CropButton(CropType.CARROT); carrotButton.x = cropButtonX; carrotButton.y = cropButtonY; cropSelectionPanel.addChild(carrotButton); var cornButton = new CropButton(CropType.CORN); cornButton.x = cropButtonX + cropButtonSpacing; cornButton.y = cropButtonY; cropSelectionPanel.addChild(cornButton); var tomatoButton = new CropButton(CropType.TOMATO); tomatoButton.x = cropButtonX + cropButtonSpacing * 2; tomatoButton.y = cropButtonY; cropSelectionPanel.addChild(tomatoButton); // Position the panel cropSelectionPanel.x = 2048 / 2; cropSelectionPanel.y = 400; // Set initial tool button states updateToolButtons(); } // Update the money display function updateMoneyDisplay() { moneyDisplay.setText("$" + money); storage.money = money; } // Open crop selection panel function openCropSelection() { cropSelectionPanel.visible = true; selectedTool = 'seed'; updateToolButtons(); } // Update tool button highlighting function updateToolButtons() { for (var tool in toolButtons) { toolButtons[tool].setSelected(tool === selectedTool); } } // Initialize game initializeFarm(); createUI(); // Play background music LK.playMusic('farmMusic'); // Game update loop game.update = function () { // Update all plots for (var i = 0; i < plots.length; i++) { plots[i].update(); } };
===================================================================
--- original.js
+++ change.js
@@ -425,25 +425,26 @@
titleText.y = 50;
LK.gui.addChild(titleText);
// Create tool buttons
var buttonSize = 120;
- var buttonStartX = 150;
- var buttonY = 200;
- // Seed button
- toolButtons.seed = new ToolButton('seed', 'seedButton');
- toolButtons.seed.x = buttonStartX;
- toolButtons.seed.y = buttonY;
- game.addChild(toolButtons.seed);
- // Water button
- toolButtons.water = new ToolButton('water', 'waterButton');
- toolButtons.water.x = buttonStartX + buttonSize * 1.5;
- toolButtons.water.y = buttonY;
- game.addChild(toolButtons.water);
- // Harvest button
+ var buttonSpacing = buttonSize * 1.2;
+ var buttonStartX = 2048 - buttonSize - 50; // Right side of screen with some margin
+ var buttonY = 2732 - buttonSize - 50; // Bottom of screen with some margin
+ // Harvest button (rightmost)
toolButtons.harvest = new ToolButton('harvest', 'harvestButton');
- toolButtons.harvest.x = buttonStartX + buttonSize * 3;
+ toolButtons.harvest.x = buttonStartX;
toolButtons.harvest.y = buttonY;
game.addChild(toolButtons.harvest);
+ // Water button (middle)
+ toolButtons.water = new ToolButton('water', 'waterButton');
+ toolButtons.water.x = buttonStartX - buttonSpacing;
+ toolButtons.water.y = buttonY;
+ game.addChild(toolButtons.water);
+ // Seed button (leftmost of the three)
+ toolButtons.seed = new ToolButton('seed', 'seedButton');
+ toolButtons.seed.x = buttonStartX - buttonSpacing * 2;
+ toolButtons.seed.y = buttonY;
+ game.addChild(toolButtons.seed);
// Market button (to sell all ready crops)
var marketButton = new MarketButton();
marketButton.x = 2048 - 200;
marketButton.y = 200;
Carrot 2d pixilated topdown. In-Game asset. 2d. High contrast. No shadows
Button blank lime 2d pixilated topdown. In-Game asset. 2d. High contrast. No shadows
Square yellow button 2d pixilated topdown. In-Game asset. 2d. High contrast. No shadows
Soil 2d pixilated topdown. In-Game asset. 2d. High contrast. No shadows
Corn 2d pixilated topdown. In-Game asset. 2d. High contrast. No shadows
Tomato 2d pixilated topdown. In-Game asset. 2d. High contrast. No shadows