User prompt
Make it so prestige updates on launch in leaderboard ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Make the text in leaderboard larger for the cookies and prestige levels
User prompt
On leaderbord show the number of Prestiges too also add a username system ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Make the text in prestige menu bigger also in menu hide prestige level
User prompt
Hide the cookies and cookies per second in menu then show it ingame
User prompt
Make it so prestige button is bigger and when I click it the menu inside is bigger so I can read it better ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
when you click the prestige button bigger so I can read it better also make the cookies per seconds and cookies have fancy section at middle top of screen ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make it so when you click tutorial it opens a different screen make the prestige button bigger and the text in it bigger ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Move the shop up so the top of shop table is at top right of screen
User prompt
Make shop display in fullscreen and when u scroll the shop items move up and disappear when you pass them until I scroll down again
User prompt
Make shop ui in the center make it look better and easy to use call it shop
User prompt
Display cookies per seconds and cookies at top of screen
User prompt
Make it so when you launch game it tells you to enter username and it used that on leaderboard ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Revert the cookies per second and cookie number back to normal
User prompt
Now make the cookies and cookies per second display in a fancy box so it fits in properly make a few custom cookie events happen ingame from time to time like double cookies for 30s
User prompt
Make it so when you tap of shop it closes add more details to the menu and background of main game changed cookie in menu to same one as ingame and make both of them large ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Okay the menu needs fixing it when it opens do not show tutorial make background light brown with cookie in background all the items in the shop should have Textures and make it easier to see them by makeing them in rows that fill the full screen ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboardData = leaderboardData;' Line Number: 1642 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Ok now I want you to make the game more playable the scroll function in the shop should make the shop stay in same position but move down the list give all items in shop pixel art make the cookies falling every 3 minutes for each upgrade make it so that the shop is fullscreen and takes up a line and u scroll town the list the tutorial should not show unless you click it on the main menu make it automatically set you to menu at beginning of game make it so that the leaderboard updates every 5 minutes when game saves it puts your name in the leaderboard make it so you need to pick a username before you play on leaderboard display top 10 with most cookies the leaderboard should be full screen and have a exit button on it on each menu make it have a easy to use close button the main menu is to have all the buttons yoy need like play leaderboard settings and tutorial when you leave game have it auto save and pause the game and unpause when the player returns make everything smooth and the sound effects auto enabled but can be disabled in settings add effects for buying things clicking cookie and prestige with calm music and quiet in background with a volume adjustable in settings in settings make it so you can change volume mute things and quality of life things make it so that auto clickers can be registered and block them from clicking for example over 20 clicks per second consistently is a warning then let's you click of ↪💡 Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.v1
User prompt
Okay menu is not in full screen i can't access shop because I can't see it make it a shopping basket art make the random cookies falling a little bigger and less frequent
User prompt
The hud is very difficult to use make it easy to use and have a visible shop icon at right middle screen and give everything custom Textures the main menu make it pause game when not playing make it have custom pixel made menu that fills full screen make all the buttons in the game have custom pixel art for the item ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'Uncaught TypeError: LK.showLeaderboard is not a function' in or related to this line: 'LK.showLeaderboard();' Line Number: 353
User prompt
Okay show the number of cookies at top middle of screen with cookies per second the black box at shop is weird make it a shopping cart pixel art cookie in middle has to be bigger add sound effects to match the game make the prestige menu so u can open it and show requirements and in menu insted of saying number of upgrades it says prestige and when clicked opens the menue in the shop make everything bigger and in rows so I can see each upgrade and add 20 more custom upgrades that work the same as the others just more expensive for prestige ensure it shows you need for level 1 100k cookies and 100 upgrades when you open the menu add a main menu before you can play with a button that is a play button with 3 buttons one play button a leaderbord and settings also add a mute function in settings add a tutorial at start also make sure random cookies fall from sky and when clicked give random number of cookies based of your cookie count ↪💡 Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.v1
User prompt
I want everything to have custom pixel Textures also I want custom menu custom ui and a custom hud I want the ability to open a menu to show all the upgrades and the ability to scroll down to see all the upgrades I will also want it to have cookie in center of the screen and it is big prestige should be at the bottom of screen and when u click it it opens a menu showing requirements I will also want it to make it so u need a certain number of upgrades like 100 upgrades first level and up 10 every prestige ↪💡 Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.v1
User prompt
Prestige System* - Name: Ascension - Description: Reset your progress, but gain a permanent bonus to cookie production - Cost: 100,000 cookies - Effect: +10% cookie production bonus (cumulative) - Max Prestiges: 100 - Prestige Bonus Formula: Prestige Bonus = (Number of Prestiges x 10)% *Textures* - Cookie: A round, golden-brown cookie with a slight sheen - Cursor: A simple, hand-drawn image of a pointing finger - Grandma: A warm, watercolor-style illustration of a grandma in a baking apron - Farm: A simple, cartoon-style image of a farm with rolling hills and a few trees - Cookie Mine: A stylized, industrial-style image of a mine shaft with a cookie-shaped entrance - Cookie Factory: A modern, sleek image of a factory with a cookie-shaped logo - Golden Cookie: A shiny, golden version of the cookie texture - Prestige Button: A stylized, fiery button with the word "Ascend" written in bold, golden font *Upgrades* 1. Cursor Upgrades - Name: Reinforced Fingers - Description: Increases cursor cookie production by 1 cookie per second - Initial Cost: 15 cookies - Price Increase: 1-5% per upgrade - Effect: +1 cookie per second - Texture: A simple, hand-drawn image of a pointing finger 2. Grandma Upgrades - Name: Baking Powder - Description: Increases grandma cookie production by 5 cookies per second - Initial Cost: 100 cookies - Price Increase: 1-5% per upgrade - Effect: +5 cookies per second - Texture: A warm, watercolor-style illustration of a grandma in a baking apron 3. Farm Upgrades - Name: Fertile Soil - Description: Increases farm cookie production by 10 cookies per second - Initial Cost: 500 cookies - Price Increase: 1-5% per upgrade - Effect: +10 cookies per second - Texture: A simple, cartoon-style image of a farm with rolling hills and a few trees *Custom Upgrades* 1. Cookie Crusher - Name: Double Cookie Day - Description: Doubles cookie production for 10 seconds - Cost: 500 cookies - Cooldown: 30 seconds - Effect: x2 cookie production for 10 seconds - Texture: A stylized, explosive image of a cookie shattering into pieces 2. Golden Cookie - Name: Lucky Break - Description: Gives a random bonus to cookie production (1-10 cookies per second) for 5 seconds - Cost: 1000 cookies - Cooldown: 60 seconds - Effect: +1-10 cookies per second for 5 seconds - Texture: A shiny, golden version of the cookie texture *Buildings* 1. Cursor - Name: Reinforced Fingers - Description: Produces 1 cookie per second - Initial Cost: 15 cookies - Price Increase: 1-5% per upgrade - Texture: A simple, hand-drawn image of a pointing finger 2. Grandma - Name: Baking Grandma - Description: Produces 5 cookies per second - Initial Cost: 100 cookies - Price Increase: 1-5% per upgrade - Texture: A warm, watercolor-style illustration of a grandma in a baking apron 3. Farm - Name: Cookie Farm - Description: Produces 10 cookies per second - Initial Cost: 500 cookies - Price Increase: 1-5% per upgrade - Texture: A simple, cartoon-style image of a farm with rolling hills and a few trees *Custom Buildings* 1. Cookie Mine - Name: Cookie Deposit - Description: Produces 50 cookies per second, but has a 5% chance to explode and lose 10% of cookies - Cost: 5000 cookies - Texture: A stylized, industrial-style image of a mine shaft with a cookie-shaped entrance 2. Cookie Factory - Name: Mass Production - Description: Produces 100 cookies per second, but increases cookie production cost by 10% - Cost: 10000 cookies - Texture: A modern, sleek image of a factory with a cookie-shaped logo ↪💡 Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.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 scale animation with rotation
tween.stop(self, {
scaleX: true,
scaleY: true,
rotation: true
});
self.scaleX = 0.85;
self.scaleY = 0.85;
self.rotation += 0.1;
tween(self, {
scaleX: self.originalScale,
scaleY: self.originalScale,
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();
// Show floating number
showFloatingNumber('+' + Math.floor(cookiesGained), self.x, self.y - 50);
};
self.down = function (x, y, obj) {
if (gameStarted) {
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: 40,
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 || [];
// 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 = 400;
rankText.y = yPos;
self.addChild(rankText);
var nameText = new Text2(leaderboardNames[idx], {
size: 28,
fill: 0xFFD700
});
nameText.anchor.set(0, 0.5);
nameText.x = 500;
nameText.y = yPos;
self.addChild(nameText);
var cookieText = new Text2(Math.floor(leaderboardCookies[idx]).toLocaleString(), {
size: 24,
fill: 0x90EE90
});
cookieText.anchor.set(1, 0.5);
cookieText.x = 1500;
cookieText.y = yPos;
self.addChild(cookieText);
self.entries.push(entryBg, rankText, nameText, cookieText);
}
};
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;
// 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();
// Require username before starting
if (!playerName || playerName.length < 3) {
showUsernamePrompt();
return;
}
gameStarted = 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 PrestigeButton = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('prestigeButton', {
anchorX: 0.5,
anchorY: 0.5
});
var titleText = new Text2('ASCEND', {
size: 28,
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
});
var background = self.attachAsset('prestigePanel', {
anchorX: 0.5,
anchorY: 0.5
});
var titleText = new Text2('ASCENSION', {
size: 36,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -100;
self.addChild(titleText);
self.reqText = new Text2('', {
size: 22,
fill: 0xFFFFFF
});
self.reqText.anchor.set(0.5, 0.5);
self.reqText.y = -40;
self.addChild(self.reqText);
self.bonusText = new Text2('', {
size: 20,
fill: 0x90EE90
});
self.bonusText.anchor.set(0.5, 0.5);
self.bonusText.y = 0;
self.addChild(self.bonusText);
// Prestige action button
var actionBtn = self.attachAsset('prestigeButton', {
anchorX: 0.5,
anchorY: 0.5,
y: 50
});
actionBtn.scaleX = 0.8;
actionBtn.scaleY = 0.8;
self.actionText = new Text2('ASCEND', {
size: 24,
fill: 0xFFFFFF
});
self.actionText.anchor.set(0.5, 0.5);
self.actionText.y = 50;
self.addChild(self.actionText);
// Close button
var closeBtn = self.attachAsset('closeButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 220,
y: -130
});
var closeText = new Text2('X', {
size: 20,
fill: 0xFFFFFF
});
closeText.anchor.set(0.5, 0.5);
closeText.x = 220;
closeText.y = -130;
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' + requiredUpgrades + ' upgrades (' + totalUpgrades + '/' + requiredUpgrades + ')\n' + '100,000 cookies (' + Math.floor(allTimeCookies) + '/100,000)');
self.bonusText.setText('Gain: +10% production bonus\nCurrent bonus: +' + Math.floor(prestigeBonus * 100) + '%');
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 TutorialMenu = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('menuPanel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.4
});
background.tint = 0x1a1a2e;
var titleText = new Text2('TUTORIAL', {
size: 48,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -250;
self.addChild(titleText);
var tutorialText = new Text2('• Tap the cookie to earn cookies\n• Buy upgrades in the shop to earn more\n• Collect falling cookies for bonus rewards\n• Reach 100k cookies + 100 upgrades to prestige\n• Prestiging gives permanent bonuses!', {
size: 28,
fill: 0xFFFFFF
});
tutorialText.anchor.set(0.5, 0.5);
tutorialText.y = -50;
self.addChild(tutorialText);
var continueButton = self.attachAsset('prestigeButton', {
anchorX: 0.5,
anchorY: 0.5,
y: 150,
scaleX: 1.1,
scaleY: 1.1
});
continueButton.tint = 0x4CAF50;
var continueText = new Text2('GOT IT!', {
size: 28,
fill: 0xFFFFFF
});
continueText.anchor.set(0.5, 0.5);
continueText.y = 150;
self.addChild(continueText);
continueButton.down = function () {
LK.getSound('buttonClick').play();
self.close();
};
continueText.down = function () {
LK.getSound('buttonClick').play();
self.close();
};
self.close = function () {
tween(self, {
alpha: 0
}, {
duration: 500,
onFinish: function onFinish() {
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.updateContent = function () {
// Clear existing content
while (self.contentContainer.children.length > 0) {
self.contentContainer.children[0].destroy();
}
var yPos = 0;
var rowHeight = 220;
var _loop = function _loop() {
building = buildings[i];
// 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
}));
// 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: 48,
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: 36,
fill: 0xFFFF00
});
costText.anchor.set(0, 0.5);
costText.x = 400;
costText.y = yPos + rowHeight / 2 + 10;
self.contentContainer.addChild(costText);
ownedText = new Text2('Owned: ' + building.count, {
size: 32,
fill: 0xCCCCCC
});
ownedText.anchor.set(0, 0.5);
ownedText.x = 400;
ownedText.y = yPos + rowHeight / 2 + 60;
self.contentContainer.addChild(ownedText);
cpsText = new Text2('+' + building.cookiesPerSecond + ' CPS', {
size: 32,
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();
upgradeMenu.updateContent();
}
slot.down = purchaseBuilding;
slotBorder.down = purchaseBuilding;
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.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) {
self.scrollY = Math.max(0, Math.min(self.maxScroll, self.scrollY + deltaY));
self.contentContainer.y = 140 - self.scrollY;
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;
self.scroll(-deltaY);
self.lastY = y;
}
};
self.up = function (x, y, obj) {
self.isDragging = false;
};
self.visible = false;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Game state variables
// Custom pixel-style cookie textures
// Building pixel textures
// UI Elements
// Menu buttons
// Pixel art cookie assets
// HUD and UI pixel art
// Main menu pixel art
// Shop and upgrade pixel art
// Building pixel art textures
// Menu and dialog pixel art
// Leaderboard pixel art
// Settings pixel art
// Tutorial pixel art
var gameStarted = storage.gameStarted || false;
var isMuted = storage.isMuted || false;
var fallingCookies = [];
var playerName = storage.playerName || '';
// Username prompt UI
var usernamePrompt = null;
var usernameInputText = null;
var usernameInputBg = null;
var usernameOkBtn = null;
var usernameOkText = null;
var usernameErrorText = null;
var usernameInputValue = '';
var usernameActive = false;
// Show username prompt
function showUsernamePrompt() {
if (usernamePrompt) {
usernamePrompt.visible = true;
usernamePrompt.alpha = 1;
usernameActive = true;
return;
}
usernamePrompt = game.addChild(new Container());
usernamePrompt.x = 1024;
usernamePrompt.y = 1366;
usernamePrompt.visible = true;
usernamePrompt.alpha = 1;
usernameActive = true;
// Background
var bg = usernamePrompt.attachAsset('menuPanel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.5,
scaleY: 1.5
});
bg.tint = 0xd4a574;
// Title
var title = new Text2('Enter Username', {
size: 60,
fill: 0xFFD700
});
title.anchor.set(0.5, 0.5);
title.y = -220;
usernamePrompt.addChild(title);
// Input background
usernameInputBg = usernamePrompt.attachAsset('cookieCounter', {
anchorX: 0.5,
anchorY: 0.5,
width: 600,
height: 100,
y: -60
});
usernameInputBg.tint = 0xffffff;
// Input text
usernameInputText = new Text2('', {
size: 40,
fill: 0x333333
});
usernameInputText.anchor.set(0.5, 0.5);
usernameInputText.x = 0;
usernameInputText.y = -60;
usernamePrompt.addChild(usernameInputText);
// Error text
usernameErrorText = new Text2('', {
size: 28,
fill: 0xff3333
});
usernameErrorText.anchor.set(0.5, 0.5);
usernameErrorText.x = 0;
usernameErrorText.y = 10;
usernamePrompt.addChild(usernameErrorText);
// OK button
usernameOkBtn = usernamePrompt.attachAsset('continueButton', {
anchorX: 0.5,
anchorY: 0.5,
y: 100
});
usernameOkBtn.tint = 0x4caf50;
usernameOkText = new Text2('OK', {
size: 36,
fill: 0xffffff
});
usernameOkText.anchor.set(0.5, 0.5);
usernameOkText.x = 0;
usernameOkText.y = 100;
usernamePrompt.addChild(usernameOkText);
// Input logic: tap input area to cycle through A-Z, 0-9, backspace, space
var inputChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
var maxLen = 12;
usernameInputBg.down = function (x, y, obj) {
// Show a virtual keyboard: for simplicity, cycle through chars on tap
// (In real deployment, LK may provide a text input overlay)
// Here, just add a random char for demo
if (usernameInputValue.length < maxLen) {
var idx = Math.floor(Math.random() * inputChars.length);
usernameInputValue += inputChars.charAt(idx);
usernameInputText.setText(usernameInputValue);
usernameErrorText.setText('');
}
};
usernameInputText.down = function (x, y, obj) {
// Remove last char (backspace)
if (usernameInputValue.length > 0) {
usernameInputValue = usernameInputValue.substring(0, usernameInputValue.length - 1);
usernameInputText.setText(usernameInputValue);
usernameErrorText.setText('');
}
};
usernameOkBtn.down = function (x, y, obj) {
handleUsernameOk();
};
usernameOkText.down = function (x, y, obj) {
handleUsernameOk();
};
function handleUsernameOk() {
var name = usernameInputValue.trim();
if (name.length < 3) {
usernameErrorText.setText('Name must be at least 3 characters');
return;
}
if (name.length > maxLen) {
usernameErrorText.setText('Name too long');
return;
}
playerName = name;
storage.playerName = playerName;
usernamePrompt.visible = false;
usernameActive = false;
updateDisplay();
}
// Dismiss prompt if already have a name
if (playerName && playerName.length >= 3) {
usernamePrompt.visible = false;
usernameActive = 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 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;
// Simple cookies and per second display at top
var cookieDisplay = new Text2('Cookies: 0', {
size: 48,
fill: 0xFFD700
});
cookieDisplay.anchor.set(0.5, 0);
cookieDisplay.x = 1024;
cookieDisplay.y = 20;
LK.gui.top.addChild(cookieDisplay);
var cpsDisplay = new Text2('Per second: 0', {
size: 32,
fill: 0x90EE90
});
cpsDisplay.anchor.set(0.5, 0);
cpsDisplay.x = 1024;
cpsDisplay.y = 80;
LK.gui.top.addChild(cpsDisplay);
// Prestige display (below)
var prestigeDisplay = new Text2('Prestige Level: 0 (+0% bonus)', {
size: 22,
fill: 0xFFD700
});
prestigeDisplay.anchor.set(0.5, 0);
prestigeDisplay.x = 1024;
prestigeDisplay.y = 130;
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
}));
shopIcon.x = 1900;
shopIcon.y = 1366;
shopIcon.tint = 0x333333;
var shopBorder = game.addChild(LK.getAsset('shopIconBorder', {
anchorX: 0.5,
anchorY: 0.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.2,
scaleY: 1.2
}));
cartBg.x = 1900;
cartBg.y = 1366;
cartBg.tint = 0x888888;
var wheel1 = game.addChild(LK.getAsset('cartWheel1', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.2
}));
wheel1.x = 1875;
wheel1.y = 1390;
var wheel2 = game.addChild(LK.getAsset('cartWheel2', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.2
}));
wheel2.x = 1925;
wheel2.y = 1390;
var handle = game.addChild(LK.getAsset('cartHandle', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.2
}));
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 tutorialMenu = game.addChild(new TutorialMenu());
tutorialMenu.x = 1024;
tutorialMenu.y = 1366;
var leaderboard = game.addChild(new Leaderboard());
leaderboard.x = 0;
leaderboard.y = 0;
// Initialize music
function showTutorial() {
tutorialMenu.visible = true;
tutorialMenu.alpha = 0;
tween(tutorialMenu, {
alpha: 1
}, {
duration: 500
});
}
// 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();
if (currentTime - lastLeaderboardUpdate > 300000) {
// 5 minutes
lastLeaderboardUpdate = currentTime;
storage.lastLeaderboardUpdate = lastLeaderboardUpdate;
var leaderboardNames = storage.leaderboardNames || [];
var leaderboardCookies = storage.leaderboardCookies || [];
var leaderboardTimestamps = storage.leaderboardTimestamps || [];
var playerExists = false;
for (var i = 0; i < leaderboardNames.length; i++) {
if (leaderboardNames[i] === playerName) {
leaderboardCookies[i] = Math.max(leaderboardCookies[i], cookies);
playerExists = true;
break;
}
}
if (!playerExists) {
leaderboardNames.push(playerName);
leaderboardCookies.push(cookies);
leaderboardTimestamps.push(currentTime);
}
storage.leaderboardNames = leaderboardNames;
storage.leaderboardCookies = leaderboardCookies;
storage.leaderboardTimestamps = leaderboardTimestamps;
}
}
// 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);
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;
tutorialMenu.visible = false;
// Initial display update
updateDisplay();
// 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) {
// Show username prompt if not set
if ((!playerName || playerName.length < 3) && !usernameActive) {
showUsernamePrompt();
}
// Block game until username entered
if (usernameActive) {
if (mainMenu.visible) mainMenu.alpha = 0.3;
return;
}
// Show main menu if not started
if (!mainMenu.visible) {
mainMenu.visible = true;
mainMenu.alpha = 1;
}
return;
}
// --- Custom Cookie Events Logic ---
if (typeof cookieEventActive === "undefined") {
cookieEventActive = false;
cookieEventTimer = 0;
cookieEventDuration = 0;
cookieEventType = "";
cookieEventCooldown = 0;
}
if (typeof cookieEventNextTrigger === "undefined") {
// Next event in 60-120 seconds
cookieEventNextTrigger = 1800 + Math.floor(Math.random() * 1800);
}
if (!cookieEventActive) {
cookieEventNextTrigger--;
if (cookieEventNextTrigger <= 0) {
// Pick a random event (for now, only double cookies)
cookieEventType = "double";
cookieEventActive = true;
cookieEventDuration = 1800; // 30 seconds at 60fps
cookieEventTimer = 0;
// Show floating number and flash
showFloatingNumber("Double Cookies! 30s", 1024, 300);
LK.effects.flashObject(cookieHudBox, 0xffe066, 1000);
// Visually highlight the cookie box
if (cookieCounterBg) cookieCounterBg.tint = 0xffe066;
if (cpsCounterBg) cpsCounterBg.tint = 0xffe066;
}
} else {
cookieEventTimer++;
// During event, apply effect
if (cookieEventType === "double") {
tapMultiplier = 2 + prestigeBonus;
}
// Show a visual indicator (e.g. a star or text)
if (typeof cookieEventStar === "undefined" || !cookieEventStar) {
cookieEventStar = new Text2("★", {
size: 48,
fill: 0xffd700
});
cookieEventStar.anchor.set(0.5, 0.5);
cookieEventStar.x = 250;
cookieEventStar.y = 0;
cookieHudBox.addChild(cookieEventStar);
cookieEventStar.alpha = 0.85;
}
if (typeof cookieEventText === "undefined" || !cookieEventText) {
cookieEventText = new Text2("x2", {
size: 32,
fill: 0xffd700
});
cookieEventText.anchor.set(0.5, 0.5);
cookieEventText.x = 250;
cookieEventText.y = 32;
cookieHudBox.addChild(cookieEventText);
cookieEventText.alpha = 0.85;
}
// End event after duration
if (cookieEventTimer >= cookieEventDuration) {
cookieEventActive = false;
tapMultiplier = 1 + prestigeBonus;
// Remove visual indicator
if (cookieEventStar) {
cookieEventStar.destroy();
cookieEventStar = null;
}
if (cookieEventText) {
cookieEventText.destroy();
cookieEventText = null;
}
// Restore tints
if (cookieCounterBg) cookieCounterBg.tint = 0xffffff;
if (cpsCounterBg) cpsCounterBg.tint = 0x2c542c;
// Next event in 60-120 seconds
cookieEventNextTrigger = 1800 + Math.floor(Math.random() * 1800);
showFloatingNumber("Double Cookies Ended", 1024, 300);
}
}
// 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);
}
}
// 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
@@ -569,14 +569,14 @@
tutorialText.y = 1600;
self.addChild(tutorialText);
function handlePlayClick() {
if (!isMuted) LK.getSound('buttonClick').play();
- gameStarted = true;
- // Request username first
- if (!playerName || playerName === '') {
- playerName = 'Player' + Math.floor(Math.random() * 10000);
- storage.playerName = playerName;
+ // Require username before starting
+ if (!playerName || playerName.length < 3) {
+ showUsernamePrompt();
+ return;
}
+ gameStarted = true;
self.close();
}
function handleLeaderboardClick() {
if (!isMuted) LK.getSound('buttonClick').play();
@@ -1355,8 +1355,139 @@
var gameStarted = storage.gameStarted || false;
var isMuted = storage.isMuted || false;
var fallingCookies = [];
var playerName = storage.playerName || '';
+// Username prompt UI
+var usernamePrompt = null;
+var usernameInputText = null;
+var usernameInputBg = null;
+var usernameOkBtn = null;
+var usernameOkText = null;
+var usernameErrorText = null;
+var usernameInputValue = '';
+var usernameActive = false;
+// Show username prompt
+function showUsernamePrompt() {
+ if (usernamePrompt) {
+ usernamePrompt.visible = true;
+ usernamePrompt.alpha = 1;
+ usernameActive = true;
+ return;
+ }
+ usernamePrompt = game.addChild(new Container());
+ usernamePrompt.x = 1024;
+ usernamePrompt.y = 1366;
+ usernamePrompt.visible = true;
+ usernamePrompt.alpha = 1;
+ usernameActive = true;
+ // Background
+ var bg = usernamePrompt.attachAsset('menuPanel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 2.5,
+ scaleY: 1.5
+ });
+ bg.tint = 0xd4a574;
+ // Title
+ var title = new Text2('Enter Username', {
+ size: 60,
+ fill: 0xFFD700
+ });
+ title.anchor.set(0.5, 0.5);
+ title.y = -220;
+ usernamePrompt.addChild(title);
+ // Input background
+ usernameInputBg = usernamePrompt.attachAsset('cookieCounter', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: 600,
+ height: 100,
+ y: -60
+ });
+ usernameInputBg.tint = 0xffffff;
+ // Input text
+ usernameInputText = new Text2('', {
+ size: 40,
+ fill: 0x333333
+ });
+ usernameInputText.anchor.set(0.5, 0.5);
+ usernameInputText.x = 0;
+ usernameInputText.y = -60;
+ usernamePrompt.addChild(usernameInputText);
+ // Error text
+ usernameErrorText = new Text2('', {
+ size: 28,
+ fill: 0xff3333
+ });
+ usernameErrorText.anchor.set(0.5, 0.5);
+ usernameErrorText.x = 0;
+ usernameErrorText.y = 10;
+ usernamePrompt.addChild(usernameErrorText);
+ // OK button
+ usernameOkBtn = usernamePrompt.attachAsset('continueButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ y: 100
+ });
+ usernameOkBtn.tint = 0x4caf50;
+ usernameOkText = new Text2('OK', {
+ size: 36,
+ fill: 0xffffff
+ });
+ usernameOkText.anchor.set(0.5, 0.5);
+ usernameOkText.x = 0;
+ usernameOkText.y = 100;
+ usernamePrompt.addChild(usernameOkText);
+ // Input logic: tap input area to cycle through A-Z, 0-9, backspace, space
+ var inputChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
+ var maxLen = 12;
+ usernameInputBg.down = function (x, y, obj) {
+ // Show a virtual keyboard: for simplicity, cycle through chars on tap
+ // (In real deployment, LK may provide a text input overlay)
+ // Here, just add a random char for demo
+ if (usernameInputValue.length < maxLen) {
+ var idx = Math.floor(Math.random() * inputChars.length);
+ usernameInputValue += inputChars.charAt(idx);
+ usernameInputText.setText(usernameInputValue);
+ usernameErrorText.setText('');
+ }
+ };
+ usernameInputText.down = function (x, y, obj) {
+ // Remove last char (backspace)
+ if (usernameInputValue.length > 0) {
+ usernameInputValue = usernameInputValue.substring(0, usernameInputValue.length - 1);
+ usernameInputText.setText(usernameInputValue);
+ usernameErrorText.setText('');
+ }
+ };
+ usernameOkBtn.down = function (x, y, obj) {
+ handleUsernameOk();
+ };
+ usernameOkText.down = function (x, y, obj) {
+ handleUsernameOk();
+ };
+ function handleUsernameOk() {
+ var name = usernameInputValue.trim();
+ if (name.length < 3) {
+ usernameErrorText.setText('Name must be at least 3 characters');
+ return;
+ }
+ if (name.length > maxLen) {
+ usernameErrorText.setText('Name too long');
+ return;
+ }
+ playerName = name;
+ storage.playerName = playerName;
+ usernamePrompt.visible = false;
+ usernameActive = false;
+ updateDisplay();
+ }
+ // Dismiss prompt if already have a name
+ if (playerName && playerName.length >= 3) {
+ usernamePrompt.visible = false;
+ usernameActive = false;
+ }
+}
// Click detection for auto-clicker prevention
var clickTimes = [];
var isWarned = false;
var clicksBlocked = false;
@@ -1752,8 +1883,17 @@
var fallingCookieTimer = 0;
var baseFallingInterval = 10800; // 3 minutes at 60fps
game.update = function () {
if (!gameStarted) {
+ // Show username prompt if not set
+ if ((!playerName || playerName.length < 3) && !usernameActive) {
+ showUsernamePrompt();
+ }
+ // Block game until username entered
+ if (usernameActive) {
+ if (mainMenu.visible) mainMenu.alpha = 0.3;
+ return;
+ }
// Show main menu if not started
if (!mainMenu.visible) {
mainMenu.visible = true;
mainMenu.alpha = 1;