-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
114 lines (106 loc) · 3.4 KB
/
index.html
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BananaClicker</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
background-color: #f0f4c3;
color: #3e2723;
}
h1 {
font-size: 2em;
color: #ffeb3b;
}
.banana {
width: 150px; /* Adjust width */
cursor: pointer;
margin-top: 20px;
}
#score {
font-size: 2em;
margin-top: 20px;
}
#shop-btn {
display: inline-block;
margin-top: 20px;
padding: 10px 20px;
font-size: 1.2em;
color: white;
background-color: #f57c00;
border: none;
cursor: pointer;
border-radius: 5px;
}
/* Add styles for monkeys */
.monkey {
display: inline-block;
width: 50px;
height: 50px;
background-image: url('images/monkey.png'); /* Add your monkey image path */
background-size: cover;
margin: 5px;
}
#monkey-container {
margin-top: 20px;
}
</style>
</head>
<body>
<h1>🍌 BananaClicker 🍌</h1>
<p id="score">Score: 0</p>
<!-- Replace the banana emoji with an image -->
<img
class="banana"
src="images/banana.png"
alt="Click to earn bananas"
onclick="clickBanana()"
/>
<br />
<button id="shop-btn" onclick="goToShop()">Go to The Shop</button>
<div id="monkey-container"></div>
<!-- Container for displaying monkeys -->
<script>
// Load saved score and upgrade data from localStorage
let score = parseInt(localStorage.getItem("score")) || 0;
let clickPower = parseInt(localStorage.getItem("clickPower")) || 1;
let monkeyCount = parseInt(localStorage.getItem("monkeyCount")) || 0;
// Display the saved score
document.getElementById("score").innerText = "Score: " + score;
function clickBanana() {
// Increase score by clickPower
score += clickPower;
// Save the new score to localStorage
localStorage.setItem("score", score);
document.getElementById("score").innerText = "Score: " + score;
}
function goToShop() {
window.location.href = "shop.html"; // Redirect to shop page
}
// Function to display monkeys
function displayMonkeys() {
const monkeyContainer = document.getElementById("monkey-container");
monkeyContainer.innerHTML = ""; // Clear existing monkeys
for (let i = 0; i < monkeyCount; i++) {
const monkeyDiv = document.createElement("div");
monkeyDiv.className = "monkey";
monkeyContainer.appendChild(monkeyDiv);
}
}
// Function to generate bananas over time
function generateBananas() {
setInterval(() => {
score += monkeyCount; // Generate bananas based on the number of monkeys
localStorage.setItem("score", score); // Update score in localStorage
document.getElementById("score").innerText = "Score: " + score; // Update score display
}, 1000); // Adjust the interval as needed (1000 ms = 1 second)
}
// Call the functions to display monkeys and start generating bananas
displayMonkeys();
generateBananas();
</script>
</body>
</html>
<!-- Hello stupid fart potato-->