ssoni

cookie.html

Mar 30th, 2022 (edited)
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.23 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <title>Cookie Clicker Basic</title>
  4.         <style>
  5.             #progress {
  6.                 background-color: red;
  7.             }
  8.             #cookie {
  9.                 position: absolute;
  10.                 top: 150px;
  11.             }
  12.         </style>
  13.         <script>
  14.             function hit()
  15.             {
  16.                 //update score
  17.                 var score;
  18.                 score = document.getElementById("score").innerHTML;
  19.                 score++;
  20.                 document.getElementById("score").innerHTML = score;
  21.  
  22.                 //move cookie
  23.                 var newX = Math.random() * 500;
  24.                 var newY = Math.random() * 500;
  25.                 document.getElementById("cookie").style.left = newX;
  26.                 document.getElementById("cookie").style.top = newY;
  27.  
  28.             }
  29.         </script>
  30.     </head>
  31.     <body>
  32.         <img id="cookie" src="cookie.jpg" alt="face" height="80" width="80" onClick="hit()">
  33.         <br><br>
  34.         <table border=1>
  35.             <tr>
  36.                 <td>Score</td>
  37.                 <td id="score">0</td>
  38.             </tr>
  39.         </table>
  40.         <br>
  41.         <span id="progress">Progress Bar goes here</span>
  42.     </body>
  43. </html>
  44.  
  45.  
  46.  
Add Comment
Please, Sign In to add comment