User prompt
Make the Upgrade Cookie Button Bigger!
User prompt
The upgrade cookie still doesn't do anything.
User prompt
The upgrade cookie, you cannot buy it.
User prompt
Can you please add another button? Upgrade.
User prompt
Shop and upgrade buttons go down a tiny bit and not the upgrades itself
User prompt
Make shop and upgrades go down a little bit.
User prompt
make fortune cookie lower
User prompt
Please fix the bug: 'self.getCost is not a function' in or related to this line: 'self.costText = new Text2("Cost: " + self.getCost(), {' Line Number: 125
Code edit (1 edits merged)
Please save this source code
User prompt
Cookie Fortune: The Clicker Quest
Initial prompt
Cookie Clicker
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { crumbs: 0, cookieLevel: 1, totalCrumbs: 0, generators: {}, upgrades: {}, fortunesCollected: 0 }); /**** * Classes ****/ var CrumbParticle = Container.expand(function (startX, startY) { var self = Container.call(this); var crumbGraphic = self.attachAsset('crumb', { anchorX: 0.5, anchorY: 0.5 }); self.x = startX; self.y = startY; self.velocityX = (Math.random() - 0.5) * 10; self.velocityY = -5 - Math.random() * 10; self.rotationSpeed = (Math.random() - 0.5) * 0.2; self.lifespan = 60; // frames self.update = function () { self.velocityY += 0.5; // gravity self.x += self.velocityX; self.y += self.velocityY; self.rotation += self.rotationSpeed; self.lifespan--; if (self.lifespan < 20) { self.alpha = self.lifespan / 20; } return self.lifespan > 0; }; return self; }); var Fortune = Container.expand(function (text, bonus) { var self = Container.call(this); self.text = text; self.bonus = bonus || 0; var background = self.attachAsset('fortunePaper', { anchorX: 0.5, anchorY: 0.5 }); self.fortuneText = new Text2('"' + text + '"', { size: 36, fill: 0x333333 }); self.fortuneText.anchor.set(0.5, 0.5); self.addChild(self.fortuneText); if (bonus > 0) { self.bonusText = new Text2("+" + bonus + "% crumbs", { size: 30, fill: 0x009900 }); self.bonusText.anchor.set(0.5, 0.5); self.bonusText.position.set(0, 80); self.addChild(self.bonusText); } self.show = function () { self.scale.set(0.1); tween(self.scale, { x: 1, y: 1 }, { duration: 500, easing: tween.elasticOut }); }; self.hide = function (callback) { tween(self.scale, { x: 0, y: 0 }, { duration: 300, easing: tween.easeIn, onFinish: function onFinish() { if (callback) { callback(); } } }); }; return self; }); var FortuneGenerator = Container.expand(function (type, level, baseCost, baseOutput) { var self = Container.call(this); self.type = type; self.level = level || 0; self.baseCost = baseCost; self.baseOutput = baseOutput; self.getCost = function () { return Math.floor(self.baseCost * Math.pow(1.15, self.level)); }; self.getOutput = function () { return self.baseOutput * self.level; }; var background = self.attachAsset('generatorShape', { anchorX: 0, anchorY: 0, width: 350, height: 100 }); self.nameText = new Text2(type, { size: 40, fill: 0xFFFFFF }); self.nameText.position.set(10, 10); self.addChild(self.nameText); self.levelText = new Text2("Lvl: " + self.level, { size: 30, fill: 0xFFFFFF }); self.levelText.position.set(10, 60); self.addChild(self.levelText); self.costText = new Text2("Cost: " + self.getCost(), { size: 30, fill: 0xFFFF00 }); self.costText.position.set(180, 60); self.addChild(self.costText); self.outputText = new Text2(self.getOutput() + "/s", { size: 30, fill: 0x90FF90 }); self.outputText.position.set(180, 10); self.addChild(self.outputText); self.levelUp = function () { if (crumbs >= self.getCost()) { crumbs -= self.getCost(); self.level++; self.updateTexts(); LK.getSound('purchase').play(); return true; } return false; }; self.updateTexts = function () { self.levelText.setText("Lvl: " + self.level); self.costText.setText("Cost: " + self.getCost()); self.outputText.setText(self.getOutput() + "/s"); }; self.down = function (x, y, obj) { if (self.levelUp()) { storage.generators[self.type] = self.level; updateCrumbsText(); } }; return self; }); var UpgradeButton = Container.expand(function (name, description, cost, effect, purchased) { var self = Container.call(this); self.name = name; self.description = description; self.cost = cost; self.effect = effect; self.purchased = purchased || false; var background = self.attachAsset('buttonShape', { anchorX: 0, anchorY: 0, width: 500, height: 80 }); self.nameText = new Text2(name, { size: 36, fill: self.purchased ? "#90FF90" : "#FFFFFF" }); self.nameText.position.set(10, 10); self.addChild(self.nameText); self.descText = new Text2(description, { size: 24, fill: 0xEEEEEE }); self.descText.position.set(10, 50); self.addChild(self.descText); self.costText = new Text2("Cost: " + cost, { size: 30, fill: 0xFFFF00 }); self.costText.position.set(350, 25); self.addChild(self.costText); self.purchase = function () { if (!self.purchased && crumbs >= self.cost) { crumbs -= self.cost; self.purchased = true; storage.upgrades[self.name] = true; self.nameText.fill = "#90FF90"; self.costText.setText("PURCHASED"); self.effect(); LK.getSound('purchase').play(); updateCrumbsText(); return true; } return false; }; self.down = function (x, y, obj) { self.purchase(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game variables var crumbs = storage.crumbs || 0; var cookieLevel = storage.cookieLevel || 1; var totalCrumbs = storage.totalCrumbs || 0; var crumbsPerClick = 1; var crumbsPerSecond = 0; var lastUpdateTime = Date.now(); var fortuneChance = 0.05; var particles = []; var cookieScale = 1; var fortuneQuotes = ["A cookie a day keeps sadness away.", "Your future is crumby... in a good way!", "Great wealth awaits those who click cookies.", "Today's lucky numbers: 3, 7, 42, 108.", "You will soon embark on a delicious journey.", "A tasty fortune is on the horizon.", "Fame and cookies go hand in hand.", "Someone is thinking of you while eating cookies.", "Your cookie empire will reach new heights.", "Wisely invest in your cookie future."]; var fortunesCollected = storage.fortunesCollected || 0; // Create cookie var fortuneCookie = game.addChild(new Container()); var cookieGraphic = fortuneCookie.attachAsset('fortuneCookie', { anchorX: 0.5, anchorY: 0.5, scaleX: 1, scaleY: 1 }); fortuneCookie.x = 2048 / 2; fortuneCookie.y = 1200; // Create UI elements var crumbsText = new Text2("Crumbs: 0", { size: 60, fill: 0xFFFFFF }); crumbsText.anchor.set(0.5, 0); LK.gui.top.addChild(crumbsText); var cpsText = new Text2("0 per second", { size: 40, fill: 0xFFFFFF }); cpsText.anchor.set(0.5, 0); cpsText.y = 70; LK.gui.top.addChild(cpsText); // Create tab buttons var shopButton = new Container(); var shopButtonBg = shopButton.attachAsset('buttonShape', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 60 }); var shopButtonText = new Text2("SHOP", { size: 40, fill: 0xFFFFFF }); shopButtonText.anchor.set(0.5, 0.5); shopButton.addChild(shopButtonText); shopButton.x = 2048 / 2 - 150; shopButton.y = 180; game.addChild(shopButton); var upgradesButton = new Container(); var upgradesBg = upgradesButton.attachAsset('buttonShape', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 60 }); var upgradesText = new Text2("UPGRADES", { size: 40, fill: 0xFFFFFF }); upgradesText.anchor.set(0.5, 0.5); upgradesButton.addChild(upgradesText); upgradesButton.x = 2048 / 2 + 150; upgradesButton.y = 180; game.addChild(upgradesButton); // Create tab containers var shopContainer = new Container(); game.addChild(shopContainer); shopContainer.visible = true; var upgradesContainer = new Container(); game.addChild(upgradesContainer); upgradesContainer.visible = false; // Create generators for shop var generators = [{ type: "Auto-Clicker", baseCost: 15, baseOutput: 0.1 }, { type: "Crumb Farm", baseCost: 100, baseOutput: 1 }, { type: "Crumb Factory", baseCost: 1100, baseOutput: 8 }, { type: "Cookie Mine", baseCost: 12000, baseOutput: 47 }, { type: "Crumb Bank", baseCost: 130000, baseOutput: 260 }]; // Create upgrades list var upgrades = [{ name: "Better Fingers", description: "Double clicking power", cost: 100, effect: function effect() { crumbsPerClick *= 2; } }, { name: "Golden Fortune", description: "10% more crumbs per click", cost: 500, effect: function effect() { crumbsPerClick *= 1.1; } }, { name: "Lucky Clicker", description: "5% chance of double crumbs", cost: 1000, effect: function effect() {} }, { name: "Wisdom Cookies", description: "Fortune cookies give 5% production boost", cost: 2500, effect: function effect() {} }, { name: "Crumbly Touch", description: "Triple clicking power", cost: 10000, effect: function effect() { crumbsPerClick *= 3; } }]; // Populate shop with generators var generatorObjects = {}; for (var i = 0; i < generators.length; i++) { var gen = generators[i]; var genObj = new FortuneGenerator(gen.type, storage.generators[gen.type] || 0, gen.baseCost, gen.baseOutput); genObj.x = 1024 - 175; genObj.y = 350 + i * 120; shopContainer.addChild(genObj); generatorObjects[gen.type] = genObj; } // Populate upgrades tab var upgradeObjects = {}; for (var i = 0; i < upgrades.length; i++) { var upg = upgrades[i]; var purchased = storage.upgrades[upg.name] || false; var upgObj = new UpgradeButton(upg.name, upg.description, upg.cost, upg.effect, purchased); if (purchased) { upg.effect(); // Apply effect of purchased upgrades } upgObj.x = 1024 - 250; upgObj.y = 350 + i * 100; upgradesContainer.addChild(upgObj); upgradeObjects[upg.name] = upgObj; } // Fortune display area var fortuneDisplay = new Container(); fortuneDisplay.x = 2048 / 2; fortuneDisplay.y = 1500; fortuneDisplay.visible = false; game.addChild(fortuneDisplay); // Helper functions function updateCrumbsText() { crumbsText.setText("Crumbs: " + Math.floor(crumbs)); storage.crumbs = crumbs; storage.totalCrumbs = totalCrumbs; } function calculateCrumbsPerSecond() { var cps = 0; for (var key in generatorObjects) { var gen = generatorObjects[key]; cps += gen.getOutput(); } return cps; } function spawnCrumbParticles(x, y, count) { for (var i = 0; i < count; i++) { var particle = new CrumbParticle(x, y); particles.push(particle); game.addChild(particle); } } function showFortune() { var randomIndex = Math.floor(Math.random() * fortuneQuotes.length); var bonus = Math.random() < 0.3 ? Math.floor(Math.random() * 5) + 1 : 0; var fortune = new Fortune(fortuneQuotes[randomIndex], bonus); fortuneDisplay.removeChildren(); fortuneDisplay.addChild(fortune); fortuneDisplay.visible = true; fortunesCollected++; storage.fortunesCollected = fortunesCollected; LK.getSound('fortune').play(); fortune.show(); LK.setTimeout(function () { fortune.hide(function () { fortuneDisplay.visible = false; }); }, 3000); // Apply bonus if there is one if (bonus > 0 && upgradeObjects["Wisdom Cookies"] && upgradeObjects["Wisdom Cookies"].purchased) { crumbsPerSecond *= 1 + bonus / 100; // This effect is temporary LK.setTimeout(function () { crumbsPerSecond = calculateCrumbsPerSecond(); }, 30000); // 30 seconds of bonus } } // Tab switching logic shopButton.down = function () { shopContainer.visible = true; upgradesContainer.visible = false; tween(shopButton.scale, { x: 1.1, y: 1.1 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { tween(shopButton.scale, { x: 1, y: 1 }, { duration: 100, easing: tween.easeIn }); } }); }; upgradesButton.down = function () { shopContainer.visible = false; upgradesContainer.visible = true; tween(upgradesButton.scale, { x: 1.1, y: 1.1 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { tween(upgradesButton.scale, { x: 1, y: 1 }, { duration: 100, easing: tween.easeIn }); } }); }; // Cookie click handler fortuneCookie.down = function (x, y) { // Apply click effect tween(fortuneCookie.scale, { x: 0.9, y: 0.9 }, { duration: 50, easing: tween.easeOut, onFinish: function onFinish() { tween(fortuneCookie.scale, { x: cookieScale, y: cookieScale }, { duration: 200, easing: tween.elasticOut }); } }); // Add crumbs var clickAmount = crumbsPerClick; // Check for Lucky Clicker upgrade if (upgradeObjects["Lucky Clicker"] && upgradeObjects["Lucky Clicker"].purchased) { if (Math.random() < 0.05) { clickAmount *= 2; // Flash the cookie gold to indicate lucky click tween(cookieGraphic, { tint: 0xFFD700 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { tween(cookieGraphic, { tint: 0xE6B142 }, { duration: 300, easing: tween.easeIn }); } }); } } crumbs += clickAmount; totalCrumbs += clickAmount; // Spawn particles spawnCrumbParticles(fortuneCookie.x, fortuneCookie.y, 5); // Play sound LK.getSound('cookieClick').play(); // Update display updateCrumbsText(); // Check for fortune if (Math.random() < fortuneChance) { showFortune(); } }; // Initialize CPS crumbsPerSecond = calculateCrumbsPerSecond(); // Play background music LK.playMusic('bgmusic', { fade: { start: 0, end: 0.3, duration: 1000 } }); // Main game loop game.update = function () { // Update time-based resources var now = Date.now(); var deltaTime = (now - lastUpdateTime) / 1000; // Convert to seconds lastUpdateTime = now; // Add automatic crumbs var crumbsToAdd = crumbsPerSecond * deltaTime; crumbs += crumbsToAdd; totalCrumbs += crumbsToAdd; // Update display every 10 frames to avoid performance issues if (LK.ticks % 10 === 0) { updateCrumbsText(); cpsText.setText(crumbsPerSecond.toFixed(1) + " per second"); } // Every second, recalculate CPS if (LK.ticks % 60 === 0) { crumbsPerSecond = calculateCrumbsPerSecond(); } // Update cookie scale based on total crumbs if (totalCrumbs >= 1000 && cookieLevel === 1) { cookieLevel = 2; cookieScale = 1.2; tween(fortuneCookie.scale, { x: cookieScale, y: cookieScale }, { duration: 1000, easing: tween.elasticOut }); storage.cookieLevel = cookieLevel; updateUpgradeCost(); } else if (totalCrumbs >= 10000 && cookieLevel === 2) { cookieLevel = 3; cookieScale = 1.4; tween(fortuneCookie.scale, { x: cookieScale, y: cookieScale }, { duration: 1000, easing: tween.elasticOut }); storage.cookieLevel = cookieLevel; updateUpgradeCost(); } else if (totalCrumbs >= 100000 && cookieLevel === 3) { cookieLevel = 4; cookieScale = 1.6; tween(fortuneCookie.scale, { x: cookieScale, y: cookieScale }, { duration: 1000, easing: tween.elasticOut }); storage.cookieLevel = cookieLevel; updateUpgradeCost(); } // Update particles for (var i = particles.length - 1; i >= 0; i--) { var alive = particles[i].update(); if (!alive) { particles[i].destroy(); particles.splice(i, 1); } } }; // Restore stored cookie level if (cookieLevel > 1) { fortuneCookie.scale.set(cookieScale, cookieScale); } // Create upgrade button at bottom of screen var upgradeButton = new Container(); var upgradeButtonBg = upgradeButton.attachAsset('buttonShape', { anchorX: 0.5, anchorY: 0.5, width: 500, height: 120 }); var upgradeButtonText = new Text2("UPGRADE COOKIE", { size: 60, fill: 0xFFFFFF }); upgradeButtonText.anchor.set(0.5, 0.5); upgradeButton.addChild(upgradeButtonText); // Add cost display var upgradeCost = Math.floor(500 * Math.pow(5, cookieLevel - 1)); var costText = new Text2("Cost: " + upgradeCost, { size: 40, fill: 0xFFFF00 }); costText.anchor.set(0.5, 0.5); costText.y = 35; upgradeButton.addChild(costText); // Function to update the cost display function updateUpgradeCost() { var upgradeCost = Math.floor(500 * Math.pow(5, cookieLevel - 1)); costText.setText("Cost: " + upgradeCost); } // Position at bottom center of screen upgradeButton.x = 2048 / 2; upgradeButton.y = 2400; // Add click handler upgradeButton.down = function () { // Calculate upgrade cost based on current level var upgradeCost = Math.floor(500 * Math.pow(5, cookieLevel - 1)); // Check if player has enough crumbs if (crumbs >= upgradeCost) { // Deduct cost crumbs -= upgradeCost; // Increase cookie level cookieLevel += 1; // Save to storage storage.cookieLevel = cookieLevel; // Increase cookie scale cookieScale += 0.2; // Increase crumbs per click crumbsPerClick *= 2; // Animate cookie growth tween(fortuneCookie.scale, { x: cookieScale, y: cookieScale }, { duration: 1000, easing: tween.elasticOut, onFinish: function onFinish() { // Flash gold to indicate successful upgrade tween(cookieGraphic, { tint: 0xFFD700 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { tween(cookieGraphic, { tint: 0xE6B142 }, { duration: 300, easing: tween.easeIn }); } }); } }); // Play purchase sound LK.getSound('purchase').play(); // Update crumbs display updateCrumbsText(); } else { // Not enough crumbs - flash red tween(upgradeButtonBg, { tint: 0xFF0000 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { tween(upgradeButtonBg, { tint: 0xc09030 }, { duration: 500, easing: tween.easeIn }); } }); } }; // Add to game game.addChild(upgradeButton); // Initial display update updateCrumbsText();
===================================================================
--- original.js
+++ change.js
@@ -601,25 +601,25 @@
var upgradeButton = new Container();
var upgradeButtonBg = upgradeButton.attachAsset('buttonShape', {
anchorX: 0.5,
anchorY: 0.5,
- width: 300,
- height: 80
+ width: 500,
+ height: 120
});
var upgradeButtonText = new Text2("UPGRADE COOKIE", {
- size: 40,
+ size: 60,
fill: 0xFFFFFF
});
upgradeButtonText.anchor.set(0.5, 0.5);
upgradeButton.addChild(upgradeButtonText);
// Add cost display
var upgradeCost = Math.floor(500 * Math.pow(5, cookieLevel - 1));
var costText = new Text2("Cost: " + upgradeCost, {
- size: 26,
+ size: 40,
fill: 0xFFFF00
});
costText.anchor.set(0.5, 0.5);
-costText.y = 30;
+costText.y = 35;
upgradeButton.addChild(costText);
// Function to update the cost display
function updateUpgradeCost() {
var upgradeCost = Math.floor(500 * Math.pow(5, cookieLevel - 1));