User prompt
Remove the enemies and make upgrade cookie not free anymore.
User prompt
Make it so that there is not a limit to the upgrade cookie.
User prompt
Make the enemies a lot faster.
User prompt
Make the enemies faster.
User prompt
make it so that when you die you get infinite crumbs and add enemies
User prompt
Give me zero crumbs.
User prompt
Make it so that Lucky Gambler and Bob's Friend restart when hit the restart button.
User prompt
Make it so that Lucky Gambler and Bob's friend restart when either hit the rebirth button or the restart button.
User prompt
Make Bob be able to go below 20 clicks.
User prompt
Give me a trillion crumbs.
User prompt
Make a restart button.
User prompt
make a gun
User prompt
Make an upgrade so that Bob's clicks go down.
User prompt
Make it so you can buy Lucky Gambler multiple times.
User prompt
Make Lucky Gambler in the shop.
User prompt
make an upgrade that upgrades your chance of winning when you gamble
User prompt
Make gambling.
User prompt
Make it so when Bob says something, it's beside him instead of above.
User prompt
make it if you click Bob 100 times he gives you a thousand crumbs
User prompt
Moves Bob a little bit up.
User prompt
Put Bob above the rebirth button.
User prompt
Make a dude named Bob.
User prompt
Make you have to have one million cookies to buy the Rebirth. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
I can't buy the rebirth button.
User prompt
Make a rebirth button.
/**** * 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, rebirthBonus: 1 }); /**** * Classes ****/ var Bob = Container.expand(function () { var self = Container.call(this); // Track number of clicks on Bob self.clickCount = 0; // Create Bob's body - a simple box shape var bobBody = self.attachAsset('generatorShape', { anchorX: 0.5, anchorY: 0.5, width: 100, height: 150 }); bobBody.tint = 0x4287f5; // Blue color for Bob // Create Bob's head var bobHead = self.attachAsset('crumb', { anchorX: 0.5, anchorY: 0.5, scaleX: 5, scaleY: 5 }); bobHead.y = -100; bobHead.tint = 0xFFE0BD; // Skin tone // Add Bob's name var nameText = new Text2("Bob", { size: 40, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.y = -150; self.addChild(nameText); // Add click counter text self.clickCountText = new Text2("Clicks: 0/100", { size: 30, fill: 0xFFFF00 }); self.clickCountText.anchor.set(0.5, 0.5); self.clickCountText.y = -180; self.addChild(self.clickCountText); // Add some animation to Bob self.update = function () { self.rotation = Math.sin(LK.ticks / 60) * 0.05; }; // Make Bob interactive self.down = function (x, y, obj) { tween(self.scale, { x: 0.9, y: 0.9 }, { duration: 50, easing: tween.easeOut, onFinish: function onFinish() { tween(self.scale, { x: 1, y: 1 }, { duration: 200, easing: tween.elasticOut }); } }); // Increment click count self.clickCount++; self.clickCountText.setText("Clicks: " + self.clickCount + "/100"); // Get Bob's Friend upgrade level if purchased var bobsFriendLevel = 0; if (upgradeObjects["Bob's Friend"] && upgradeObjects["Bob's Friend"].purchased) { bobsFriendLevel = upgradeObjects["Bob's Friend"].level || 1; } // Calculate clicks needed based on upgrade level (20% reduction per level) var clicksNeeded = 100; if (bobsFriendLevel > 0) { clicksNeeded = Math.max(1, Math.floor(100 * Math.pow(0.8, bobsFriendLevel))); } // Update text to show correct number of clicks needed self.clickCountText.setText("Clicks: " + self.clickCount + "/" + clicksNeeded); // Check if we've reached the required number of clicks if (self.clickCount >= clicksNeeded) { // Give reward of 1000 crumbs crumbs += 1000; totalCrumbs += 1000; updateCrumbsText(); // Reset click count for future rewards self.clickCount = 0; self.clickCountText.setText("Clicks: 0/" + clicksNeeded); // Celebration effect LK.effects.flashObject(self, 0xFFD700, 1000); // Special message for reward self.sayText("Here's 1000 crumbs for you!"); // Spawn particles around Bob spawnCrumbParticles(self.x, self.y, 20); } else { // Say something when clicked var phrases = ["Hello!", "I'm Bob!", "Nice to meet you!", "How are you?", "Have a nice day!", "Keep clicking!", "You're getting closer!", "Almost there!", "Don't give up!"]; var randomPhrase = phrases[Math.floor(Math.random() * phrases.length)]; // Only show speech bubble every 5 clicks to avoid spam if (self.clickCount % 5 === 0) { self.sayText(randomPhrase); } } }; // Method to make Bob say something self.sayText = function (text) { // Remove any existing speech bubble if (self.speechBubble) { self.speechBubble.destroy(); } // Create speech bubble self.speechBubble = new Container(); var bubble = self.speechBubble.attachAsset('fortunePaper', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 100 }); var speechText = new Text2(text, { size: 30, fill: 0x000000 }); speechText.anchor.set(0.5, 0.5); self.speechBubble.addChild(speechText); // Position speech bubble beside Bob instead of above self.speechBubble.x = 200; self.speechBubble.y = 0; self.addChild(self.speechBubble); // Animate speech bubble appearance self.speechBubble.scale.set(0.1, 0.1); tween(self.speechBubble.scale, { x: 1, y: 1 }, { duration: 300, easing: tween.elasticOut }); // Make the speech bubble disappear after a few seconds LK.setTimeout(function () { if (self.speechBubble) { tween(self.speechBubble.scale, { x: 0, y: 0 }, { duration: 200, easing: tween.easeIn, onFinish: function onFinish() { if (self.speechBubble) { self.speechBubble.destroy(); self.speechBubble = null; } } }); } }, 3000); }; return self; }); 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 Enemy = Container.expand(function (type, speed, health) { var self = Container.call(this); self.type = type || "Basic"; self.speed = speed || 2; self.maxHealth = health || 100; self.health = self.maxHealth; self.isDead = false; // Create enemy body var enemyBody = self.attachAsset('generatorShape', { anchorX: 0.5, anchorY: 0.5, width: 80, height: 80 }); enemyBody.tint = 0xFF0000; // Red color for enemies // Create health bar background var healthBarBg = self.attachAsset('buttonShape', { anchorX: 0.5, anchorY: 0.5, width: 60, height: 8 }); healthBarBg.tint = 0x000000; healthBarBg.y = -50; // Create health bar self.healthBar = self.attachAsset('buttonShape', { anchorX: 0, anchorY: 0.5, width: 60, height: 6 }); self.healthBar.tint = 0x00FF00; self.healthBar.x = -30; self.healthBar.y = -50; // Enemy name var nameText = new Text2(self.type + " Enemy", { size: 24, fill: 0xFFFFFF }); nameText.anchor.set(0.5, 0.5); nameText.y = -70; self.addChild(nameText); // Movement pattern self.direction = 1; self.startX = 0; self.update = function () { if (self.isDead) return; // Move horizontally self.x += self.speed * self.direction; // Bounce off screen edges if (self.x <= 100 || self.x >= 2048 - 100) { self.direction *= -1; self.y += 50; // Move down when hitting edge } // Check if enemy reached bottom (player loses) if (self.y >= 2732 - 200) { self.triggerPlayerDeath(); } // Animate enemy self.rotation = Math.sin(LK.ticks / 30) * 0.1; }; self.takeDamage = function (damage) { if (self.isDead) return; self.health -= damage; // Update health bar var healthPercent = self.health / self.maxHealth; self.healthBar.width = 60 * healthPercent; // Change health bar color based on health if (healthPercent > 0.6) { self.healthBar.tint = 0x00FF00; // Green } else if (healthPercent > 0.3) { self.healthBar.tint = 0xFFFF00; // Yellow } else { self.healthBar.tint = 0xFF0000; // Red } // Flash when taking damage tween(enemyBody, { tint: 0xFFFFFF }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { tween(enemyBody, { tint: 0xFF0000 }, { duration: 100, easing: tween.easeIn }); } }); if (self.health <= 0) { self.die(); } }; self.die = function () { self.isDead = true; // Death animation tween(self.scale, { x: 0, y: 0 }, { duration: 300, easing: tween.easeIn, onFinish: function onFinish() { // Remove from enemies array for (var i = enemies.length - 1; i >= 0; i--) { if (enemies[i] === self) { enemies.splice(i, 1); break; } } self.destroy(); } }); // Reward player crumbs += 100; totalCrumbs += 100; updateCrumbsText(); // Spawn particles spawnCrumbParticles(self.x, self.y, 10); }; self.triggerPlayerDeath = function () { // Give player infinite crumbs when they die crumbs = Number.MAX_SAFE_INTEGER; totalCrumbs = Number.MAX_SAFE_INTEGER; updateCrumbsText(); // Flash screen red to indicate death LK.effects.flashScreen(0xFF0000, 2000); // Show message var deathMessage = new Text2("YOU DIED! But gained infinite crumbs!", { size: 60, fill: 0xFFFFFF }); deathMessage.anchor.set(0.5, 0.5); deathMessage.x = 2048 / 2; deathMessage.y = 2732 / 2; game.addChild(deathMessage); // Remove message after delay LK.setTimeout(function () { deathMessage.destroy(); }, 4000); // Clear all enemies for (var i = enemies.length - 1; i >= 0; i--) { enemies[i].destroy(); } enemies = []; }; // Make enemy clickable to attack self.down = function (x, y, obj) { self.takeDamage(25); }; 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 RebirthButton = Container.expand(function (cost, bonus) { var self = Container.call(this); self.cost = 1000000; // Always require exactly one million cookies self.bonus = bonus || 1.5; var background = self.attachAsset('buttonShape', { anchorX: 0.5, anchorY: 0.5, width: 500, height: 120 }); background.tint = 0xAA2020; var buttonText = new Text2("REBIRTH", { size: 60, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); buttonText.y = -20; self.addChild(buttonText); var costText = new Text2("Cost: 1,000,000 crumbs", { size: 30, fill: 0xFFFF00 }); costText.anchor.set(0.5, 0.5); costText.y = 20; self.addChild(costText); var descriptionText = new Text2("Reset for +" + Math.round((self.bonus - 1) * 100) + "% permanent bonus", { size: 30, fill: 0xFFFFFF }); descriptionText.anchor.set(0.5, 0.5); descriptionText.y = 50; self.addChild(descriptionText); self.down = function (x, y, obj) { if (crumbs >= 1000000) { // Always check for exactly one million // Store the rebirth bonus var currentBonus = storage.rebirthBonus || 1; var newBonus = currentBonus * self.bonus; storage.rebirthBonus = newBonus; // Reset game progress but keep rebirth bonus crumbs = 0; cookieLevel = 1; cookieScale = 1; fortuneCookie.scale.set(1, 1); // Reset generators for (var key in generatorObjects) { var gen = generatorObjects[key]; gen.level = 0; gen.updateTexts(); storage.generators[gen.type] = 0; } // Reset upgrades but keep the rebirth bonus for (var key in upgradeObjects) { var upg = upgradeObjects[key]; upg.purchased = false; upg.nameText.fill = "#FFFFFF"; upg.costText.setText("Cost: " + upg.cost); storage.upgrades[key] = false; // Reset levels for multi-purchase upgrades if (upg.isMultiPurchase) { upg.level = 0; storage.upgrades[key + "Level"] = 0; } } // Increase base clicking power based on rebirth bonus crumbsPerClick = 1 * newBonus; // Keep total crumbs for progress tracking but reset current totalCrumbs = 0; storage.totalCrumbs = totalCrumbs; storage.crumbs = 0; // Update the display updateCrumbsText(); crumbsPerSecond = calculateCrumbsPerSecond(); // Show effect LK.effects.flashScreen(0xAA2020, 1000); } else { // Not enough crumbs - flash button red tween(background, { tint: 0xFF0000 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { tween(background, { tint: 0xAA2020 }, { duration: 500, easing: tween.easeIn }); } }); } }; return self; }); var RestartButton = Container.expand(function () { var self = Container.call(this); // Create button background var background = self.attachAsset('buttonShape', { anchorX: 0.5, anchorY: 0.5, width: 300, height: 80 }); background.tint = 0x3080A0; // Blue-ish color // Create button text var buttonText = new Text2("RESTART", { size: 45, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); // Add press animation self.down = function (x, y, obj) { // Confirm restart with player tween(self.scale, { x: 0.9, y: 0.9 }, { duration: 50, easing: tween.easeOut, onFinish: function onFinish() { tween(self.scale, { x: 1, y: 1 }, { duration: 200, easing: tween.elasticOut }); } }); // Reset all game progress crumbs = 0; cookieLevel = 1; cookieScale = 1; fortuneCookie.scale.set(1, 1); // Reset generators for (var key in generatorObjects) { var gen = generatorObjects[key]; gen.level = 0; gen.updateTexts(); storage.generators[gen.type] = 0; } // Reset upgrades but keep the rebirth bonus for (var key in upgradeObjects) { var upg = upgradeObjects[key]; upg.purchased = false; upg.nameText.fill = "#FFFFFF"; upg.costText.setText("Cost: " + upg.cost); storage.upgrades[key] = false; // Reset levels for multi-purchase upgrades if (upg.isMultiPurchase) { upg.level = 0; storage.upgrades[key + "Level"] = 0; } } // Specifically reset Lucky Gambler upgrade if (upgradeObjects["Lucky Gambler"]) { upgradeObjects["Lucky Gambler"].purchased = false; upgradeObjects["Lucky Gambler"].level = 0; upgradeObjects["Lucky Gambler"].nameText.fill = "#FFFFFF"; upgradeObjects["Lucky Gambler"].costText.setText("Cost: " + 5000); storage.upgrades["Lucky Gambler"] = false; storage.upgrades["Lucky GamblerLevel"] = 0; } // Specifically reset Bob's Friend upgrade if (upgradeObjects["Bob's Friend"]) { upgradeObjects["Bob's Friend"].purchased = false; upgradeObjects["Bob's Friend"].level = 0; upgradeObjects["Bob's Friend"].nameText.fill = "#FFFFFF"; upgradeObjects["Bob's Friend"].costText.setText("Cost: " + 2000); storage.upgrades["Bob's Friend"] = false; storage.upgrades["Bob's FriendLevel"] = 0; } // Reset to base clicking power with rebirth bonus crumbsPerClick = 1 * rebirthBonus; // Reset total crumbs totalCrumbs = 0; storage.totalCrumbs = totalCrumbs; storage.crumbs = 0; // Update the display updateCrumbsText(); crumbsPerSecond = calculateCrumbsPerSecond(); // Update upgrade cost updateUpgradeCost(); // Visual effect for restart LK.effects.flashScreen(0x3080A0, 1000); }; return self; }); var SlotMachine = Container.expand(function () { var self = Container.call(this); // Create slot machine background var background = self.attachAsset('buttonShape', { anchorX: 0.5, anchorY: 0.5, width: 700, height: 400 }); background.tint = 0x222222; // Create title var titleText = new Text2("CRUMB SLOTS", { size: 50, fill: 0xFFD700 }); titleText.anchor.set(0.5, 0.5); titleText.y = -150; self.addChild(titleText); // Create reels self.reels = []; var reelSymbols = ["7️⃣", "🍪", "💰", "✨", "🎲"]; var reelPositions = [-120, 0, 120]; for (var i = 0; i < 3; i++) { var reel = new Container(); reel.x = reelPositions[i]; var reelBg = reel.attachAsset('buttonShape', { anchorX: 0.5, anchorY: 0.5, width: 150, height: 150 }); reelBg.tint = 0xFFFFFF; var symbolText = new Text2(reelSymbols[Math.floor(Math.random() * reelSymbols.length)], { size: 80, fill: 0x000000 }); symbolText.anchor.set(0.5, 0.5); reel.addChild(symbolText); reel.symbol = symbolText; reel.currentSymbol = symbolText.text; self.reels.push(reel); self.addChild(reel); } // Create bet buttons self.currentBet = 10; var betOptions = [10, 50, 100, 500, 1000]; self.betIndex = 0; var betButton = new Container(); var betBg = betButton.attachAsset('buttonShape', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 60 }); betBg.tint = 0x30c090; self.betText = new Text2("BET: " + self.currentBet, { size: 30, fill: 0xFFFFFF }); self.betText.anchor.set(0.5, 0.5); betButton.addChild(self.betText); betButton.y = 80; betButton.x = -150; self.addChild(betButton); // Create spin button var spinButton = new Container(); var spinBg = spinButton.attachAsset('buttonShape', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 60 }); spinBg.tint = 0xFF4500; var spinText = new Text2("SPIN!", { size: 30, fill: 0xFFFFFF }); spinText.anchor.set(0.5, 0.5); spinButton.addChild(spinText); spinButton.y = 80; spinButton.x = 150; self.addChild(spinButton); // Result text self.resultText = new Text2("", { size: 36, fill: 0xFFFFFF }); self.resultText.anchor.set(0.5, 0.5); self.resultText.y = 150; self.addChild(self.resultText); // Spinning state self.spinning = false; // Bet button handler betButton.down = function () { if (self.spinning) { return; } self.betIndex = (self.betIndex + 1) % betOptions.length; self.currentBet = betOptions[self.betIndex]; self.betText.setText("BET: " + self.currentBet); tween(betButton.scale, { x: 1.1, y: 1.1 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { tween(betButton.scale, { x: 1, y: 1 }, { duration: 100, easing: tween.easeIn }); } }); }; // Spin button handler spinButton.down = function () { if (self.spinning) { return; } // Check if player has enough crumbs if (crumbs < self.currentBet) { self.resultText.setText("Not enough crumbs!"); self.resultText.fill = 0xFF0000; tween(spinBg, { tint: 0xFF0000 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { tween(spinBg, { tint: 0xFF4500 }, { duration: 500, easing: tween.easeIn }); } }); return; } // Deduct bet amount crumbs -= self.currentBet; updateCrumbsText(); // Start spinning self.spinning = true; self.resultText.setText("Spinning..."); self.resultText.fill = 0xFFFFFF; // Animate spin button tween(spinButton.scale, { x: 0.9, y: 0.9 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { tween(spinButton.scale, { x: 1, y: 1 }, { duration: 100, easing: tween.easeIn }); } }); // Spin each reel with slight delay between them self.spinReels(); }; // Spin reels function self.spinReels = function () { var spinDurations = [1500, 2000, 2500]; // Different durations for each reel var spinFrames = [20, 25, 30]; // How many symbol changes per reel // For each reel for (var i = 0; i < self.reels.length; i++) { (function (index) { var reel = self.reels[index]; var frameCount = 0; // Create spinning interval for this reel var spinInterval = LK.setInterval(function () { // Change symbol var newSymbol = reelSymbols[Math.floor(Math.random() * reelSymbols.length)]; reel.symbol.setText(newSymbol); reel.currentSymbol = newSymbol; // Animate symbol change reel.scale.set(1.1, 1.1); tween(reel.scale, { x: 1, y: 1 }, { duration: 100, easing: tween.easeOut }); frameCount++; // Stop spinning after defined frames if (frameCount >= spinFrames[index]) { LK.clearInterval(spinInterval); // If this is the last reel, check results if (index === self.reels.length - 1) { LK.setTimeout(function () { self.checkResults(); }, 500); } } }, 100); })(i); } }; // Check results function self.checkResults = function () { var symbols = self.reels.map(function (reel) { return reel.currentSymbol; }); // Check if Lucky Gambler upgrade is purchased and get level var luckyGamblerLevel = 0; if (upgradeObjects["Lucky Gambler"] && upgradeObjects["Lucky Gambler"].purchased) { luckyGamblerLevel = upgradeObjects["Lucky Gambler"].level || 1; } // With Lucky Gambler upgrade, there's a chance to improve outcome - improves with level if (luckyGamblerLevel > 0) { // Base chance 15%, increases by 5% per level var matchChance = 0.15 + (luckyGamblerLevel - 1) * 0.05; matchChance = Math.min(matchChance, 0.5); // Cap at 50% chance if (Math.random() < matchChance) { // Make at least two symbols match var symbolToMatch = symbols[Math.floor(Math.random() * symbols.length)]; var indices = [0, 1, 2]; // Randomly select two positions to match indices.sort(function () { return Math.random() - 0.5; }); symbols[indices[0]] = symbolToMatch; symbols[indices[1]] = symbolToMatch; // At level 3+, small chance to make all three match if (luckyGamblerLevel >= 3 && Math.random() < 0.2) { symbols[indices[2]] = symbolToMatch; self.reels[indices[2]].symbol.setText(symbolToMatch); self.reels[indices[2]].currentSymbol = symbolToMatch; } // Update the visual display of reels self.reels[indices[0]].symbol.setText(symbolToMatch); self.reels[indices[0]].currentSymbol = symbolToMatch; self.reels[indices[1]].symbol.setText(symbolToMatch); self.reels[indices[1]].currentSymbol = symbolToMatch; } } var allSame = symbols[0] === symbols[1] && symbols[1] === symbols[2]; var twoSame = symbols[0] === symbols[1] || symbols[1] === symbols[2] || symbols[0] === symbols[2]; var winAmount = 0; var resultMessage = ""; var resultColor = 0xFF0000; // Determine win amount based on results if (allSame) { // Jackpot for three 7s if (symbols[0] === "7️⃣") { // Increase jackpot with Lucky Gambler upgrade var baseJackpot = 50; var jackpotMultiplier = baseJackpot; if (luckyGamblerLevel > 0) { // Each level adds 25% to jackpot multiplier jackpotMultiplier = baseJackpot * (1 + 0.25 * luckyGamblerLevel); } winAmount = self.currentBet * jackpotMultiplier; resultMessage = "JACKPOT! " + winAmount + " CRUMBS!"; resultColor = 0xFFD700; // Special effects for jackpot LK.effects.flashScreen(0xFFD700, 1000); for (var i = 0; i < 5 + luckyGamblerLevel; i++) { spawnCrumbParticles(self.x + (Math.random() - 0.5) * 300, self.y + (Math.random() - 0.5) * 300, 20); } } else { // Increase win amount with Lucky Gambler upgrade var baseBigWin = 10; var bigWinMultiplier = baseBigWin; if (luckyGamblerLevel > 0) { // Each level adds 20% to big win multiplier bigWinMultiplier = baseBigWin * (1 + 0.2 * luckyGamblerLevel); } winAmount = self.currentBet * bigWinMultiplier; resultMessage = "BIG WIN! " + winAmount + " CRUMBS!"; resultColor = 0x00FF00; } } else if (twoSame) { // Increase win amount with Lucky Gambler upgrade var baseWin = 2; var winMultiplier = baseWin; if (luckyGamblerLevel > 0) { // Each level adds 0.5 to the multiplier winMultiplier = baseWin + 0.5 * luckyGamblerLevel; } winAmount = self.currentBet * winMultiplier; resultMessage = "WIN! " + winAmount + " CRUMBS!"; resultColor = 0x00FF00; } else { // With Lucky Gambler, small chance to win something anyway var luckChance = luckyGamblerLevel > 0 ? 0.1 + (luckyGamblerLevel - 1) * 0.05 : 0; var luckMultiplier = 0.5 + (luckyGamblerLevel > 1 ? (luckyGamblerLevel - 1) * 0.1 : 0); if (luckyGamblerLevel > 0 && Math.random() < luckChance) { winAmount = Math.floor(self.currentBet * luckMultiplier); resultMessage = "LUCKY! " + winAmount + " CRUMBS!"; resultColor = 0x00FF00; } else { resultMessage = "TRY AGAIN!"; resultColor = 0xFF0000; } } // Award winnings if (winAmount > 0) { crumbs += winAmount; totalCrumbs += winAmount; updateCrumbsText(); } // Update result text self.resultText.setText(resultMessage); self.resultText.fill = resultColor; // End spinning state self.spinning = false; }; 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; self.level = purchased ? 1 : 0; self.isMultiPurchase = name === "Lucky Gambler" || name === "Bob's Friend"; // Special flag for Lucky Gambler and Bob's Friend 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.isMultiPurchase) { // For Lucky Gambler, allow multiple purchases with increasing cost if (crumbs >= self.cost) { crumbs -= self.cost; self.level++; if (self.level === 1) { self.purchased = true; storage.upgrades[self.name] = true; self.nameText.fill = "#90FF90"; } // Increase cost for next level self.cost = Math.floor(self.cost * 1.5); self.costText.setText("Level: " + self.level + " - Next: " + self.cost); // Store level in storage storage.upgrades[self.name + "Level"] = self.level; self.effect(); LK.getSound('purchase').play(); updateCrumbsText(); return true; } } else { // Regular upgrades - one-time purchase 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 = 0; // Zero crumbs var cookieLevel = storage.cookieLevel || 1; var totalCrumbs = storage.totalCrumbs || 0; var rebirthBonus = storage.rebirthBonus || 1; var crumbsPerClick = 1 * rebirthBonus; var crumbsPerSecond = 0; var lastUpdateTime = Date.now(); var fortuneChance = 0.05; var particles = []; var cookieScale = 1; var enemies = []; var enemySpawnTimer = 0; var enemySpawnRate = 300; // Spawn enemy every 5 seconds (300 frames at 60fps) 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 - 300; 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; upgradesButton.y = 180; game.addChild(upgradesButton); var gamblingButton = new Container(); var gamblingBg = gamblingButton.attachAsset('buttonShape', { anchorX: 0.5, anchorY: 0.5, width: 200, height: 60 }); gamblingBg.tint = 0xAA3030; var gamblingText = new Text2("GAMBLE", { size: 40, fill: 0xFFFFFF }); gamblingText.anchor.set(0.5, 0.5); gamblingButton.addChild(gamblingText); gamblingButton.x = 2048 / 2 + 300; gamblingButton.y = 180; game.addChild(gamblingButton); // Create tab containers var shopContainer = new Container(); game.addChild(shopContainer); shopContainer.visible = true; var upgradesContainer = new Container(); game.addChild(upgradesContainer); upgradesContainer.visible = false; var gamblingContainer = new Container(); game.addChild(gamblingContainer); gamblingContainer.visible = false; // Create slot machine var slotMachine = new SlotMachine(); slotMachine.x = 2048 / 2; slotMachine.y = 900; gamblingContainer.addChild(slotMachine); // 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; } }, { name: "Lucky Gambler", description: "Better odds and larger jackpots (can be upgraded multiple times)", cost: 5000, effect: function effect() { // The actual effect is implemented in the SlotMachine.checkResults method } }, { name: "Bob's Friend", description: "Reduce Bob's clicks needed for reward (can be upgraded multiple times)", cost: 2000, effect: function effect() { // The actual effect is implemented in the Bob.down method } }]; // 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); // Handle special cases for multi-purchase upgrades if ((upg.name === "Lucky Gambler" || upg.name === "Bob's Friend") && purchased) { // Get level from storage var upgradeLevel = storage.upgrades[upg.name + "Level"] || 1; upgObj.level = upgradeLevel; // Update cost based on level upgObj.cost = Math.floor(upg.cost * Math.pow(1.5, upgradeLevel - 1)); upgObj.costText.setText("Level: " + upgradeLevel + " - Next: " + upgObj.cost); // Apply effect multiple times based on level for (var j = 0; j < upgradeLevel; j++) { upg.effect(); } } else 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 * rebirthBonus; // Apply rebirth bonus to crumbs per second } 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; gamblingContainer.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; gamblingContainer.visible = false; 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 }); } }); }; gamblingButton.down = function () { shopContainer.visible = false; upgradesContainer.visible = false; gamblingContainer.visible = true; tween(gamblingButton.scale, { x: 1.1, y: 1.1 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { tween(gamblingButton.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); } } // Enemy spawning enemySpawnTimer++; if (enemySpawnTimer >= enemySpawnRate) { enemySpawnTimer = 0; // Spawn enemy at random position at top var enemy = new Enemy("Basic", 2 + Math.random() * 3, 100 + Math.random() * 50); enemy.x = 200 + Math.random() * (2048 - 400); enemy.y = 300; enemy.startX = enemy.x; enemies.push(enemy); game.addChild(enemy); // Increase spawn rate over time (decrease spawn timer) if (enemySpawnRate > 120) { // Minimum 2 seconds between spawns enemySpawnRate -= 2; } } }; // 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); // Add rebirth button above upgrade button var rebirthButton = new RebirthButton(null, 1.5); // Cost parameter is ignored, always one million rebirthButton.x = 2048 / 2; rebirthButton.y = 2250; game.addChild(rebirthButton); // Add restart button in the top right corner var restartButton = new RestartButton(); restartButton.x = 2048 - 180; // Position in top right with some padding restartButton.y = 100; game.addChild(restartButton); // Create Bob and add him to the game var bob = new Bob(); bob.x = 2048 / 2; bob.y = 2050; // Position Bob higher above the rebirth button game.addChild(bob); // Set storage to match the zero crumbs storage.crumbs = crumbs; storage.totalCrumbs = 0; totalCrumbs = 0; // Initial display update updateCrumbsText();
===================================================================
--- original.js
+++ change.js
@@ -192,8 +192,161 @@
return self.lifespan > 0;
};
return self;
});
+var Enemy = Container.expand(function (type, speed, health) {
+ var self = Container.call(this);
+ self.type = type || "Basic";
+ self.speed = speed || 2;
+ self.maxHealth = health || 100;
+ self.health = self.maxHealth;
+ self.isDead = false;
+ // Create enemy body
+ var enemyBody = self.attachAsset('generatorShape', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: 80,
+ height: 80
+ });
+ enemyBody.tint = 0xFF0000; // Red color for enemies
+ // Create health bar background
+ var healthBarBg = self.attachAsset('buttonShape', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: 60,
+ height: 8
+ });
+ healthBarBg.tint = 0x000000;
+ healthBarBg.y = -50;
+ // Create health bar
+ self.healthBar = self.attachAsset('buttonShape', {
+ anchorX: 0,
+ anchorY: 0.5,
+ width: 60,
+ height: 6
+ });
+ self.healthBar.tint = 0x00FF00;
+ self.healthBar.x = -30;
+ self.healthBar.y = -50;
+ // Enemy name
+ var nameText = new Text2(self.type + " Enemy", {
+ size: 24,
+ fill: 0xFFFFFF
+ });
+ nameText.anchor.set(0.5, 0.5);
+ nameText.y = -70;
+ self.addChild(nameText);
+ // Movement pattern
+ self.direction = 1;
+ self.startX = 0;
+ self.update = function () {
+ if (self.isDead) return;
+ // Move horizontally
+ self.x += self.speed * self.direction;
+ // Bounce off screen edges
+ if (self.x <= 100 || self.x >= 2048 - 100) {
+ self.direction *= -1;
+ self.y += 50; // Move down when hitting edge
+ }
+ // Check if enemy reached bottom (player loses)
+ if (self.y >= 2732 - 200) {
+ self.triggerPlayerDeath();
+ }
+ // Animate enemy
+ self.rotation = Math.sin(LK.ticks / 30) * 0.1;
+ };
+ self.takeDamage = function (damage) {
+ if (self.isDead) return;
+ self.health -= damage;
+ // Update health bar
+ var healthPercent = self.health / self.maxHealth;
+ self.healthBar.width = 60 * healthPercent;
+ // Change health bar color based on health
+ if (healthPercent > 0.6) {
+ self.healthBar.tint = 0x00FF00; // Green
+ } else if (healthPercent > 0.3) {
+ self.healthBar.tint = 0xFFFF00; // Yellow
+ } else {
+ self.healthBar.tint = 0xFF0000; // Red
+ }
+ // Flash when taking damage
+ tween(enemyBody, {
+ tint: 0xFFFFFF
+ }, {
+ duration: 100,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(enemyBody, {
+ tint: 0xFF0000
+ }, {
+ duration: 100,
+ easing: tween.easeIn
+ });
+ }
+ });
+ if (self.health <= 0) {
+ self.die();
+ }
+ };
+ self.die = function () {
+ self.isDead = true;
+ // Death animation
+ tween(self.scale, {
+ x: 0,
+ y: 0
+ }, {
+ duration: 300,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ // Remove from enemies array
+ for (var i = enemies.length - 1; i >= 0; i--) {
+ if (enemies[i] === self) {
+ enemies.splice(i, 1);
+ break;
+ }
+ }
+ self.destroy();
+ }
+ });
+ // Reward player
+ crumbs += 100;
+ totalCrumbs += 100;
+ updateCrumbsText();
+ // Spawn particles
+ spawnCrumbParticles(self.x, self.y, 10);
+ };
+ self.triggerPlayerDeath = function () {
+ // Give player infinite crumbs when they die
+ crumbs = Number.MAX_SAFE_INTEGER;
+ totalCrumbs = Number.MAX_SAFE_INTEGER;
+ updateCrumbsText();
+ // Flash screen red to indicate death
+ LK.effects.flashScreen(0xFF0000, 2000);
+ // Show message
+ var deathMessage = new Text2("YOU DIED! But gained infinite crumbs!", {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ deathMessage.anchor.set(0.5, 0.5);
+ deathMessage.x = 2048 / 2;
+ deathMessage.y = 2732 / 2;
+ game.addChild(deathMessage);
+ // Remove message after delay
+ LK.setTimeout(function () {
+ deathMessage.destroy();
+ }, 4000);
+ // Clear all enemies
+ for (var i = enemies.length - 1; i >= 0; i--) {
+ enemies[i].destroy();
+ }
+ enemies = [];
+ };
+ // Make enemy clickable to attack
+ self.down = function (x, y, obj) {
+ self.takeDamage(25);
+ };
+ return self;
+});
var Fortune = Container.expand(function (text, bonus) {
var self = Container.call(this);
self.text = text;
self.bonus = bonus || 0;
@@ -913,8 +1066,11 @@
var lastUpdateTime = Date.now();
var fortuneChance = 0.05;
var particles = [];
var cookieScale = 1;
+var enemies = [];
+var enemySpawnTimer = 0;
+var enemySpawnRate = 300; // Spawn enemy every 5 seconds (300 frames at 60fps)
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());
@@ -1355,8 +1511,25 @@
particles[i].destroy();
particles.splice(i, 1);
}
}
+ // Enemy spawning
+ enemySpawnTimer++;
+ if (enemySpawnTimer >= enemySpawnRate) {
+ enemySpawnTimer = 0;
+ // Spawn enemy at random position at top
+ var enemy = new Enemy("Basic", 2 + Math.random() * 3, 100 + Math.random() * 50);
+ enemy.x = 200 + Math.random() * (2048 - 400);
+ enemy.y = 300;
+ enemy.startX = enemy.x;
+ enemies.push(enemy);
+ game.addChild(enemy);
+ // Increase spawn rate over time (decrease spawn timer)
+ if (enemySpawnRate > 120) {
+ // Minimum 2 seconds between spawns
+ enemySpawnRate -= 2;
+ }
+ }
};
// Restore stored cookie level
if (cookieLevel > 1) {
fortuneCookie.scale.set(cookieScale, cookieScale);