/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { eggPoints: 0, coins: 0, currentSkin: "basic", autoClickerLevel: 0, unlockedSkins: {}, enteredCodes: {} }); /**** * Classes ****/ var CodeInputPanel = Container.expand(function () { var self = Container.call(this); // Create background var background = self.attachAsset('shopPanelBg', { anchorX: 0.5, anchorY: 0.5 }); // Create title var title = self.addChild(new Text2("Enter Code", { size: 60, fill: 0x000000 })); title.anchor.set(0.5, 0); title.y = -320; // Create input background var inputBg = self.attachAsset('codeInputBg', { anchorX: 0.5, anchorY: 0.5, y: -100 }); // Create input text display var inputText = self.addChild(new Text2("", { size: 40, fill: 0x000000 })); inputText.anchor.set(0.5, 0.5); inputText.y = -100; // Create submit button var submitButton = self.attachAsset('convertButton', { anchorX: 0.5, anchorY: 0.5, y: 50 }); var submitText = self.addChild(new Text2("Submit", { size: 40, fill: 0xFFFFFF })); submitText.anchor.set(0.5, 0.5); submitText.y = 50; // Create result text var resultText = self.addChild(new Text2("", { size: 30, fill: 0x000000 })); resultText.anchor.set(0.5, 0.5); resultText.y = 150; // Create close button var closeButton = self.attachAsset('closeButton', { anchorX: 0.5, anchorY: 0.5, x: 300, y: -320 }); // Input handling self.currentInput = ""; // Virtual keyboard buttons var keyboard = self.addChild(new Container()); keyboard.y = 220; // Custom key arrangement with all letters and numbers var keys = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "]", "<", ">"]; var keySize = 60; var keysPerRow = 10; for (var i = 0; i < keys.length; i++) { var keyX = (i % keysPerRow - keysPerRow / 2 + 0.5) * (keySize + 5); var keyY = Math.floor(i / keysPerRow) * (keySize + 10); var keyBg = keyboard.attachAsset('shopItemBg', { anchorX: 0.5, anchorY: 0.5, x: keyX, y: keyY, width: keySize, height: keySize }); var keyText = keyboard.addChild(new Text2(keys[i], { size: 30, fill: 0x000000 })); keyText.anchor.set(0.5, 0.5); keyText.x = keyX; keyText.y = keyY; // Make key interactive keyBg.interactive = true; keyBg.keyValue = keys[i]; keyBg.down = function () { if (self.currentInput.length < 15) { self.currentInput += this.keyValue; inputText.setText(self.currentInput); LK.getSound('click').play(); } }; } // Control buttons at the bottom var controlY = Math.ceil(keys.length / keysPerRow) * (keySize + 10) + 30; // Clear button var clearBg = keyboard.attachAsset('shopItemBg', { anchorX: 0.5, anchorY: 0.5, x: -140, y: controlY, width: 120, height: 60 }); var clearText = keyboard.addChild(new Text2("Clear", { size: 30, fill: 0x000000 })); clearText.anchor.set(0.5, 0.5); clearText.x = -140; clearText.y = controlY; clearBg.interactive = true; clearBg.down = function () { self.currentInput = ""; inputText.setText(""); LK.getSound('click').play(); }; // Backspace button var backspaceBg = keyboard.attachAsset('shopItemBg', { anchorX: 0.5, anchorY: 0.5, x: 140, y: controlY, width: 120, height: 60 }); var backspaceText = keyboard.addChild(new Text2("Delete", { size: 30, fill: 0x000000 })); backspaceText.anchor.set(0.5, 0.5); backspaceText.x = 140; backspaceText.y = controlY; backspaceBg.interactive = true; backspaceBg.down = function () { if (self.currentInput.length > 0) { self.currentInput = self.currentInput.slice(0, -1); inputText.setText(self.currentInput); LK.getSound('click').play(); } }; // Submit button handler submitButton.interactive = true; submitButton.down = function () { LK.getSound('click').play(); self.checkCode(self.currentInput); }; // Close button handler closeButton.interactive = true; closeButton.down = function () { self.visible = false; LK.getSound('click').play(); }; // Code checking self.checkCode = function (code) { // Check if code has already been used if (storage.enteredCodes[code]) { resultText.setText("Code already used!"); LK.getSound('error').play(); return; } // Check valid codes if (code === "RESET") { // Reset the game completely resultText.setText("Resetting game..."); LK.getSound('purchase').play(); // Clear all storage and set fresh defaults storage.eggPoints = 0; storage.coins = 0; storage.currentSkin = "basic"; storage.autoClickerLevel = 0; storage.unlockedSkins = { "basic": true }; storage.enteredCodes = {}; // Reset entered codes too // Recreate game elements LK.setTimeout(function () { // Destroy existing elements if (egg) egg.destroy(); if (skinsPanel) skinsPanel.destroy(); if (autoClickerPanel) autoClickerPanel.destroy(); if (codeInputPanel) { codeInputPanel.visible = false; } // Re-initialize the game initGame(); }, 500); } else if (code === "CODE1[NOTFOUND]" || code === "code1[notfound]") { // Special ERROR egg skin unlockSpecialSkin("error"); resultText.setText("ERROR egg unlocked!"); storage.enteredCodes[code] = true; LK.getSound('purchase').play(); } else if (code === "DIAMOND123") { unlockSpecialSkin("diamond"); resultText.setText("Diamond egg unlocked!"); storage.enteredCodes[code] = true; LK.getSound('purchase').play(); } else if (code === "PIXEL8BIT" || code === "PIXEL") { unlockSpecialSkin("pixel"); resultText.setText("Pixel egg unlocked!"); storage.enteredCodes[code] = true; LK.getSound('purchase').play(); } else if (code === "OBSIDIAN") { unlockSpecialSkin("obsidian"); resultText.setText("Obsidian egg unlocked!"); storage.enteredCodes[code] = true; LK.getSound('purchase').play(); } else if (code === "WIDE") { // Wide egg unlockSpecialSkin("wide"); resultText.setText("Wide egg unlocked!"); storage.enteredCodes[code] = true; LK.getSound('purchase').play(); } else if (code === "FREECOINS") { storage.coins += 100; resultText.setText("100 coins added!"); storage.enteredCodes[code] = true; LK.getSound('purchase').play(); updateUI(); } else if (code === "BOOST") { storage.eggPoints += 10000; resultText.setText("10,000 egg points added!"); storage.enteredCodes[code] = true; LK.getSound('purchase').play(); updateUI(); } else { resultText.setText("Invalid code"); LK.getSound('error').play(); } }; return self; }); var Egg = Container.expand(function () { var self = Container.call(this); // Properties self.skin = storage.currentSkin || 'basic'; self.pointsPerClick = getPointsPerClick(self.skin); // Create egg graphic based on current skin var eggGraphic; if (self.skin === "wide") { eggGraphic = self.attachAsset('wideegg', { anchorX: 0.5, anchorY: 0.5, scaleX: 1, scaleY: 1 }); } else { eggGraphic = self.attachAsset(self.skin + 'Egg', { anchorX: 0.5, anchorY: 0.5, scaleX: 1, scaleY: 1 }); } // Animation state self.isAnimating = false; // Click handler self.down = function (x, y, obj) { if (!self.isAnimating) { self.isAnimating = true; // Play tap sound LK.getSound('eggTap').play(); // Animate egg on tap tween(eggGraphic, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100, onFinish: function onFinish() { tween(eggGraphic, { scaleX: 1, scaleY: 1 }, { duration: 100, onFinish: function onFinish() { self.isAnimating = false; } }); } }); // Add points addEggPoints(self.pointsPerClick); // Create floating number effect createFloatingPoints(self.pointsPerClick, x, y); } }; // Change skin method self.changeSkin = function (newSkin) { // Remove old graphic eggGraphic.destroy(); // Update skin and points self.skin = newSkin; self.pointsPerClick = getPointsPerClick(newSkin); // Create new graphic with updated skin if (newSkin === "wide") { eggGraphic = self.attachAsset('wideegg', { anchorX: 0.5, anchorY: 0.5 }); } else { eggGraphic = self.attachAsset(newSkin + 'Egg', { anchorX: 0.5, anchorY: 0.5 }); } // Save current skin to storage storage.currentSkin = newSkin; // Flash to indicate upgrade LK.effects.flashObject(eggGraphic, 0xFFFFFF, 500); }; return self; }); var FloatingPoints = Container.expand(function (value, startX, startY) { var self = Container.call(this); // Position the container self.x = startX; self.y = startY; // Create text var text = self.addChild(new Text2("+" + value, { size: 40, fill: 0xFFCC00 })); text.anchor.set(0.5, 0.5); // Animate the floating points tween(self, { y: self.y - 100, alpha: 0 }, { duration: 1000, onFinish: function onFinish() { self.destroy(); } }); return self; }); var ShopItem = Container.expand(function (itemType, itemName, cost, description) { var self = Container.call(this); // Properties self.itemType = itemType; // "skin" or "autoClicker" self.itemName = itemName; self.cost = cost; self.description = description; self.purchased = false; // Create background var background = self.attachAsset('shopItemBg', { anchorX: 0.5, anchorY: 0.5 }); // Create icon var icon; if (itemType === "skin") { if (itemName === "wide") { icon = self.attachAsset('wideegg', { anchorX: 0.5, anchorY: 0.5, x: -150, scaleX: 0.6, scaleY: 0.6 }); } else { icon = self.attachAsset(itemName + 'Egg', { anchorX: 0.5, anchorY: 0.5, x: -150, scaleX: 0.6, scaleY: 0.6 }); } } else { icon = self.attachAsset('autoClicker', { anchorX: 0.5, anchorY: 0.5, x: -150, scaleX: 0.6, scaleY: 0.6 }); } // Create item name text var nameText = self.addChild(new Text2(itemName, { size: 40, fill: 0x000000 })); nameText.anchor.set(0, 0.5); nameText.x = -70; nameText.y = -30; // Create description text var descText = self.addChild(new Text2(description, { size: 30, fill: 0x444444 })); descText.anchor.set(0, 0.5); descText.x = -70; descText.y = 10; // Create cost text var costText = self.addChild(new Text2((itemType === "skin" ? "🥚 " : "💰 ") + cost, { size: 35, fill: 0x000000 })); costText.anchor.set(1, 0.5); costText.x = 170; costText.y = 0; // Click handler self.down = function () { if (self.itemType === "skin") { if (storage.eggPoints >= self.cost && storage.currentSkin !== self.itemName) { // Purchase skin storage.eggPoints -= self.cost; egg.changeSkin(self.itemName); LK.getSound('purchase').play(); updateUI(); } else if (storage.currentSkin === self.itemName) { // Already equipped LK.getSound('error').play(); } else { // Not enough points LK.getSound('error').play(); LK.effects.flashObject(costText, 0xFF0000, 300); } } else if (self.itemType === "autoClicker") { if (storage.coins >= self.cost && storage.autoClickerLevel < 20) { // Purchase auto-clicker upgrade storage.coins -= self.cost; storage.autoClickerLevel++; LK.getSound('purchase').play(); updateAutoClickerInfo(); updateUI(); } else if (storage.autoClickerLevel >= 20) { // Max level reached LK.getSound('error').play(); } else { // Not enough coins LK.getSound('error').play(); LK.effects.flashObject(costText, 0xFF0000, 300); } } }; return self; }); var ShopPanel = Container.expand(function (panelType) { var self = Container.call(this); // Properties self.panelType = panelType; // "skins" or "autoClicker" // Create background var background = self.attachAsset('shopPanelBg', { anchorX: 0.5, anchorY: 0.5 }); // Create title var title = self.addChild(new Text2(panelType === "skins" ? "Egg Skins" : "Auto-Clicker", { size: 60, fill: 0x000000 })); title.anchor.set(0.5, 0); title.y = -320; // Create items container var itemsContainer = self.addChild(new Container()); itemsContainer.y = -220; // Add shop items based on panel type if (panelType === "skins") { // Add skin items var skins = [{ name: "basic", cost: 0, desc: "Standard egg (1 pt/click)" }, { name: "golden", cost: 100, desc: "Fancy gold egg (5 pts/click)" }, { name: "spotted", cost: 500, desc: "Spotted egg (25 pts/click)" }, { name: "striped", cost: 2500, desc: "Striped egg (100 pts/click)" }, { name: "crystal", cost: 10000, desc: "Crystal egg (500 pts/click)" }, { name: "galaxy", cost: 50000, desc: "Cosmic egg (2,500 pts/click)" }, { name: "rainbow", cost: 1000000, desc: "Ultimate egg (100,000 pts/click)" }]; // Add special skins that can be unlocked through codes if (storage.unlockedSkins && storage.unlockedSkins.error) { skins.push({ name: "error", cost: 0, desc: "ERROR egg (50,000 pts/click)" }); } if (storage.unlockedSkins && storage.unlockedSkins.diamond) { skins.push({ name: "diamond", cost: 0, desc: "Diamond egg (10,000 pts/click)" }); } if (storage.unlockedSkins && storage.unlockedSkins.pixel) { skins.push({ name: "pixel", cost: 0, desc: "Pixel egg (15,000 pts/click)" }); } if (storage.unlockedSkins && storage.unlockedSkins.obsidian) { skins.push({ name: "obsidian", cost: 0, desc: "Obsidian egg (20,000 pts/click)" }); } if (storage.unlockedSkins && storage.unlockedSkins.wide) { skins.push({ name: "wide", cost: 0, desc: "Wide egg (7,500 pts/click)" }); } // Square egg removed for (var i = 0; i < skins.length; i++) { var skin = skins[i]; var item = itemsContainer.addChild(new ShopItem("skin", skin.name, skin.cost, skin.desc)); item.y = i * 100; } } else { // Add auto-clicker info var infoBox = itemsContainer.attachAsset('infoBg', { anchorX: 0.5, anchorY: 0.5, y: -50 }); autoClickerInfoText = itemsContainer.addChild(new Text2("", { size: 35, fill: 0x000000 })); autoClickerInfoText.anchor.set(0.5, 0.5); autoClickerInfoText.y = -50; // Create upgrade button var upgradeItem = itemsContainer.addChild(new ShopItem("autoClicker", "Upgrade Auto-Clicker", getAutoClickerUpgradeCost(), "Level up your automatic egg tapper")); upgradeItem.y = 70; // Create convert button var convertButton = itemsContainer.attachAsset('convertButton', { anchorX: 0.5, anchorY: 0.5, y: 170 }); var convertText = itemsContainer.addChild(new Text2("Convert 1000 Points to 1 Coin", { size: 35, fill: 0xFFFFFF })); convertText.anchor.set(0.5, 0.5); convertText.y = 170; // Add convert button functionality convertButton.interactive = true; convertButton.down = function () { if (storage.eggPoints >= 1000) { storage.eggPoints -= 1000; storage.coins++; LK.getSound('convert').play(); updateUI(); } else { LK.getSound('error').play(); LK.effects.flashObject(convertText, 0xFF0000, 300); } }; } // Create close button var closeButton = self.attachAsset('closeButton', { anchorX: 0.5, anchorY: 0.5, x: 300, y: -320 }); closeButton.down = function () { self.visible = false; LK.getSound('click').play(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xF5F5F5 }); /**** * Game Code ****/ // Play background music // Assets will be initialized automatically based on usage // Initialize assets required for the game // Initialize sounds // Initialize music LK.playMusic('bgMusic'); // Game variables var lastAutoClickTime = Date.now(); var lastCoinGenerationTime = Date.now(); var egg; var eggPointsText; var coinsText; var skinsPanel; var autoClickerPanel; var autoClickerInfoText; var codeInputPanel; // Function to unlock special skins function unlockSpecialSkin(skinName) { if (!storage.unlockedSkins) { storage.unlockedSkins = { "basic": true }; } storage.unlockedSkins[skinName] = true; // Refresh shop panel to show new skin skinsPanel.destroy(); skinsPanel = game.addChild(new ShopPanel("skins")); skinsPanel.x = 2048 / 2; skinsPanel.y = 2732 / 2; skinsPanel.visible = false; } // Initialize game elements initGame(); function initGame() { // Create egg egg = game.addChild(new Egg()); egg.x = 2048 / 2; egg.y = 2732 / 2; // Create UI elements createUI(); // Create shop panels createShopPanels(); // Update UI with initial values updateUI(); // Initialize auto-clicker info updateAutoClickerInfo(); } function createUI() { // Create egg points counter eggPointsText = new Text2("🥚 0", { size: 60, fill: 0x333333 }); eggPointsText.anchor.set(0, 0); eggPointsText.x = 30; eggPointsText.y = 30; LK.gui.addChild(eggPointsText); // Create coins counter coinsText = new Text2("💰 0", { size: 60, fill: 0x333333 }); coinsText.anchor.set(1, 0); coinsText.x = 2048 - 30; coinsText.y = 30; LK.gui.addChild(coinsText); // Create skins shop button var skinsButton = LK.getAsset('shopButton', { anchorX: 0.5, anchorY: 0.5 }); skinsButton.x = 120; skinsButton.y = 2732 - 120; game.addChild(skinsButton); var skinsButtonText = new Text2("Skins", { size: 40, fill: 0xFFFFFF }); skinsButtonText.anchor.set(0.5, 0.5); skinsButtonText.x = 120; skinsButtonText.y = 2732 - 120; game.addChild(skinsButtonText); // Create auto-clicker button var autoClickerButton = LK.getAsset('autoClickerButton', { anchorX: 0.5, anchorY: 0.5 }); autoClickerButton.x = 2048 - 120; autoClickerButton.y = 2732 - 120; game.addChild(autoClickerButton); var autoClickerButtonText = new Text2("Auto", { size: 40, fill: 0xFFFFFF }); autoClickerButtonText.anchor.set(0.5, 0.5); autoClickerButtonText.x = 2048 - 120; autoClickerButtonText.y = 2732 - 120; game.addChild(autoClickerButtonText); // Create code button var codeButton = LK.getAsset('shopButton', { anchorX: 0.5, anchorY: 0.5 }); codeButton.x = 2048 / 2; codeButton.y = 2732 - 120; game.addChild(codeButton); var codeButtonText = new Text2("Codes", { size: 40, fill: 0xFFFFFF }); codeButtonText.anchor.set(0.5, 0.5); codeButtonText.x = 2048 / 2; codeButtonText.y = 2732 - 120; game.addChild(codeButtonText); // Add click handlers to buttons skinsButton.interactive = true; skinsButton.down = function () { skinsPanel.visible = true; autoClickerPanel.visible = false; codeInputPanel.visible = false; LK.getSound('click').play(); }; autoClickerButton.interactive = true; autoClickerButton.down = function () { autoClickerPanel.visible = true; skinsPanel.visible = false; codeInputPanel.visible = false; LK.getSound('click').play(); }; codeButton.interactive = true; codeButton.down = function () { codeInputPanel.visible = true; skinsPanel.visible = false; autoClickerPanel.visible = false; LK.getSound('click').play(); }; } function createShopPanels() { // Create skins panel skinsPanel = game.addChild(new ShopPanel("skins")); skinsPanel.x = 2048 / 2; skinsPanel.y = 2732 / 2; skinsPanel.visible = false; // Create auto-clicker panel autoClickerPanel = game.addChild(new ShopPanel("autoClicker")); autoClickerPanel.x = 2048 / 2; autoClickerPanel.y = 2732 / 2; autoClickerPanel.visible = false; // Create code input panel codeInputPanel = game.addChild(new CodeInputPanel()); codeInputPanel.x = 2048 / 2; codeInputPanel.y = 2732 / 2; codeInputPanel.visible = false; } function updateUI() { // Update egg points counter eggPointsText.setText("🥚 " + formatNumber(storage.eggPoints)); // Update coins counter coinsText.setText("💰 " + formatNumber(storage.coins)); } function updateAutoClickerInfo() { if (!autoClickerInfoText) return; var level = storage.autoClickerLevel; var pointsRate = getAutoClickerPointsRate(); var coinsRate = getAutoClickerCoinsRate(); var infoString = "Level " + level + "/20\n"; infoString += "+" + formatNumber(pointsRate) + " pts/sec"; if (level >= 10) { infoString += " | +" + formatNumber(coinsRate) + " coins/sec"; } autoClickerInfoText.setText(infoString); } function addEggPoints(amount) { storage.eggPoints += amount; updateUI(); } function createFloatingPoints(value, x, y) { var floatingPoints = game.addChild(new FloatingPoints(value, x, y)); } function getPointsPerClick(skin) { switch (skin) { case "basic": return 1; case "golden": return 5; case "spotted": return 25; case "striped": return 100; case "crystal": return 500; case "galaxy": return 2500; case "rainbow": return 100000; case "error": return 50000; case "diamond": return 10000; case "pixel": return 15000; case "obsidian": return 20000; case "wide": return 7500; // Square egg removed default: return 1; } } function getAutoClickerPointsRate() { var level = storage.autoClickerLevel; if (level === 0) return 0; return (0.05 * Math.pow(1.2, level - 1)).toFixed(2); } function getAutoClickerCoinsRate() { var level = storage.autoClickerLevel; if (level < 10) return 0; return (0.005 * Math.pow(1.2, level - 10)).toFixed(3); } function getAutoClickerUpgradeCost() { var level = storage.autoClickerLevel; return Math.floor(5 * Math.pow(2, level)); } function formatNumber(num) { if (num >= 1000000) { return (num / 1000000).toFixed(1) + "M"; } else if (num >= 1000) { return (num / 1000).toFixed(1) + "K"; } return Math.floor(num); } // Game update loop game.update = function () { var currentTime = Date.now(); // Handle auto-clicker if (storage.autoClickerLevel > 0) { // Calculate points to add based on time passed var pointsRate = getAutoClickerPointsRate(); var timeSinceLastAutoClick = (currentTime - lastAutoClickTime) / 1000; // in seconds var pointsToAdd = pointsRate * timeSinceLastAutoClick; if (pointsToAdd >= 0.1) { // Only update if at least 0.1 points to add storage.eggPoints += pointsToAdd; lastAutoClickTime = currentTime; updateUI(); } // Handle coin generation (level 10+) if (storage.autoClickerLevel >= 10) { var coinsRate = getAutoClickerCoinsRate(); var timeSinceLastCoinGeneration = (currentTime - lastCoinGenerationTime) / 1000; // in seconds var coinsToAdd = coinsRate * timeSinceLastCoinGeneration; if (coinsToAdd >= 0.01) { // Only update if at least 0.01 coins to add storage.coins += coinsToAdd; lastCoinGenerationTime = currentTime; updateUI(); } } } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
eggPoints: 0,
coins: 0,
currentSkin: "basic",
autoClickerLevel: 0,
unlockedSkins: {},
enteredCodes: {}
});
/****
* Classes
****/
var CodeInputPanel = Container.expand(function () {
var self = Container.call(this);
// Create background
var background = self.attachAsset('shopPanelBg', {
anchorX: 0.5,
anchorY: 0.5
});
// Create title
var title = self.addChild(new Text2("Enter Code", {
size: 60,
fill: 0x000000
}));
title.anchor.set(0.5, 0);
title.y = -320;
// Create input background
var inputBg = self.attachAsset('codeInputBg', {
anchorX: 0.5,
anchorY: 0.5,
y: -100
});
// Create input text display
var inputText = self.addChild(new Text2("", {
size: 40,
fill: 0x000000
}));
inputText.anchor.set(0.5, 0.5);
inputText.y = -100;
// Create submit button
var submitButton = self.attachAsset('convertButton', {
anchorX: 0.5,
anchorY: 0.5,
y: 50
});
var submitText = self.addChild(new Text2("Submit", {
size: 40,
fill: 0xFFFFFF
}));
submitText.anchor.set(0.5, 0.5);
submitText.y = 50;
// Create result text
var resultText = self.addChild(new Text2("", {
size: 30,
fill: 0x000000
}));
resultText.anchor.set(0.5, 0.5);
resultText.y = 150;
// Create close button
var closeButton = self.attachAsset('closeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 300,
y: -320
});
// Input handling
self.currentInput = "";
// Virtual keyboard buttons
var keyboard = self.addChild(new Container());
keyboard.y = 220;
// Custom key arrangement with all letters and numbers
var keys = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "]", "<", ">"];
var keySize = 60;
var keysPerRow = 10;
for (var i = 0; i < keys.length; i++) {
var keyX = (i % keysPerRow - keysPerRow / 2 + 0.5) * (keySize + 5);
var keyY = Math.floor(i / keysPerRow) * (keySize + 10);
var keyBg = keyboard.attachAsset('shopItemBg', {
anchorX: 0.5,
anchorY: 0.5,
x: keyX,
y: keyY,
width: keySize,
height: keySize
});
var keyText = keyboard.addChild(new Text2(keys[i], {
size: 30,
fill: 0x000000
}));
keyText.anchor.set(0.5, 0.5);
keyText.x = keyX;
keyText.y = keyY;
// Make key interactive
keyBg.interactive = true;
keyBg.keyValue = keys[i];
keyBg.down = function () {
if (self.currentInput.length < 15) {
self.currentInput += this.keyValue;
inputText.setText(self.currentInput);
LK.getSound('click').play();
}
};
}
// Control buttons at the bottom
var controlY = Math.ceil(keys.length / keysPerRow) * (keySize + 10) + 30;
// Clear button
var clearBg = keyboard.attachAsset('shopItemBg', {
anchorX: 0.5,
anchorY: 0.5,
x: -140,
y: controlY,
width: 120,
height: 60
});
var clearText = keyboard.addChild(new Text2("Clear", {
size: 30,
fill: 0x000000
}));
clearText.anchor.set(0.5, 0.5);
clearText.x = -140;
clearText.y = controlY;
clearBg.interactive = true;
clearBg.down = function () {
self.currentInput = "";
inputText.setText("");
LK.getSound('click').play();
};
// Backspace button
var backspaceBg = keyboard.attachAsset('shopItemBg', {
anchorX: 0.5,
anchorY: 0.5,
x: 140,
y: controlY,
width: 120,
height: 60
});
var backspaceText = keyboard.addChild(new Text2("Delete", {
size: 30,
fill: 0x000000
}));
backspaceText.anchor.set(0.5, 0.5);
backspaceText.x = 140;
backspaceText.y = controlY;
backspaceBg.interactive = true;
backspaceBg.down = function () {
if (self.currentInput.length > 0) {
self.currentInput = self.currentInput.slice(0, -1);
inputText.setText(self.currentInput);
LK.getSound('click').play();
}
};
// Submit button handler
submitButton.interactive = true;
submitButton.down = function () {
LK.getSound('click').play();
self.checkCode(self.currentInput);
};
// Close button handler
closeButton.interactive = true;
closeButton.down = function () {
self.visible = false;
LK.getSound('click').play();
};
// Code checking
self.checkCode = function (code) {
// Check if code has already been used
if (storage.enteredCodes[code]) {
resultText.setText("Code already used!");
LK.getSound('error').play();
return;
}
// Check valid codes
if (code === "RESET") {
// Reset the game completely
resultText.setText("Resetting game...");
LK.getSound('purchase').play();
// Clear all storage and set fresh defaults
storage.eggPoints = 0;
storage.coins = 0;
storage.currentSkin = "basic";
storage.autoClickerLevel = 0;
storage.unlockedSkins = {
"basic": true
};
storage.enteredCodes = {}; // Reset entered codes too
// Recreate game elements
LK.setTimeout(function () {
// Destroy existing elements
if (egg) egg.destroy();
if (skinsPanel) skinsPanel.destroy();
if (autoClickerPanel) autoClickerPanel.destroy();
if (codeInputPanel) {
codeInputPanel.visible = false;
}
// Re-initialize the game
initGame();
}, 500);
} else if (code === "CODE1[NOTFOUND]" || code === "code1[notfound]") {
// Special ERROR egg skin
unlockSpecialSkin("error");
resultText.setText("ERROR egg unlocked!");
storage.enteredCodes[code] = true;
LK.getSound('purchase').play();
} else if (code === "DIAMOND123") {
unlockSpecialSkin("diamond");
resultText.setText("Diamond egg unlocked!");
storage.enteredCodes[code] = true;
LK.getSound('purchase').play();
} else if (code === "PIXEL8BIT" || code === "PIXEL") {
unlockSpecialSkin("pixel");
resultText.setText("Pixel egg unlocked!");
storage.enteredCodes[code] = true;
LK.getSound('purchase').play();
} else if (code === "OBSIDIAN") {
unlockSpecialSkin("obsidian");
resultText.setText("Obsidian egg unlocked!");
storage.enteredCodes[code] = true;
LK.getSound('purchase').play();
} else if (code === "WIDE") {
// Wide egg
unlockSpecialSkin("wide");
resultText.setText("Wide egg unlocked!");
storage.enteredCodes[code] = true;
LK.getSound('purchase').play();
} else if (code === "FREECOINS") {
storage.coins += 100;
resultText.setText("100 coins added!");
storage.enteredCodes[code] = true;
LK.getSound('purchase').play();
updateUI();
} else if (code === "BOOST") {
storage.eggPoints += 10000;
resultText.setText("10,000 egg points added!");
storage.enteredCodes[code] = true;
LK.getSound('purchase').play();
updateUI();
} else {
resultText.setText("Invalid code");
LK.getSound('error').play();
}
};
return self;
});
var Egg = Container.expand(function () {
var self = Container.call(this);
// Properties
self.skin = storage.currentSkin || 'basic';
self.pointsPerClick = getPointsPerClick(self.skin);
// Create egg graphic based on current skin
var eggGraphic;
if (self.skin === "wide") {
eggGraphic = self.attachAsset('wideegg', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1,
scaleY: 1
});
} else {
eggGraphic = self.attachAsset(self.skin + 'Egg', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1,
scaleY: 1
});
}
// Animation state
self.isAnimating = false;
// Click handler
self.down = function (x, y, obj) {
if (!self.isAnimating) {
self.isAnimating = true;
// Play tap sound
LK.getSound('eggTap').play();
// Animate egg on tap
tween(eggGraphic, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100,
onFinish: function onFinish() {
tween(eggGraphic, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
onFinish: function onFinish() {
self.isAnimating = false;
}
});
}
});
// Add points
addEggPoints(self.pointsPerClick);
// Create floating number effect
createFloatingPoints(self.pointsPerClick, x, y);
}
};
// Change skin method
self.changeSkin = function (newSkin) {
// Remove old graphic
eggGraphic.destroy();
// Update skin and points
self.skin = newSkin;
self.pointsPerClick = getPointsPerClick(newSkin);
// Create new graphic with updated skin
if (newSkin === "wide") {
eggGraphic = self.attachAsset('wideegg', {
anchorX: 0.5,
anchorY: 0.5
});
} else {
eggGraphic = self.attachAsset(newSkin + 'Egg', {
anchorX: 0.5,
anchorY: 0.5
});
}
// Save current skin to storage
storage.currentSkin = newSkin;
// Flash to indicate upgrade
LK.effects.flashObject(eggGraphic, 0xFFFFFF, 500);
};
return self;
});
var FloatingPoints = Container.expand(function (value, startX, startY) {
var self = Container.call(this);
// Position the container
self.x = startX;
self.y = startY;
// Create text
var text = self.addChild(new Text2("+" + value, {
size: 40,
fill: 0xFFCC00
}));
text.anchor.set(0.5, 0.5);
// Animate the floating points
tween(self, {
y: self.y - 100,
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
self.destroy();
}
});
return self;
});
var ShopItem = Container.expand(function (itemType, itemName, cost, description) {
var self = Container.call(this);
// Properties
self.itemType = itemType; // "skin" or "autoClicker"
self.itemName = itemName;
self.cost = cost;
self.description = description;
self.purchased = false;
// Create background
var background = self.attachAsset('shopItemBg', {
anchorX: 0.5,
anchorY: 0.5
});
// Create icon
var icon;
if (itemType === "skin") {
if (itemName === "wide") {
icon = self.attachAsset('wideegg', {
anchorX: 0.5,
anchorY: 0.5,
x: -150,
scaleX: 0.6,
scaleY: 0.6
});
} else {
icon = self.attachAsset(itemName + 'Egg', {
anchorX: 0.5,
anchorY: 0.5,
x: -150,
scaleX: 0.6,
scaleY: 0.6
});
}
} else {
icon = self.attachAsset('autoClicker', {
anchorX: 0.5,
anchorY: 0.5,
x: -150,
scaleX: 0.6,
scaleY: 0.6
});
}
// Create item name text
var nameText = self.addChild(new Text2(itemName, {
size: 40,
fill: 0x000000
}));
nameText.anchor.set(0, 0.5);
nameText.x = -70;
nameText.y = -30;
// Create description text
var descText = self.addChild(new Text2(description, {
size: 30,
fill: 0x444444
}));
descText.anchor.set(0, 0.5);
descText.x = -70;
descText.y = 10;
// Create cost text
var costText = self.addChild(new Text2((itemType === "skin" ? "🥚 " : "💰 ") + cost, {
size: 35,
fill: 0x000000
}));
costText.anchor.set(1, 0.5);
costText.x = 170;
costText.y = 0;
// Click handler
self.down = function () {
if (self.itemType === "skin") {
if (storage.eggPoints >= self.cost && storage.currentSkin !== self.itemName) {
// Purchase skin
storage.eggPoints -= self.cost;
egg.changeSkin(self.itemName);
LK.getSound('purchase').play();
updateUI();
} else if (storage.currentSkin === self.itemName) {
// Already equipped
LK.getSound('error').play();
} else {
// Not enough points
LK.getSound('error').play();
LK.effects.flashObject(costText, 0xFF0000, 300);
}
} else if (self.itemType === "autoClicker") {
if (storage.coins >= self.cost && storage.autoClickerLevel < 20) {
// Purchase auto-clicker upgrade
storage.coins -= self.cost;
storage.autoClickerLevel++;
LK.getSound('purchase').play();
updateAutoClickerInfo();
updateUI();
} else if (storage.autoClickerLevel >= 20) {
// Max level reached
LK.getSound('error').play();
} else {
// Not enough coins
LK.getSound('error').play();
LK.effects.flashObject(costText, 0xFF0000, 300);
}
}
};
return self;
});
var ShopPanel = Container.expand(function (panelType) {
var self = Container.call(this);
// Properties
self.panelType = panelType; // "skins" or "autoClicker"
// Create background
var background = self.attachAsset('shopPanelBg', {
anchorX: 0.5,
anchorY: 0.5
});
// Create title
var title = self.addChild(new Text2(panelType === "skins" ? "Egg Skins" : "Auto-Clicker", {
size: 60,
fill: 0x000000
}));
title.anchor.set(0.5, 0);
title.y = -320;
// Create items container
var itemsContainer = self.addChild(new Container());
itemsContainer.y = -220;
// Add shop items based on panel type
if (panelType === "skins") {
// Add skin items
var skins = [{
name: "basic",
cost: 0,
desc: "Standard egg (1 pt/click)"
}, {
name: "golden",
cost: 100,
desc: "Fancy gold egg (5 pts/click)"
}, {
name: "spotted",
cost: 500,
desc: "Spotted egg (25 pts/click)"
}, {
name: "striped",
cost: 2500,
desc: "Striped egg (100 pts/click)"
}, {
name: "crystal",
cost: 10000,
desc: "Crystal egg (500 pts/click)"
}, {
name: "galaxy",
cost: 50000,
desc: "Cosmic egg (2,500 pts/click)"
}, {
name: "rainbow",
cost: 1000000,
desc: "Ultimate egg (100,000 pts/click)"
}];
// Add special skins that can be unlocked through codes
if (storage.unlockedSkins && storage.unlockedSkins.error) {
skins.push({
name: "error",
cost: 0,
desc: "ERROR egg (50,000 pts/click)"
});
}
if (storage.unlockedSkins && storage.unlockedSkins.diamond) {
skins.push({
name: "diamond",
cost: 0,
desc: "Diamond egg (10,000 pts/click)"
});
}
if (storage.unlockedSkins && storage.unlockedSkins.pixel) {
skins.push({
name: "pixel",
cost: 0,
desc: "Pixel egg (15,000 pts/click)"
});
}
if (storage.unlockedSkins && storage.unlockedSkins.obsidian) {
skins.push({
name: "obsidian",
cost: 0,
desc: "Obsidian egg (20,000 pts/click)"
});
}
if (storage.unlockedSkins && storage.unlockedSkins.wide) {
skins.push({
name: "wide",
cost: 0,
desc: "Wide egg (7,500 pts/click)"
});
}
// Square egg removed
for (var i = 0; i < skins.length; i++) {
var skin = skins[i];
var item = itemsContainer.addChild(new ShopItem("skin", skin.name, skin.cost, skin.desc));
item.y = i * 100;
}
} else {
// Add auto-clicker info
var infoBox = itemsContainer.attachAsset('infoBg', {
anchorX: 0.5,
anchorY: 0.5,
y: -50
});
autoClickerInfoText = itemsContainer.addChild(new Text2("", {
size: 35,
fill: 0x000000
}));
autoClickerInfoText.anchor.set(0.5, 0.5);
autoClickerInfoText.y = -50;
// Create upgrade button
var upgradeItem = itemsContainer.addChild(new ShopItem("autoClicker", "Upgrade Auto-Clicker", getAutoClickerUpgradeCost(), "Level up your automatic egg tapper"));
upgradeItem.y = 70;
// Create convert button
var convertButton = itemsContainer.attachAsset('convertButton', {
anchorX: 0.5,
anchorY: 0.5,
y: 170
});
var convertText = itemsContainer.addChild(new Text2("Convert 1000 Points to 1 Coin", {
size: 35,
fill: 0xFFFFFF
}));
convertText.anchor.set(0.5, 0.5);
convertText.y = 170;
// Add convert button functionality
convertButton.interactive = true;
convertButton.down = function () {
if (storage.eggPoints >= 1000) {
storage.eggPoints -= 1000;
storage.coins++;
LK.getSound('convert').play();
updateUI();
} else {
LK.getSound('error').play();
LK.effects.flashObject(convertText, 0xFF0000, 300);
}
};
}
// Create close button
var closeButton = self.attachAsset('closeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 300,
y: -320
});
closeButton.down = function () {
self.visible = false;
LK.getSound('click').play();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xF5F5F5
});
/****
* Game Code
****/
// Play background music
// Assets will be initialized automatically based on usage
// Initialize assets required for the game
// Initialize sounds
// Initialize music
LK.playMusic('bgMusic');
// Game variables
var lastAutoClickTime = Date.now();
var lastCoinGenerationTime = Date.now();
var egg;
var eggPointsText;
var coinsText;
var skinsPanel;
var autoClickerPanel;
var autoClickerInfoText;
var codeInputPanel;
// Function to unlock special skins
function unlockSpecialSkin(skinName) {
if (!storage.unlockedSkins) {
storage.unlockedSkins = {
"basic": true
};
}
storage.unlockedSkins[skinName] = true;
// Refresh shop panel to show new skin
skinsPanel.destroy();
skinsPanel = game.addChild(new ShopPanel("skins"));
skinsPanel.x = 2048 / 2;
skinsPanel.y = 2732 / 2;
skinsPanel.visible = false;
}
// Initialize game elements
initGame();
function initGame() {
// Create egg
egg = game.addChild(new Egg());
egg.x = 2048 / 2;
egg.y = 2732 / 2;
// Create UI elements
createUI();
// Create shop panels
createShopPanels();
// Update UI with initial values
updateUI();
// Initialize auto-clicker info
updateAutoClickerInfo();
}
function createUI() {
// Create egg points counter
eggPointsText = new Text2("🥚 0", {
size: 60,
fill: 0x333333
});
eggPointsText.anchor.set(0, 0);
eggPointsText.x = 30;
eggPointsText.y = 30;
LK.gui.addChild(eggPointsText);
// Create coins counter
coinsText = new Text2("💰 0", {
size: 60,
fill: 0x333333
});
coinsText.anchor.set(1, 0);
coinsText.x = 2048 - 30;
coinsText.y = 30;
LK.gui.addChild(coinsText);
// Create skins shop button
var skinsButton = LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5
});
skinsButton.x = 120;
skinsButton.y = 2732 - 120;
game.addChild(skinsButton);
var skinsButtonText = new Text2("Skins", {
size: 40,
fill: 0xFFFFFF
});
skinsButtonText.anchor.set(0.5, 0.5);
skinsButtonText.x = 120;
skinsButtonText.y = 2732 - 120;
game.addChild(skinsButtonText);
// Create auto-clicker button
var autoClickerButton = LK.getAsset('autoClickerButton', {
anchorX: 0.5,
anchorY: 0.5
});
autoClickerButton.x = 2048 - 120;
autoClickerButton.y = 2732 - 120;
game.addChild(autoClickerButton);
var autoClickerButtonText = new Text2("Auto", {
size: 40,
fill: 0xFFFFFF
});
autoClickerButtonText.anchor.set(0.5, 0.5);
autoClickerButtonText.x = 2048 - 120;
autoClickerButtonText.y = 2732 - 120;
game.addChild(autoClickerButtonText);
// Create code button
var codeButton = LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5
});
codeButton.x = 2048 / 2;
codeButton.y = 2732 - 120;
game.addChild(codeButton);
var codeButtonText = new Text2("Codes", {
size: 40,
fill: 0xFFFFFF
});
codeButtonText.anchor.set(0.5, 0.5);
codeButtonText.x = 2048 / 2;
codeButtonText.y = 2732 - 120;
game.addChild(codeButtonText);
// Add click handlers to buttons
skinsButton.interactive = true;
skinsButton.down = function () {
skinsPanel.visible = true;
autoClickerPanel.visible = false;
codeInputPanel.visible = false;
LK.getSound('click').play();
};
autoClickerButton.interactive = true;
autoClickerButton.down = function () {
autoClickerPanel.visible = true;
skinsPanel.visible = false;
codeInputPanel.visible = false;
LK.getSound('click').play();
};
codeButton.interactive = true;
codeButton.down = function () {
codeInputPanel.visible = true;
skinsPanel.visible = false;
autoClickerPanel.visible = false;
LK.getSound('click').play();
};
}
function createShopPanels() {
// Create skins panel
skinsPanel = game.addChild(new ShopPanel("skins"));
skinsPanel.x = 2048 / 2;
skinsPanel.y = 2732 / 2;
skinsPanel.visible = false;
// Create auto-clicker panel
autoClickerPanel = game.addChild(new ShopPanel("autoClicker"));
autoClickerPanel.x = 2048 / 2;
autoClickerPanel.y = 2732 / 2;
autoClickerPanel.visible = false;
// Create code input panel
codeInputPanel = game.addChild(new CodeInputPanel());
codeInputPanel.x = 2048 / 2;
codeInputPanel.y = 2732 / 2;
codeInputPanel.visible = false;
}
function updateUI() {
// Update egg points counter
eggPointsText.setText("🥚 " + formatNumber(storage.eggPoints));
// Update coins counter
coinsText.setText("💰 " + formatNumber(storage.coins));
}
function updateAutoClickerInfo() {
if (!autoClickerInfoText) return;
var level = storage.autoClickerLevel;
var pointsRate = getAutoClickerPointsRate();
var coinsRate = getAutoClickerCoinsRate();
var infoString = "Level " + level + "/20\n";
infoString += "+" + formatNumber(pointsRate) + " pts/sec";
if (level >= 10) {
infoString += " | +" + formatNumber(coinsRate) + " coins/sec";
}
autoClickerInfoText.setText(infoString);
}
function addEggPoints(amount) {
storage.eggPoints += amount;
updateUI();
}
function createFloatingPoints(value, x, y) {
var floatingPoints = game.addChild(new FloatingPoints(value, x, y));
}
function getPointsPerClick(skin) {
switch (skin) {
case "basic":
return 1;
case "golden":
return 5;
case "spotted":
return 25;
case "striped":
return 100;
case "crystal":
return 500;
case "galaxy":
return 2500;
case "rainbow":
return 100000;
case "error":
return 50000;
case "diamond":
return 10000;
case "pixel":
return 15000;
case "obsidian":
return 20000;
case "wide":
return 7500;
// Square egg removed
default:
return 1;
}
}
function getAutoClickerPointsRate() {
var level = storage.autoClickerLevel;
if (level === 0) return 0;
return (0.05 * Math.pow(1.2, level - 1)).toFixed(2);
}
function getAutoClickerCoinsRate() {
var level = storage.autoClickerLevel;
if (level < 10) return 0;
return (0.005 * Math.pow(1.2, level - 10)).toFixed(3);
}
function getAutoClickerUpgradeCost() {
var level = storage.autoClickerLevel;
return Math.floor(5 * Math.pow(2, level));
}
function formatNumber(num) {
if (num >= 1000000) {
return (num / 1000000).toFixed(1) + "M";
} else if (num >= 1000) {
return (num / 1000).toFixed(1) + "K";
}
return Math.floor(num);
}
// Game update loop
game.update = function () {
var currentTime = Date.now();
// Handle auto-clicker
if (storage.autoClickerLevel > 0) {
// Calculate points to add based on time passed
var pointsRate = getAutoClickerPointsRate();
var timeSinceLastAutoClick = (currentTime - lastAutoClickTime) / 1000; // in seconds
var pointsToAdd = pointsRate * timeSinceLastAutoClick;
if (pointsToAdd >= 0.1) {
// Only update if at least 0.1 points to add
storage.eggPoints += pointsToAdd;
lastAutoClickTime = currentTime;
updateUI();
}
// Handle coin generation (level 10+)
if (storage.autoClickerLevel >= 10) {
var coinsRate = getAutoClickerCoinsRate();
var timeSinceLastCoinGeneration = (currentTime - lastCoinGenerationTime) / 1000; // in seconds
var coinsToAdd = coinsRate * timeSinceLastCoinGeneration;
if (coinsToAdd >= 0.01) {
// Only update if at least 0.01 coins to add
storage.coins += coinsToAdd;
lastCoinGenerationTime = currentTime;
updateUI();
}
}
}
};
A Pixelated Egg. In-Game asset. 2d. High contrast. No shadows
A Diamond egg. In-Game asset. 2d. High contrast. No shadows
A Rainbow egg. In-Game asset. 2d. High contrast. No shadows
A regular Egg. In-Game asset. 2d. High contrast. No shadows
A Crystal-like egg. In-Game asset. 2d. High contrast. No shadows
A yellow egg With Blue dots. In-Game asset. 2d. High contrast. No shadows
A Galactic Egg. In-Game asset. 2d. High contrast. No shadows
A Golden egg. In-Game asset. 2d. High contrast. No shadows
A Cyan egg with Blue Stripes. In-Game asset. 2d. High contrast. No shadows
A Obsidian egg. In-Game asset. 2d. High contrast. No shadows
A glitched, Error egg. In-Game asset. 2d. High contrast. No shadows