User prompt
Compilation error[L2112]: Uncaught TypeError: Cannot read properties of undefined (reading '0') ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Fix error in line 2112
User prompt
Rework full shop
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'break;' Line Number: 2113
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'storage.leaderboardPrestiges = leaderboardPrestiges;' Line Number: 2112 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'storage.leaderboardPrestiges = leaderboardPrestiges;' Line Number: 2107 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Shop is bugged so when I click it it pause the game fix it
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'break;' Line Number: 2100
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'break;' Line Number: 2101
User prompt
Move the cookies per second down a little bit
User prompt
Hide the black box at top right of screen
User prompt
Make it so when I scroll it hides the above ones
User prompt
Make the shop when open take up less of screen and when you scroll it shows you the ones below and hides ones above
User prompt
Make it so you can't click cookie in menu
User prompt
Move the gain and current bonus in the prestige menu and remove it
User prompt
Make text in prestige menu easy to read by adding gaps
User prompt
Make it so when you click the cookie instead of +1 it is a mini cookie that randomly pops out main cookie ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make it when you click the cookie is stays same size ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'Uncaught TypeError: setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 1620
User prompt
The shop scroll is laggy add a fix and make it display better ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'RangeError: Maximum call stack size exceeded' in or related to this line: 'leaderboardPrestiges[i] = Math.max(leaderboardPrestiges[i] || 0, prestigeLevel);' Line Number: 1950 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Make the app mobile friendly
User prompt
Make it so I can change username by clicking old one ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Make it so i can change username but also do not allow repet usernames ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
In menu make it so i can enter a username and then use that username in leaderboard ↪💡 Consider importing and using the following plugins: @upit/storage.v1
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* 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
});
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: ' + Math.floor(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 nameText = new Text2(leaderboardNames[idx], {
size: 28,
fill: 0xFFD700
});
nameText.anchor.set(0, 0.5);
nameText.x = 400;
nameText.y = yPos;
self.addChild(nameText);
var cookieText = new Text2(Math.floor(leaderboardCookies[idx]).toLocaleString(), {
size: 36,
fill: 0x90EE90
});
cookieText.anchor.set(0, 0.5);
cookieText.x = 800;
cookieText.y = yPos - 10;
self.addChild(cookieText);
var prestigeText = new Text2('Prestige: ' + (leaderboardPrestiges[idx] || 0), {
size: 32,
fill: 0xFFB347
});
prestigeText.anchor.set(0, 0.5);
prestigeText.x = 800;
prestigeText.y = yPos + 15;
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();
var newUsername = prompt('Enter your username (max 20 characters):') || '';
if (newUsername.length > 0 && newUsername.length <= 20) {
if (isUsernameAvailable(newUsername) || newUsername === playerName) {
playerName = newUsername;
storage.playerName = playerName;
self.usernameDisplay.setText(playerName);
} else {
alert('Username already taken! Please choose another username.');
}
} else if (newUsername.length > 20) {
alert('Username too long! Maximum 20 characters.');
}
};
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
});
var newUsername = prompt('Enter your username (max 20 characters):') || '';
if (newUsername.length > 0 && newUsername.length <= 20) {
if (isUsernameAvailable(newUsername) || newUsername === playerName) {
playerName = newUsername;
storage.playerName = playerName;
self.usernameDisplay.setText(playerName);
} else {
alert('Username already taken! Please choose another username.');
}
} else if (newUsername.length > 20) {
alert('Username too long! Maximum 20 characters.');
}
};
self.updateUsername = function () {
self.usernameDisplay.setText(playerName || 'Tap to enter username');
// Reset visual properties when updating
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 random username if none set
if (!playerName || playerName === '') {
playerName = 'Player' + Math.floor(Math.random() * 10000);
storage.playerName = playerName;
}
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
});
var closeX1 = self.attachAsset('closeButtonX', {
anchorX: 0.5,
anchorY: 0.5,
x: 300,
y: -200,
rotation: Math.PI / 4
});
var closeX2 = self.attachAsset('closeButtonX', {
anchorX: 0.5,
anchorY: 0.5,
x: 300,
y: -200,
rotation: -Math.PI / 4
});
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 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;
});
var UpgradeMenu = Container.expand(function () {
var self = Container.call(this);
self.isOpen = false;
self.scrollY = 0;
self.maxScroll = 0;
// Fullscreen 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,
y: 0
});
var headerText = new Text2('SHOP - UPGRADES', {
size: 52,
fill: 0xFFD700
});
headerText.anchor.set(0.5, 0.5);
headerText.x = 1024;
headerText.y = 60;
self.addChild(headerText);
// Close button
var closeBtn = self.attachAsset('closeButtonPixel', {
anchorX: 0.5,
anchorY: 0.5,
x: 1900,
y: 60
});
var closeX1 = self.attachAsset('closeButtonX', {
anchorX: 0.5,
anchorY: 0.5,
x: 1900,
y: 60,
rotation: Math.PI / 4
});
var closeX2 = self.attachAsset('closeButtonX', {
anchorX: 0.5,
anchorY: 0.5,
x: 1900,
y: 60,
rotation: -Math.PI / 4
});
// Content container for scrolling
self.contentContainer = new Container();
self.contentContainer.y = 140;
self.addChild(self.contentContainer);
// Scroll bar
self.scrollBar = self.attachAsset('scrollBarPixel', {
anchorX: 0.5,
anchorY: 0,
x: 2000,
y: 140
});
self.scrollThumb = self.attachAsset('scrollThumb', {
anchorX: 0.5,
anchorY: 0,
x: 2000,
y: 140
});
self.buildContent = function () {
// Only rebuild content if not already built
if (self.contentBuilt) return;
self.contentBuilt = true;
// Clear existing content
while (self.contentContainer.children.length > 0) {
self.contentContainer.children[0].destroy();
}
self.buildingElements = []; // Store references for updates
var yPos = 0;
var rowHeight = 220;
var _loop = function _loop() {
building = buildings[i];
var elements = {};
// Full-width slot border and background for each row
slotBorder = self.contentContainer.addChild(LK.getAsset('upgradeSlotBorder', {
anchorX: 0.5,
anchorY: 0,
x: 1024,
y: yPos,
width: 1920,
height: rowHeight - 10
}));
slot = self.contentContainer.addChild(LK.getAsset('upgradeSlot', {
anchorX: 0.5,
anchorY: 0,
x: 1024,
y: yPos,
width: 1900,
height: rowHeight - 30
}));
elements.slot = slot;
elements.slotBorder = slotBorder;
// Icon area (left side, big and clear)
iconBorder = self.contentContainer.addChild(LK.getAsset('upgradeIconBorder', {
anchorX: 0.5,
anchorY: 0.5,
x: 220,
y: yPos + rowHeight / 2,
scaleX: 1.7,
scaleY: 1.7
}));
iconBg = self.contentContainer.addChild(LK.getAsset('upgradeIcon', {
anchorX: 0.5,
anchorY: 0.5,
x: 220,
y: yPos + rowHeight / 2,
scaleX: 1.5,
scaleY: 1.5
}));
// Add detailed building pixel art
if (building.buildingType === 'grandma') {
grandmaPixel = self.contentContainer.addChild(LK.getAsset('grandmaPixel', {
anchorX: 0.5,
anchorY: 0.5,
x: 220,
y: yPos + rowHeight / 2
}));
grandmaHead = self.contentContainer.addChild(LK.getAsset('grandmaHead', {
anchorX: 0.5,
anchorY: 0.5,
x: 220,
y: yPos + rowHeight / 2 - 25
}));
apron = self.contentContainer.addChild(LK.getAsset('grandmaApron', {
anchorX: 0.5,
anchorY: 0.5,
x: 220,
y: yPos + rowHeight / 2 + 20
}));
} else if (building.buildingType === 'oven') {
ovenPixel = self.contentContainer.addChild(LK.getAsset('ovenPixel', {
anchorX: 0.5,
anchorY: 0.5,
x: 220,
y: yPos + rowHeight / 2
}));
door = self.contentContainer.addChild(LK.getAsset('ovenDoor', {
anchorX: 0.5,
anchorY: 0.5,
x: 220,
y: yPos + rowHeight / 2 + 20
}));
knob = self.contentContainer.addChild(LK.getAsset('ovenKnob', {
anchorX: 0.5,
anchorY: 0.5,
x: 250,
y: yPos + rowHeight / 2 - 10
}));
window = self.contentContainer.addChild(LK.getAsset('ovenWindow', {
anchorX: 0.5,
anchorY: 0.5,
x: 220,
y: yPos + rowHeight / 2 - 10
}));
} else if (building.buildingType === 'factory') {
factoryPixel = self.contentContainer.addChild(LK.getAsset('factoryPixel', {
anchorX: 0.5,
anchorY: 0.5,
x: 220,
y: yPos + rowHeight / 2
}));
chimney = self.contentContainer.addChild(LK.getAsset('factoryChimney', {
anchorX: 0.5,
anchorY: 0.5,
x: 250,
y: yPos + rowHeight / 2 - 25
}));
factoryWindow = self.contentContainer.addChild(LK.getAsset('factoryWindow', {
anchorX: 0.5,
anchorY: 0.5,
x: 220,
y: yPos + rowHeight / 2
}));
smoke = self.contentContainer.addChild(LK.getAsset('factorySmoke', {
anchorX: 0.5,
anchorY: 0.5,
x: 250,
y: yPos + rowHeight / 2 - 40
}));
}
// Name, cost, owned, and CPS (centered in row, large and clear)
nameText = new Text2(building.buildingType.toUpperCase(), {
size: 56,
fill: 0xFFFFFF
});
nameText.anchor.set(0, 0.5);
nameText.x = 400;
nameText.y = yPos + rowHeight / 2 - 40;
self.contentContainer.addChild(nameText);
costText = new Text2('Cost: ' + Math.floor(building.cost).toLocaleString(), {
size: 42,
fill: 0xFFFF00
});
costText.anchor.set(0, 0.5);
costText.x = 400;
costText.y = yPos + rowHeight / 2 + 10;
self.contentContainer.addChild(costText);
elements.costText = costText;
ownedText = new Text2('Owned: ' + building.count, {
size: 38,
fill: 0xCCCCCC
});
ownedText.anchor.set(0, 0.5);
ownedText.x = 400;
ownedText.y = yPos + rowHeight / 2 + 60;
self.contentContainer.addChild(ownedText);
elements.ownedText = ownedText;
cpsText = new Text2('+' + building.cookiesPerSecond + ' CPS', {
size: 38,
fill: 0x90EE90
});
cpsText.anchor.set(1, 0.5);
cpsText.x = 1800;
cpsText.y = yPos + rowHeight / 2;
self.contentContainer.addChild(cpsText);
// Purchase functionality
slot.buildingRef = building;
slotBorder.buildingRef = building;
function purchaseBuilding() {
this.buildingRef.purchase();
self.updateTextContent();
}
slot.down = purchaseBuilding;
slotBorder.down = purchaseBuilding;
elements.building = building;
self.buildingElements.push(elements);
yPos += rowHeight;
},
building,
slotBorder,
slot,
iconBorder,
iconBg,
grandmaPixel,
grandmaHead,
apron,
ovenPixel,
door,
knob,
window,
factoryPixel,
chimney,
factoryWindow,
smoke,
nameText,
costText,
ownedText,
cpsText;
for (var i = 0; i < buildings.length; i++) {
_loop();
}
self.maxScroll = Math.max(0, yPos - 2400);
self.updateScrollBar();
};
self.updateTextContent = function () {
// Only update text content, not rebuild entire UI
for (var i = 0; i < self.buildingElements.length; i++) {
var elements = self.buildingElements[i];
var building = elements.building;
elements.costText.setText('Cost: ' + Math.floor(building.cost).toLocaleString());
elements.ownedText.setText('Owned: ' + building.count);
// Update affordability tinting
if (cookies >= building.cost) {
elements.slot.tint = 0x4169E1;
elements.slotBorder.tint = 0x5A79F1;
} else {
elements.slot.tint = 0x666666;
elements.slotBorder.tint = 0x4A4A4A;
}
}
};
self.updateContent = function () {
self.buildContent();
self.updateTextContent();
};
self.updateScrollBar = function () {
if (self.maxScroll > 0) {
var scrollPercent = self.scrollY / self.maxScroll;
self.scrollThumb.y = 140 + scrollPercent * 2300;
self.scrollBar.alpha = 1;
self.scrollThumb.alpha = 1;
} else {
self.scrollBar.alpha = 0.3;
self.scrollThumb.alpha = 0.3;
}
};
self.scroll = function (deltaY) {
var newScrollY = Math.max(0, Math.min(self.maxScroll, self.scrollY + deltaY));
if (newScrollY !== self.scrollY) {
self.scrollY = newScrollY;
// Use smooth tween animation for scrolling
tween.stop(self.contentContainer, {
y: true
});
tween(self.contentContainer, {
y: 140 - self.scrollY
}, {
duration: 150,
easing: tween.easeOut
});
self.updateScrollBar();
}
};
self.open = function () {
self.isOpen = true;
self.scrollY = 0;
self.alpha = 0;
self.visible = true;
self.updateContent();
tween(self, {
alpha: 1
}, {
duration: 300
});
};
self.close = function () {
self.isOpen = false;
tween(self, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
self.visible = false;
}
});
};
function handleClose() {
if (!isMuted) LK.getSound('buttonClick').play();
self.close();
}
closeBtn.down = handleClose;
closeX1.down = handleClose;
closeX2.down = handleClose;
// Handle scrolling
self.lastY = 0;
self.isDragging = false;
self.down = function (x, y, obj) {
self.lastY = y;
self.isDragging = true;
};
self.move = function (x, y, obj) {
if (self.isDragging && self.maxScroll > 0) {
var deltaY = y - self.lastY;
// Throttle scroll updates for better performance
if (!self.scrollThrottled) {
self.scrollThrottled = true;
self.scroll(-deltaY * 1.5); // Add some scroll sensitivity
LK.setTimeout(function () {
self.scrollThrottled = false;
}, 16); // ~60fps throttling
}
self.lastY = y;
self.scrollVelocity = -deltaY; // Store velocity for momentum
}
};
self.up = function (x, y, obj) {
self.isDragging = false;
// Add momentum scrolling
if (self.scrollVelocity && Math.abs(self.scrollVelocity) > 2) {
var momentum = self.scrollVelocity * 8; // Momentum multiplier
var targetY = Math.max(0, Math.min(self.maxScroll, self.scrollY + momentum));
if (targetY !== self.scrollY) {
self.scrollY = targetY;
tween.stop(self.contentContainer, {
y: true
});
tween(self.contentContainer, {
y: 140 - self.scrollY
}, {
duration: 400,
easing: tween.easeOut
});
self.updateScrollBar();
}
}
self.scrollVelocity = 0;
};
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
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;
}
// 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;
storage.playerName = playerName;
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: 330000000,
cps: 260000
}, {
type: 'condenser',
cost: 5100000000,
cps: 1600000
}, {
type: 'prism',
cost: 75000000000,
cps: 10000000
}, {
type: 'chancemaker',
cost: 1000000000000,
cps: 65000000
}, {
type: 'fractal',
cost: 14000000000000,
cps: 430000000
}, {
type: 'console',
cost: 170000000000000,
cps: 2900000000
}, {
type: 'idleverse',
cost: 2100000000000000,
cps: 21000000000
}, {
type: 'cortex',
cost: 26000000000000000,
cps: 150000000000
}, {
type: 'you',
cost: 310000000000000000,
cps: 1100000000000
}, {
type: 'synclavier',
cost: 71000000000000000000,
cps: 51000000000000
}, {
type: 'ascendancy',
cost: 12000000000000000000000,
cps: 440000000000000
}, {
type: 'altruism',
cost: 1900000000000000000000000,
cps: 4000000000000000
}, {
type: 'luminous',
cost: 540000000000000000000000000,
cps: 100000000000000000
}, {
type: 'sucroblast',
cost: 540000000000000000000000000000,
cps: 30000000000000000000
}, {
type: 'infinitude',
cost: 540000000000000000000000000000000,
cps: 999999999999999999999
}, {
type: 'cortexbaker',
cost: 540000000000000000000000000000000000,
cps: 9999999999999999999999999
}];
var buildings = [];
var floatingNumbers = [];
// Create custom HUD background
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 upgrade menu (initially hidden)
var upgradeMenu = game.addChild(new UpgradeMenu());
upgradeMenu.x = 1024;
upgradeMenu.y = 400;
// Close shop menu when tapping outside the shop area
game.down = function (x, y, obj) {
// If shop is open and tap is outside the shop area, close it
if (upgradeMenu && upgradeMenu.isOpen) {
// Convert tap to local coordinates of upgradeMenu
var local = upgradeMenu.toLocal({
x: x,
y: y
});
// Shop area is roughly 2048x2400 (shop menu height)
if (local.x < 0 || local.x > 2048 || local.y < 0 || local.y > 2400) {
upgradeMenu.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 (upgradeMenu.isOpen) {
upgradeMenu.close();
} else {
LK.getSound('menuOpen').play();
upgradeMenu.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);
}
// 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 (upgradeMenu && upgradeMenu.isOpen) {
upgradeMenu.updateContent();
}
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;
storage.playerName = playerName;
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();
// 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
@@ -162,9 +162,9 @@
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) {
+ if (gameStarted && !upgradeMenu.isOpen && !settingsMenu.isOpen && !leaderboard.isOpen && !tutorialScreen.isOpen && (!prestigeMenu || !prestigeMenu.isOpen)) {
self.tap();
}
};
return self;