User prompt
make it in the order of watering can, sprinkler, good sprinkler, great sprinkler, mega sprinkler
User prompt
Get rid of the pond and make a tool shop (EG sprinkler, water can, mega sprinkler ECT ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
you can only put the pond plants on the pond
User prompt
delete the level
User prompt
300 dollars for level 3, 400 for level 4, 500 for level 5 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
if you have 200 dollars you go to level 2 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
add levels. with levels you can unlock stuff. level 1 has carrot, strawberry. level 2 has blueberry, corn. level 3 has tulip, tomato, daffodil. level 4 has watermelon, fanmade shop. level 5 has pond shop ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
make the garden and pond downer
User prompt
add a pond next to your garden and add a pond shop. there's seaweed, olded seaweed, kelp in side of the pond shop
User prompt
when you sell a plant will give you times 2 more money than it costs
User prompt
candy corn is $18 thousand
User prompt
pink pineapple is $11 thousand
User prompt
can you make the FANMADE shop a other button
User prompt
can you add a new type of shop called FANMADE and add pink pineapple and candy corn
User prompt
please make a restart button to restart your progress ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
please make the cost of all the seeds times 2
User prompt
make daffodil $51 and watermelon $68
User prompt
add daffodil and watermelon
User prompt
make the corn $39 and the tulip $41 and the tomato $45
User prompt
can you add corn between blueberry and tulip
User prompt
delete orange
User prompt
can you add orange tulip and tomato
User prompt
if you press the shop button again the shop will go
User prompt
can you make it so when you open the shop please make the shop background over layer the garden
Code edit (1 edits merged)
Please save this source code
/**** * Plugins ****/ var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var GardenPlot = Container.expand(function () { var self = Container.call(this); var plotGraphics = self.attachAsset('gardenPlot', { anchorX: 0.5, anchorY: 0.5 }); self.cropType = null; self.plantTime = 0; self.growthStage = 0; // 0 = empty, 1 = seed, 2 = sprout, 3 = mature self.cropAsset = null; self.plantSeed = function (seedType) { if (self.growthStage > 0) return false; self.cropType = seedType; self.plantTime = LK.ticks; self.growthStage = 1; plotGraphics.tint = 0x654321; var seedAssetName = seedType + 'Seed'; self.cropAsset = self.attachAsset(seedAssetName, { anchorX: 0.5, anchorY: 0.5 }); LK.getSound('plant').play(); return true; }; self.harvest = function () { if (self.growthStage !== 3) return null; var harvestedCrop = self.cropType; self.cropType = null; self.plantTime = 0; self.growthStage = 0; plotGraphics.tint = 0xFFFFFF; if (self.cropAsset) { self.removeChild(self.cropAsset); self.cropAsset = null; } LK.getSound('harvest').play(); return harvestedCrop; }; self.update = function () { if (self.growthStage === 0 || !self.cropType) return; var growthTime = LK.ticks - self.plantTime; var cropData = getCropData(self.cropType); if (self.growthStage === 1 && growthTime >= cropData.sproutTime) { self.growthStage = 2; if (self.cropAsset) { self.removeChild(self.cropAsset); } var sproutAssetName = self.cropType + 'Sprout'; self.cropAsset = self.attachAsset(sproutAssetName, { anchorX: 0.5, anchorY: 0.5 }); } else if (self.growthStage === 2 && growthTime >= cropData.matureTime) { self.growthStage = 3; if (self.cropAsset) { self.removeChild(self.cropAsset); } var cropAssetName = self.cropType + 'Crop'; self.cropAsset = self.attachAsset(cropAssetName, { anchorX: 0.5, anchorY: 0.5 }); } }; self.down = function (x, y, obj) { if (self.growthStage === 3) { var harvestedCrop = self.harvest(); if (harvestedCrop) { var cropData = getCropData(harvestedCrop); money += cropData.sellPrice; updateMoneyDisplay(); checkLevelUp(); } } else if (self.growthStage === 0 && selectedSeed && inventory[selectedSeed] > 0) { var unlockedCrops = getUnlockedCrops(level); if (unlockedCrops.indexOf(selectedSeed) !== -1) { if (self.plantSeed(selectedSeed)) { inventory[selectedSeed]--; updateInventoryDisplay(); } } } }; return self; }); var PondPlot = Container.expand(function () { var self = Container.call(this); var plotGraphics = self.attachAsset('pondPlot', { anchorX: 0.5, anchorY: 0.5 }); self.cropType = null; self.plantTime = 0; self.growthStage = 0; // 0 = empty, 1 = seed, 2 = sprout, 3 = mature self.cropAsset = null; self.plantSeed = function (seedType) { if (self.growthStage > 0) return false; self.cropType = seedType; self.plantTime = LK.ticks; self.growthStage = 1; plotGraphics.tint = 0x006080; var seedAssetName = seedType + 'Seed'; self.cropAsset = self.attachAsset(seedAssetName, { anchorX: 0.5, anchorY: 0.5 }); LK.getSound('plant').play(); return true; }; self.harvest = function () { if (self.growthStage !== 3) return null; var harvestedCrop = self.cropType; self.cropType = null; self.plantTime = 0; self.growthStage = 0; plotGraphics.tint = 0xFFFFFF; if (self.cropAsset) { self.removeChild(self.cropAsset); self.cropAsset = null; } LK.getSound('harvest').play(); return harvestedCrop; }; self.update = function () { if (self.growthStage === 0 || !self.cropType) return; var growthTime = LK.ticks - self.plantTime; var cropData = getCropData(self.cropType); if (self.growthStage === 1 && growthTime >= cropData.sproutTime) { self.growthStage = 2; if (self.cropAsset) { self.removeChild(self.cropAsset); } var sproutAssetName = self.cropType + 'Sprout'; self.cropAsset = self.attachAsset(sproutAssetName, { anchorX: 0.5, anchorY: 0.5 }); } else if (self.growthStage === 2 && growthTime >= cropData.matureTime) { self.growthStage = 3; if (self.cropAsset) { self.removeChild(self.cropAsset); } var cropAssetName = self.cropType + 'Crop'; self.cropAsset = self.attachAsset(cropAssetName, { anchorX: 0.5, anchorY: 0.5 }); } }; self.down = function (x, y, obj) { if (self.growthStage === 3) { var harvestedCrop = self.harvest(); if (harvestedCrop) { var cropData = getCropData(harvestedCrop); money += cropData.sellPrice; updateMoneyDisplay(); checkLevelUp(); } } else if (self.growthStage === 0 && selectedSeed && inventory[selectedSeed] > 0) { // Check if selected seed is a pond crop and level is sufficient var pondCrops = ['seaweed', 'oldSeaweed', 'kelp']; if (pondCrops.indexOf(selectedSeed) !== -1 && level >= 5) { if (self.plantSeed(selectedSeed)) { inventory[selectedSeed]--; updateInventoryDisplay(); } } } }; return self; }); var ShopItem = Container.expand(function (cropType, yPos) { var self = Container.call(this); var buyButton = self.attachAsset('buyButton', { anchorX: 0.5, anchorY: 0.5 }); self.x = 300; self.y = yPos; var cropData = getCropData(cropType); var nameText = new Text2(cropData.name, { size: 40, fill: 0x000000 }); nameText.anchor.set(0.5, 0.5); nameText.x = -50; nameText.y = -15; self.addChild(nameText); var priceText = new Text2('$' + cropData.seedPrice, { size: 35, fill: 0x000000 }); priceText.anchor.set(0.5, 0.5); priceText.x = -50; priceText.y = 15; self.addChild(priceText); self.down = function (x, y, obj) { var unlockedCrops = getUnlockedCrops(level); if (money >= cropData.seedPrice && unlockedCrops.indexOf(cropType) !== -1) { money -= cropData.seedPrice; inventory[cropType] = (inventory[cropType] || 0) + 1; selectedSeed = cropType; updateMoneyDisplay(); updateInventoryDisplay(); LK.getSound('purchase').play(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game state // Garden plots // Seeds and crops // UI elements var money = storage.money || 100; var inventory = storage.inventory || {}; var level = storage.level || 1; var selectedSeed = null; var shopOpen = false; var fanmadeShopOpen = false; var pondShopOpen = false; // Crop data function getUnlockedCrops(playerLevel) { var unlockedCrops = []; if (playerLevel >= 1) { unlockedCrops = unlockedCrops.concat(['carrot', 'strawberry']); } if (playerLevel >= 2) { unlockedCrops = unlockedCrops.concat(['blueberry', 'corn']); } if (playerLevel >= 3) { unlockedCrops = unlockedCrops.concat(['tulip', 'tomato', 'daffodil']); } if (playerLevel >= 4) { unlockedCrops = unlockedCrops.concat(['watermelon']); } return unlockedCrops; } function getCropData(cropType) { var cropData = { 'carrot': { name: 'Carrot', seedPrice: 20, sellPrice: 40, sproutTime: 180, // 3 seconds matureTime: 300 // 5 seconds }, 'strawberry': { name: 'Strawberry', seedPrice: 40, sellPrice: 80, sproutTime: 300, // 5 seconds matureTime: 480 // 8 seconds }, 'blueberry': { name: 'Blueberry', seedPrice: 70, sellPrice: 140, sproutTime: 480, // 8 seconds matureTime: 720 // 12 seconds }, 'corn': { name: 'Corn', seedPrice: 78, sellPrice: 156, sproutTime: 360, // 6 seconds matureTime: 600 // 10 seconds }, 'tulip': { name: 'Tulip', seedPrice: 82, sellPrice: 164, sproutTime: 240, // 4 seconds matureTime: 420 // 7 seconds }, 'tomato': { name: 'Tomato', seedPrice: 90, sellPrice: 180, sproutTime: 420, // 7 seconds matureTime: 660 // 11 seconds }, 'daffodil': { name: 'Daffodil', seedPrice: 102, sellPrice: 204, sproutTime: 300, // 5 seconds matureTime: 480 // 8 seconds }, 'watermelon': { name: 'Watermelon', seedPrice: 136, sellPrice: 272, sproutTime: 600, // 10 seconds matureTime: 900 // 15 seconds }, 'pinkPineapple': { name: 'Pink Pineapple', seedPrice: 11000, sellPrice: 22000, sproutTime: 720, // 12 seconds matureTime: 1080 // 18 seconds }, 'candyCorn': { name: 'Candy Corn', seedPrice: 18000, sellPrice: 36000, sproutTime: 660, // 11 seconds matureTime: 960 // 16 seconds }, 'seaweed': { name: 'Seaweed', seedPrice: 50, sellPrice: 100, sproutTime: 240, // 4 seconds matureTime: 420 // 7 seconds }, 'oldSeaweed': { name: 'Old Seaweed', seedPrice: 120, sellPrice: 240, sproutTime: 480, // 8 seconds matureTime: 720 // 12 seconds }, 'kelp': { name: 'Kelp', seedPrice: 200, sellPrice: 400, sproutTime: 600, // 10 seconds matureTime: 900 // 15 seconds } }; return cropData[cropType]; } // UI setup var moneyText = new Text2('Money: $' + money, { size: 60, fill: 0xFFFFFF }); moneyText.anchor.set(0, 0); moneyText.x = 150; moneyText.y = 20; LK.gui.topLeft.addChild(moneyText); var inventoryText = new Text2('Seeds: 0', { size: 50, fill: 0xFFFFFF }); inventoryText.anchor.set(0.5, 0); LK.gui.top.addChild(inventoryText); var selectedSeedText = new Text2('Selected: None', { size: 45, fill: 0xFFFFFF }); selectedSeedText.anchor.set(1, 0); selectedSeedText.x = -20; selectedSeedText.y = 20; LK.gui.topRight.addChild(selectedSeedText); var levelText = new Text2('Level: ' + level, { size: 50, fill: 0xFFFFFF }); levelText.anchor.set(1, 0); levelText.x = -20; levelText.y = 80; LK.gui.topRight.addChild(levelText); // Shop button var shopButton = game.addChild(LK.getAsset('shopButton', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 150 })); var shopButtonText = new Text2('SHOP', { size: 50, fill: 0xFFFFFF }); shopButtonText.anchor.set(0.5, 0.5); shopButton.addChild(shopButtonText); // FANMADE shop button var fanmadeShopButton = game.addChild(LK.getAsset('fanmadeShopButton', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 250 })); var fanmadeShopButtonText = new Text2('FANMADE', { size: 45, fill: 0xFFFFFF }); fanmadeShopButtonText.anchor.set(0.5, 0.5); fanmadeShopButton.addChild(fanmadeShopButtonText); // Pond shop button var pondShopButton = game.addChild(LK.getAsset('pondShopButton', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 350 })); var pondShopButtonText = new Text2('POND SHOP', { size: 40, fill: 0xFFFFFF }); pondShopButtonText.anchor.set(0.5, 0.5); pondShopButton.addChild(pondShopButtonText); // Shop UI var shopContainer = new Container(); var shopBackground = shopContainer.addChild(LK.getAsset('shopBackground', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, scaleX: 3.5, scaleY: 2.0 })); var shopTitle = new Text2('SEED SHOP', { size: 60, fill: 0x000000 }); shopTitle.anchor.set(0.5, 0.5); shopTitle.x = 1024; shopTitle.y = 1000; shopContainer.addChild(shopTitle); var closeShopText = new Text2('Tap outside to close', { size: 40, fill: 0x666666 }); closeShopText.anchor.set(0.5, 0.5); closeShopText.x = 1024; closeShopText.y = 1700; shopContainer.addChild(closeShopText); // Shop items var carrotShopItem = shopContainer.addChild(new ShopItem('carrot', 1200)); var strawberryShopItem = shopContainer.addChild(new ShopItem('strawberry', 1300)); var blueberryShopItem = shopContainer.addChild(new ShopItem('blueberry', 1400)); var cornShopItem = shopContainer.addChild(new ShopItem('corn', 1500)); var tulipShopItem = shopContainer.addChild(new ShopItem('tulip', 1600)); var tomatoShopItem = shopContainer.addChild(new ShopItem('tomato', 1700)); var daffodilShopItem = shopContainer.addChild(new ShopItem('daffodil', 1800)); var watermelonShopItem = shopContainer.addChild(new ShopItem('watermelon', 1900)); // FANMADE Shop UI var fanmadeShopContainer = new Container(); var fanmadeShopBackground = fanmadeShopContainer.addChild(LK.getAsset('shopBackground', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, scaleX: 3.5, scaleY: 2.0 })); var fanmadeShopTitle = new Text2('FANMADE SHOP', { size: 60, fill: 0x000000 }); fanmadeShopTitle.anchor.set(0.5, 0.5); fanmadeShopTitle.x = 1024; fanmadeShopTitle.y = 1000; fanmadeShopContainer.addChild(fanmadeShopTitle); var closeFanmadeShopText = new Text2('Tap outside to close', { size: 40, fill: 0x666666 }); closeFanmadeShopText.anchor.set(0.5, 0.5); closeFanmadeShopText.x = 1024; closeFanmadeShopText.y = 1700; fanmadeShopContainer.addChild(closeFanmadeShopText); // FANMADE shop items var pinkPineappleShopItem = fanmadeShopContainer.addChild(new ShopItem('pinkPineapple', 1200)); var candyCornShopItem = fanmadeShopContainer.addChild(new ShopItem('candyCorn', 1300)); fanmadeShopContainer.visible = false; game.addChild(fanmadeShopContainer); // Pond Shop UI var pondShopContainer = new Container(); var pondShopBackground = pondShopContainer.addChild(LK.getAsset('shopBackground', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, scaleX: 3.5, scaleY: 2.0 })); var pondShopTitle = new Text2('POND SHOP', { size: 60, fill: 0x000000 }); pondShopTitle.anchor.set(0.5, 0.5); pondShopTitle.x = 1024; pondShopTitle.y = 1000; pondShopContainer.addChild(pondShopTitle); var closePondShopText = new Text2('Tap outside to close', { size: 40, fill: 0x666666 }); closePondShopText.anchor.set(0.5, 0.5); closePondShopText.x = 1024; closePondShopText.y = 1700; pondShopContainer.addChild(closePondShopText); // Pond shop items var seaweedShopItem = pondShopContainer.addChild(new ShopItem('seaweed', 1200)); var oldSeaweedShopItem = pondShopContainer.addChild(new ShopItem('oldSeaweed', 1300)); var kelpShopItem = pondShopContainer.addChild(new ShopItem('kelp', 1400)); pondShopContainer.visible = false; game.addChild(pondShopContainer); shopContainer.visible = false; game.addChild(shopContainer); // Garden plots var plots = []; var pondPlots = []; var plotRows = 4; var plotCols = 5; var plotSpacing = 200; var startX = 1024 - (plotCols - 1) * plotSpacing / 2; var startY = 800; for (var row = 0; row < plotRows; row++) { for (var col = 0; col < plotCols; col++) { var plot = game.addChild(new GardenPlot()); plot.x = startX + col * plotSpacing; plot.y = startY + row * plotSpacing; plots.push(plot); } } // Add decorative pond var pond = game.addChild(LK.getAsset('pond', { anchorX: 0.5, anchorY: 0.5, x: 1024 + 700, y: 1200 })); // Pond plots var pondRows = 2; var pondCols = 3; var pondSpacing = 150; var pondStartX = 1024 + 700 - (pondCols - 1) * pondSpacing / 2; var pondStartY = 1100; for (var row = 0; row < pondRows; row++) { for (var col = 0; col < pondCols; col++) { var pondPlot = game.addChild(new PondPlot()); pondPlot.x = pondStartX + col * pondSpacing; pondPlot.y = pondStartY + row * pondSpacing; pondPlots.push(pondPlot); } } // Helper functions function updateMoneyDisplay() { moneyText.setText('Money: $' + money); storage.money = money; } function updateLevelDisplay() { levelText.setText('Level: ' + level); storage.level = level; } function checkLevelUp() { var newLevel = 1; if (money >= 500) newLevel = 2; if (money >= 2000) newLevel = 3; if (money >= 8000) newLevel = 4; if (money >= 20000) newLevel = 5; if (newLevel > level) { level = newLevel; updateLevelDisplay(); updateShopVisibility(); } } function updateInventoryDisplay() { var totalSeeds = 0; for (var seedType in inventory) { totalSeeds += inventory[seedType]; } inventoryText.setText('Seeds: ' + totalSeeds); if (selectedSeed && inventory[selectedSeed] > 0) { var cropData = getCropData(selectedSeed); selectedSeedText.setText('Selected: ' + cropData.name + ' (' + inventory[selectedSeed] + ')'); } else { selectedSeedText.setText('Selected: None'); selectedSeed = null; } storage.inventory = inventory; } function updateShopVisibility() { var unlockedCrops = getUnlockedCrops(level); // Update regular shop items carrotShopItem.visible = unlockedCrops.indexOf('carrot') !== -1; strawberryShopItem.visible = unlockedCrops.indexOf('strawberry') !== -1; blueberryShopItem.visible = unlockedCrops.indexOf('blueberry') !== -1; cornShopItem.visible = unlockedCrops.indexOf('corn') !== -1; tulipShopItem.visible = unlockedCrops.indexOf('tulip') !== -1; tomatoShopItem.visible = unlockedCrops.indexOf('tomato') !== -1; daffodilShopItem.visible = unlockedCrops.indexOf('daffodil') !== -1; watermelonShopItem.visible = unlockedCrops.indexOf('watermelon') !== -1; // Update shop button visibility fanmadeShopButton.visible = level >= 4; pondShopButton.visible = level >= 5; } // Shop button handler shopButton.down = function (x, y, obj) { if (shopOpen) { shopOpen = false; shopContainer.visible = false; } else { shopOpen = true; shopContainer.visible = true; } }; // FANMADE shop button handler fanmadeShopButton.down = function (x, y, obj) { if (fanmadeShopOpen) { fanmadeShopOpen = false; fanmadeShopContainer.visible = false; } else { fanmadeShopOpen = true; fanmadeShopContainer.visible = true; } }; // Pond shop button handler pondShopButton.down = function (x, y, obj) { if (pondShopOpen) { pondShopOpen = false; pondShopContainer.visible = false; } else { pondShopOpen = true; pondShopContainer.visible = true; } }; // Game click handler for closing shop game.down = function (x, y, obj) { if (shopOpen && obj === game) { shopOpen = false; shopContainer.visible = false; } if (fanmadeShopOpen && obj === game) { fanmadeShopOpen = false; fanmadeShopContainer.visible = false; } if (pondShopOpen && obj === game) { pondShopOpen = false; pondShopContainer.visible = false; } }; // Restart button var restartButton = game.addChild(LK.getAsset('restartButton', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 2600 })); var restartButtonText = new Text2('RESTART', { size: 45, fill: 0xFFFFFF }); restartButtonText.anchor.set(0.5, 0.5); restartButton.addChild(restartButtonText); restartButton.down = function (x, y, obj) { // Reset all storage data storage.money = 100; storage.inventory = {}; storage.level = 1; // Reset game variables money = 100; inventory = {}; level = 1; selectedSeed = null; shopOpen = false; fanmadeShopOpen = false; pondShopOpen = false; // Reset all plots for (var i = 0; i < plots.length; i++) { var plot = plots[i]; plot.cropType = null; plot.plantTime = 0; plot.growthStage = 0; if (plot.cropAsset) { plot.removeChild(plot.cropAsset); plot.cropAsset = null; } // Reset plot graphics tint plot.children[0].tint = 0xFFFFFF; } // Reset all pond plots for (var i = 0; i < pondPlots.length; i++) { var pondPlot = pondPlots[i]; pondPlot.cropType = null; pondPlot.plantTime = 0; pondPlot.growthStage = 0; if (pondPlot.cropAsset) { pondPlot.removeChild(pondPlot.cropAsset); pondPlot.cropAsset = null; } // Reset pond plot graphics tint pondPlot.children[0].tint = 0xFFFFFF; } // Close shop if open if (shopOpen) { shopOpen = false; shopContainer.visible = false; } if (fanmadeShopOpen) { fanmadeShopOpen = false; fanmadeShopContainer.visible = false; } if (pondShopOpen) { pondShopOpen = false; pondShopContainer.visible = false; } // Update displays updateMoneyDisplay(); updateInventoryDisplay(); updateLevelDisplay(); updateShopVisibility(); }; // Initialize display updateMoneyDisplay(); updateInventoryDisplay(); updateLevelDisplay(); updateShopVisibility(); game.update = function () { // Update all plots for (var i = 0; i < plots.length; i++) { plots[i].update(); } // Update all pond plots for (var i = 0; i < pondPlots.length; i++) { pondPlots[i].update(); } };
===================================================================
--- original.js
+++ change.js
@@ -76,13 +76,17 @@
if (harvestedCrop) {
var cropData = getCropData(harvestedCrop);
money += cropData.sellPrice;
updateMoneyDisplay();
+ checkLevelUp();
}
} else if (self.growthStage === 0 && selectedSeed && inventory[selectedSeed] > 0) {
- if (self.plantSeed(selectedSeed)) {
- inventory[selectedSeed]--;
- updateInventoryDisplay();
+ var unlockedCrops = getUnlockedCrops(level);
+ if (unlockedCrops.indexOf(selectedSeed) !== -1) {
+ if (self.plantSeed(selectedSeed)) {
+ inventory[selectedSeed]--;
+ updateInventoryDisplay();
+ }
}
}
};
return self;
@@ -157,13 +161,14 @@
if (harvestedCrop) {
var cropData = getCropData(harvestedCrop);
money += cropData.sellPrice;
updateMoneyDisplay();
+ checkLevelUp();
}
} else if (self.growthStage === 0 && selectedSeed && inventory[selectedSeed] > 0) {
- // Check if selected seed is a pond crop
+ // Check if selected seed is a pond crop and level is sufficient
var pondCrops = ['seaweed', 'oldSeaweed', 'kelp'];
- if (pondCrops.indexOf(selectedSeed) !== -1) {
+ if (pondCrops.indexOf(selectedSeed) !== -1 && level >= 5) {
if (self.plantSeed(selectedSeed)) {
inventory[selectedSeed]--;
updateInventoryDisplay();
}
@@ -197,9 +202,10 @@
priceText.x = -50;
priceText.y = 15;
self.addChild(priceText);
self.down = function (x, y, obj) {
- if (money >= cropData.seedPrice) {
+ var unlockedCrops = getUnlockedCrops(level);
+ if (money >= cropData.seedPrice && unlockedCrops.indexOf(cropType) !== -1) {
money -= cropData.seedPrice;
inventory[cropType] = (inventory[cropType] || 0) + 1;
selectedSeed = cropType;
updateMoneyDisplay();
@@ -225,13 +231,30 @@
// Seeds and crops
// UI elements
var money = storage.money || 100;
var inventory = storage.inventory || {};
+var level = storage.level || 1;
var selectedSeed = null;
var shopOpen = false;
var fanmadeShopOpen = false;
var pondShopOpen = false;
// Crop data
+function getUnlockedCrops(playerLevel) {
+ var unlockedCrops = [];
+ if (playerLevel >= 1) {
+ unlockedCrops = unlockedCrops.concat(['carrot', 'strawberry']);
+ }
+ if (playerLevel >= 2) {
+ unlockedCrops = unlockedCrops.concat(['blueberry', 'corn']);
+ }
+ if (playerLevel >= 3) {
+ unlockedCrops = unlockedCrops.concat(['tulip', 'tomato', 'daffodil']);
+ }
+ if (playerLevel >= 4) {
+ unlockedCrops = unlockedCrops.concat(['watermelon']);
+ }
+ return unlockedCrops;
+}
function getCropData(cropType) {
var cropData = {
'carrot': {
name: 'Carrot',
@@ -362,8 +385,16 @@
selectedSeedText.anchor.set(1, 0);
selectedSeedText.x = -20;
selectedSeedText.y = 20;
LK.gui.topRight.addChild(selectedSeedText);
+var levelText = new Text2('Level: ' + level, {
+ size: 50,
+ fill: 0xFFFFFF
+});
+levelText.anchor.set(1, 0);
+levelText.x = -20;
+levelText.y = 80;
+LK.gui.topRight.addChild(levelText);
// Shop button
var shopButton = game.addChild(LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
@@ -543,8 +574,24 @@
function updateMoneyDisplay() {
moneyText.setText('Money: $' + money);
storage.money = money;
}
+function updateLevelDisplay() {
+ levelText.setText('Level: ' + level);
+ storage.level = level;
+}
+function checkLevelUp() {
+ var newLevel = 1;
+ if (money >= 500) newLevel = 2;
+ if (money >= 2000) newLevel = 3;
+ if (money >= 8000) newLevel = 4;
+ if (money >= 20000) newLevel = 5;
+ if (newLevel > level) {
+ level = newLevel;
+ updateLevelDisplay();
+ updateShopVisibility();
+ }
+}
function updateInventoryDisplay() {
var totalSeeds = 0;
for (var seedType in inventory) {
totalSeeds += inventory[seedType];
@@ -558,8 +605,23 @@
selectedSeed = null;
}
storage.inventory = inventory;
}
+function updateShopVisibility() {
+ var unlockedCrops = getUnlockedCrops(level);
+ // Update regular shop items
+ carrotShopItem.visible = unlockedCrops.indexOf('carrot') !== -1;
+ strawberryShopItem.visible = unlockedCrops.indexOf('strawberry') !== -1;
+ blueberryShopItem.visible = unlockedCrops.indexOf('blueberry') !== -1;
+ cornShopItem.visible = unlockedCrops.indexOf('corn') !== -1;
+ tulipShopItem.visible = unlockedCrops.indexOf('tulip') !== -1;
+ tomatoShopItem.visible = unlockedCrops.indexOf('tomato') !== -1;
+ daffodilShopItem.visible = unlockedCrops.indexOf('daffodil') !== -1;
+ watermelonShopItem.visible = unlockedCrops.indexOf('watermelon') !== -1;
+ // Update shop button visibility
+ fanmadeShopButton.visible = level >= 4;
+ pondShopButton.visible = level >= 5;
+}
// Shop button handler
shopButton.down = function (x, y, obj) {
if (shopOpen) {
shopOpen = false;
@@ -620,11 +682,13 @@
restartButton.down = function (x, y, obj) {
// Reset all storage data
storage.money = 100;
storage.inventory = {};
+ storage.level = 1;
// Reset game variables
money = 100;
inventory = {};
+ level = 1;
selectedSeed = null;
shopOpen = false;
fanmadeShopOpen = false;
pondShopOpen = false;
@@ -669,12 +733,16 @@
}
// Update displays
updateMoneyDisplay();
updateInventoryDisplay();
+ updateLevelDisplay();
+ updateShopVisibility();
};
// Initialize display
updateMoneyDisplay();
updateInventoryDisplay();
+updateLevelDisplay();
+updateShopVisibility();
game.update = function () {
// Update all plots
for (var i = 0; i < plots.length; i++) {
plots[i].update();