-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
36 lines (30 loc) · 974 Bytes
/
script.js
File metadata and controls
36 lines (30 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
let cookieCount = 0;
let cursorCount = 0;
let cursorCost = 10;
const cookieDisplay = document.getElementById("cookieCount");
const cookieBtn = document.getElementById("cookieBtn");
const buyCursorBtn = document.getElementById("buyCursor");
const cursorCountDisplay = document.getElementById("cursorCount");
const cursorCostDisplay = document.getElementById("cursorCost");
cookieBtn.addEventListener("click", () => {
cookieCount++;
updateDisplay();
});
buyCursorBtn.addEventListener("click", () => {
if (cookieCount >= cursorCost) {
cookieCount -= cursorCost;
cursorCount++;
cursorCost = Math.floor(cursorCost * 1.5); // コスト上昇
updateDisplay();
}
});
function updateDisplay() {
cookieDisplay.textContent = cookieCount;
cursorCountDisplay.textContent = cursorCount;
cursorCostDisplay.textContent = cursorCost;
}
// 自動的にクッキーを増やす
setInterval(() => {
cookieCount += cursorCount;
updateDisplay();
}, 1000);