high score
This commit is contained in:
parent
4063840011
commit
abb217d5b8
15
index.html
15
index.html
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#catboy {
|
#catboy {
|
||||||
max-width: 80vw;
|
max-width: 80vw;
|
||||||
max-height: 80vh;
|
max-height: 70vh;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
scale: calc(1 / sqrt(2));
|
scale: calc(1 / sqrt(2));
|
||||||
}
|
}
|
||||||
|
@ -36,14 +36,18 @@
|
||||||
<h1>Catboy spinner</h1>
|
<h1>Catboy spinner</h1>
|
||||||
<img src="catboy.png" alt="" id="catboy" />
|
<img src="catboy.png" alt="" id="catboy" />
|
||||||
<p><span id="rpm">0</span> RPM</p>
|
<p><span id="rpm">0</span> RPM</p>
|
||||||
|
<p>High score: <span id="high">0</span> RPM</p>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
const catboyImage = document.getElementById("catboy");
|
const catboyImage = document.getElementById("catboy");
|
||||||
const rpmIndiCATor = document.getElementById("rpm");
|
const rpmIndiCATor = document.getElementById("rpm");
|
||||||
|
const highScore = document.getElementById("high");
|
||||||
|
|
||||||
let rpm = 6000;
|
let rpm = 0;
|
||||||
let rot = 0;
|
let rot = 0;
|
||||||
|
|
||||||
|
let high = 0;
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
catboyImage.style.rotate = `${rot}deg`;
|
catboyImage.style.rotate = `${rot}deg`;
|
||||||
rot += rpm / 60;
|
rot += rpm / 60;
|
||||||
|
@ -59,6 +63,13 @@
|
||||||
|
|
||||||
catboyImage.onclick = () => {
|
catboyImage.onclick = () => {
|
||||||
rpm += 300;
|
rpm += 300;
|
||||||
|
if (rpm > high) {
|
||||||
|
high = rpm;
|
||||||
|
highScore.innerHTML = Math.floor(rpm);
|
||||||
|
highScore.style.color = "yellow";
|
||||||
|
} else {
|
||||||
|
highScore.style.color = '';
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in a new issue