-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton_Clicker_100.html
More file actions
191 lines (182 loc) · 5.51 KB
/
Button_Clicker_100.html
File metadata and controls
191 lines (182 loc) · 5.51 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<!DOCTYPE html>
<html>
<head>
<title>Button Clicker</title>
<style>
body {
font-family: Arial, sans-serif;
background: linear-gradient(135deg, #828080 0%, #f2f2f2 100%);
background-attachment: fixed;
background-size: cover;
}
h1 {
text-align: center;
margin-top: 50px;
margin-bottom: 30px;
font-size: 40px;
color: #333;
}
.button-container {
display: flex;
justify-content: center;
align-items: center;
}
button {
background-color: #4CAF50;
border: none;
color: white;
padding: 30px 60px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 30px;
margin: 20px;
margin-bottom: 50px;
cursor: pointer;
border-radius: 10px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
transition: all 0.3s ease-in-out;
}
button:hover {
background-color: #3e8e41;
transform: scale(1.1);
}
#counter {
text-align: center;
font-size: 100px;
color: #333;
margin-top: 50px;
animation: pulse 0.5s ease-out;
animation-fill-mode: backwards;
}
@keyframes pulse {
0% {
color: #4CAF50;
}
100% {
color: #333;
}
}
#timer {
text-align: center;
font-size: 30px;
color: #333;
margin-top: 50px;
}
#instructions {
text-align: center;
font-size: 20px;
color: #555;
margin-top: 50px;2
}
#dedication {
bottom: 0px;
left: 0;
right: 0;
text-align: center;
padding: 3px;
font-size: 15px;
color: #333;
font-weight: bold;
background-color: transparent;
}
#creator {
bottom: 0px;
left: 0;
right: 0;
text-align: center;
padding: 0px;
font-size: 15px;
color: #333;
font-weight: bold;
background-color: transparent;
}
#highscore {
text-align: center;
font-size: 20px;
color: #555;
margin-top: 20px;
font-style: italic;
}
#CPS {
text-align: center;
font-size: 20px;
color: #555;
margin-top: 20px;
font-style: italic;
}
</style>
</head>
<body>
<h1>Button Clicker</h1>
<div id="instructions">Get to 100 as fast as you can!</div>
<div class="button-container">
<button onclick="increment()">Add 1</button>
</div>
<h2 id="counter">0</h2>
<div id="timer"></div>
<div id="highscore">Best time: N/A</div>
<div id="CPS">Average CPS: N/A</div>
<audio id="dream-speedrun" src="https://www.youtube.com/watch?v=AplG-bmjOYE"></audio>
<div class="button-container">
<button onclick="Restart()">Restart</button>
</div>
<div id="dedication">dedicated to <a href="https://www.youtube.com/@noticxgd">This Button</a>
</div>
<div id="creator">created by <a href="https://www.youtube.com/@Ryder7223">This Button</a>
</div>
<script>
let count = 0;
let startTime;
const AverageCPS = Infinity;
let highScore = Infinity;
let CPS = Infinity;
const counter = document.getElementById("counter");
const timer = document.getElementById("timer");
const dreamSpeedrun = new Audio("https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3");
function increment() {
count++;
counter.innerText = count;
counter.style.animation = 'none';
counter.offsetHeight;
counter.style.animation = 'pulse 0.5s ease-out';
counter.style.animationFillMode = 'backwards';
if (count === 1) {
startTime = new Date();
dreamSpeedrun.play();
}
document.addEventListener("keydown", function(event) {
if (event.keyCode === 82) { // keyCode 82 is the "r" key
Restart();
}
});
document.body.onkeydown = function(e) {
if (e.keyCode === 32) { // keyCode 32 is the " " key
increment();
e.preventDefault();
}
};
if (count === 100) {
dreamSpeedrun.pause();
const endTime = new Date();
const totalTime = (endTime - startTime) / 1000;
timer.innerText = 'Time to reach 100: ' + totalTime + ' seconds';
const AverageCPS = (100 / totalTime);
document.getElementById('CPS').innerText = 'Average CPS: ' + AverageCPS.toFixed(2);
if (totalTime < highScore) {
highScore = totalTime;
document.getElementById('highscore').innerText = 'Best time: ' + highScore.toFixed(3) + ' seconds';
}
}
}
function Restart() {
count = 0;
counter.innerText = 0;
timer.innerText = "";
CPS.innerText = "";
dreamSpeedrun.currentTime = 0;
dreamSpeedrun.pause();
}
</script>
</body>
</html>