Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Game.ClickCookie=function(e,amount)
- {
- var now=Date.now();
- if (e) e.preventDefault();
- if (Game.OnAscend || Game.AscendTimer>0) {}
- else if (now-Game.lastClick<1000/250) {}
- else
- {
- if (now-Game.lastClick<1000/15)
- {
- Game.autoclickerDetected+=Game.fps;
- if (Game.autoclickerDetected>=Game.fps*5) Game.Win('Uncanny clicker');
- }
- Game.loseShimmeringVeil('click');
- var amount=amount?amount:Game.computedMouseCps;
- Game.Earn(amount);
- Game.handmadeCookies+=amount;
- if (Game.prefs.particles)
- {
- Game.particleAdd();
- Game.particleAdd(Game.mouseX,Game.mouseY,Math.random()*4-2,Math.random()*-2-2,Math.random()*0.5+0.75,1,2);
- }
- 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));
- for (var i in Game.customCookieClicks) {Game.customCookieClicks[i]();}
- Game.playCookieClickSound();
- Game.cookieClicks++;
- }
- Game.lastClick=now;
- Game.Click=0;
- }
- Game.mouseX=0;
- Game.mouseY=0;
- Game.mouseX2=0;
- Game.mouseY2=0;
- Game.mouseMoved=0;
- Game.GetMouseCoords=function(e)
- {
- var posx=0;
- var posy=0;
- if (!e) var e=window.event;
- if (e.pageX||e.pageY)
- {
- posx=e.pageX;
- posy=e.pageY;
- }
- else if (e.clientX || e.clientY)
- {
- posx=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
- posy=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;
- }
- var x=0;
- var y=32;
- /*
- var el=l('sectionLeft');
- while(el && !isNaN(el.offsetLeft) && !isNaN(el.offsetTop))
- {
- x+=el.offsetLeft-el.scrollLeft;
- y+=el.offsetTop-el.scrollTop;
- el=el.offsetParent;
- }*/
- Game.mouseX2=Game.mouseX;
- Game.mouseY2=Game.mouseY;
- Game.mouseX=posx-x;
- Game.mouseY=posy-y;
- Game.mouseMoved=1;
- Game.lastActivity=Game.time;
- }
- var bigCookie=l('bigCookie');
- Game.Click=0;
- Game.lastClickedEl=0;
- Game.clickFrom=0;
- Game.Scroll=0;
- Game.mouseDown=0;
- if (!Game.touchEvents)
- {
- AddEvent(bigCookie,'click',Game.ClickCookie);
- AddEvent(bigCookie,'mousedown',function(event){Game.BigCookieState=1;if (Game.prefs.cookiesound) {Game.playCookieClickSound();}if (event) event.preventDefault();});
- AddEvent(bigCookie,'mouseup',function(event){Game.BigCookieState=2;if (event) event.preventDefault();});
- AddEvent(bigCookie,'mouseout',function(event){Game.BigCookieState=0;});
- AddEvent(bigCookie,'mouseover',function(event){Game.BigCookieState=2;});
- AddEvent(document,'mousemove',Game.GetMouseCoords);
- AddEvent(document,'mousedown',function(event){Game.lastActivity=Game.time;Game.mouseDown=1;Game.clickFrom=event.target;});
- AddEvent(document,'mouseup',function(event){Game.lastActivity=Game.time;Game.mouseDown=0;Game.clickFrom=0;});
- AddEvent(document,'click',function(event){Game.lastActivity=Game.time;Game.Click=1;Game.lastClickedEl=event.target;Game.clickFrom=0;});
- Game.handleScroll=function(e)
- {
- if (!e) e=event;
- Game.Scroll=(e.detail<0||e.wheelDelta>0)?1:-1;
- Game.lastActivity=Game.time;
- };
- AddEvent(document,'DOMMouseScroll',Game.handleScroll);
- AddEvent(document,'mousewheel',Game.handleScroll);
- }
- else
- {
- //touch events
- AddEvent(bigCookie,'touchend',Game.ClickCookie);
- AddEvent(bigCookie,'touchstart',function(event){Game.BigCookieState=1;if (event) event.preventDefault();});
- AddEvent(bigCookie,'touchend',function(event){Game.BigCookieState=0;if (event) event.preventDefault();});
- //AddEvent(document,'touchmove',Game.GetMouseCoords);
- AddEvent(document,'mousemove',Game.GetMouseCoords);
- AddEvent(document,'touchstart',function(event){Game.lastActivity=Game.time;Game.mouseDown=1;});
- AddEvent(document,'touchend',function(event){Game.lastActivity=Game.time;Game.mouseDown=0;});
- AddEvent(document,'touchend',function(event){Game.lastActivity=Game.time;Game.Click=1;});
- }
- Game.keys=[];
- AddEvent(window,'keyup',function(e){
- Game.lastActivity=Game.time;
- if (e.keyCode==27)
- {
- Game.ClosePrompt();
- if (Game.AscendTimer>0) Game.AscendTimer=Game.AscendDuration;
- }//esc closes prompt
- else if (e.keyCode==13) Game.ConfirmPrompt();//enter confirms prompt
- Game.keys[e.keyCode]=0;
- });
- AddEvent(window,'keydown',function(e){
- if (!Game.OnAscend && Game.AscendTimer==0)
- {
- if (e.ctrlKey && e.keyCode==83) {Game.toSave=true;e.preventDefault();}//ctrl-s saves the game
- else if (e.ctrlKey && e.keyCode==79) {Game.ImportSave();e.preventDefault();}//ctrl-o opens the import menu
- }
- if ((e.keyCode==16 || e.keyCode==17) && Game.tooltip.dynamic) Game.tooltip.update();
- Game.keys[e.keyCode]=1;
- });
- AddEvent(window,'visibilitychange',function(e){
- Game.keys=[];//reset all key pressed on visibility change (should help prevent ctrl still being down after ctrl-tab)
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement