Advertisement
Guest User

Untitled

a guest
Aug 24th, 2013
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 27.74 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <title>Cookie Clicker</title>
  6. <!--
  7. Code and graphics are copyright Orteil, 2013
  8. this code is bad don't look
  9.  
  10. to add :
  11. -achievements
  12. -off-focus running
  13. -fix cookie algo
  14. -add counter to each purchasable
  15. -add counter for general cookie-generation
  16. -upgrades
  17. -milk (?)
  18.  
  19. Remember, cheated cookies taste awful!
  20. -->
  21.  <script type="text/javascript">
  22. //<![CDATA[
  23. try{if (!window.CloudFlare) { var CloudFlare=[{verbose:0,p:0,byc:0,owlid:"cf",mirage:{responsive:0,lazy:0},mirage2:0,oracle:0,paths:{cloudflare:"/cdn-cgi/nexp/abv=2332175737/"},atok:"acd34630df1f5855b51ec91d891fd57c",zone:"dashnet.org",rocket:"a",apps:{}}];document.write('<script type="text/javascript" src="//ajax.cloudflare.com/cdn-cgi/nexp/abv=2310247235/cloudflare.min.js"><'+'\/script>')}}catch(e){};
  24. //]]>
  25. </script>
  26. <style>
  27.  
  28. body,html
  29. {
  30.     padding:0px;
  31.     margin:0px;
  32. }
  33. body
  34. {
  35.     font-family:Courier new,monospace;
  36.     -webkit-touch-callout: none;
  37.     -webkit-user-select: none;
  38.     -khtml-user-select: none;
  39.     -moz-user-select: moz-none;
  40.     -ms-user-select: none;
  41.     user-select: none;
  42.     background:#ccc;
  43.     overflow-y:auto;
  44. }
  45.  
  46. body::selection{background:transparent;}
  47. body::-moz-selection{background:transparent;}
  48.  
  49. #cookie
  50. {
  51.     width:128px;
  52.     height:128px;
  53.     background:url(cookie.png);
  54.     position:absolute;
  55.     left:-64px;
  56.     cursor:pointer;
  57. }
  58. #cookie:hover
  59. {
  60.     background-position:-128px;
  61. }
  62. #cookie:active
  63. {
  64.     background-position:-256px;
  65. }
  66. #cookie .cursor
  67. {
  68.     width:32px;
  69.     height:32px;
  70.     position:absolute;
  71.     background:url(cursor.png);
  72. }
  73.  
  74. #pops
  75. {
  76.     position:absolute;
  77.     left:0px;
  78.     top:0px;
  79.     z-index:10000;
  80.     pointer-events:none;
  81. }
  82.  
  83. .pop
  84. {
  85.     font-weight:bold;
  86.     color:#fff;
  87.     width:200px;
  88.     height:20px;
  89.     font-size:20px;
  90.     text-align:center;
  91. }
  92.  
  93. #rightPanel
  94. {
  95.     position:absolute;
  96.     right:0px;
  97.     top:0px;
  98.     z-index:100000;
  99. }
  100. #store
  101. {
  102.     position:relative;
  103. }
  104. #store>div
  105. {
  106.     background:#eee no-repeat;
  107.     width:256px;
  108.     height:64px;
  109.     padding-left:72px;
  110.     cursor:pointer;
  111.     border:#000 2px solid;
  112.     position:relative;
  113. }
  114. #store>div:hover
  115. {
  116.     background-color:#fff;
  117. }
  118. #store>div:active
  119. {
  120.     background-color:#ccc;
  121. }
  122. #store>div b
  123. {
  124.     display:block;
  125. }
  126. #store>div.grayed
  127. {
  128.     background-color:#666;
  129.     color:#f00;
  130. }
  131.  
  132. #store>div .amount
  133. {
  134.     position:absolute;
  135.     right:8px;
  136.     top:8px;
  137.     font-size:48px;
  138.     color:#000;
  139.     opacity:0.2;
  140. }
  141.  
  142. #money
  143. {
  144.     background:url(currency.png) no-repeat;
  145.     background-color:#fff;
  146.     background-color:rgba(255,255,255,0.75);
  147.     border-radius:18px;
  148.     position:absolute;
  149.     left:0px;
  150.     top:0px;
  151.     margin:16px;
  152.     height:28px;
  153.     padding:4px 4px 0px 36px;
  154.     font-weight:bold;
  155.     font-size:24px;
  156.     z-index:100;
  157. }
  158. #saveMenu
  159. {
  160.     position:absolute;
  161.     left:0px;
  162.     top:45px;
  163.     margin:10px 16px;
  164.     padding:2px 6px;
  165.     font-weight:bold;
  166.     font-size:14px;
  167.     background:#fff;
  168.     background:rgba(255,255,255,0.75);
  169.     border-radius:8px;
  170.     line-height:125%;
  171.     z-index:100;
  172.     font-size:12px;
  173. }
  174. #saveMenu .button
  175. {
  176.     text-decoration:underline;
  177.     cursor:pointer;
  178.     font-size:14px;
  179. }
  180. #updateLog
  181. {
  182.     position:fixed;
  183.     left:0px;
  184.     bottom:20px;
  185.     margin:16px;
  186.     padding:6px;
  187.     font-weight:bold;
  188.     font-size:12px;
  189.     color:#666;
  190.     background:#fff;
  191.     background:rgba(255,255,255,0.75);
  192.     border-radius:8px;
  193.     line-height:125%;
  194.     width:250px;
  195.     height:300px;
  196.     overflow-y:auto;
  197.     z-index:100;
  198. }
  199. #updateLog b {color:#000;}
  200.  
  201.  
  202. moni
  203. {
  204.     background:url(currencysmall.png) no-repeat;
  205.     width:16px;
  206.     height:16px;
  207.     display:inline-block;
  208.     position:relative;
  209.     top:4px;
  210.     margin-right:-8px;
  211. }
  212.  
  213. #grandmas
  214. {
  215.     position:absolute;
  216.     left:100px;
  217.     width:240px;
  218. }
  219. .grandma
  220. {
  221.     position:absolute;
  222.     background:url(grandma.png);
  223.     width:24px;
  224.     height:48px;
  225. }
  226. .goldengrandma{background:url(goldengrandma.png);}
  227. .factorygrandma{background:url(factorygrandma.png);}
  228. .minegrandma{background:url(minegrandma.png);}
  229. .shipmentgrandma{background:url(shipmentgrandma.png);}
  230. .portalgrandma{background:url(portalgrandma.png);}
  231. .pledgedgrandma{background:url(pledgedgrandma.png);}
  232. .timegrandma{background:url(timegrandma.png);}
  233. #factories
  234. {
  235.     position:absolute;
  236.     left:-420px;
  237.     width:320px;
  238. }
  239. .factory
  240. {
  241.     position:absolute;
  242.     background:url(factory.png);
  243.     width:32px;
  244.     height:48px;
  245. }
  246. #mines
  247. {
  248.     position:absolute;
  249.     left:100px;
  250.     width:160px;
  251.     top:100px;
  252. }
  253. .mine
  254. {
  255.     position:absolute;
  256.     background:url(mine.png);
  257.     width:32px;
  258.     height:32px;
  259. }
  260. #shipments
  261. {
  262.     position:absolute;
  263.     left:-340px;
  264.     width:240px;
  265.     top:100px;
  266. }
  267. .shipment
  268. {
  269.     position:absolute;
  270.     background:url(shipment.png);
  271.     width:48px;
  272.     height:48px;
  273. }
  274. #labs
  275. {
  276.     position:absolute;
  277.     left:-120px;
  278.     width:240px;
  279.     top:180px;
  280. }
  281. .lab
  282. {
  283.     position:absolute;
  284.     background:url(lab.png);
  285.     width:24px;
  286.     height:32px;
  287. }
  288. #portals
  289. {
  290.     position:absolute;
  291.     left:-340px;
  292.     width:240px;
  293.     top:180px;
  294. }
  295. .portal
  296. {
  297.     position:absolute;
  298.     background:url(portal.png);
  299.     width:48px;
  300.     height:48px;
  301. }
  302. #times
  303. {
  304.     position:absolute;
  305.     left:100px;
  306.     width:240px;
  307.     top:180px;
  308. }
  309. .time
  310. {
  311.     position:absolute;
  312.     background:url(timemachine.png);
  313.     width:48px;
  314.     height:48px;
  315. }
  316.  
  317. #comment
  318. {
  319.     position:absolute;
  320.     left:-200px;
  321.     top:-115px;
  322.     width:400px;
  323.     font-weight:bold;
  324.     font-size:16px;
  325.     text-align:center;
  326.     background-color:#fff;
  327.     background-color:rgba(255,255,255,0.75);
  328.     border-radius:18px;
  329. }
  330.  
  331.  
  332. #middle
  333. {
  334.     position:absolute;
  335.     left:50%;
  336.     top:150px;
  337.     width:0px;
  338. }
  339.  
  340. #credits
  341. {
  342.     width:100%;
  343.     height:20px;
  344.     background:#666;
  345.     color:#fff;
  346.     position:fixed;
  347.     bottom:0px;
  348.     margin:0px;
  349.     font-size:12px;
  350.     border-top:2px solid #999;
  351.     z-index:100000;
  352. }
  353. #credits span
  354. {
  355.     margin:4px;
  356. }
  357. a {color:#fff;}
  358.  
  359. #alert
  360. {
  361.     background-color:#666;
  362.     color:#fff;
  363.     border:2px solid #000;
  364.     position:fixed;
  365.     right:0px;
  366.     bottom:0px;
  367.     padding:8px;
  368.     z-index:20000000;
  369.     visibility:hidden;
  370.     font-size:14px;
  371. }
  372. #ads
  373. {
  374.     width:332px;
  375.     text-align:center;
  376.     margin-top:16px;
  377. }
  378.  
  379. #tip
  380. {
  381.     position:fixed;
  382.     left:0px;
  383.     bottom:20px;
  384.     width:100%;
  385.     height:20px;
  386. }
  387. </style>
  388.  
  389. <script data-rocketsrc="ajax.js" type="text/rocketscript" ></script>
  390.  
  391. <link rel="shortcut icon" href="favicon.ico" />
  392. <script type="text/rocketscript">
  393.   var _gaq = _gaq || [];
  394.   _gaq.push(['_setAccount', 'UA-29324474-2']);
  395.   _gaq.push(['_setDomainName', 'dashnet.org']);
  396.   _gaq.push(['_trackPageview']);
  397.  
  398.   (function() {
  399.     var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  400.     ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  401.     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  402.   })();
  403. </script>
  404.  
  405. </head>
  406. <body id="whole">
  407.  
  408. <div id="hiddenLoader" style="display:none;"></div>
  409.  
  410. <div id="credits">
  411. <span><b>Cookie Clicker</b> &copy; <a href="http://orteil.dashnet.org">Orteil</a>, 2013 - hosted by <a href="http://dashnet.org">DashNet</a> | check out my <a href="http://twitter.com/orteil42">twitter</a> and <a href="http://orteil42.tumblr.com">tumblr</a> | also : <a href="http://orteil.dashnet.org/nested">Nested</a> | the big update is <a href="http://orteil.dashnet.org/cookieclicker/" target="blank">out</a>!</span>
  412. </div>
  413. <div id="game">
  414. <div id="log"></div>
  415. <div id="updateLog">
  416. <b>Note :</b> we are aware of the connection problems and are in the process of getting better servers, possibly, maybe.<br>
  417. We would also like to <b>thank everyone</b> for the support and donations.<br><br>
  418. <b>24/08/2013 : the big update is finally out!<br>
  419. <a href="http://orteil.dashnet.org/cookieclicker/" target="blank" style="color:#000;">Check it out!</a></b><br>
  420. <b>0.125</b><br>
  421. -added a new object<br>
  422. -added option to disable flashing<br>
  423. -welp I'm going back to work<br>
  424. <b>0.124</b><br>
  425. -elder pledge is cheaper and now buffs grandmas and clicking while active<br>
  426. -page title now displays cookies<br>
  427. <b>0.123</b><br>
  428. -added cookies per second<br>
  429. -reworked grandmas<br>
  430. -still not the big update<br>
  431. <br>
  432. <b>13/08/2013</b> : this isn't the big update, just a couple features that have been requested often.<br>
  433. <b>0.122</b><br>
  434. -fixed background flashing<br>
  435. -added a new secret end-game item to counter the grandmapocalypse<br>
  436. <b>0.121</b><br>
  437. -import/export save<br>
  438. -ask confirm on reset<br>
  439. -speed tweaks<br>
  440. </div>
  441.  
  442.  
  443. <div id="money"></div>
  444. <div id="saveMenu">
  445. <div id="cps"></div>
  446. <div class="button" id="exportSave" onclick="exportSave();">Export save</div>
  447. <div class="button" id="importSave" onclick="importSave();">Import save</div>
  448. <div class="button" id="reset" onclick="Reset();">Reset</div>
  449. <br>
  450. <div class="button" id="toggleNumbers" onclick="ToggleNumbers();">Numbers On</div>
  451. <div class="button" id="toggleFlash" onclick="ToggleFlash();">Flashing On</div>
  452. <br>
  453. <div id="version"></div>
  454. </div>
  455.  
  456. <div id="rightPanel">
  457. <div id="store">
  458. </div>
  459. <div id="ads">
  460. <form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="donate" style="margin:0px 16px;">
  461. <small style="opacity:0.5;">it ain't gonna host itself</small><br>
  462. <input type="hidden" name="cmd" value="_s-xclick">
  463. <input type="hidden" name="hosted_button_id" value="BBN2WL3TC6QH4">
  464. <input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
  465. <img alt="" border="0" src="https://www.paypalobjects.com/nl_NL/i/scr/pixel.gif" width="1" height="1">
  466. </form>
  467. <script async data-rocketsrc="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" type="text/rocketscript" ></script>
  468. <!-- Cookie Clicker -->
  469. <ins class="adsbygoogle"
  470.     style="display:inline-block;width:120px;height:240px"
  471.     data-ad-client="ca-pub-8491708950677704"
  472.     data-ad-slot="3046382095"></ins>
  473. <script type="text/rocketscript" >
  474. (adsbygoogle = window.adsbygoogle || []).push({});
  475. </script>
  476. <script async data-rocketsrc="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" type="text/rocketscript" ></script>
  477. <!-- Cookie Clicker -->
  478. <ins class="adsbygoogle"
  479.     style="display:inline-block;width:120px;height:240px"
  480.     data-ad-client="ca-pub-8491708950677704"
  481.     data-ad-slot="3046382095"></ins>
  482. <script type="text/rocketscript" >
  483. (adsbygoogle = window.adsbygoogle || []).push({});
  484. </script>
  485. </div>
  486. </div>
  487.  
  488. <div id="middle">
  489. <div id="grandmas"></div>
  490. <div id="factories"></div>
  491. <div id="mines"></div>
  492. <div id="shipments"></div>
  493. <div id="labs"></div>
  494. <div id="portals"></div>
  495. <div id="times"></div>
  496. <div id="comment">Loading...</div>
  497. <div id="cookie" onmouseup="ClickCookie();" onmouseover="HoverCookie();"></div>
  498. </div>
  499.  
  500. <div id="pops"></div>
  501. </div>
  502. <div id="alert"></div>
  503.  
  504. <script type="text/rocketscript" >
  505. function eventFire(el, etype){
  506.   if (el.fireEvent) {
  507.     (el.fireEvent('on' + etype));
  508.   } else {
  509.     var evObj = document.createEvent('Events');
  510.     evObj.initEvent(etype, true, false);
  511.     el.dispatchEvent(evObj);
  512.   }
  513. }
  514.  
  515. function l(what) {return document.getElementById(what);}
  516.  
  517. Game=l('game');
  518. Version=0.1251;
  519. l('version').innerHTML='running v.'+Version;
  520. Loaded=0;
  521.  
  522. function Beautify(what)//turns 9999999 into 9,999,999
  523. {
  524.     var str='';
  525.     what=Math.floor(what);
  526.     what=(what+'').split('').reverse();
  527.     for (var i in what)
  528.     {
  529.         if (i%3==0 && i>0) str=','+str;
  530.         str=what[i]+str;
  531.     }
  532.     return str;
  533. }
  534.  
  535. //CookieSave='<?php echo ($_COOKIE['CookieClickerSave']?('1|'.$_COOKIE['CookieClickerSave']):'0'); ?>';
  536.  
  537. var str='';
  538. var pics=['cursor','grandma','mine','factory','lab','shipment','goldengrandma','grandmaiconinvert','grandmaiconlustful','portal','skellington','kaleigrandma','factorygrandma','minegrandma','shipmentgrandma','portalgrandma','pledgedgrandma','pledgeicon','timemachine','timegrandma'];
  539. for (var i in pics) {str+='<img src="'+pics[i]+'.png"/>';}
  540. l('hiddenLoader').innerHTML=str;
  541.  
  542. Cookies=0;
  543. CookiesDisplay=0;
  544. Clicking=0;
  545. Hovering=0;
  546. T=0;
  547. Achievments=['Masses']
  548. AchievmentCollected=['False']
  549.  
  550. Cursors=0;
  551. Grandmas=0;
  552. Factories=0;
  553. Mines=0;
  554. Shipments=0;
  555. Labs=0;
  556. Portals=0;
  557. Times=0;
  558.  
  559. Pledge=0;
  560.  
  561. NumbersOn=1;
  562. Flashing=1;
  563.  
  564. StoreToRebuild=0;
  565.  
  566. function ToggleNumbers()
  567. {
  568.     if (NumbersOn) {NumbersOn=0;l('toggleNumbers').innerHTML='Numbers Off';}
  569.     else if (!NumbersOn) {NumbersOn=1;l('toggleNumbers').innerHTML='Numbers On';}
  570. }
  571. function ToggleFlash()
  572. {
  573.     if (Flashing) {Flashing=0;l('toggleFlash').innerHTML='Flashing Off';}
  574.     else if (!Flashing) {Flashing=1;l('toggleFlash').innerHTML='Flashing On';}
  575. }
  576.  
  577.  
  578. importSave=function()
  579. {
  580.     var save=prompt('Please paste in the text that was given to you on save export.','');
  581.     if (save && save!='') ImportResponse('1|'+save);
  582.     Save();
  583. }
  584. exportSave=function()
  585. {
  586.     var save=prompt('Copypaste this text and keep it somewhere safe! (yes, it\'s easy to edit - but remember : cheated cookies taste terrible!)',MakeSaveString());
  587. }
  588.  
  589. ImportResponse=function(response)
  590. {
  591.     var r=response.split('|');
  592.     if (response!='0' && response)
  593.     {
  594.         if (r[0]=='1')
  595.         {
  596.             Cookies=parseInt(r[2]);
  597.             Pledge=0;
  598.             Cursors=Math.min(1000,parseInt(r[3]));Buyables['Cursor'].price=parseInt(r[4]);
  599.             Grandmas=Math.min(1000,parseInt(r[5]));Buyables['Grandma'].price=parseInt(r[6]);
  600.             Factories=Math.min(1000,parseInt(r[7]));Buyables['Factory'].price=parseInt(r[8]);
  601.             Mines=Math.min(1000,parseInt(r[9]));Buyables['Mine'].price=parseInt(r[10]);
  602.             Shipments=Math.min(1000,parseInt(r[11]));Buyables['Shipment'].price=parseInt(r[12]);
  603.             Labs=Math.min(1000,parseInt(r[13]));Buyables['Alchemy lab'].price=parseInt(r[14]);
  604.             if (r[15]) {Portals=Math.min(1000,parseInt(r[15]));Buyables['Portal'].price=parseInt(r[16]);}
  605.             if (r[17]) {Times=Math.min(1000,parseInt(r[17]));Buyables['Time machine'].price=parseInt(r[18]);}
  606.             Buyables['Grandma'].func(0);
  607.             Buyables['Factory'].func(0);
  608.             Buyables['Mine'].func(0);
  609.             Buyables['Shipment'].func(0);
  610.             Buyables['Alchemy lab'].func(0);
  611.             Buyables['Portal'].func(0);
  612.             Buyables['Time machine'].func(0);
  613.             StoreToRebuild=1;
  614.         }
  615.     }
  616.     new Pop('credits','Imported.');
  617. }
  618.  
  619.  
  620.  
  621. Reset=function()
  622. {
  623.     if (confirm('Do you REALLY want to start over?')) ajax('backend.php?q=reset',ResetResponse);
  624. }
  625. ResetResponse=function()
  626. {
  627.     location.reload(true);
  628. }
  629.  
  630. MakeSaveString=function()
  631. {
  632.     var str='';
  633.     str+=Version+'|'+parseInt(Cookies)+'|'+
  634.     parseInt(Cursors)+'|'+parseInt(Buyables['Cursor'].price)+'|'+
  635.     parseInt(Grandmas)+'|'+parseInt(Buyables['Grandma'].price)+'|'+
  636.     parseInt(Factories)+'|'+parseInt(Buyables['Factory'].price)+'|'+
  637.     parseInt(Mines)+'|'+parseInt(Buyables['Mine'].price)+'|'+
  638.     parseInt(Shipments)+'|'+parseInt(Buyables['Shipment'].price)+'|'+
  639.     parseInt(Labs)+'|'+parseInt(Buyables['Alchemy lab'].price)+'|'+
  640.     parseInt(Portals)+'|'+parseInt(Buyables['Portal'].price)+'|'+
  641.     parseInt(Times)+'|'+parseInt(Buyables['Time machine'].price);
  642.     return str;
  643. }
  644.  
  645. SaveTimer=30*60;
  646. Save=function()
  647. {
  648.     var str=MakeSaveString();
  649.     ajax('backend.php?q=save|'+str,SaveResponse);
  650.     SaveTimer=30*60*2;
  651. }
  652.  
  653. SaveResponse=function(response)
  654. {
  655.     var r=response.split('|');
  656.     if (r[0]=='1' && parseFloat(r[1])>Version)
  657.     {
  658.         l('alert').style.visibility='visible';
  659.         l('alert').innerHTML='New version available ('+r[1]+').<br>Please refresh to see it!';
  660.     }
  661.     if (r[0]=='1') new Pop('credits','Saved');
  662.     else new Pop('credits','<span style="color:#f00;">Error while saving</span>');
  663. }
  664.  
  665. Load=function()
  666. {
  667.     ajax('backend.php?q=load',LoadResponse);
  668.     l('comment').innerHTML='Loading cookie...';
  669.     //LoadResponse(CookieSave);
  670. }
  671.  
  672. LoadResponse=function(response)
  673. {
  674.     var r=response.split('|');
  675.     if (response!='0' && response)
  676.     {
  677.         if (r[0]=='1')
  678.         {
  679.             Cookies=parseInt(r[2]);
  680.             Pledge=0;
  681.             Cursors=Math.min(1000,parseInt(r[3]));Buyables['Cursor'].price=parseInt(r[4]);
  682.             Grandmas=Math.min(1000,parseInt(r[5]));Buyables['Grandma'].price=parseInt(r[6]);
  683.             Factories=Math.min(1000,parseInt(r[7]));Buyables['Factory'].price=parseInt(r[8]);
  684.             Mines=Math.min(1000,parseInt(r[9]));Buyables['Mine'].price=parseInt(r[10]);
  685.             Shipments=Math.min(1000,parseInt(r[11]));Buyables['Shipment'].price=parseInt(r[12]);
  686.             Labs=Math.min(1000,parseInt(r[13]));Buyables['Alchemy lab'].price=parseInt(r[14]);
  687.             if (r[15]) {Portals=Math.min(1000,parseInt(r[15]));Buyables['Portal'].price=parseInt(r[16]);}
  688.             if (r[17]) {Times=Math.min(1000,parseInt(r[17]));Buyables['Time machine'].price=parseInt(r[18]);}
  689.             Buyables['Grandma'].func(0);
  690.             Buyables['Factory'].func(0);
  691.             Buyables['Mine'].func(0);
  692.             Buyables['Shipment'].func(0);
  693.             Buyables['Alchemy lab'].func(0);
  694.             Buyables['Portal'].func(0);
  695.             Buyables['Time machine'].func(0);
  696.             StoreToRebuild=1;
  697.         }
  698.     }
  699.     new Pop('credits','Loaded.');
  700.     Loaded=1;
  701.     Main();
  702. }
  703.  
  704. ClickCookie=function()
  705. {
  706.     var howmany=(Pledge>0?Math.ceil(Cursors*1.5):1);
  707.     Cookies+=howmany;
  708.     if (Pops.length<260 && NumbersOn) new Pop('cookie','+'+howmany);
  709.     Clicking=1;
  710. }
  711. HoverCookie=function()
  712. {
  713.     Hovering=1;
  714. }
  715.  
  716. AddCookie=function(howmany,el)
  717. {
  718.     Cookies+=howmany;
  719.     if (el && Pops.length<250 && NumbersOn) new Pop(el,'+'+howmany);
  720. }
  721.  
  722. RebuildStore=function()
  723. {
  724.     var str='';
  725.     for (var i in Buyables)
  726.     {
  727.         var amount=0;
  728.         if (Buyables[i].name=='Cursor') amount=Cursors;
  729.         else if (Buyables[i].name=='Grandma') amount=Grandmas;
  730.         else if (Buyables[i].name=='Factory') amount=Factories;
  731.         else if (Buyables[i].name=='Mine') amount=Mines;
  732.         else if (Buyables[i].name=='Shipment') amount=Shipments;
  733.         else if (Buyables[i].name=='Alchemy lab') amount=Labs;
  734.         else if (Buyables[i].name=='Portal') amount=Portals;
  735.         else if (Buyables[i].name=='Time machine') amount=Times;
  736.         str+='<div id="buy'+Buyables[i].name+'" onclick="Buy(\''+Buyables[i].name+'\');" style="'+(Buyables[i].name=='Elder Pledge'?'display:none;':'')+(Buyables[i].name=='Time machine'?'font-size:90%;':'')+'background-image:url('+Buyables[i].pic+'.png);"><b>'+Buyables[i].name+' - <moni></moni> '+Beautify(Buyables[i].price)+'</b>'+Buyables[i].desc+''+(amount>0?('<div class="amount">'+amount+'</div>'):'')+'</div>';
  737.     }
  738.     l('store').innerHTML=str;
  739.     StoreToRebuild=0;
  740. }
  741. Buyables=[];
  742. Buyable=function(name,desc,pic,price,func)
  743. {
  744.     this.name=name;
  745.     this.desc=desc;
  746.     this.pic=pic;
  747.     this.price=price;
  748.     this.func=func;
  749.     Buyables[name]=this;
  750.    
  751.     this.Buy=function()
  752.     {
  753.         if (Cookies>=this.price && Loaded)
  754.         {
  755.             Cookies-=this.price;
  756.             this.price=Math.ceil(this.price*1.1);
  757.             this.func(1);
  758.             //Buyables[this.name]=0;
  759.             StoreToRebuild=1;
  760.         }
  761.     }
  762.     StoreToRebuild=1;
  763. }
  764. Buy=function(what)
  765. {
  766.     Buyables[what].Buy();
  767. }
  768.  
  769. new Buyable('Cursor','Autoclicks every 5 seconds.','cursoricon',15,function(){Cursors++;});
  770. new Buyable('Grandma','A nice grandma to bake more cookies.','grandmaicon',100,function(buy)
  771. {
  772.     if (buy) Grandmas++;
  773.     var str='';
  774.     for (var i=0;i<Grandmas;i++)
  775.     {
  776.         var x=Math.floor(Math.random()*20+(i%10)*24);
  777.         var y=Math.floor(Math.random()*20+Math.floor(i/10)*24);
  778.         var cl=0;
  779.         if (Labs && Math.random()<0.2) cl='goldengrandma';
  780.         if (Factories && Math.random()<0.2) cl='factorygrandma';
  781.         if (Mines && Math.random()<0.2) cl='minegrandma';
  782.         if (Shipments && Math.random()<0.2) cl='shipmentgrandma';
  783.         if (Portals && Pledge<=0 && Math.random()<0.2) cl='portalgrandma';
  784.         if (Times && Math.random()<0.2) cl='timegrandma';
  785.         if (Pledge && Math.random()<0.2) cl='pledgedgrandma';
  786.         str+='<div class="'+(cl?cl+' ':'')+'grandma" style="left:'+x+'px;top:'+y+'px;"></div>';
  787.     }
  788.     l('grandmas').innerHTML=str;
  789. });
  790. new Buyable('Factory','Produces large quantities of cookies.','factoryicon',500,function(buy)
  791. {
  792.     if (buy) Factories++;
  793.     if (buy && Factories==1) Buyables['Grandma'].func();
  794.     var str='';
  795.     for (var i=0;i<Factories;i++)
  796.     {
  797.         var x=Math.floor(Math.random()*20+(i%10)*32);
  798.         var y=Math.floor(Math.random()*20+Math.floor(i/10)*24);
  799.         str+='<div class="factory" style="right:'+x+'px;top:'+y+'px;"></div>';
  800.     }
  801.     l('factories').innerHTML=str;
  802. });
  803. new Buyable('Mine','Mines out cookie dough and chocolate chips.','mineicon',2000,function(buy)
  804. {
  805.     if (buy) Mines++;
  806.     if (buy && Mines==1) Buyables['Grandma'].func();
  807.     var str='';
  808.     for (var i=0;i<Mines;i++)
  809.     {
  810.         var x=Math.floor(Math.random()*20+(i%10)*16);
  811.         var y=Math.floor(Math.random()*20+Math.floor(i/10)*16);
  812.         str+='<div class="mine" style="left:'+x+'px;top:'+y+'px;"></div>';
  813.     }
  814.     l('mines').innerHTML=str;
  815. });
  816. new Buyable('Shipment','Brings in fresh cookies from the cookie planet.','shipmenticon',7000,function(buy)
  817. {
  818.     if (buy) Shipments++;
  819.     if (buy && Shipments==1) Buyables['Grandma'].func();
  820.     var str='';
  821.     for (var i=0;i<Shipments;i++)
  822.     {
  823.         var x=Math.floor(Math.random()*20+(i%10)*24);
  824.         var y=Math.floor(Math.random()*20+Math.floor(i/10)*24);
  825.         str+='<div class="shipment" style="right:'+x+'px;top:'+y+'px;"></div>';
  826.     }
  827.     l('shipments').innerHTML=str;
  828. });
  829. new Buyable('Alchemy lab','Turns gold into cookies!','labicon',50000,function(buy)
  830. {
  831.     if (buy) Labs++;
  832.     if (buy && Labs==1) Buyables['Grandma'].func();
  833.     var str='';
  834.     for (var i=0;i<Labs;i++)
  835.     {
  836.         var x=Math.floor(Math.random()*20+(i%10)*24);
  837.         var y=Math.floor(Math.random()*20+Math.floor(i/10)*16);
  838.         str+='<div class="lab" style="right:'+x+'px;top:'+y+'px;"></div>';
  839.     }
  840.     l('labs').innerHTML=str;
  841. });
  842. new Buyable('Portal','Opens a door to the Cookieverse.','portalicon',1000000,function(buy)
  843. {
  844.     if (buy) Portals++;
  845.     if (buy && Portals==1) Buyables['Grandma'].func();
  846.     var str='';
  847.     for (var i=0;i<Portals;i++)
  848.     {
  849.         var x=Math.floor(Math.random()*20+(i%10)*24);
  850.         var y=Math.floor(Math.random()*20+Math.floor(i/10)*24);
  851.         str+='<div class="portal" style="right:'+x+'px;top:'+y+'px;"></div>';
  852.     }
  853.     l('portals').innerHTML=str;
  854. });
  855. new Buyable('Time machine','<span style="font-size:80%;">Brings cookies from the past, before they were even eaten.</span>','timemachineicon',123456789,function(buy)
  856. {
  857.     if (buy) Times++;
  858.     if (buy && Times==1) Buyables['Grandma'].func();
  859.     var str='';
  860.     for (var i=0;i<Times;i++)
  861.     {
  862.         var x=Math.floor(Math.random()*20+(i%10)*24);
  863.         var y=Math.floor(Math.random()*20+Math.floor(i/10)*24);
  864.         str+='<div class="time" style="right:'+x+'px;top:'+y+'px;"></div>';
  865.     }
  866.     l('times').innerHTML=str;
  867. });
  868.  
  869. new Buyable('Elder Pledge','<span style="font-size:80%;">Puts an end to the Ancients\' wrath, at least for a while.</span>','pledgeicon',666666,function(buy)
  870. {
  871.     if (buy) {Pledge*=2;Pledge+=30*60*10;}
  872.     if (buy) Buyables['Grandma'].func();
  873.     l('buyElder Pledge').style.display='none';
  874. });
  875.  
  876.  
  877. Pops=[];
  878. Pop=function(el,str)
  879. {
  880.     this.el=el;
  881.     this.str=str;
  882.     this.life=0;
  883.     this.offx=Math.floor(Math.random()*20-10);
  884.     this.offy=Math.floor(Math.random()*20-10);
  885.     Pops.push(this);
  886. }
  887.  
  888.  
  889. Main=function()
  890. {
  891.     var str='';
  892.     if (StoreToRebuild)
  893.     {
  894.         RebuildStore();
  895.         StoreToRebuild=0;
  896.     }
  897.    
  898.     for (var i in Pops)
  899.     {
  900.         var rect=l(Pops[i].el).getBoundingClientRect();
  901.         var x=Math.floor((rect.left+rect.right)/2+Pops[i].offx)-100;
  902.         var y=Math.floor((rect.top+rect.bottom)/2-Math.pow(Pops[i].life/100,0.5)*100+Pops[i].offy)-10;
  903.         var opacity=1-(Math.max(Pops[i].life,80)-80)/20;
  904.         str+='<div class="pop" style="position:absolute;left:'+x+'px;top:'+y+'px;opacity:'+opacity+';">'+Pops[i].str+'</div>';
  905.         Pops[i].life+=2;
  906.         if (Pops[i].life>=100) Pops.splice(i,1);
  907.     }
  908.     l('pops').innerHTML=str;
  909.    
  910.     var str='';
  911.     for (var i=0;i<Cursors;i++)
  912.     {
  913.         var rot=-Math.floor((360/Cursors)*i);
  914.         var x=Math.floor(64+Math.sin((Math.PI*2/Cursors)*i)*64)-16;
  915.         var y=Math.floor(64+Math.cos((Math.PI*2/Cursors)*i)*64)-16;
  916.         if ((T)%150==Math.ceil((150/Cursors)*i)) y+=2;
  917.         str+='<div class="cursor" style="left:'+x+'px;top:'+y+'px;transform:rotate('+rot+'deg);-webkit-transform:rotate('+rot+'deg);-moz-transform:rotate('+rot+'deg);-ms-transform:rotate('+rot+'deg);"></div>';
  918.     }
  919.     l('cookie').innerHTML=str;
  920.    
  921.     var grandmaGain=Math.ceil(4+(Factories?1:0)+(Mines?2:0)+(Shipments?3:0)+(Labs?4:0)+(Portals?(Pledge?5+Portals*0.5:5):0)+(Times?6:0));
  922.     var cursorGain=(Pledge>0?Math.ceil(Cursors*1.5):1);
  923.    
  924.     if (Times && T%Math.ceil(150/Times)==0) AddCookie(123456,'times');
  925.     if (Portals && T%Math.ceil(150/Portals)==0) AddCookie(6666,'portals');
  926.     if (Labs && T%Math.ceil(150/Labs)==0) AddCookie(500,'labs');
  927.     if (Shipments && T%Math.ceil(150/Shipments)==0) AddCookie(100,'shipments');
  928.     if (Mines && T%Math.ceil(150/Mines)==0) AddCookie(50,'mines');
  929.     if (Factories && T%Math.ceil(150/Factories)==0) AddCookie(20,'factories');
  930.     if (Grandmas && T%Math.ceil(150/Grandmas)==0) AddCookie(grandmaGain,'grandmas');
  931.     if (Cursors && T%Math.ceil(150/Cursors)==0) eventFire(l('cookie'),'mouseup');
  932.    
  933.    
  934.     var cps=0;
  935.     cps+=Times*123456/5;
  936.     cps+=Portals*6666/5;
  937.     cps+=Labs*500/5;
  938.     cps+=Shipments*100/5;
  939.     cps+=Mines*50/5;
  940.     cps+=Factories*20/5;
  941.     cps+=Grandmas*grandmaGain/5;
  942.     cps+=Cursors*cursorGain/5;
  943.    
  944.     var floater=Math.round(cps*10-Math.floor(cps)*10);
  945.     cps=Beautify(cps)+(floater?('.'+floater):'');
  946.     l('cps').innerHTML='cookies/second : '+cps;
  947.    
  948.    
  949.     for (var i in Buyables)
  950.     {
  951.         if (Cookies>=Buyables[i].price) l('buy'+Buyables[i].name).className=''; else l('buy'+Buyables[i].name).className='grayed';
  952.     }
  953.    
  954.     CookiesDisplay+=(Cookies-CookiesDisplay)*0.5;
  955.     l('money').innerHTML=Beautify(Math.round(CookiesDisplay));
  956.    
  957.     var str='';
  958.     if (Cookies<5) str='You feel like making cookies.<br>But nobody wants to eat your cookies.';
  959.     else if (Cookies<25) str='Your cookies are popular<br>with your dog.';
  960.     else if (Cookies<50) str='Your cookies are popular<br>with your family.';
  961.     else if (Cookies<100) str='Your cookies are popular<br>in the neighborhood.';
  962.     else if (Cookies<500) str='Your cookies are renowned<br>in the whole town!';
  963.     else if (Cookies<2000) str='Your cookies are worth<br>a lot of money.';
  964.     else if (Cookies<5000) str='Your cookies bring<br>all the boys to the yard.';
  965.     else if (Cookies<10000) str='People come from very far away<br>to get a taste of your cookies.';
  966.     else if (Cookies<17000) str='Kings and queens from all over the world<br>are enjoying your cookies.';
  967.     else if (Cookies<30000) str='Your cookies have been named<br>a part of the world wonders.';
  968.     else if (Cookies<60000) str='Your cookies have been placed<br>under government surveillance.';
  969.     else if (Cookies<100000) str='The whole planet is<br>enjoying your cookies!';
  970.     else if (Cookies<150000) str='Creatures from neighboring planets<br>wish to try your cookies.';
  971.     else if (Cookies<250000) str='Elder gods from the whole cosmos<br>have awoken to taste your cookies.';
  972.     else if (Cookies<400000) str='Your cookies have achieved sentience.';
  973.     else if (Cookies<1000000) str='The universe has now turned into<br>cookie dough, to the molecular level.';
  974.     else if (Cookies<1000000000) str='A local news station runs<br>a 10-minute segment about your cookies. Success!<br><span style="font-size:50%;">(you win a cookie)</span>';
  975.     else str='it\'s time to stop playing<br><span style="font-size:50%;">(more fun milestones in the next update I promise)</span>';
  976.     l('comment').innerHTML=str;
  977.    
  978.    
  979.     if (Pledge>0) Pledge--;
  980.    
  981.     if (Cookies>=1000000 && Pledge<=0 && Flashing)
  982.     {
  983.         var r=(Cookies-1000000)/2000000;
  984.         var r2=Math.max(0,(Cookies-100000000)/400000000);
  985.         var icon='grandmaicon';
  986.         if (Cookies>=2000000)
  987.         {
  988.             l('buyElder Pledge').style.display='block';
  989.             if (Math.random()<0.02) icon='grandmaiconinvert';
  990.             else if (Math.random()<0.02) icon='grandmaiconlustful';
  991.         }
  992.         if (Cookies>=10000000 && Math.random()<0.02) icon='skellington';
  993.         if (Cookies>=1000000000) l('whole').style.background='url(kaleigrandma.png) '+Math.floor(T*0.2)+'px -'+Math.floor(T*0.1)+'px';
  994.         else if (Math.random()<r)
  995.         {
  996.             l('whole').style.background='url('+icon+'.png) '+Math.floor(Math.random()*4)+'px '+Math.floor(Math.random()*4)+'px';
  997.             l('whole').style.backgroundSize=Math.floor(r2*Math.random()*64+64)+'px '+Math.floor(r2*Math.random()*64+64)+'px ';
  998.         }
  999.     }//sorry
  1000.     else l('whole').style.background='#ccc';
  1001.    
  1002.     if (T%30==0 && Loaded) document.title=Beautify(Cookies)+' cookies - Cookie Clicker';
  1003.     Clicking=0;
  1004.     Hovering=0;
  1005.     if (Cookies==100 && AchievmentCollected[0] == "False")
  1006.     {
  1007.             AchievmentCollected[0] == "True"
  1008.         alert("Achievment Get: Loads of Cookies! (Got 100 cookies!)")
  1009.    
  1010.     SaveTimer--;
  1011.     if (SaveTimer==0 && Loaded) Save();
  1012.    
  1013.     T++;
  1014.     setTimeout(Main,1000/30);
  1015. }
  1016.  
  1017.  
  1018. Load();
  1019.  
  1020. </script>
  1021. </body>
  1022.  
  1023. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement