<project id="cookie-clicker" title="Cookie Clicker Game"> <file path="index.html"> <!DOCTYPE html> <html> <head> <title>Cookie Clicker</title> <style> body { display: flex; flex-direction: column; align-items: center; font-family: Arial, sans-serif; } #game { width: 200px; height: 200px; position: relative; } #cookie { width: 150px; height: 150px; cursor: pointer; transition: transform 0.1s; } #cookie:active { transform: scale(0.95); } #counter { font-size: 24px; margin-top: 10px; } </style> </head> <body> <h1>Cookie Clicker</h1> <div id="game"> <img id="cookie" src="https://cdn.pixabay.com/photo/2014/04/03/00/41/cookie-309168_960_720.png" alt="Cookie"> </div> <div id="counter">0</div> <script> let count = 0; const cookie = document.getElementById('cookie'); const counter = document.getElementById('counter'); cookie.addEventListener('click', () => { count++; counter.textContent = count; }); </script> </body> </html> </file> </project>I'll create a simple 200x200px cookie clicker game using HTML, CSS, and JavaScript. The game will have a cookie image that can be clicked to increase a counter.
The cookie clicker game is ready to play! Just click on the cookie to increase your score. The game features:
Would you like me to make any adjustments or add more features?
<project id="cookie-clicker" title="Cookie Clicker Game"> <file path="cookie-clicker.html"> <!DOCTYPE html> <html> <head> <title>Cookie Clicker</title> <style> body { display: flex; flex-direction: column; align-items: center; font-family: Arial, sans-serif; margin: 0; padding: 20px; } #game { width: 200px; height: 200px; position: relative; margin: 0 auto; } #cookie { width: 150px; height: 150px; cursor: pointer; transition: transform 0.1s; user-select: none; } #cookie:active { transform: scale(0.95); } #counter { font-size: 24px; margin-top: 10px; text-align: center; } </style> </head> <body> <div id="game"> <img id="cookie" src="https://cdn.pixabay.com/photo/2014/04/03/00/41/cookie-309168_960_720.png" alt="Cookie"> <div id="counter">0</div> </div> <script> let count = 0; const cookie = document.getElementById('cookie'); const counter = document.getElementById('counter'); cookie.addEventListener('click', () => { count++; counter.textContent = count; }); </script> </body> </html> </file> </project>I'll create a single HTML file for the cookie clicker game with all the CSS and JavaScript included.
Here's the final version of the 200x200px cookie clicker game in a single HTML file:
<!DOCTYPE html>
<html>
<head>
<title>Cookie Clicker</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background: #f5f5f5;
}
#game {
width: 200px;
height: 200px;
position: relative;
margin: 0 auto;
background: white;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
padding: 10px;
box-sizing: border-box;
}
#cookie {
width: 150px;
height: 150px;
cursor: pointer;
transition: transform 0.1s;
user-select: none;
display: block;
margin: 0 auto;
}
#cookie:active {
transform: scale(0.95);
}
#counter {
font-size: 24px;
margin-top: 10px;
text-align: center;
font-weight: bold;
color: #333;
}
</style>
</head>
<body>
<div id="game">
<img id="cookie" src="https://cdn.pixabay.com/photo/2014/04/03/00/41/cookie-309168_960_720.png" alt="Cookie">
<div id="counter">0</div>
</div>
<script>
let count = 0;
const cookie = document.getElementById('cookie');
const counter = document.getElementById('counter');
cookie.addEventListener('click', () => {
count++;
counter.textContent = count;
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Cookie Clicker</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background: #f5f5f5;
}
#game {
width: 200px;
height: 200px;
position: relative;
margin: 0 auto;
background: white;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
padding: 10px;
box-sizing: border-box;
}
#cookie {
width: 150px;
height: 150px;
cursor: pointer;
transition: transform 0.1s;
user-select: none;
display: block;
margin: 0 auto;
}
#cookie:active {
transform: scale(0.95);
}
#counter {
font-size: 24px;
margin-top: 10px;
text-align: center;
font-weight: bold;
color: #333;
}
</style>
</head>
<body>
<div id="game">
<img id="cookie" src="https://cdn.pixabay.com/photo/2014/04/03/00/41/cookie-309168_960_720.png" alt="Cookie">
<div id="counter">0</div>
</div>
<script>
let count = 0;
const cookie = document.getElementById('cookie');
const counter = document.getElementById('counter');
cookie.addEventListener('click', () => {
count++;
counter.textContent = count;
});
</script>
</body>
</html>
Key features:
You're right - the container was slightly larger than 200x200px due to padding. Here's the fixed version with exactly 200x200px dimensions:
<!DOCTYPE html>
<html>
<head>
<title>Cookie Clicker</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: #f5f5f5;
font-family: Arial, sans-serif;
}
#game {
width: 200px;
height: 200px;
background: white;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
#cookie {
width: 120px;
height: 120px;
cursor: pointer;
transition: transform 0.1s;
user-select: none;
}
#cookie:active {
transform: scale(0.95);
}
#counter {
font-size: 20px;
margin-top: 10px;
font-weight: bold;
color: #333;
}
</style>
</head>
<body>
<div id="game">
<img id="cookie" src="https://cdn.pixabay.com/photo/2014/04/03/00/41/cookie-309168_960_720.png" alt="Cookie">
<div id="counter">0</div>
</div>
<script>
let count = 0;
const cookie = document.getElementById('cookie');
const counter = document.getElementById('counter');
cookie.addEventListener('click', () => {
count++;
counter.textContent = count;
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Cookie Clicker</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: #f5f5f5;
font-family: Arial, sans-serif;
}
#game {
width: 200px;
height: 200px;
background: white;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
#cookie {
width: 120px;
height: 120px;
cursor: pointer;
transition: transform 0.1s;
user-select: none;
}
#cookie:active {
transform: scale(0.95);
}
#counter {
font-size: 20px;
margin-top: 10px;
font-weight: bold;
color: #333;
}
</style>
</head>
<body>
<div id="game">
<img id="cookie" src="https://cdn.pixabay.com/photo/2014/04/03/00/41/cookie-309168_960_720.png" alt="Cookie">
<div id="counter">0</div>
</div>
<script>
let count = 0;
const cookie = document.getElementById('cookie');
const counter = document.getElementById('counter');
cookie.addEventListener('click', () => {
count++;
counter.textContent = count;
});
</script>
</body>
</html>
Changes made:
I'll update the cookie image URL in the HTML code. Here's the corrected version:
<!DOCTYPE html>
<html>
<head>
<title>Cookie Clicker</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: #f5f5f5;
font-family: Arial, sans-serif;
}
#game {
width: 200px;
height: 200px;
background: white;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
#cookie {
width: 120px;
height: 120px;
cursor: pointer;
transition: transform 0.1s;
user-select: none;
}
#cookie:active {
transform: scale(0.95);
}
#counter {
font-size: 20px;
margin-top: 10px;
font-weight: bold;
color: #333;
}
</style>
</head>
<body>
<div id="game">
<img id="cookie" src="https://png.pngtree.com/png-clipart/20240320/original/pngtree-chocolate-chip-cookie-png-image_14636259.png" alt="Cookie">
<div id="counter">0</div>
</div>
<script>
let count = 0;
const cookie = document.getElementById('cookie');
const counter = document.getElementById('counter');
cookie.addEventListener('click', () => {
count++;
counter.textContent = count;
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Cookie Clicker</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: #f5f5f5;
font-family: Arial, sans-serif;
}
#game {
width: 200px;
height: 200px;
background: white;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
#cookie {
width: 120px;
height: 120px;
cursor: pointer;
transition: transform 0.1s;
user-select: none;
}
#cookie:active {
transform: scale(0.95);
}
#counter {
font-size: 20px;
margin-top: 10px;
font-weight: bold;
color: #333;
}
</style>
</head>
<body>
<div id="game">
<img id="cookie" src="https://png.pngtree.com/png-clipart/20240320/original/pngtree-chocolate-chip-cookie-png-image_14636259.png" alt="Cookie">
<div id="counter">0</div>
</div>
<script>
let count = 0;
const cookie = document.getElementById('cookie');
const counter = document.getElementById('counter');
cookie.addEventListener('click', () => {
count++;
counter.textContent = count;
});
</script>
</body>
</html>
Key changes:
The cookie image should now show the chocolate chip cookie from the URL you provided._
I'll add the upgrades and golden cookie feature to your cookie clicker game. Here's the updated version:
<!DOCTYPE html>
<html>
<head>
<title>Cookie Clicker</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: #f5f5f5;
font-family: Arial, sans-serif;
}
#game {
width: 300px;
height: 300px;
background: white;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
position: relative;
}
#cookie {
width: 120px;
height: 120px;
cursor: pointer;
transition: transform 0.1s;
user-select: none;
}
#cookie:active {
transform: scale(0.95);
}
#counter {
font-size: 20px;
margin-top: 10px;
font-weight: bold;
color: #333;
}
#cps {
font-size: 16px;
margin-top: 5px;
color: #666;
}
.upgrade {
margin-top: 10px;
padding: 5px 10px;
background: #4CAF50;
color: white;
border: none;
border-radius: 3px;
cursor: pointer;
}
.upgrade:disabled {
background: #cccccc;
cursor: not-allowed;
}
#golden-cookie {
position: absolute;
width: 40px;
height: 40px;
background: gold;
border-radius: 50%;
display: none;
cursor: pointer;
z-index: 10;
}
</style>
</head>
<body>
<div id="game">
<div id="counter">Cookies: 0</div>
<div id="cps">Cookies per second: 0</div>
<img id="cookie" src="https://png.pngtree.com/png-clipart/20240320/original/pngtree-chocolate-chip-cookie-png-image_14636259.png" alt="Cookie">
<button class="upgrade" id="upgrade1">Upgrade 1 (10 cookies) - +3 CPS</button>
<button class="upgrade" id="upgrade2">Upgrade 2 (25 cookies) - +1 CPS</button>
<div id="golden-cookie"></div>
</div>
<script>
let cookies = 0;
let cps = 0;
let upgrade1Cost = 10;
let upgrade2Cost = 25;
let goldenCookieActive = false;
const cookie = document.getElementById('cookie');
const counter = document.getElementById('counter');
const cpsDisplay = document.getElementById('cps');
const upgrade1 = document.getElementById('upgrade1');
const upgrade2 = document.getElementById('upgrade2');
const goldenCookie = document.getElementById('golden-cookie');
// Main cookie click
cookie.addEventListener('click', () => {
cookies++;
updateCounter();
});
// Upgrade 1 - +3 CPS
upgrade1.addEventListener('click', () => {
if (cookies >= upgrade1Cost) {
cookies -= upgrade1Cost;
cps += 3;
upgrade1Cost = Math.floor(upgrade1Cost * 1.5);
upgrade1.textContent = `Upgrade 1 (${upgrade1Cost} cookies) - +3 CPS`;
updateCounter();
updateUpgradeButtons();
}
});
// Upgrade 2 - +1 CPS
upgrade2.addEventListener('click', () => {
if (cookies >= upgrade2Cost) {
cookies -= upgrade2Cost;
cps += 1;
upgrade2Cost = Math.floor(upgrade2Cost * 1.5);
upgrade2.textContent = `Upgrade 2 (${upgrade2Cost} cookies) - +1 CPS`;
updateCounter();
updateUpgradeButtons();
}
});
// Golden cookie
goldenCookie.addEventListener('click', () => {
cookies += 100;
goldenCookie.style.display = 'none';
goldenCookieActive = false;
updateCounter();
setTimeout(spawnGoldenCookie, 300000); // 5 minutes
});
function updateCounter() {
counter.textContent = `Cookies: ${cookies}`;
cpsDisplay.textContent = `Cookies per second: ${cps}`;
}
function updateUpgradeButtons() {
upgrade1.disabled = cookies < upgrade1Cost;
upgrade2.disabled = cookies < upgrade2Cost;
}
function spawnGoldenCookie() {
if (!goldenCookieActive) {
goldenCookie.style.display = 'block';
goldenCookie.style.left = Math.random() * 220 + 'px';
goldenCookie.style.top = Math.random() * 220 + 'px';
goldenCookieActive = true;
}
}
// CPS interval
setInterval(() => {
cookies += cps;
updateCounter();
updateUpgradeButtons();
}, 1000);
// Initial golden cookie spawn
setTimeout(spawnGoldenCookie, 300000); // 5 minutes
// Initial update
updateCounter();
updateUpgradeButtons();
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Cookie Clicker</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: #f5f5f5;
font-family: Arial, sans-serif;
}
#game {
width: 300px;
height: 300px;
background: white;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
position: relative;
}
#cookie {
width: 120px;
height: 120px;
cursor: pointer;
transition: transform 0.1s;
user-select: none;
}
#cookie:active {
transform: scale(0.95);
}
#counter {
font-size: 20px;
margin-top: 10px;
font-weight: bold;
color: #333;
}
#cps {
font-size: 16px;
margin-top: 5px;
color: #666;
}
.upgrade {
margin-top: 10px;
padding: 5px 10px;
background: #4CAF50;
color: white;
border: none;
border-radius: 3px;
cursor: pointer;
}
.upgrade:disabled {
background: #cccccc;
cursor: not-allowed;
}
#golden-cookie {
position: absolute;
width: 40px;
height: 40px;
background: gold;
border-radius: 50%;
display: none;
cursor: pointer;
z-index: 10;
}
</style>
</head>
<body>
<div id="game">
<div id="counter">Cookies: 0</div>
<div id="cps">Cookies per second: 0</div>
<img id="cookie" src="https://png.pngtree.com/png-clipart/20240320/original/pngtree-chocolate-chip-cookie-png-image_14636259.png" alt="Cookie">
<button class="upgrade" id="upgrade1">Upgrade 1 (10 cookies) - +3 CPS</button>
<button class="upgrade" id="upgrade2">Upgrade 2 (25 cookies) - +1 CPS</button>
<div id="golden-cookie"></div>
</div>
<script>
let cookies = 0;
let cps = 0;
let upgrade1Cost = 10;
let upgrade2Cost = 25;
let goldenCookieActive = false;
const cookie = document.getElementById('cookie');
const counter = document.getElementById('counter');
const cpsDisplay = document.getElementById('cps');
const upgrade1 = document.getElementById('upgrade1');
const upgrade2 = document.getElementById('upgrade2');
const goldenCookie = document.getElementById('golden-cookie');
// Main cookie click
cookie.addEventListener('click', () => {
cookies++;
updateCounter();
});
// Upgrade 1 - +3 CPS
upgrade1.addEventListener('click', () => {
if (cookies >= upgrade1Cost) {
cookies -= upgrade1Cost;
cps += 3;
upgrade1Cost = Math.floor(upgrade1Cost * 1.5);
upgrade1.textContent = `Upgrade 1 (${upgrade1Cost} cookies) - +3 CPS`;
updateCounter();
updateUpgradeButtons();
}
});
// Upgrade 2 - +1 CPS
upgrade2.addEventListener('click', () => {
if (cookies >= upgrade2Cost) {
cookies -= upgrade2Cost;
cps += 1;
upgrade2Cost = Math.floor(upgrade2Cost * 1.5);
upgrade2.textContent = `Upgrade 2 (${upgrade2Cost} cookies) - +1 CPS`;
updateCounter();
updateUpgradeButtons();
}
});
// Golden cookie
goldenCookie.addEventListener('click', () => {
cookies += 100;
goldenCookie.style.display = 'none';
goldenCookieActive = false;
updateCounter();
setTimeout(spawnGoldenCookie, 300000); // 5 minutes
});
function updateCounter() {
counter.textContent = `Cookies: ${cookies}`;
cpsDisplay.textContent = `Cookies per second: ${cps}`;
}
function updateUpgradeButtons() {
upgrade1.disabled = cookies < upgrade1Cost;
upgrade2.disabled = cookies < upgrade2Cost;
}
function spawnGoldenCookie() {
if (!goldenCookieActive) {
goldenCookie.style.display = 'block';
goldenCookie.style.left = Math.random() * 220 + 'px';
goldenCookie.style.top = Math.random() * 220 + 'px';
goldenCookieActive = true;
}
}
// CPS interval
setInterval(() => {
cookies += cps;
updateCounter();
updateUpgradeButtons();
}, 1000);
// Initial golden cookie spawn
setTimeout(spawnGoldenCookie, 300000); // 5 minutes
// Initial update
updateCounter();
updateUpgradeButtons();
</script>
</body>
</html>
Key features added:
The game now has passive income (CPS) and active clicking rewards, plus the golden cookie bonus._
I'll update the golden cookie image URL in the HTML code. Here's the corrected version:
<!DOCTYPE html>
<html>
<head>
<title>Cookie Clicker</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: #f5f5f5;
font-family: Arial, sans-serif;
}
#game {
width: 300px;
height: 300px;
background: white;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
position: relative;
}
#cookie {
width: 120px;
height: 120px;
cursor: pointer;
transition: transform 0.1s;
user-select: none;
}
#cookie:active {
transform: scale(0.95);
}
#counter {
font-size: 20px;
margin-top: 10px;
font-weight: bold;
color: #333;
}
#cps {
font-size: 16px;
margin-top: 5px;
color: #666;
}
.upgrade {
margin-top: 10px;
padding: 5px 10px;
background: #4CAF50;
color: white;
border: none;
border-radius: 3px;
cursor: pointer;
}
.upgrade:disabled {
background: #cccccc;
cursor: not-allowed;
}
#golden-cookie {
position: absolute;
width: 40px;
height: 40px;
border-radius: 50%;
display: none;
cursor: pointer;
z-index: 10;
}
</style>
</head>
<body>
<div id="game">
<div id="counter">Cookies: 0</div>
<div id="cps">Cookies per second: 0</div>
<img id="cookie" src="https://png.pngtree.com/png-clipart/20240320/original/pngtree-chocolate-chip-cookie-png-image_14636259.png" alt="Cookie">
<button class="upgrade" id="upgrade1">Upgrade 1 (10 cookie) - +3 CPS</button>
<button class="upgrade" id="upgrade2">Upgrade 2 (25 cookie) - +1 CPS</button>
<img id="golden-cookie" src="https://png.pngtree.com/png-clipart/20250202/original/pngtree-a-close-up-of-yellow-cookie-showcase-its-golden-texture-and-png-image_20146787.png" alt="Golden Cookie">
</div>
<script>
let cookies = 0;
let cps = 0;
let upgrade1Cost = 10;
let upgrade2Cost = 25;
let goldenCookieActive = false;
const cookie = document.getElementById('cookie');
const counter = document.getElementById('counter');
const cpsDisplay = document.getElementById('cps');
const upgrade1 = document.getElementById('upgrade1');
const upgrade2 = document.getElementById('upgrade2');
const goldenCookie = document.getElementById('golden-cookie');
// Main cookie click
cookie.addEventListener('click', () => {
cookies++;
updateCounter();
});
// Upgrade 1 - +3 CPS
upgrade1.addEventListener('click', () => {
if (cookies >= upgrade1Cost) {
cookies -= upgrade1Cost;
cps += 3;
upgrade1Cost = Math.floor(upgrade1Cost * 1.5);
upgrade1.textContent = `Upgrade 1 (${upgrade1Cost} cookie) - +3 CPS`;
updateCounter();
updateUpgradeButton();
}
});
// Upgrade 2 - +1 CPS
upgrade2.addEventListener('click', () => {
if (cookies >= upgrade2Cost) {
cookies -= upgrade2Cost;
cps += 1;
upgrade2Cost = Math.floor(upgrade2Cost * 1.5);
upgrade2.textContent = `Upgrade 2 (${upgrade2Cost} cookie) - +1 CPS`;
updateCounter();
updateUpgradeButton();
}
});
// Golden cookie
goldenCookie.addEventListener('click', () => {
cookies += 100;
goldenCookie.style.display = 'none';
goldenCookieActive = false;
updateCounter();
setTimeout(spawnGoldenCookie, 300000); // 5 minutes
});
function updateCounter() {
counter.textContent = `Cookies: ${cookies}`;
cpsDisplay.textContent = `Cookies per second: ${cps}`;
}
function updateUpgradeButton() {
upgrade1.disabled = cookies < upgrade1Cost;
upgrade2.disabled = cookies < upgrade2Cost;
}
function spawnGoldenCookie() {
if (!goldenCookieActive) {
goldenCookie.style.display = 'block';
goldenCookie.style.left = Math.random() * 220 + 'px';
goldenCookie.style.top = Math.random() * 220 + 'px';
goldenCookieActive = true;
}
}
// CPS interval
setInterval(() => {
cookies += cps;
updateCounter();
updateUpgradeButton();
}, 1000);
// Initial golden cookie spawn
setTimeout(spawnGoldenCookie, 300000); // 5 minutes
// Initial update
updateCounter();
updateUpgradeButton();
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Cookie Clicker</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: #f5f5f5;
font-family: Arial, sans-serif;
}
#game {
width: 300px;
height: 300px;
background: white;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
position: relative;
}
#cookie {
width: 120px;
height: 120px;
cursor: pointer;
transition: transform 0.1s;
user-select: none;
}
#cookie:active {
transform: scale(0.95);
}
#counter {
font-size: 20px;
margin-top: 10px;
font-weight: bold;
color: #333;
}
#cps {
font-size: 16px;
margin-top: 5px;
color: #666;
}
.upgrade {
margin-top: 10px;
padding: 5px 10px;
background: #4CAF50;
color: white;
border: none;
border-radius: 3px;
cursor: pointer;
}
.upgrade:disabled {
background: #cccccc;
cursor: not-allowed;
}
#golden-cookie {
position: absolute;
width: 40px;
height: 40px;
border-radius: 50%;
display: none;
cursor: pointer;
z-index: 10;
}
</style>
</head>
<body>
<div id="game">
<div id="counter">Cookies: 0</div>
<div id="cps">Cookies per second: 0</div>
<img id="cookie" src="https://png.pngtree.com/png-clipart/20240320/original/pngtree-chocolate-chip-cookie-png-image_14636259.png" alt="Cookie">
<button class="upgrade" id="upgrade1">Upgrade 1 (10 cookie) - +3 CPS</button>
<button class="upgrade" id="upgrade2">Upgrade 2 (25 cookie) - +1 CPS</button>
<img id="golden-cookie" src="https://png.pngtree.com/png-clipart/20250202/original/pngtree-a-close-up-of-yellow-cookie-showcase-its-golden-texture-and-png-image_20146787.png" alt="Golden Cookie">
</div>
<script>
let cookies = 0;
let cps = 0;
let upgrade1Cost = 10;
let upgrade2Cost = 25;
let goldenCookieActive = false;
const cookie = document.getElementById('cookie');
const counter = document.getElementById('counter');
const cpsDisplay = document.getElementById('cps');
const upgrade1 = document.getElementById('upgrade1');
const upgrade2 = document.getElementById('upgrade2');
const goldenCookie = document.getElementById('golden-cookie');
// Main cookie click
cookie.addEventListener('click', () => {
cookies++;
updateCounter();
});
// Upgrade 1 - +3 CPS
upgrade1.addEventListener('click', () => {
if (cookies >= upgrade1Cost) {
cookies -= upgrade1Cost;
cps += 3;
upgrade1Cost = Math.floor(upgrade1Cost * 1.5);
upgrade1.textContent = `Upgrade 1 (${upgrade1Cost} cookie) - +3 CPS`;
updateCounter();
updateUpgradeButton();
}
});
// Upgrade 2 - +1 CPS
upgrade2.addEventListener('click', () => {
if (cookies >= upgrade2Cost) {
cookies -= upgrade2Cost;
cps += 1;
upgrade2Cost = Math.floor(upgrade2Cost * 1.5);
upgrade2.textContent = `Upgrade 2 (${upgrade2Cost} cookie) - +1 CPS`;
updateCounter();
updateUpgradeButton();
}
});
// Golden cookie
goldenCookie.addEventListener('click', () => {
cookies += 100;
goldenCookie.style.display = 'none';
goldenCookieActive = false;
updateCounter();
setTimeout(spawnGoldenCookie, 300000); // 5 minutes
});
function updateCounter() {
counter.textContent = `Cookies: ${cookies}`;
cpsDisplay.textContent = `Cookies per second: ${cps}`;
}
function updateUpgradeButton() {
upgrade1.disabled = cookies < upgrade1Cost;
upgrade2.disabled = cookies < upgrade2Cost;
}
function spawnGoldenCookie() {
if (!goldenCookieActive) {
goldenCookie.style.display = 'block';
goldenCookie.style.left = Math.random() * 220 + 'px';
goldenCookie.style.top = Math.random() * 220 + 'px';
goldenCookieActive = true;
}
}
// CPS interval
setInterval(() => {
cookies += cps;
updateCounter();
updateUpgradeButton();
}, 1000);
// Initial golden cookie spawn
setTimeout(spawnGoldenCookie, 300000); // 5 minutes
// Initial update
updateCounter();
updateUpgradeButton();
</script>
</body>
</html>
Key changes: