Advertisement
Adiquus

Untitled

Nov 11th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Game.ClickCookie=function(e,amount)
  2.         {
  3.             var now=Date.now();
  4.             if (e) e.preventDefault();
  5.             if (Game.OnAscend || Game.AscendTimer>0) {}
  6.             else if (now-Game.lastClick<1000/250) {}
  7.             else
  8.             {
  9.                 if (now-Game.lastClick<1000/15)
  10.                 {
  11.                     Game.autoclickerDetected+=Game.fps;
  12.                     if (Game.autoclickerDetected>=Game.fps*5) Game.Win('Uncanny clicker');
  13.                 }
  14.                 Game.loseShimmeringVeil('click');
  15.                 var amount=amount?amount:Game.computedMouseCps;
  16.                 Game.Earn(amount);
  17.                 Game.handmadeCookies+=amount;
  18.                 if (Game.prefs.particles)
  19.                 {
  20.                     Game.particleAdd();
  21.                     Game.particleAdd(Game.mouseX,Game.mouseY,Math.random()*4-2,Math.random()*-2-2,Math.random()*0.5+0.75,1,2);
  22.                 }
  23.                 if (Game.prefs.numbers) Game.particleAdd(Game.mouseX+Math.random()*8-4,Game.mouseY-8+Math.random()*8-4,0,-2,1,4,2,'','+'+Beautify(amount,1));
  24.                
  25.                 for (var i in Game.customCookieClicks) {Game.customCookieClicks[i]();}
  26.            
  27.                 Game.playCookieClickSound();
  28.                 Game.cookieClicks++;
  29.             }
  30.             Game.lastClick=now;
  31.             Game.Click=0;
  32.         }
  33.         Game.mouseX=0;
  34.         Game.mouseY=0;
  35.         Game.mouseX2=0;
  36.         Game.mouseY2=0;
  37.         Game.mouseMoved=0;
  38.         Game.GetMouseCoords=function(e)
  39.         {
  40.             var posx=0;
  41.             var posy=0;
  42.             if (!e) var e=window.event;
  43.             if (e.pageX||e.pageY)
  44.             {
  45.                 posx=e.pageX;
  46.                 posy=e.pageY;
  47.             }
  48.             else if (e.clientX || e.clientY)
  49.             {
  50.                 posx=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
  51.                 posy=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;
  52.             }
  53.             var x=0;
  54.             var y=32;
  55.             /*
  56.             var el=l('sectionLeft');
  57.             while(el && !isNaN(el.offsetLeft) && !isNaN(el.offsetTop))
  58.             {
  59.                 x+=el.offsetLeft-el.scrollLeft;
  60.                 y+=el.offsetTop-el.scrollTop;
  61.                 el=el.offsetParent;
  62.             }*/
  63.             Game.mouseX2=Game.mouseX;
  64.             Game.mouseY2=Game.mouseY;
  65.             Game.mouseX=posx-x;
  66.             Game.mouseY=posy-y;
  67.             Game.mouseMoved=1;
  68.             Game.lastActivity=Game.time;
  69.         }
  70.         var bigCookie=l('bigCookie');
  71.         Game.Click=0;
  72.         Game.lastClickedEl=0;
  73.         Game.clickFrom=0;
  74.         Game.Scroll=0;
  75.         Game.mouseDown=0;
  76.         if (!Game.touchEvents)
  77.         {
  78.             AddEvent(bigCookie,'click',Game.ClickCookie);
  79.             AddEvent(bigCookie,'mousedown',function(event){Game.BigCookieState=1;if (Game.prefs.cookiesound) {Game.playCookieClickSound();}if (event) event.preventDefault();});
  80.             AddEvent(bigCookie,'mouseup',function(event){Game.BigCookieState=2;if (event) event.preventDefault();});
  81.             AddEvent(bigCookie,'mouseout',function(event){Game.BigCookieState=0;});
  82.             AddEvent(bigCookie,'mouseover',function(event){Game.BigCookieState=2;});
  83.             AddEvent(document,'mousemove',Game.GetMouseCoords);
  84.             AddEvent(document,'mousedown',function(event){Game.lastActivity=Game.time;Game.mouseDown=1;Game.clickFrom=event.target;});
  85.             AddEvent(document,'mouseup',function(event){Game.lastActivity=Game.time;Game.mouseDown=0;Game.clickFrom=0;});
  86.             AddEvent(document,'click',function(event){Game.lastActivity=Game.time;Game.Click=1;Game.lastClickedEl=event.target;Game.clickFrom=0;});
  87.             Game.handleScroll=function(e)
  88.             {
  89.                 if (!e) e=event;
  90.                 Game.Scroll=(e.detail<0||e.wheelDelta>0)?1:-1;
  91.                 Game.lastActivity=Game.time;
  92.             };
  93.             AddEvent(document,'DOMMouseScroll',Game.handleScroll);
  94.             AddEvent(document,'mousewheel',Game.handleScroll);
  95.         }
  96.         else
  97.         {
  98.             //touch events
  99.             AddEvent(bigCookie,'touchend',Game.ClickCookie);
  100.             AddEvent(bigCookie,'touchstart',function(event){Game.BigCookieState=1;if (event) event.preventDefault();});
  101.             AddEvent(bigCookie,'touchend',function(event){Game.BigCookieState=0;if (event) event.preventDefault();});
  102.             //AddEvent(document,'touchmove',Game.GetMouseCoords);
  103.             AddEvent(document,'mousemove',Game.GetMouseCoords);
  104.             AddEvent(document,'touchstart',function(event){Game.lastActivity=Game.time;Game.mouseDown=1;});
  105.             AddEvent(document,'touchend',function(event){Game.lastActivity=Game.time;Game.mouseDown=0;});
  106.             AddEvent(document,'touchend',function(event){Game.lastActivity=Game.time;Game.Click=1;});
  107.         }
  108.        
  109.         Game.keys=[];
  110.         AddEvent(window,'keyup',function(e){
  111.             Game.lastActivity=Game.time;
  112.             if (e.keyCode==27)
  113.             {
  114.                 Game.ClosePrompt();
  115.                 if (Game.AscendTimer>0) Game.AscendTimer=Game.AscendDuration;
  116.             }//esc closes prompt
  117.             else if (e.keyCode==13) Game.ConfirmPrompt();//enter confirms prompt
  118.             Game.keys[e.keyCode]=0;
  119.         });
  120.         AddEvent(window,'keydown',function(e){
  121.             if (!Game.OnAscend && Game.AscendTimer==0)
  122.             {
  123.                 if (e.ctrlKey && e.keyCode==83) {Game.toSave=true;e.preventDefault();}//ctrl-s saves the game
  124.                 else if (e.ctrlKey && e.keyCode==79) {Game.ImportSave();e.preventDefault();}//ctrl-o opens the import menu
  125.             }
  126.             if ((e.keyCode==16 || e.keyCode==17) && Game.tooltip.dynamic) Game.tooltip.update();
  127.             Game.keys[e.keyCode]=1;
  128.         });
  129.        
  130.         AddEvent(window,'visibilitychange',function(e){
  131.             Game.keys=[];//reset all key pressed on visibility change (should help prevent ctrl still being down after ctrl-tab)
  132.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement