76 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			76 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <!doctype html>
 | |
| <html lang="en">
 | |
|   <head>
 | |
|     <meta charset="UTF-8" />
 | |
|     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 | |
|     <title>Catboy Spinner</title>
 | |
|     <style>
 | |
|       .col {
 | |
|         display: flex;
 | |
|         flex-direction: column;
 | |
|         gap: 10px;
 | |
|         margin: auto;
 | |
|         max-width: 900px;
 | |
|         background: #7eb0ff;
 | |
|       }
 | |
| 
 | |
|       * {
 | |
|         text-align: center;
 | |
|         color: #fff;
 | |
|       }
 | |
| 
 | |
|       h1 {
 | |
|         font-family: sans;
 | |
|       }
 | |
| 
 | |
|       #catboy {
 | |
|         max-width: 80vw;
 | |
|         max-height: 70vh;
 | |
|         object-fit: contain;
 | |
|         scale: calc(1 / sqrt(2));
 | |
|       }
 | |
|     </style>
 | |
|   </head>
 | |
|   <body>
 | |
|     <div class="col">
 | |
|       <h1>Catboy spinner</h1>
 | |
|       <img src="catboy.png" alt="" id="catboy" />
 | |
|       <p><span id="rpm">0</span> RPM</p>
 | |
|       <p>High score: <span id="high">0</span> RPM</p>
 | |
|     </div>
 | |
|     <script>
 | |
|       const catboyImage = document.getElementById("catboy");
 | |
|       const rpmIndiCATor = document.getElementById("rpm");
 | |
|       const highScore = document.getElementById("high");
 | |
| 
 | |
|       let rpm = 0;
 | |
|       let rot = 0;
 | |
| 
 | |
|       let high = 0;
 | |
| 
 | |
|       setInterval(() => {
 | |
|         catboyImage.style.rotate = `${rot}deg`;
 | |
|         rot += rpm / 60;
 | |
|         while (rot > 360) {
 | |
|           rot -= 360;
 | |
|         }
 | |
|       }, 1000 / 60);
 | |
| 
 | |
|       setInterval(() => {
 | |
|         if (rpm > 0) rpm -= rpm / 100;
 | |
|         rpmIndiCATor.innerHTML = Math.floor(rpm);
 | |
|       }, 10);
 | |
| 
 | |
|       catboyImage.onclick = () => {
 | |
|         rpm += 300;
 | |
|         if (rpm > high) {
 | |
|           high = rpm;
 | |
|           highScore.innerHTML = Math.floor(rpm);
 | |
|           highScore.style.color = "yellow";
 | |
|         } else {
 | |
|           highScore.style.color = '';
 | |
|         }
 | |
|       };
 | |
|     </script>
 | |
|   </body>
 | |
| </html>
 |