Advertisement
Guest User

Timer Viimane

a guest
Oct 15th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.92 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4. <meta charset=”utf-8? />
  5. <meta name=”format-detection” content=”telephone=no” />
  6. <meta name=”msapplication-tap-highlight” content=”no” />
  7. <meta name=”viewport” content=”user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width/>
  8. <meta http-equiv=”Content-Security-Policy” content=”default-src * ‘unsafe-inline’; style-src ‘self’ ‘unsafe-inline’; media-src *” />
  9. <link rel="icon" href="icon.png">
  10. <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.css">
  11. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  12. <script src="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js"></script>
  13. <title>Cookie clicker</title>
  14.  
  15. </head>
  16. <style>
  17.     body{
  18.         font-size: 3vh;
  19.     }
  20.     img {
  21.         max-width:100%;
  22.         height:auto;
  23.     }
  24.     .game{
  25.         height: 25vw;
  26.         width: 25vw;
  27.     }
  28.    
  29.     table, td, tr {
  30.         border: 1px solid black;
  31.     }
  32.    
  33.     .clickable{
  34.         background-color: red;
  35.     }
  36.    
  37.     .ui-btn{
  38.         font-size: 3vh;
  39.     }
  40.    
  41. </style>
  42.  
  43. <body>
  44.     <center>
  45.     <h1>Cookie clicker</h1>
  46.     <div style="height: 550px;">
  47.         <img id="cookie" src="PerfectCookie.png">
  48.     </div>
  49.     <p>Cookies: <text id="currentCookies">0</text></p>
  50.    
  51.     <h3>Shop</h3>
  52.     <table>
  53.         <tr><td><img id="mineShop" src="Mine_new.png"></td><td><img id="farmShop" src="Farm.png"></td></tr>
  54.         <tr><td id="minePrice">15</td><td id="farmPrice">10</td></tr>
  55.     </table>
  56.     </center>
  57. </body>
  58.  
  59. <script>
  60.  
  61.     var cookiesInBank = 0;
  62.     var cookiesPerSecond = 0;
  63.     var minesPrice = 15;
  64.     var farmsPrice = 10;
  65.     var mines = 0;
  66.     var farms = 0;
  67.    
  68.     function animateClickOnCookie(){
  69.         $( "#cookie" ).animate({
  70.             width: "540px",
  71.             height: "540px"
  72.           }, 100 );
  73.          
  74.         $( "#cookie" ).animate({
  75.             width: "512px",
  76.             height: "512px"
  77.           }, 100 );
  78.     }
  79.    
  80.     function changeCookiesInBank(value){
  81.         cookiesInBank += value;
  82.         $("#currentCookies").html(Math.round(cookiesInBank));
  83.     }
  84.    
  85.     function increaseMinePrice(){
  86.         minesPrice = Math.floor(minesPrice*1.2);
  87.         $("#minePrice").html(minesPrice);
  88.     }
  89.    
  90.     function increaseFarmPrice(){
  91.         farmsPrice =  Math.floor(farmsPrice*1.2);
  92.         $("#farmPrice").html(farmsPrice);
  93.     }
  94.    
  95.     setInterval(function(){
  96.         changeCookiesInBank(cookiesPerSecond);
  97.     }, 1000);
  98.    
  99.     $("#cookie").click(function(){
  100.         animateClickOnCookie();
  101.         changeCookiesInBank(1 + mines*3 + farms*2);
  102.     });
  103.    
  104.     $("#mineShop").click(function(){
  105.         if(cookiesInBank >= minesPrice){
  106.             mines += 1;
  107.             cookiesPerSecond += 0.3;
  108.             changeCookiesInBank(-1*minesPrice);
  109.             increaseMinePrice();
  110.         }else{
  111.             alert("Not enought cookies!");
  112.         }
  113.     });
  114.    
  115.     $("#farmShop").click(function(){
  116.         if(cookiesInBank >= farmsPrice){
  117.             farms += 1;
  118.             cookiesPerSecond += 0.1;
  119.             changeCookiesInBank(-1*farmsPrice);
  120.             increaseFarmPrice();
  121.         }else{
  122.             alert("Not enought cookies!");
  123.         }
  124.     });
  125.    
  126.    
  127.    
  128.    
  129.    
  130. </script>
  131.  
  132. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement