User prompt
Please fix the bug: 'Uncaught ReferenceError: upgradeMenu is not defined' in or related to this line: 'if (gameStarted && !upgradeMenu.isOpen && !settingsMenu.isOpen && !leaderboard.isOpen && !tutorialScreen.isOpen && (!prestigeMenu || !prestigeMenu.isOpen)) {' Line Number: 494
User prompt
Update leaderboard ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Make the close button in leaderboard easy to click
User prompt
Make it so when you change your name it changes in leaderboard too and dose not make another account ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Delete player 9240 from the entire game and remove his data ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Remove player9240 out of the game ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Make it when you set your username it changes your old one in leaderboard to make sure u only have 1 account on leaderboard ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Remove player9240 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Make it so nobody can use same username as other people ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Only give owner tag to NEO ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Make a custom prefix for my account that says owner ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Make it so It opens your keyboard to let you type your username in and auto saves ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Timeout.tick error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.playerName = playerName;' Line Number: 2361
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage.playerName = playerName;' Line Number: 809 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage.playerName = playerName;' Line Number: 808 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'if (newUsername.length > 20) {' Line Number: 802
User prompt
Make it so I can edit my username in menu by clicking it and let's you type your own username ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
In leaderboard move prestige country beside cookies also make it say for cookies for example 1k 10k 100k and so on
User prompt
Remove prestige button when u open the shop then show it when closed also make all the buttons to close things like sitting and shop bigger
User prompt
None of the items have Textures add photos for each one
User prompt
Now for items in the shop make the pixel art for all of them
User prompt
Make it so insted of a bunch of numbers use things like 1k 10k 100k 1mil and so on for items in shop
User prompt
Make the later items much cheaper
User prompt
Move the cps in shop to the left on each item
User prompt
In the new shop make it so all items are easy to read
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
leaderboardNames: [],
leaderboardCookies: [],
leaderboardTimestamps: [],
leaderboardPrestiges: [],
playerName: "",
isOwner: false
});
/****
* Classes
****/
var Building = Container.expand(function (buildingType, cost, cps) {
var self = Container.call(this);
self.buildingType = buildingType;
self.cost = cost;
self.baseCost = cost;
self.cookiesPerSecond = cps;
self.count = 0;
var background = self.attachAsset('upgradeButton', {
anchorX: 0,
anchorY: 0
});
// Create detailed pixel art for each building type
if (buildingType === 'grandma') {
var grandmaBase = self.attachAsset('grandma', {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 40
});
var grandmaHair = self.attachAsset('grandmaHair', {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 25
});
var grandmaFace = self.attachAsset('grandmaFace', {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 35
});
var grandmaEyes1 = self.attachAsset('grandmaEyes', {
anchorX: 0.5,
anchorY: 0.5,
x: 35,
y: 32
});
var grandmaEyes2 = self.attachAsset('grandmaEyes', {
anchorX: 0.5,
anchorY: 0.5,
x: 45,
y: 32
});
var grandmaNose = self.attachAsset('grandmaNose', {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 37
});
var grandmaApron = self.attachAsset('grandmaApron', {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 55
});
} else if (buildingType === 'oven') {
var ovenBase = self.attachAsset('oven', {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 40
});
var ovenBody = self.attachAsset('ovenBody', {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 40
});
var ovenDoor = self.attachAsset('ovenDoor', {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 45
});
var ovenWindow = self.attachAsset('ovenWindow', {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 40
});
var ovenHandle = self.attachAsset('ovenHandle', {
anchorX: 0.5,
anchorY: 0.5,
x: 60,
y: 45
});
var ovenKnob1 = self.attachAsset('ovenKnob', {
anchorX: 0.5,
anchorY: 0.5,
x: 30,
y: 25
});
var ovenKnob2 = self.attachAsset('ovenKnob', {
anchorX: 0.5,
anchorY: 0.5,
x: 50,
y: 25
});
var ovenVents = self.attachAsset('ovenVents', {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 20
});
} else if (buildingType === 'factory') {
var factoryBase = self.attachAsset('factory', {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 40
});
var factoryRoof = self.attachAsset('factoryRoof', {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 15
});
var factoryChimney = self.attachAsset('factoryChimney', {
anchorX: 0.5,
anchorY: 0.5,
x: 30,
y: 10
});
var factorySmoke1 = self.attachAsset('factorySmoke', {
anchorX: 0.5,
anchorY: 0.5,
x: 25,
y: -10
});
var factorySmoke2 = self.attachAsset('factorySmoke', {
anchorX: 0.5,
anchorY: 0.5,
x: 35,
y: -15
});
var factoryWindow1 = self.attachAsset('factoryWindow', {
anchorX: 0.5,
anchorY: 0.5,
x: 20,
y: 35
});
var factoryWindow2 = self.attachAsset('factoryWindow', {
anchorX: 0.5,
anchorY: 0.5,
x: 60,
y: 35
});
var factoryDoor = self.attachAsset('factoryDoor', {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 55
});
} else {
var icon = self.attachAsset(buildingType, {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 40
});
}
var nameText = new Text2(buildingType.toUpperCase(), {
size: 24,
fill: 0xFFFFFF
});
nameText.anchor.set(0, 0.5);
nameText.x = 90;
nameText.y = 25;
self.addChild(nameText);
self.costText = new Text2('Cost: ' + self.cost, {
size: 20,
fill: 0xFFFF00
});
self.costText.anchor.set(0, 0.5);
self.costText.x = 90;
self.costText.y = 45;
self.addChild(self.costText);
self.countText = new Text2('Owned: ' + self.count, {
size: 18,
fill: 0xCCCCCC
});
self.countText.anchor.set(0, 0.5);
self.countText.x = 90;
self.countText.y = 65;
self.addChild(self.countText);
self.updateDisplay = function () {
self.costText.setText('Cost: ' + formatNumber(self.cost));
self.countText.setText('Owned: ' + self.count);
if (cookies >= self.cost) {
background.tint = 0x4169E1;
} else {
background.tint = 0x666666;
}
};
self.purchase = function () {
if (cookies >= self.cost) {
cookies -= self.cost;
self.count++;
totalCPS += self.cookiesPerSecond;
// Increase cost by 15%
self.cost = Math.floor(self.cost * 1.15);
if (!isMuted) {
LK.getSound('purchase').play();
}
self.updateDisplay();
updateDisplay();
saveGame();
}
};
self.down = function (x, y, obj) {
self.purchase();
};
return self;
});
var Cookie = Container.expand(function () {
var self = Container.call(this);
var cookieGraphics = self.attachAsset('cookie', {
anchorX: 0.5,
anchorY: 0.5
});
// Add detailed cookie decorations with pixel art style
var highlight = self.attachAsset('cookieHighlight', {
anchorX: 0.5,
anchorY: 0.5,
x: -40,
y: -60
});
highlight.alpha = 0.6;
var chip1 = self.attachAsset('cookieChip1', {
anchorX: 0.5,
anchorY: 0.5,
x: -50,
y: -30
});
var chip2 = self.attachAsset('cookieChip2', {
anchorX: 0.5,
anchorY: 0.5,
x: 60,
y: 40
});
var chip3 = self.attachAsset('cookieChip3', {
anchorX: 0.5,
anchorY: 0.5,
x: -20,
y: 70
});
var chip4 = self.attachAsset('cookieChip1', {
anchorX: 0.5,
anchorY: 0.5,
x: 30,
y: -50
});
var chip5 = self.attachAsset('cookieChip2', {
anchorX: 0.5,
anchorY: 0.5,
x: -70,
y: 20
});
self.originalScale = 1;
self.tap = function () {
// Check for auto-clicker
if (!recordClick() || clicksBlocked) {
return;
}
// Enhanced rotation animation without scaling
tween.stop(self, {
rotation: true
});
self.rotation += 0.1;
tween(self, {
rotation: 0
}, {
duration: 300,
easing: tween.elasticOut
});
// Color flash effect
tween.stop(cookieGraphics, {
tint: true
});
cookieGraphics.tint = 0xffff99;
tween(cookieGraphics, {
tint: 0xffffff
}, {
duration: 200
});
// Play sound effect
if (!isMuted) {
LK.getSound('cookieTap').play();
}
// Add cookies with prestige bonus
var cookiesGained = cookiesPerTap * tapMultiplier;
cookies += cookiesGained;
allTimeCookies += cookiesGained;
updateDisplay();
// Spawn mini cookie instead of floating number
var miniCookie = game.addChild(new MiniCookie());
miniCookie.x = self.x + (Math.random() - 0.5) * 100;
miniCookie.y = self.y + (Math.random() - 0.5) * 100;
};
self.down = function (x, y, obj) {
if (gameStarted && !upgradeMenu.isOpen && !settingsMenu.isOpen && !leaderboard.isOpen && !tutorialScreen.isOpen && (!prestigeMenu || !prestigeMenu.isOpen)) {
self.tap();
}
};
return self;
});
var FallingCookie = Container.expand(function () {
var self = Container.call(this);
var cookieGraphics = self.attachAsset('fallingCookie', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
var chip1 = self.attachAsset('cookieChip1', {
anchorX: 0.5,
anchorY: 0.5,
x: -15,
y: -10
});
var chip2 = self.attachAsset('cookieChip2', {
anchorX: 0.5,
anchorY: 0.5,
x: 20,
y: 15
});
self.fallSpeed = 3 + Math.random() * 4;
self.rotationSpeed = 0.05 + Math.random() * 0.1;
self.value = Math.floor(cookies * 0.01) + Math.floor(Math.random() * (cookies * 0.05)) + 1;
self.update = function () {
self.y += self.fallSpeed;
self.rotation += self.rotationSpeed;
if (self.y > 2800) {
self.destroy();
}
};
self.collect = function () {
cookies += self.value;
allTimeCookies += self.value;
LK.getSound('fallingCookieClick').play();
showFloatingNumber('+' + self.value, self.x, self.y);
updateDisplay();
self.destroy();
};
self.down = function (x, y, obj) {
self.collect();
};
return self;
});
var FloatingNumber = Container.expand(function (text, startX, startY) {
var self = Container.call(this);
var numberText = new Text2(text, {
size: 56,
fill: 0xFFD700
});
numberText.anchor.set(0.5, 0.5);
self.addChild(numberText);
self.x = startX;
self.y = startY;
self.alpha = 1;
// Animate upward and fade out
tween(self, {
y: self.y - 100,
alpha: 0
}, {
duration: 1500,
easing: tween.easeOut,
onFinish: function onFinish() {
self.destroy();
}
});
return self;
});
var Leaderboard = Container.expand(function () {
var self = Container.call(this);
self.isOpen = false;
var background = self.attachAsset('leaderboardBg', {
anchorX: 0,
anchorY: 0,
width: 2048,
height: 2732
});
var panel = self.attachAsset('leaderboardPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
});
var header = self.attachAsset('leaderboardHeader', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 400
});
var titleText = new Text2('LEADERBOARD - TOP 10', {
size: 48,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 400;
self.addChild(titleText);
var closeBtn = self.attachAsset('closeButtonPixel', {
anchorX: 0.5,
anchorY: 0.5,
x: 1700,
y: 400
});
var closeX1 = self.attachAsset('closeButtonX', {
anchorX: 0.5,
anchorY: 0.5,
x: 1700,
y: 400,
rotation: Math.PI / 4
});
var closeX2 = self.attachAsset('closeButtonX', {
anchorX: 0.5,
anchorY: 0.5,
x: 1700,
y: 400,
rotation: -Math.PI / 4
});
self.entries = [];
self.updateLeaderboard = function () {
// Clear existing entries
for (var i = 0; i < self.entries.length; i++) {
self.entries[i].destroy();
}
self.entries = [];
var leaderboardNames = storage.leaderboardNames || [];
var leaderboardCookies = storage.leaderboardCookies || [];
var leaderboardTimestamps = storage.leaderboardTimestamps || [];
var leaderboardPrestiges = storage.leaderboardPrestiges || [];
// Create array of indices and sort by cookies
var indices = [];
for (var i = 0; i < leaderboardNames.length; i++) {
indices.push(i);
}
indices.sort(function (a, b) {
return leaderboardCookies[b] - leaderboardCookies[a];
});
for (var i = 0; i < Math.min(10, indices.length); i++) {
var idx = indices[i];
var yPos = 600 + i * 100;
var entryBg = self.addChild(LK.getAsset('leaderboardEntry', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: yPos
}));
var rankText = new Text2(i + 1 + '.', {
size: 32,
fill: 0xFFFFFF
});
rankText.anchor.set(0.5, 0.5);
rankText.x = 300;
rankText.y = yPos;
self.addChild(rankText);
var displayName = getDisplayName(leaderboardNames[idx]);
var nameText = new Text2(displayName, {
size: 28,
fill: leaderboardNames[idx] === 'NEO' ? 0xFF6B35 : 0xFFD700
});
nameText.anchor.set(0, 0.5);
nameText.x = 400;
nameText.y = yPos;
self.addChild(nameText);
var cookieText = new Text2(formatNumber(Math.floor(leaderboardCookies[idx])) + ' cookies', {
size: 36,
fill: 0x90EE90
});
cookieText.anchor.set(0, 0.5);
cookieText.x = 800;
cookieText.y = yPos;
self.addChild(cookieText);
var prestigeText = new Text2('Prestige: ' + (leaderboardPrestiges[idx] || 0), {
size: 32,
fill: 0xFFB347
});
prestigeText.anchor.set(0, 0.5);
prestigeText.x = 1400;
prestigeText.y = yPos;
self.addChild(prestigeText);
self.entries.push(entryBg, rankText, nameText, cookieText, prestigeText);
}
};
self.open = function () {
self.isOpen = true;
self.alpha = 0;
self.visible = true;
self.updateLeaderboard();
tween(self, {
alpha: 1
}, {
duration: 300
});
};
self.close = function () {
self.isOpen = false;
tween(self, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
self.visible = false;
}
});
};
closeBtn.down = function () {
if (!isMuted) LK.getSound('buttonClick').play();
self.close();
};
closeX1.down = function () {
if (!isMuted) LK.getSound('buttonClick').play();
self.close();
};
closeX2.down = function () {
if (!isMuted) LK.getSound('buttonClick').play();
self.close();
};
self.visible = false;
return self;
});
var MainMenu = Container.expand(function () {
var self = Container.call(this);
// Light brown background
var background = self.attachAsset('mainMenuBg', {
anchorX: 0,
anchorY: 0,
width: 2048,
height: 2732
});
background.tint = 0xd4a574; // light brown
// Large cookie in the background, centered and faded, matching in-game cookie
var bgCookie = self.attachAsset('cookie', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
scaleX: 2.5,
scaleY: 2.5
});
bgCookie.alpha = 0.22;
// Username input section
var usernameBg = self.attachAsset('cookieCounter', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 800
});
var usernameLabel = new Text2('USERNAME:', {
size: 32,
fill: 0xFFFFFF
});
usernameLabel.anchor.set(0.5, 0.5);
usernameLabel.x = 1024;
usernameLabel.y = 760;
self.addChild(usernameLabel);
self.usernameDisplay = new Text2(playerName || 'Tap to enter username', {
size: 28,
fill: 0xFFD700
});
self.usernameDisplay.anchor.set(0.5, 0.5);
self.usernameDisplay.x = 1024;
self.usernameDisplay.y = 800;
self.addChild(self.usernameDisplay);
// Add visual feedback for clickable username
self.usernameDisplay.originalTint = 0xFFD700;
// Make username input clickable
usernameBg.down = function () {
if (!isMuted) LK.getSound('buttonClick').play();
self.editUsername();
};
self.usernameDisplay.down = function () {
if (!isMuted) LK.getSound('buttonClick').play();
// Add visual feedback
tween.stop(self.usernameDisplay, {
tint: true
});
self.usernameDisplay.tint = 0xFFFFFF;
tween(self.usernameDisplay, {
tint: self.usernameDisplay.originalTint
}, {
duration: 200
});
self.editUsername();
};
self.editUsername = function () {
// Create keyboard input overlay
if (self.keyboardOverlay) return; // Prevent multiple overlays
self.keyboardOverlay = self.addChild(LK.getAsset('leaderboardBg', {
anchorX: 0,
anchorY: 0,
width: 2048,
height: 2732
}));
self.keyboardOverlay.alpha = 0.9;
var inputPanel = self.keyboardOverlay.addChild(LK.getAsset('leaderboardPanel', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
}));
var titleText = new Text2('ENTER USERNAME', {
size: 48,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 1000;
self.keyboardOverlay.addChild(titleText);
var instructionText = new Text2('Max 20 characters', {
size: 32,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0.5);
instructionText.x = 1024;
instructionText.y = 1100;
self.keyboardOverlay.addChild(instructionText);
// Input field background
var inputBg = self.keyboardOverlay.addChild(LK.getAsset('cookieCounter', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1200,
scaleX: 1.5,
scaleY: 1.2
}));
// Current input display
self.currentInput = playerName || '';
self.inputDisplay = new Text2(self.currentInput || 'Enter username...', {
size: 40,
fill: self.currentInput ? 0xFFD700 : 0x888888
});
self.inputDisplay.anchor.set(0.5, 0.5);
self.inputDisplay.x = 1024;
self.inputDisplay.y = 1200;
self.keyboardOverlay.addChild(self.inputDisplay);
// Create virtual keyboard
var keyboardKeys = [['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P'], ['A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L'], ['Z', 'X', 'C', 'V', 'B', 'N', 'M']];
var keySize = 80;
var keySpacing = 90;
var startY = 1350;
self.keyboardButtons = [];
for (var row = 0; row < keyboardKeys.length; row++) {
var rowKeys = keyboardKeys[row];
var rowWidth = rowKeys.length * keySpacing;
var startX = 1024 - rowWidth / 2 + keySpacing / 2;
for (var col = 0; col < rowKeys.length; col++) {
var key = rowKeys[col];
var keyX = startX + col * keySpacing;
var keyY = startY + row * 100;
var keyButton = self.keyboardOverlay.addChild(LK.getAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: keyX,
y: keyY,
scaleX: 0.8,
scaleY: 0.8
}));
var keyText = new Text2(key, {
size: 32,
fill: 0xFFFFFF
});
keyText.anchor.set(0.5, 0.5);
keyText.x = keyX;
keyText.y = keyY;
self.keyboardOverlay.addChild(keyText);
keyButton.keyChar = key;
keyButton.down = function () {
if (self.currentInput.length < 20) {
self.currentInput += this.keyChar;
self.inputDisplay.setText(self.currentInput);
self.inputDisplay.fill = 0xFFD700;
}
};
self.keyboardButtons.push(keyButton);
}
}
// Space bar
var spaceButton = self.keyboardOverlay.addChild(LK.getAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: startY + 300,
scaleX: 3,
scaleY: 0.8
}));
var spaceText = new Text2('SPACE', {
size: 28,
fill: 0xFFFFFF
});
spaceText.anchor.set(0.5, 0.5);
spaceText.x = 1024;
spaceText.y = startY + 300;
self.keyboardOverlay.addChild(spaceText);
spaceButton.down = function () {
if (self.currentInput.length < 20) {
self.currentInput += ' ';
self.inputDisplay.setText(self.currentInput);
self.inputDisplay.fill = 0xFFD700;
}
};
// Backspace button
var backspaceButton = self.keyboardOverlay.addChild(LK.getAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024 - 200,
y: startY + 300,
scaleX: 1.5,
scaleY: 0.8
}));
var backspaceText = new Text2('⌫', {
size: 32,
fill: 0xFFFFFF
});
backspaceText.anchor.set(0.5, 0.5);
backspaceText.x = 1024 - 200;
backspaceText.y = startY + 300;
self.keyboardOverlay.addChild(backspaceText);
backspaceButton.down = function () {
if (self.currentInput.length > 0) {
self.currentInput = self.currentInput.slice(0, -1);
self.inputDisplay.setText(self.currentInput || 'Enter username...');
self.inputDisplay.fill = self.currentInput ? 0xFFD700 : 0x888888;
}
};
// Clear button
var clearButton = self.keyboardOverlay.addChild(LK.getAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024 + 200,
y: startY + 300,
scaleX: 1.5,
scaleY: 0.8
}));
var clearText = new Text2('CLEAR', {
size: 28,
fill: 0xFFFFFF
});
clearText.anchor.set(0.5, 0.5);
clearText.x = 1024 + 200;
clearText.y = startY + 300;
self.keyboardOverlay.addChild(clearText);
clearButton.down = function () {
self.currentInput = '';
self.inputDisplay.setText('Enter username...');
self.inputDisplay.fill = 0x888888;
};
// Confirm button
var confirmButton = self.keyboardOverlay.addChild(LK.getAsset('playButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: startY + 450,
scaleX: 1.2,
scaleY: 1
}));
var confirmText = new Text2('CONFIRM', {
size: 36,
fill: 0xFFFFFF
});
confirmText.anchor.set(0.5, 0.5);
confirmText.x = 1024;
confirmText.y = startY + 450;
self.keyboardOverlay.addChild(confirmText);
confirmButton.down = function () {
self.confirmUsername();
};
// Cancel button
var cancelButton = self.keyboardOverlay.addChild(LK.getAsset('closeButtonPixel', {
anchorX: 0.5,
anchorY: 0.5,
x: 1750,
y: 1000
}));
var cancelX1 = self.keyboardOverlay.addChild(LK.getAsset('closeButtonX', {
anchorX: 0.5,
anchorY: 0.5,
x: 1750,
y: 1000,
rotation: Math.PI / 4
}));
var cancelX2 = self.keyboardOverlay.addChild(LK.getAsset('closeButtonX', {
anchorX: 0.5,
anchorY: 0.5,
x: 1750,
y: 1000,
rotation: -Math.PI / 4
}));
cancelButton.down = function () {
self.closeKeyboard();
};
};
self.confirmUsername = function () {
var newUsername = self.currentInput.trim();
if (!newUsername) {
// Generate unique random username if empty
var attempts = 0;
do {
newUsername = 'Player' + Math.floor(Math.random() * 10000);
attempts++;
} while (!isUsernameAvailable(newUsername) && attempts < 100);
}
if (newUsername.length > 20) {
// Show error without alert
self.inputDisplay.setText('Too long! Max 20 chars');
self.inputDisplay.fill = 0xFF5555;
return;
}
if (isUsernameAvailable(newUsername) || newUsername === playerName) {
// If changing username, remove old entry from leaderboard
if (playerName && playerName !== newUsername) {
var leaderboardNames = (storage.leaderboardNames || []).slice();
var leaderboardCookies = (storage.leaderboardCookies || []).slice();
var leaderboardTimestamps = (storage.leaderboardTimestamps || []).slice();
var leaderboardPrestiges = (storage.leaderboardPrestiges || []).slice();
for (var i = 0; i < leaderboardNames.length; i++) {
if (leaderboardNames[i] === playerName) {
leaderboardNames.splice(i, 1);
leaderboardCookies.splice(i, 1);
leaderboardTimestamps.splice(i, 1);
leaderboardPrestiges.splice(i, 1);
break;
}
}
storage.leaderboardNames = leaderboardNames;
storage.leaderboardCookies = leaderboardCookies;
storage.leaderboardTimestamps = leaderboardTimestamps;
storage.leaderboardPrestiges = leaderboardPrestiges;
}
playerName = newUsername;
// Auto-save immediately
var nameToStore = String(playerName);
storage.playerName = nameToStore;
self.usernameDisplay.setText(playerName);
self.closeKeyboard();
if (!isMuted) LK.getSound('buttonClick').play();
} else {
self.inputDisplay.setText('Username taken!');
self.inputDisplay.fill = 0xFF5555;
}
};
self.closeKeyboard = function () {
if (self.keyboardOverlay) {
self.keyboardOverlay.destroy();
self.keyboardOverlay = null;
self.keyboardButtons = [];
self.inputDisplay = null;
self.currentInput = '';
}
};
self.updateUsername = function () {
var displayName = getDisplayName(playerName) || 'Tap to enter username';
self.usernameDisplay.setText(displayName);
// Set special color for owner
if (playerName === 'NEO') {
self.usernameDisplay.fill = 0xFF6B35;
} else if (self.usernameDisplay.originalTint) {
self.usernameDisplay.tint = self.usernameDisplay.originalTint;
}
};
// Add detailed cookie decorations for menu cookie (same as in-game)
var bgHighlight = self.attachAsset('cookieHighlight', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024 - 40,
y: 1366 - 60,
scaleX: 1.5,
scaleY: 1.5
});
bgHighlight.alpha = 0.18;
var bgChip1 = self.attachAsset('cookieChip1', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024 - 50,
y: 1366 - 30,
scaleX: 1.2,
scaleY: 1.2
});
bgChip1.alpha = 0.18;
var bgChip2 = self.attachAsset('cookieChip2', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024 + 60,
y: 1366 + 40,
scaleX: 1.1,
scaleY: 1.1
});
bgChip2.alpha = 0.18;
var bgChip3 = self.attachAsset('cookieChip3', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024 - 20,
y: 1366 + 70,
scaleX: 1.1,
scaleY: 1.1
});
bgChip3.alpha = 0.18;
var bgChip4 = self.attachAsset('cookieChip1', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024 + 30,
y: 1366 - 50,
scaleX: 1.1,
scaleY: 1.1
});
bgChip4.alpha = 0.18;
var bgChip5 = self.attachAsset('cookieChip2', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024 - 70,
y: 1366 + 20,
scaleX: 1.1,
scaleY: 1.1
});
bgChip5.alpha = 0.18;
// Add more menu details: subtle border and shadow
var menuPanel = self.attachAsset('menuPanelPixel', {
anchorX: 0,
anchorY: 0,
width: 2048,
height: 2732
});
menuPanel.alpha = 0.12;
var menuPanelBorder = self.attachAsset('menuPanel', {
anchorX: 0,
anchorY: 0,
width: 2048,
height: 2732
});
menuPanelBorder.alpha = 0.08;
var titleText = new Text2('COOKIE TAP EMPIRE', {
size: 80,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 600;
self.addChild(titleText);
// Play button with pixel art
var playBorder = self.attachAsset('playButtonBorder', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1000
});
var playButton = self.attachAsset('playButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1000
});
var playHighlight = self.attachAsset('playButtonHighlight', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 980
});
var playText = new Text2('PLAY', {
size: 36,
fill: 0xFFFFFF
});
playText.anchor.set(0.5, 0.5);
playText.x = 1024;
playText.y = 1000;
self.addChild(playText);
// Leaderboard button
var leaderBorder = self.attachAsset('leaderboardBorder', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1200
});
var leaderButton = self.attachAsset('leaderboardButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1200
});
var leaderText = new Text2('LEADERBOARD', {
size: 32,
fill: 0xFFFFFF
});
leaderText.anchor.set(0.5, 0.5);
leaderText.x = 1024;
leaderText.y = 1200;
self.addChild(leaderText);
// Settings button
var settingsBorder = self.attachAsset('settingsBorder', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1400
});
var settingsButton = self.attachAsset('settingsButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1400
});
var settingsText = new Text2('SETTINGS', {
size: 32,
fill: 0xFFFFFF
});
settingsText.anchor.set(0.5, 0.5);
settingsText.x = 1024;
settingsText.y = 1400;
self.addChild(settingsText);
// Tutorial button
var tutorialBorder = self.attachAsset('tutorialBorder', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1600
});
var tutorialButton = self.attachAsset('tutorialButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1600
});
var tutorialText = new Text2('TUTORIAL', {
size: 32,
fill: 0xFFFFFF
});
tutorialText.anchor.set(0.5, 0.5);
tutorialText.x = 1024;
tutorialText.y = 1600;
self.addChild(tutorialText);
function handlePlayClick() {
if (!isMuted) LK.getSound('buttonClick').play();
// Generate unique random username if none set
if (!playerName || playerName === '') {
var attempts = 0;
do {
playerName = 'Player' + Math.floor(Math.random() * 10000);
attempts++;
} while (!isUsernameAvailable(playerName) && attempts < 100);
try {
// Store as simple string literal to avoid storage restrictions
var nameToStore = String(playerName);
storage.playerName = nameToStore;
} catch (e) {
console.log('Storage not available for username save');
}
}
gameStarted = true;
// Show cookie counters when game starts
cookieCounterBg.visible = true;
cookieDisplay.visible = true;
cpsCounterBg.visible = true;
cpsDisplay.visible = true;
// Show prestige level when game starts
prestigeDisplay.visible = true;
self.close();
}
function handleLeaderboardClick() {
if (!isMuted) LK.getSound('buttonClick').play();
leaderboard.open();
}
function handleSettingsClick() {
if (!isMuted) LK.getSound('buttonClick').play();
settingsMenu.open();
}
function handleTutorialClick() {
if (!isMuted) LK.getSound('buttonClick').play();
showTutorial();
}
playBorder.down = handlePlayClick;
playButton.down = handlePlayClick;
playText.down = handlePlayClick;
leaderBorder.down = handleLeaderboardClick;
leaderButton.down = handleLeaderboardClick;
leaderText.down = handleLeaderboardClick;
settingsBorder.down = handleSettingsClick;
settingsButton.down = handleSettingsClick;
settingsText.down = handleSettingsClick;
tutorialBorder.down = handleTutorialClick;
tutorialButton.down = handleTutorialClick;
tutorialText.down = handleTutorialClick;
self.close = function () {
tween(self, {
alpha: 0
}, {
duration: 500,
onFinish: function onFinish() {
self.visible = false;
// Only show tutorial if requested from menu
}
});
};
return self;
});
var MiniCookie = Container.expand(function () {
var self = Container.call(this);
var cookieGraphics = self.attachAsset('fallingCookie', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6
});
var chip1 = self.attachAsset('cookieChip1', {
anchorX: 0.5,
anchorY: 0.5,
x: -8,
y: -5
});
var chip2 = self.attachAsset('cookieChip2', {
anchorX: 0.5,
anchorY: 0.5,
x: 10,
y: 8
});
// Random movement direction
self.velocityX = (Math.random() - 0.5) * 8;
self.velocityY = -2 - Math.random() * 4;
self.rotationSpeed = (Math.random() - 0.5) * 0.2;
self.gravity = 0.15;
self.lifetime = 0;
self.maxLifetime = 120; // 2 seconds at 60fps
self.update = function () {
// Update position
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += self.gravity;
// Update rotation
self.rotation += self.rotationSpeed;
// Fade out over time
self.lifetime++;
if (self.lifetime > self.maxLifetime * 0.7) {
self.alpha = 1 - (self.lifetime - self.maxLifetime * 0.7) / (self.maxLifetime * 0.3);
}
// Remove when lifetime expires
if (self.lifetime >= self.maxLifetime) {
self.destroy();
}
};
return self;
});
var PrestigeButton = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('prestigeButton', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.5,
scaleY: 2.5
});
var titleText = new Text2('ASCEND', {
size: 64,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0.5);
self.addChild(titleText);
self.updateDisplay = function () {
var totalUpgrades = 0;
for (var i = 0; i < buildings.length; i++) {
totalUpgrades += buildings[i].count;
}
var requiredUpgrades = 100 + prestigeLevel * 10;
var hasEnoughUpgrades = totalUpgrades >= requiredUpgrades;
canPrestige = allTimeCookies >= 100000 && hasEnoughUpgrades;
if (canPrestige) {
background.tint = 0xFF4500;
background.alpha = 1;
titleText.setText('PRESTIGE');
} else {
background.tint = 0x666666;
background.alpha = 0.5;
titleText.setText('PRESTIGE');
}
};
self.showPrestigeMenu = function () {
if (!prestigeMenu) {
prestigeMenu = game.addChild(new PrestigeMenu());
prestigeMenu.x = 1024;
prestigeMenu.y = 1366;
}
prestigeMenu.open();
};
self.down = function (x, y, obj) {
self.showPrestigeMenu();
};
return self;
});
var PrestigeMenu = Container.expand(function () {
var self = Container.call(this);
self.isOpen = false;
// Menu border and background
var border = self.attachAsset('prestigeBorder', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.8,
scaleY: 1.8
});
var background = self.attachAsset('prestigePanel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.8,
scaleY: 1.8
});
var titleText = new Text2('ASCENSION', {
size: 52,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -150;
self.addChild(titleText);
self.reqText = new Text2('', {
size: 42,
fill: 0xFFFFFF
});
self.reqText.anchor.set(0.5, 0.5);
self.reqText.y = -80;
self.addChild(self.reqText);
// Prestige action button
var actionBtn = self.attachAsset('prestigeButton', {
anchorX: 0.5,
anchorY: 0.5,
y: 120,
scaleX: 1.4,
scaleY: 1.4
});
self.actionText = new Text2('ASCEND', {
size: 36,
fill: 0xFFFFFF
});
self.actionText.anchor.set(0.5, 0.5);
self.actionText.y = 120;
self.addChild(self.actionText);
// Close button
var closeBtn = self.attachAsset('closeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 320,
y: -180
});
var closeText = new Text2('X', {
size: 28,
fill: 0xFFFFFF
});
closeText.anchor.set(0.5, 0.5);
closeText.x = 320;
closeText.y = -180;
self.addChild(closeText);
self.updateDisplay = function () {
var totalUpgrades = 0;
for (var i = 0; i < buildings.length; i++) {
totalUpgrades += buildings[i].count;
}
var requiredUpgrades = 100 + prestigeLevel * 10;
var hasEnoughUpgrades = totalUpgrades >= requiredUpgrades;
var hasEnoughCookies = allTimeCookies >= 100000;
self.reqText.setText('Level 1 Requirements:\n\n' + requiredUpgrades + ' upgrades (' + totalUpgrades + '/' + requiredUpgrades + ')\n\n' + '100,000 cookies (' + Math.floor(allTimeCookies) + '/100,000)');
canPrestige = hasEnoughUpgrades && hasEnoughCookies;
if (canPrestige) {
actionBtn.tint = 0xFF4500;
actionBtn.alpha = 1;
self.actionText.setText('ASCEND');
} else {
actionBtn.tint = 0x666666;
actionBtn.alpha = 0.5;
self.actionText.setText('REQUIREMENTS NOT MET');
}
};
self.prestige = function () {
if (!canPrestige) return;
// Reset game state
cookies = 0;
totalCPS = 0;
for (var i = 0; i < buildings.length; i++) {
buildings[i].count = 0;
buildings[i].cost = buildings[i].baseCost;
}
// Increase prestige
prestigeLevel++;
prestigeBonus = prestigeLevel * 0.1;
allTimeCookies = 0;
canPrestige = false;
// Apply prestige bonus to tap multiplier
tapMultiplier = 1 + prestigeBonus;
LK.getSound('prestige').play();
updateDisplay();
saveGame();
// Flash effect and close menu
LK.effects.flashScreen(0xFFD700, 1000);
self.close();
};
self.open = function () {
self.isOpen = true;
self.alpha = 0;
self.visible = true;
self.updateDisplay();
tween(self, {
alpha: 1
}, {
duration: 300
});
};
self.close = function () {
self.isOpen = false;
tween(self, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
self.visible = false;
}
});
};
actionBtn.down = function () {
self.prestige();
};
self.actionText.down = function () {
self.prestige();
};
closeBtn.down = function () {
self.close();
};
closeText.down = function () {
self.close();
};
self.visible = false;
return self;
});
var SettingsMenu = Container.expand(function () {
var self = Container.call(this);
self.isOpen = false;
var background = self.attachAsset('settingsPanel', {
anchorX: 0.5,
anchorY: 0.5
});
var border = self.attachAsset('settingsBorder', {
anchorX: 0.5,
anchorY: 0.5
});
var titleText = new Text2('SETTINGS', {
size: 48,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -200;
self.addChild(titleText);
// Mute button
var muteButton = self.attachAsset('muteButton', {
anchorX: 0.5,
anchorY: 0.5,
y: -80
});
self.muteText = new Text2('SOUND: ON', {
size: 32,
fill: 0xFFFFFF
});
self.muteText.anchor.set(0.5, 0.5);
self.muteText.y = -80;
self.addChild(self.muteText);
// Volume controls
var volumeText = new Text2('MUSIC VOLUME', {
size: 24,
fill: 0xFFFFFF
});
volumeText.anchor.set(0.5, 0.5);
volumeText.y = 0;
self.addChild(volumeText);
var volumeSlider = self.attachAsset('volumeSlider', {
anchorX: 0.5,
anchorY: 0.5,
y: 40
});
self.volumeHandle = self.attachAsset('volumeHandle', {
anchorX: 0.5,
anchorY: 0.5,
x: storage.musicVolume ? (storage.musicVolume - 0.5) * 300 : -60,
y: 40
});
// Quality settings
var qualityText = new Text2('GRAPHICS: HIGH', {
size: 24,
fill: 0xFFFFFF
});
qualityText.anchor.set(0.5, 0.5);
qualityText.y = 120;
self.addChild(qualityText);
// Close button
var closeBtn = self.attachAsset('closeButtonPixel', {
anchorX: 0.5,
anchorY: 0.5,
x: 300,
y: -200,
scaleX: 1.5,
scaleY: 1.5
});
var closeX1 = self.attachAsset('closeButtonX', {
anchorX: 0.5,
anchorY: 0.5,
x: 300,
y: -200,
rotation: Math.PI / 4,
scaleX: 1.5,
scaleY: 1.5
});
var closeX2 = self.attachAsset('closeButtonX', {
anchorX: 0.5,
anchorY: 0.5,
x: 300,
y: -200,
rotation: -Math.PI / 4,
scaleX: 1.5,
scaleY: 1.5
});
self.updateMuteDisplay = function () {
if (isMuted) {
self.muteText.setText('SOUND: OFF');
muteButton.tint = 0xFF5722;
LK.stopMusic();
} else {
self.muteText.setText('SOUND: ON');
muteButton.tint = 0x4CAF50;
LK.playMusic('bgmusic', {
loop: true
});
}
};
muteButton.down = function () {
isMuted = !isMuted;
storage.isMuted = isMuted;
self.updateMuteDisplay();
if (!isMuted) LK.getSound('buttonClick').play();
};
self.muteText.down = function () {
isMuted = !isMuted;
storage.isMuted = isMuted;
self.updateMuteDisplay();
if (!isMuted) LK.getSound('buttonClick').play();
};
// Volume slider functionality
self.volumeHandle.down = function () {
self.draggingVolume = true;
};
self.move = function (x, y, obj) {
if (self.draggingVolume) {
var localX = Math.max(-150, Math.min(150, x));
self.volumeHandle.x = localX;
var volume = (localX + 150) / 300;
storage.musicVolume = volume;
// Update music volume here if needed
}
};
self.up = function (x, y, obj) {
self.draggingVolume = false;
};
function handleClose() {
if (!isMuted) LK.getSound('buttonClick').play();
self.close();
}
closeBtn.down = handleClose;
closeX1.down = handleClose;
closeX2.down = handleClose;
self.open = function () {
self.isOpen = true;
self.alpha = 0;
self.visible = true;
self.updateMuteDisplay();
tween(self, {
alpha: 1
}, {
duration: 300
});
};
self.close = function () {
self.isOpen = false;
tween(self, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
self.visible = false;
}
});
};
self.visible = false;
return self;
});
var Shop = Container.expand(function () {
var self = Container.call(this);
self.isOpen = false;
self.currentPage = 0;
self.itemsPerPage = 6;
// Full screen background
var background = self.attachAsset('shopFullscreen', {
anchorX: 0,
anchorY: 0,
width: 2048,
height: 2732
});
// Header
var header = self.attachAsset('shopHeader', {
anchorX: 0,
anchorY: 0,
width: 2048,
height: 150
});
var headerText = new Text2('SHOP', {
size: 64,
fill: 0xFFD700
});
headerText.anchor.set(0.5, 0.5);
headerText.x = 1024;
headerText.y = 75;
self.addChild(headerText);
// Close button
var closeBtn = self.attachAsset('closeButtonPixel', {
anchorX: 0.5,
anchorY: 0.5,
x: 1850,
y: 75,
scaleX: 1.5,
scaleY: 1.5
});
var closeX1 = self.attachAsset('closeButtonX', {
anchorX: 0.5,
anchorY: 0.5,
x: 1850,
y: 75,
rotation: Math.PI / 4,
scaleX: 1.5,
scaleY: 1.5
});
var closeX2 = self.attachAsset('closeButtonX', {
anchorX: 0.5,
anchorY: 0.5,
x: 1850,
y: 75,
rotation: -Math.PI / 4,
scaleX: 1.5,
scaleY: 1.5
});
// Page navigation
self.prevButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: 2500,
scaleX: 1.5,
scaleY: 0.8
});
self.nextButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1848,
y: 2500,
scaleX: 1.5,
scaleY: 0.8
});
self.prevText = new Text2('← PREV', {
size: 36,
fill: 0xFFFFFF
});
self.prevText.anchor.set(0.5, 0.5);
self.prevText.x = 200;
self.prevText.y = 2500;
self.addChild(self.prevText);
self.nextText = new Text2('NEXT →', {
size: 36,
fill: 0xFFFFFF
});
self.nextText.anchor.set(0.5, 0.5);
self.nextText.x = 1848;
self.nextText.y = 2500;
self.addChild(self.nextText);
// Page indicator
self.pageText = new Text2('Page 1 of 1', {
size: 32,
fill: 0xCCCCCC
});
self.pageText.anchor.set(0.5, 0.5);
self.pageText.x = 1024;
self.pageText.y = 2500;
self.addChild(self.pageText);
// Item slots
self.itemSlots = [];
self.createItemSlots = function () {
// Clear existing slots
for (var i = 0; i < self.itemSlots.length; i++) {
self.itemSlots[i].destroy();
}
self.itemSlots = [];
var cols = 2;
var rows = 3;
var slotWidth = 900;
var slotHeight = 320;
var startX = 1024 - cols * slotWidth / 2 + slotWidth / 2;
var startY = 300;
for (var row = 0; row < rows; row++) {
for (var col = 0; col < cols; col++) {
var slotIndex = row * cols + col;
var x = startX + col * slotWidth;
var y = startY + row * slotHeight;
var slot = self.addChild(new ShopItem(x, y, slotIndex));
self.itemSlots.push(slot);
}
}
};
self.updatePage = function () {
var totalPages = Math.ceil(buildings.length / self.itemsPerPage);
// Update page indicator
self.pageText.setText('Page ' + (self.currentPage + 1) + ' of ' + totalPages);
// Update navigation buttons
self.prevButton.alpha = self.currentPage > 0 ? 1 : 0.3;
self.nextButton.alpha = self.currentPage < totalPages - 1 ? 1 : 0.3;
self.prevText.alpha = self.currentPage > 0 ? 1 : 0.3;
self.nextText.alpha = self.currentPage < totalPages - 1 ? 1 : 0.3;
// Update item slots
for (var i = 0; i < self.itemSlots.length; i++) {
var slot = self.itemSlots[i];
var buildingIndex = self.currentPage * self.itemsPerPage + i;
if (buildingIndex < buildings.length) {
slot.setBuilding(buildings[buildingIndex]);
slot.visible = true;
} else {
slot.visible = false;
}
}
};
self.prevPage = function () {
if (self.currentPage > 0) {
self.currentPage--;
self.updatePage();
if (!isMuted) LK.getSound('buttonClick').play();
}
};
self.nextPage = function () {
var totalPages = Math.ceil(buildings.length / self.itemsPerPage);
if (self.currentPage < totalPages - 1) {
self.currentPage++;
self.updatePage();
if (!isMuted) LK.getSound('buttonClick').play();
}
};
self.open = function () {
self.isOpen = true;
self.currentPage = 0;
self.alpha = 0;
self.visible = true;
// Hide prestige button when shop opens
prestigeButton.visible = false;
self.createItemSlots();
self.updatePage();
tween(self, {
alpha: 1
}, {
duration: 300
});
if (!isMuted) LK.getSound('menuOpen').play();
};
self.close = function () {
self.isOpen = false;
// Show prestige button when shop closes
prestigeButton.visible = true;
tween(self, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
self.visible = false;
}
});
if (!isMuted) LK.getSound('buttonClick').play();
};
function handleClose() {
if (!isMuted) LK.getSound('buttonClick').play();
self.close();
}
closeBtn.down = handleClose;
closeX1.down = handleClose;
closeX2.down = handleClose;
self.prevButton.down = self.prevPage;
self.prevText.down = self.prevPage;
self.nextButton.down = self.nextPage;
self.nextText.down = self.nextPage;
self.visible = false;
return self;
});
var ShopItem = Container.expand(function (x, y, slotIndex) {
var self = Container.call(this);
self.x = x;
self.y = y;
self.building = null;
// Item background
var background = self.attachAsset('upgradeSlot', {
anchorX: 0.5,
anchorY: 0.5,
width: 850,
height: 280
});
// Icon area
var iconBg = self.attachAsset('upgradeIcon', {
anchorX: 0.5,
anchorY: 0.5,
x: -300,
y: 0,
scaleX: 2,
scaleY: 2
});
// Text elements
self.nameText = new Text2('', {
size: 56,
fill: 0xFFFFFF
});
self.nameText.anchor.set(0, 0.5);
self.nameText.x = -100;
self.nameText.y = -70;
self.addChild(self.nameText);
self.costText = new Text2('', {
size: 44,
fill: 0xFFFF00
});
self.costText.anchor.set(0, 0.5);
self.costText.x = -100;
self.costText.y = -20;
self.addChild(self.costText);
self.ownedText = new Text2('', {
size: 40,
fill: 0xCCCCCC
});
self.ownedText.anchor.set(0, 0.5);
self.ownedText.x = -100;
self.ownedText.y = 30;
self.addChild(self.ownedText);
self.cpsText = new Text2('', {
size: 42,
fill: 0x90EE90
});
self.cpsText.anchor.set(0, 0.5);
self.cpsText.x = -100;
self.cpsText.y = 80;
self.addChild(self.cpsText);
// Buy button
self.buyButton = self.attachAsset('upgradeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 300,
y: 60,
scaleX: 1.5,
scaleY: 0.8
});
self.buyText = new Text2('BUY', {
size: 36,
fill: 0xFFFFFF
});
self.buyText.anchor.set(0.5, 0.5);
self.buyText.x = 300;
self.buyText.y = 60;
self.addChild(self.buyText);
self.setBuilding = function (building) {
self.building = building;
self.updateDisplay();
};
self.updateDisplay = function () {
if (!self.building) return;
self.nameText.setText(self.building.buildingType.toUpperCase());
self.costText.setText('Cost: ' + formatNumber(self.building.cost));
self.ownedText.setText('Owned: ' + self.building.count);
self.cpsText.setText('+' + formatNumber(self.building.cookiesPerSecond) + ' CPS');
// Update affordability
var canAfford = cookies >= self.building.cost;
background.tint = canAfford ? 0x4169E1 : 0x666666;
iconBg.tint = canAfford ? 0xFFFFFF : 0x888888;
self.buyButton.tint = canAfford ? 0x4CAF50 : 0x666666;
self.buyButton.alpha = canAfford ? 1 : 0.5;
};
self.purchase = function () {
if (self.building && cookies >= self.building.cost) {
self.building.purchase();
self.updateDisplay();
}
};
self.down = function () {
self.purchase();
};
self.buyButton.down = function () {
self.purchase();
};
self.buyText.down = function () {
self.purchase();
};
return self;
});
var TutorialScreen = Container.expand(function () {
var self = Container.call(this);
self.isOpen = false;
// Fullscreen background
var background = self.attachAsset('tutorialBg', {
anchorX: 0,
anchorY: 0,
width: 2048,
height: 2732
});
background.tint = 0x1a1a2e;
var titleText = new Text2('TUTORIAL', {
size: 72,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 400;
self.addChild(titleText);
var tutorialText = new Text2('HOW TO PLAY COOKIE TAP EMPIRE:\n\n• Tap the large cookie to earn cookies\n• Use earned cookies to buy upgrades from the shop\n• Each upgrade increases your cookies per second (CPS)\n• Collect falling cookies for bonus rewards\n• Reach 100,000+ cookies and 100+ upgrades to unlock prestige\n• Prestiging resets your progress but gives permanent bonuses\n• Higher prestige levels provide greater production bonuses\n• Check the leaderboard to see how you rank against others!', {
size: 36,
fill: 0xFFFFFF
});
tutorialText.anchor.set(0.5, 0.5);
tutorialText.x = 1024;
tutorialText.y = 1200;
self.addChild(tutorialText);
var continueButton = self.attachAsset('continueButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 2000,
scaleX: 1.5,
scaleY: 1.5
});
var continueGlow = self.attachAsset('continueGlow', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1980
});
var continueText = new Text2('GOT IT!', {
size: 42,
fill: 0xFFFFFF
});
continueText.anchor.set(0.5, 0.5);
continueText.x = 1024;
continueText.y = 2000;
self.addChild(continueText);
// Close button
var closeBtn = self.attachAsset('closeButtonPixel', {
anchorX: 0.5,
anchorY: 0.5,
x: 1800,
y: 400
});
var closeX1 = self.attachAsset('closeButtonX', {
anchorX: 0.5,
anchorY: 0.5,
x: 1800,
y: 400,
rotation: Math.PI / 4
});
var closeX2 = self.attachAsset('closeButtonX', {
anchorX: 0.5,
anchorY: 0.5,
x: 1800,
y: 400,
rotation: -Math.PI / 4
});
function handleClose() {
if (!isMuted) LK.getSound('buttonClick').play();
self.close();
}
continueButton.down = handleClose;
continueText.down = handleClose;
closeBtn.down = handleClose;
closeX1.down = handleClose;
closeX2.down = handleClose;
self.open = function () {
self.isOpen = true;
self.alpha = 0;
self.visible = true;
tween(self, {
alpha: 1
}, {
duration: 300
});
};
self.close = function () {
self.isOpen = false;
tween(self, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
self.visible = false;
}
});
};
self.visible = false;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Tutorial pixel art
// Settings pixel art
// Leaderboard pixel art
// Menu and dialog pixel art
// Building pixel art textures
// Shop and upgrade pixel art
// Main menu pixel art
// HUD and UI pixel art
// Pixel art cookie assets
// Menu buttons
// UI Elements
// Building pixel textures
// Custom pixel-style cookie textures
// Game state variables
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
var gameStarted = storage.gameStarted || false;
var isMuted = storage.isMuted || false;
var fallingCookies = [];
var miniCookies = [];
var playerName = storage.playerName || '';
// Username validation function
function isUsernameAvailable(username) {
var leaderboardNames = storage.leaderboardNames || [];
for (var i = 0; i < leaderboardNames.length; i++) {
if (leaderboardNames[i] === username) {
return false;
}
}
return true;
}
// Get display name with owner prefix
function getDisplayName(name) {
if (name === 'NEO') {
return '[OWNER] ' + name;
}
return name;
}
// Username input function
function requestUsername() {
var username = prompt('Enter your username for the leaderboard:') || '';
if (username.length > 0 && username.length <= 20) {
if (isUsernameAvailable(username) || username === playerName) {
playerName = username;
try {
// Store as simple string literal to avoid storage restrictions
var nameToStore = String(playerName);
storage.playerName = nameToStore;
} catch (e) {
console.log('Storage not available for username save');
}
return true;
} else {
alert('Username already taken! Please choose another username.');
return requestUsername();
}
} else if (username.length > 20) {
alert('Username too long! Maximum 20 characters.');
return requestUsername();
}
return false;
}
// Click detection for auto-clicker prevention
var clickTimes = [];
var isWarned = false;
var clicksBlocked = false;
// Game variables
var cookies = storage.cookies || 0;
var totalCPS = storage.totalCPS || 0;
var cookiesPerTap = 1;
var tapMultiplier = 1;
// Prestige system variables
var prestigeLevel = storage.prestigeLevel || 0;
var prestigeBonus = prestigeLevel * 0.1; // 10% bonus per prestige
var allTimeCookies = storage.allTimeCookies || 0;
var canPrestige = false;
// Leaderboard system
var lastLeaderboardUpdate = storage.lastLeaderboardUpdate || 0;
// Buildings data
var buildingsData = [{
type: 'grandma',
cost: 15,
cps: 1
}, {
type: 'oven',
cost: 100,
cps: 8
}, {
type: 'factory',
cost: 1100,
cps: 47
}, {
type: 'mine',
cost: 12000,
cps: 260
}, {
type: 'bank',
cost: 130000,
cps: 1400
}, {
type: 'temple',
cost: 1400000,
cps: 7800
}, {
type: 'portal',
cost: 20000000,
cps: 44000
}, {
type: 'machine',
cost: 150000000,
cps: 260000
}, {
type: 'condenser',
cost: 800000000,
cps: 1600000
}, {
type: 'prism',
cost: 5000000000,
cps: 10000000
}, {
type: 'chancemaker',
cost: 25000000000,
cps: 65000000
}, {
type: 'fractal',
cost: 120000000000,
cps: 430000000
}, {
type: 'console',
cost: 600000000000,
cps: 2900000000
}, {
type: 'idleverse',
cost: 3000000000000,
cps: 21000000000
}, {
type: 'cortex',
cost: 15000000000000,
cps: 150000000000
}, {
type: 'you',
cost: 75000000000000,
cps: 1100000000000
}, {
type: 'synclavier',
cost: 400000000000000,
cps: 51000000000000
}, {
type: 'ascendancy',
cost: 2000000000000000,
cps: 440000000000000
}, {
type: 'altruism',
cost: 10000000000000000,
cps: 4000000000000000
}, {
type: 'luminous',
cost: 50000000000000000,
cps: 100000000000000000
}, {
type: 'sucroblast',
cost: 250000000000000000,
cps: 30000000000000000000
}, {
type: 'infinitude',
cost: 1250000000000000000,
cps: 999999999999999999999
}, {
type: 'cortexbaker',
cost: 6250000000000000000,
cps: 9999999999999999999999999
}];
var buildings = [];
var floatingNumbers = [];
// Create custom HUD background - removed to hide black box
// var hudBg = LK.getAsset('hudBackground', {
// anchorX: 0,
// anchorY: 0,
// height: 250
// });
// hudBg.alpha = 0.9;
// LK.gui.top.addChild(hudBg);
// Create cookie (centered and much larger, matches menu cookie)
var mainCookie = game.addChild(new Cookie());
mainCookie.x = 1024;
mainCookie.y = 1200;
mainCookie.scaleX = 2.5;
mainCookie.scaleY = 2.5;
// Custom UI with styled backgrounds - moved to top center
var cookieCounterBg = LK.getAsset('cookieCounter', {
anchorX: 0.5,
anchorY: 0.5
});
cookieCounterBg.x = 0;
cookieCounterBg.y = 40;
cookieCounterBg.visible = false; // Hide in menu
LK.gui.top.addChild(cookieCounterBg);
var cookieDisplay = new Text2('Cookies: 0', {
size: 52,
fill: 0xFFD700
});
cookieDisplay.anchor.set(0.5, 0.5);
cookieDisplay.x = 0;
cookieDisplay.y = 40;
cookieDisplay.visible = false; // Hide in menu
LK.gui.top.addChild(cookieDisplay);
var cpsCounterBg = LK.getAsset('cpsCounter', {
anchorX: 0.5,
anchorY: 0.5
});
cpsCounterBg.x = 0;
cpsCounterBg.y = 90;
cpsCounterBg.visible = false; // Hide in menu
LK.gui.top.addChild(cpsCounterBg);
var cpsDisplay = new Text2('Per second: 0', {
size: 36,
fill: 0x90EE90
});
cpsDisplay.anchor.set(0.5, 0.5);
cpsDisplay.x = 0;
cpsDisplay.y = 90;
cpsDisplay.visible = false; // Hide in menu
LK.gui.top.addChild(cpsDisplay);
// Prestige display
var prestigeDisplay = new Text2('Prestige Level: 0 (+0% bonus)', {
size: 28,
fill: 0xFFD700
});
prestigeDisplay.anchor.set(0.5, 0.5);
prestigeDisplay.x = 0;
prestigeDisplay.y = 160;
LK.gui.top.addChild(prestigeDisplay);
// Shopping cart menu button (middle-right screen, larger and more visible)
var shopIcon = game.addChild(LK.getAsset('shopIconBg', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
}));
shopIcon.x = 1900;
shopIcon.y = 1366;
shopIcon.tint = 0x333333;
var shopBorder = game.addChild(LK.getAsset('shopIconBorder', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
}));
shopBorder.x = 1900;
shopBorder.y = 1366;
shopBorder.tint = 0x666666;
var cartBg = game.addChild(LK.getAsset('shoppingCart', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.8,
scaleY: 1.8
}));
cartBg.x = 1900;
cartBg.y = 1366;
cartBg.tint = 0x888888;
var wheel1 = game.addChild(LK.getAsset('cartWheel1', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.8,
scaleY: 1.8
}));
wheel1.x = 1875;
wheel1.y = 1390;
var wheel2 = game.addChild(LK.getAsset('cartWheel2', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.8,
scaleY: 1.8
}));
wheel2.x = 1925;
wheel2.y = 1390;
var handle = game.addChild(LK.getAsset('cartHandle', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.8,
scaleY: 1.8
}));
handle.x = 1940;
handle.y = 1350;
// Create shop (initially hidden)
var shop = game.addChild(new Shop());
shop.x = 0;
shop.y = 0;
// Close shop menu when tapping outside
game.down = function (x, y, obj) {
// If shop is open and tap is outside the shop area, close it
if (shop && shop.isOpen) {
// Allow taps on shop elements, close only on background taps
if (y < 150 || x < 100 || x > 1948) {
shop.close();
}
}
};
// Create prestige button (bottom of screen)
var prestigeButton = new PrestigeButton();
prestigeButton.x = 1024;
prestigeButton.y = 2600;
game.addChild(prestigeButton);
// Initialize menus
var mainMenu = game.addChild(new MainMenu());
mainMenu.x = 0;
mainMenu.y = 0;
var settingsMenu = game.addChild(new SettingsMenu());
settingsMenu.x = 1024;
settingsMenu.y = 1366;
var tutorialScreen = game.addChild(new TutorialScreen());
tutorialScreen.x = 0;
tutorialScreen.y = 0;
var leaderboard = game.addChild(new Leaderboard());
leaderboard.x = 0;
leaderboard.y = 0;
// Initialize music
function showTutorial() {
tutorialScreen.open();
}
// Auto-pause when user leaves
function pauseGame() {
saveGame();
// Additional pause logic can be added here
}
function unpauseGame() {
// Resume game logic
updateDisplay();
}
// Auto-save and leaderboard update system
function updateLeaderboard() {
if (!playerName || playerName === '') return;
var currentTime = Date.now();
// Update prestige immediately on launch, then every 5 minutes for cookies
var shouldUpdate = currentTime - lastLeaderboardUpdate > 300000 || lastLeaderboardUpdate === 0;
if (shouldUpdate) {
// 5 minutes
lastLeaderboardUpdate = currentTime;
storage.lastLeaderboardUpdate = lastLeaderboardUpdate;
var leaderboardNames = (storage.leaderboardNames || []).slice();
var leaderboardCookies = (storage.leaderboardCookies || []).slice();
var leaderboardTimestamps = (storage.leaderboardTimestamps || []).slice();
var leaderboardPrestiges = (storage.leaderboardPrestiges || []).slice();
var playerExists = false;
for (var i = 0; i < leaderboardNames.length; i++) {
if (leaderboardNames[i] === playerName) {
leaderboardCookies[i] = Math.max(leaderboardCookies[i], cookies);
leaderboardPrestiges[i] = Math.max(leaderboardPrestiges[i] || 0, prestigeLevel);
playerExists = true;
break;
}
}
if (!playerExists) {
leaderboardNames.push(playerName);
leaderboardCookies.push(cookies);
leaderboardTimestamps.push(currentTime);
leaderboardPrestiges.push(prestigeLevel);
}
storage.leaderboardNames = leaderboardNames;
storage.leaderboardCookies = leaderboardCookies;
storage.leaderboardTimestamps = leaderboardTimestamps;
storage.leaderboardPrestiges = leaderboardPrestiges;
} else {
// Always update prestige level even if not updating cookies
var leaderboardNames = storage.leaderboardNames || [];
var leaderboardPrestiges = (storage.leaderboardPrestiges || []).slice();
for (var i = 0; i < leaderboardNames.length; i++) {
if (leaderboardNames[i] === playerName) {
leaderboardPrestiges[i] = Math.max(leaderboardPrestiges[i] || 0, prestigeLevel);
storage.leaderboardPrestiges = leaderboardPrestiges;
break;
}
}
}
}
// Click detection system
function recordClick() {
var currentTime = Date.now();
clickTimes.push(currentTime);
// Remove clicks older than 1 second
clickTimes = clickTimes.filter(function (time) {
return currentTime - time < 1000;
});
// Check for suspicious clicking (over 20 clicks per second)
if (clickTimes.length > 20) {
if (!isWarned) {
isWarned = true;
showFloatingNumber('AUTO-CLICKER DETECTED!', 1024, 800);
}
if (clickTimes.length > 25) {
clicksBlocked = true;
showFloatingNumber('CLICKS BLOCKED!', 1024, 850);
LK.setTimeout(function () {
clicksBlocked = false;
isWarned = false;
}, 5000);
}
return false;
}
return true;
}
// Menu functionality
var prestigeMenu = null;
function openShopMenu() {
if (!gameStarted) return;
if (shop.isOpen) {
shop.close();
} else {
shop.open();
}
}
shopIcon.down = openShopMenu;
shopBorder.down = openShopMenu;
cartBg.down = openShopMenu;
wheel1.down = openShopMenu;
wheel2.down = openShopMenu;
handle.down = openShopMenu;
// Create buildings (no longer displayed directly, managed by upgrade menu)
for (var i = 0; i < buildingsData.length; i++) {
var buildingData = buildingsData[i];
var building = new Building(buildingData.type, buildingData.cost, buildingData.cps);
// Load saved data
var savedCount = storage['building_' + buildingData.type] || 0;
if (savedCount > 0) {
building.count = savedCount;
building.cost = Math.floor(building.baseCost * Math.pow(1.15, savedCount));
totalCPS += building.cookiesPerSecond * savedCount;
}
buildings.push(building);
}
// Number formatting function for shop display
function formatNumber(num) {
if (num < 1000) {
return Math.floor(num).toString();
} else if (num < 1000000) {
return Math.floor(num / 1000) + 'k';
} else if (num < 1000000000) {
return Math.floor(num / 1000000) + 'mil';
} else if (num < 1000000000000) {
return Math.floor(num / 1000000000) + 'bil';
} else if (num < 1000000000000000) {
return Math.floor(num / 1000000000000) + 'tril';
} else if (num < 1000000000000000000) {
return Math.floor(num / 1000000000000000) + 'quad';
} else {
return Math.floor(num / 1000000000000000000) + 'quin';
}
}
// Game functions
function updateDisplay() {
cookieDisplay.setText('Cookies: ' + Math.floor(cookies));
cpsDisplay.setText('Per second: ' + totalCPS);
prestigeDisplay.setText('Prestige Level: ' + prestigeLevel + ' (+' + Math.floor(prestigeBonus * 100) + '% bonus)');
for (var i = 0; i < buildings.length; i++) {
buildings[i].updateDisplay();
}
prestigeButton.updateDisplay();
if (shop && shop.isOpen) {
shop.updatePage();
}
if (prestigeMenu && prestigeMenu.isOpen) {
prestigeMenu.updateDisplay();
}
}
function showFloatingNumber(text, x, y) {
var floatingNum = new FloatingNumber(text, x, y);
game.addChild(floatingNum);
floatingNumbers.push(floatingNum);
}
function saveGame() {
storage.cookies = cookies;
storage.totalCPS = totalCPS;
storage.prestigeLevel = prestigeLevel;
storage.allTimeCookies = allTimeCookies;
storage.isMuted = isMuted;
storage.gameStarted = gameStarted;
try {
// Store as simple string literal to avoid storage restrictions
var nameToStore = String(playerName || '');
storage.playerName = nameToStore;
} catch (e) {
console.log('Storage not available for playerName save');
}
storage.lastLeaderboardUpdate = lastLeaderboardUpdate;
for (var i = 0; i < buildings.length; i++) {
storage['building_' + buildings[i].buildingType] = buildings[i].count;
}
}
// Auto-save timer
var saveTimer = LK.setInterval(function () {
saveGame();
}, 5000);
// CPS generation timer
var cpsTimer = LK.setInterval(function () {
if (totalCPS > 0) {
var cpsGain = totalCPS * tapMultiplier / 10; // 10 times per second for smoother increments
cookies += cpsGain;
allTimeCookies += cpsGain;
updateDisplay();
}
}, 100);
// Always start with main menu, do not show tutorial by default
gameStarted = false;
mainMenu.visible = true;
// Update username display in menu
mainMenu.updateUsername();
// Initial display update
updateDisplay();
// Remove player9240 from leaderboard if present - comprehensive cleanup
var leaderboardNames = storage.leaderboardNames || [];
var leaderboardCookies = storage.leaderboardCookies || [];
var leaderboardTimestamps = storage.leaderboardTimestamps || [];
var leaderboardPrestiges = storage.leaderboardPrestiges || [];
// Remove all instances of player9240 (not just first occurrence)
var indicesToRemove = [];
for (var i = 0; i < leaderboardNames.length; i++) {
if (leaderboardNames[i] === 'player9240') {
indicesToRemove.push(i);
}
}
// Remove indices in reverse order to avoid index shifting issues
for (var j = indicesToRemove.length - 1; j >= 0; j--) {
var indexToRemove = indicesToRemove[j];
leaderboardNames.splice(indexToRemove, 1);
leaderboardCookies.splice(indexToRemove, 1);
leaderboardTimestamps.splice(indexToRemove, 1);
leaderboardPrestiges.splice(indexToRemove, 1);
}
storage.leaderboardNames = leaderboardNames;
storage.leaderboardCookies = leaderboardCookies;
storage.leaderboardTimestamps = leaderboardTimestamps;
storage.leaderboardPrestiges = leaderboardPrestiges;
// Update leaderboard on launch to sync prestige levels
updateLeaderboard();
// Start background music
if (!isMuted) {
LK.playMusic('bgmusic', {
loop: true
});
}
// Falling cookie spawn timer - every 3 minutes based on upgrades
var fallingCookieTimer = 0;
var baseFallingInterval = 10800; // 3 minutes at 60fps
game.update = function () {
if (!gameStarted) {
// Hide cookie counters in menu
cookieCounterBg.visible = false;
cookieDisplay.visible = false;
cpsCounterBg.visible = false;
cpsDisplay.visible = false;
// Hide prestige level in menu
prestigeDisplay.visible = false;
// Show main menu if not started
if (!mainMenu.visible) {
mainMenu.visible = true;
mainMenu.alpha = 1;
}
return;
}
// Clean up destroyed floating numbers
for (var i = floatingNumbers.length - 1; i >= 0; i--) {
if (floatingNumbers[i].destroyed) {
floatingNumbers.splice(i, 1);
}
}
// Clean up destroyed falling cookies
for (var i = fallingCookies.length - 1; i >= 0; i--) {
if (fallingCookies[i].destroyed) {
fallingCookies.splice(i, 1);
}
}
// Clean up destroyed mini cookies
for (var i = miniCookies.length - 1; i >= 0; i--) {
if (miniCookies[i].destroyed) {
miniCookies.splice(i, 1);
}
}
// Calculate falling cookie interval based on upgrades
var totalUpgrades = 0;
for (var i = 0; i < buildings.length; i++) {
totalUpgrades += buildings[i].count;
}
// Spawn falling cookies more frequently with more upgrades
var fallingInterval = Math.max(1800, baseFallingInterval - totalUpgrades * 30); // Minimum 30 seconds
fallingCookieTimer++;
if (fallingCookieTimer >= fallingInterval) {
fallingCookieTimer = 0;
var fallingCookie = game.addChild(new FallingCookie());
fallingCookie.x = 200 + Math.random() * 1648;
fallingCookie.y = -100;
fallingCookie.scaleX = 1.8; // Make them bigger
fallingCookie.scaleY = 1.8;
fallingCookies.push(fallingCookie);
}
// Update leaderboard periodically
updateLeaderboard();
}; ===================================================================
--- original.js
+++ change.js
@@ -2429,22 +2429,28 @@
// Update username display in menu
mainMenu.updateUsername();
// Initial display update
updateDisplay();
-// Remove player9240 from leaderboard if present
+// Remove player9240 from leaderboard if present - comprehensive cleanup
var leaderboardNames = storage.leaderboardNames || [];
var leaderboardCookies = storage.leaderboardCookies || [];
var leaderboardTimestamps = storage.leaderboardTimestamps || [];
var leaderboardPrestiges = storage.leaderboardPrestiges || [];
+// Remove all instances of player9240 (not just first occurrence)
+var indicesToRemove = [];
for (var i = 0; i < leaderboardNames.length; i++) {
if (leaderboardNames[i] === 'player9240') {
- leaderboardNames.splice(i, 1);
- leaderboardCookies.splice(i, 1);
- leaderboardTimestamps.splice(i, 1);
- leaderboardPrestiges.splice(i, 1);
- break;
+ indicesToRemove.push(i);
}
}
+// Remove indices in reverse order to avoid index shifting issues
+for (var j = indicesToRemove.length - 1; j >= 0; j--) {
+ var indexToRemove = indicesToRemove[j];
+ leaderboardNames.splice(indexToRemove, 1);
+ leaderboardCookies.splice(indexToRemove, 1);
+ leaderboardTimestamps.splice(indexToRemove, 1);
+ leaderboardPrestiges.splice(indexToRemove, 1);
+}
storage.leaderboardNames = leaderboardNames;
storage.leaderboardCookies = leaderboardCookies;
storage.leaderboardTimestamps = leaderboardTimestamps;
storage.leaderboardPrestiges = leaderboardPrestiges;