Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@anxolin/cow-runner-game

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@anxolin/cow-runner-game - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

dist/game/CowGame.d.ts

4

dist/lib.js

@@ -1,2 +0,2 @@

/*! For license information please see lib.js.LICENSE.txt */
(()=>{"use strict";var t={822:(t,i,e)=>{e.d(i,{Z:()=>l});var s=e(645),n=e.n(s),o=e(667),r=e.n(o),a=e(630),h=e(714),c=n()((function(t){return t[1]})),d=r()(a),u=r()(h);c.push([t.id,"/* Copyright 2013 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file. */\n\nhtml, body {\n padding: 0;\n margin: 0;\n width: 100%;\n height: 100%;\n}\n\n.icon {\n -webkit-user-select: none;\n user-select: none;\n display: inline-block;\n}\n\n.icon-offline {\n content: -webkit-image-set( url("+d+") 1x, url("+u+") 2x);\n position: relative;\n}\n\n.hidden {\n display: none;\n}\n\n\n/* Offline page */\n\n.offline .interstitial-wrapper {\n color: #2b2b2b;\n font-size: 1em;\n line-height: 1.55;\n margin: 0 auto;\n max-width: 600px;\n padding-top: 100px;\n width: 100%;\n}\n\n.offline .runner-container {\n height: 150px;\n max-width: 600px;\n overflow: hidden;\n position: absolute;\n top: 35px;\n width: 44px;\n}\n\n.offline .runner-canvas {\n height: 150px;\n max-width: 600px;\n opacity: 1;\n overflow: hidden;\n position: absolute;\n top: 0;\n z-index: 2;\n}\n\n.offline .controller {\n background: rgba(247, 247, 247, .1);\n height: 100vh;\n left: 0;\n position: absolute;\n top: 0;\n width: 100vw;\n z-index: 1;\n}\n\n#offline-resources {\n display: none;\n}\n\n@media (max-width: 420px) {\n .suggested-left > #control-buttons, .suggested-right > #control-buttons {\n float: none;\n }\n .snackbar {\n left: 0;\n bottom: 0;\n width: 100%;\n border-radius: 0;\n }\n}\n\n@media (max-height: 350px) {\n h1 {\n margin: 0 0 15px;\n }\n .icon-offline {\n margin: 0 0 10px;\n }\n .interstitial-wrapper {\n margin-top: 5%;\n }\n .nav-wrapper {\n margin-top: 30px;\n }\n}\n\n@media (min-width: 600px) and (max-width: 736px) and (orientation: landscape) {\n .offline .interstitial-wrapper {\n margin-left: 0;\n margin-right: 0;\n }\n}\n\n@media (min-width: 420px) and (max-width: 736px) and (min-height: 240px) and (max-height: 420px) and (orientation:landscape) {\n .interstitial-wrapper {\n margin-bottom: 100px;\n }\n}\n\n@media (min-height: 240px) and (orientation: landscape) {\n .offline .interstitial-wrapper {\n margin-bottom: 90px;\n }\n .icon-offline {\n margin-bottom: 20px;\n }\n}\n\n@media (max-height: 320px) and (orientation: landscape) {\n .icon-offline {\n margin-bottom: 0;\n }\n .offline .runner-container {\n top: 10px;\n }\n}\n\n@media (max-width: 240px) {\n .interstitial-wrapper {\n overflow: inherit;\n padding: 0 8px;\n }\n}",""]);const l=c},645:t=>{t.exports=function(t){var i=[];return i.toString=function(){return this.map((function(i){var e=t(i);return i[2]?"@media ".concat(i[2]," {").concat(e,"}"):e})).join("")},i.i=function(t,e,s){"string"==typeof t&&(t=[[null,t,""]]);var n={};if(s)for(var o=0;o<this.length;o++){var r=this[o][0];null!=r&&(n[r]=!0)}for(var a=0;a<t.length;a++){var h=[].concat(t[a]);s&&n[h[0]]||(e&&(h[2]?h[2]="".concat(e," and ").concat(h[2]):h[2]=e),i.push(h))}},i}},667:t=>{t.exports=function(t,i){return i||(i={}),"string"!=typeof(t=t&&t.__esModule?t.default:t)?t:(/^['"].*['"]$/.test(t)&&(t=t.slice(1,-1)),i.hash&&(t+=i.hash),/["'() \t\n]/.test(t)||i.needQuotes?'"'.concat(t.replace(/"/g,'\\"').replace(/\n/g,"\\n"),'"'):t)}},418:t=>{var i=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;function n(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}t.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var i={},e=0;e<10;e++)i["_"+String.fromCharCode(e)]=e;if("0123456789"!==Object.getOwnPropertyNames(i).map((function(t){return i[t]})).join(""))return!1;var s={};return"abcdefghijklmnopqrst".split("").forEach((function(t){s[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},s)).join("")}catch(t){return!1}}()?Object.assign:function(t,o){for(var r,a,h=n(t),c=1;c<arguments.length;c++){for(var d in r=Object(arguments[c]))e.call(r,d)&&(h[d]=r[d]);if(i){a=i(r);for(var u=0;u<a.length;u++)s.call(r,a[u])&&(h[a[u]]=r[a[u]])}}return h}},408:(t,i,e)=>{var s=e(418);if("function"==typeof Symbol&&Symbol.for){var n=Symbol.for;n("react.element"),n("react.portal"),n("react.fragment"),n("react.strict_mode"),n("react.profiler"),n("react.provider"),n("react.context"),n("react.forward_ref"),n("react.suspense"),n("react.memo"),n("react.lazy")}"function"==typeof Symbol&&Symbol.iterator;function o(t){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+t,e=1;e<arguments.length;e++)i+="&args[]="+encodeURIComponent(arguments[e]);return"Minified React error #"+t+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},a={};function h(t,i,e){this.props=t,this.context=i,this.refs=a,this.updater=e||r}function c(){}function d(t,i,e){this.props=t,this.context=i,this.refs=a,this.updater=e||r}h.prototype.isReactComponent={},h.prototype.setState=function(t,i){if("object"!=typeof t&&"function"!=typeof t&&null!=t)throw Error(o(85));this.updater.enqueueSetState(this,t,i,"setState")},h.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")},c.prototype=h.prototype;var u=d.prototype=new c;u.constructor=d,s(u,h.prototype),u.isPureReactComponent=!0;Object.prototype.hasOwnProperty},294:(t,i,e)=>{e(408)},379:(t,i,e)=>{var s,n=function(){var t={};return function(i){if(void 0===t[i]){var e=document.querySelector(i);if(window.HTMLIFrameElement&&e instanceof window.HTMLIFrameElement)try{e=e.contentDocument.head}catch(t){e=null}t[i]=e}return t[i]}}(),o=[];function r(t){for(var i=-1,e=0;e<o.length;e++)if(o[e].identifier===t){i=e;break}return i}function a(t,i){for(var e={},s=[],n=0;n<t.length;n++){var a=t[n],h=i.base?a[0]+i.base:a[0],c=e[h]||0,d="".concat(h," ").concat(c);e[h]=c+1;var u=r(d),l={css:a[1],media:a[2],sourceMap:a[3]};-1!==u?(o[u].references++,o[u].updater(l)):o.push({identifier:d,updater:m(l,i),references:1}),s.push(d)}return s}function h(t){var i=document.createElement("style"),s=t.attributes||{};if(void 0===s.nonce){var o=e.nc;o&&(s.nonce=o)}if(Object.keys(s).forEach((function(t){i.setAttribute(t,s[t])})),"function"==typeof t.insert)t.insert(i);else{var r=n(t.insert||"head");if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(i)}return i}var c,d=(c=[],function(t,i){return c[t]=i,c.filter(Boolean).join("\n")});function u(t,i,e,s){var n=e?"":s.media?"@media ".concat(s.media," {").concat(s.css,"}"):s.css;if(t.styleSheet)t.styleSheet.cssText=d(i,n);else{var o=document.createTextNode(n),r=t.childNodes;r[i]&&t.removeChild(r[i]),r.length?t.insertBefore(o,r[i]):t.appendChild(o)}}function l(t,i,e){var s=e.css,n=e.media,o=e.sourceMap;if(n?t.setAttribute("media",n):t.removeAttribute("media"),o&&"undefined"!=typeof btoa&&(s+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),t.styleSheet)t.styleSheet.cssText=s;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(s))}}var p=null,f=0;function m(t,i){var e,s,n;if(i.singleton){var o=f++;e=p||(p=h(i)),s=u.bind(null,e,o,!1),n=u.bind(null,e,o,!0)}else e=h(i),s=l.bind(null,e,i),n=function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)};return s(t),function(i){if(i){if(i.css===t.css&&i.media===t.media&&i.sourceMap===t.sourceMap)return;s(t=i)}else n()}}t.exports=function(t,i){(i=i||{}).singleton||"boolean"==typeof i.singleton||(i.singleton=(void 0===s&&(s=Boolean(window&&document&&document.all&&!window.atob)),s));var e=a(t=t||[],i);return function(t){if(t=t||[],"[object Array]"===Object.prototype.toString.call(t)){for(var s=0;s<e.length;s++){var n=r(e[s]);o[n].references--}for(var h=a(t,i),c=0;c<e.length;c++){var d=r(e[c]);0===o[d].references&&(o[d].updater(),o.splice(d,1))}e=h}}}},630:(t,i,e)=>{t.exports=e.p+"c5b7ac7a346af1d041d9.png"},375:(t,i,e)=>{t.exports=e.p+"c63bccfcbabba357a05e.png"},714:(t,i,e)=>{t.exports=e.p+"a8ab0ac921b42ec86be4.png"},537:(t,i,e)=>{t.exports=e.p+"6bbca79de6ce5ae0bac4.png"}},i={};function e(s){var n=i[s];if(void 0!==n)return n.exports;var o=i[s]={id:s,exports:{}};return t[s](o,o.exports,e),o.exports}e.n=t=>{var i=t&&t.__esModule?()=>t.default:()=>t;return e.d(i,{a:i}),i},e.d=(t,i)=>{for(var s in i)e.o(i,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:i[s]})},e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),e.o=(t,i)=>Object.prototype.hasOwnProperty.call(t,i),(()=>{var t;e.g.importScripts&&(t=e.g.location+"");var i=e.g.document;if(!t&&i&&(i.currentScript&&(t=i.currentScript.src),!t)){var s=i.getElementsByTagName("script");s.length&&(t=s[s.length-1].src)}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=t})(),(()=>{var t=window.devicePixelRatio>1,i=/iPad|iPhone|iPod/.test(window.navigator.platform),s=/Android/.test(window.navigator.userAgent)||i;function n(t,i){return new d(t.x+i.x,t.y+i.y,t.width,t.height)}function o(t,i){var e=!1,s=(t.x,t.y,i.x);return i.y,t.x<s+i.width&&t.x+t.width>s&&t.y<i.y+i.height&&t.height+t.y>i.y&&(e=!0),e}function r(t,i){return Math.floor(Math.random()*(i-t+1))+t}function a(t){for(var i=t.length/4*3,e=atob(t),s=new ArrayBuffer(i),n=new Uint8Array(s),o=0;o<i;o++)n[o]=e.charCodeAt(o);return n.buffer}function h(){return i?(new Date).getTime():performance.now()}function c(t,i,e){this.canvas=t,this.canvasCtx=this.canvas.getContext("2d"),this.spritePos=i,this.containerWidth=e,this.xPos=e,this.yPos=0,this.remove=!1,this.cloudGap=r(c.config.MIN_CLOUD_GAP,c.config.MAX_CLOUD_GAP),this.init()}function d(t,i,e,s){this.x=t,this.y=i,this.width=e,this.height=s}function u(t,i,e){this.canvas=t,this.canvasCtx=t.getContext("2d"),this.image=Runner.imageSprite,this.spritePos=i,this.x=0,this.y=5,this.currentDistance=0,this.maxScore=0,this.highScore=0,this.container=null,this.digits=[],this.acheivement=!1,this.defaultString="",this.flashTimer=0,this.flashIterations=0,this.invertTrigger=!1,this.config=u.config,this.maxScoreUnits=this.config.MAX_DISTANCE_UNITS,this.init(e)}function l(t,i,e,s){this.canvas=t,this.canvasCtx=t.getContext("2d"),this.canvasDimensions=s,this.textImgPos=i,this.restartImgPos=e,this.draw()}function p(t,i,e,s){this.canvas=t,this.canvasCtx=this.canvas.getContext("2d"),this.config=p.config,this.dimensions=e,this.gapCoefficient=s,this.obstacles=[],this.obstacleHistory=[],this.horizonOffsets=[0,0],this.cloudFrequency=this.config.CLOUD_FREQUENCY,this.spritePos=i,this.nightMode=null,this.clouds=[],this.cloudSpeed=this.config.BG_CLOUD_SPEED,this.horizonLine=null,this.init()}function f(t,i){this.spritePos=i,this.canvas=t,this.canvasCtx=t.getContext("2d"),this.sourceDimensions={},this.dimensions=f.dimensions,this.sourceXPos=[this.spritePos.x,this.spritePos.x+this.dimensions.WIDTH],this.xPos=[],this.yPos=0,this.bumpThreshold=.5,this.setSourceDimensions(),this.draw()}function m(t,i,e){this.spritePos=i,this.canvas=t,this.canvasCtx=t.getContext("2d"),this.xPos=e-50,this.yPos=30,this.currentPhase=0,this.opacity=0,this.containerWidth=e,this.stars=[],this.drawStars=!1,this.placeStars()}function g(t,i,e,s,n,o,a){this.canvasCtx=t,this.spritePos=e,this.typeConfig=i,this.gapCoefficient=n,this.size=r(1,g.MAX_OBSTACLE_LENGTH),this.dimensions=s,this.remove=!1,this.xPos=s.WIDTH+(a||0),this.yPos=0,this.width=0,this.collisionBoxes=[],this.gap=0,this.speedOffset=0,this.currentFrame=0,this.timer=0,this.init(o)}function T(t,i){if(T.instance_)return T.instance_;T.instance_=this,this.outerContainerEl=document.querySelector(t),this.containerEl=null,this.snackbarEl=null,this.detailsButton=this.outerContainerEl.querySelector("#details-button"),this.config=i||T.config,this.dimensions=T.defaultDimensions,this.canvas=null,this.canvasCtx=null,this.tRex=null,this.distanceMeter=null,this.distanceRan=0,this.highestScore=0,this.time=0,this.runningTime=0,this.msPerFrame=1e3/60,this.currentSpeed=this.config.SPEED,this.obstacles=[],this.activated=!1,this.playing=!1,this.crashed=!1,this.paused=!1,this.inverted=!1,this.invertTimer=0,this.resizeTimerId_=null,this.playCount=0,this.audioBuffer=null,this.soundFx={},this.audioContext=null,this.images={},this.imagesLoaded=0,this.isDisabled()?this.setupDisabledRunner():this.loadImages()}function E(t,i){this.canvas=t,this.canvasCtx=t.getContext("2d"),this.spritePos=i,this.xPos=0,this.yPos=0,this.groundYPos=0,this.currentFrame=0,this.currentAnimFrames=[],this.blinkDelay=0,this.blinkCount=0,this.animStartTime=0,this.timer=0,this.msPerFrame=1e3/60,this.config=E.config,this.status=E.status.WAITING,this.jumping=!1,this.ducking=!1,this.jumpVelocity=0,this.reachedMinHeight=!1,this.speedDrop=!1,this.jumpCount=0,this.jumpspotX=0,this.init()}window,c.config={HEIGHT:14,MAX_CLOUD_GAP:400,MAX_SKY_LEVEL:30,MIN_CLOUD_GAP:100,MIN_SKY_LEVEL:71,WIDTH:46},c.prototype={init:function(){this.yPos=r(c.config.MAX_SKY_LEVEL,c.config.MIN_SKY_LEVEL),this.draw()},draw:function(){this.canvasCtx.save();var i=c.config.WIDTH,e=c.config.HEIGHT;t&&(i*=2,e*=2),this.canvasCtx.drawImage(T.imageSprite,this.spritePos.x,this.spritePos.y,i,e,this.xPos,this.yPos,c.config.WIDTH,c.config.HEIGHT),this.canvasCtx.restore()},update:function(t){this.remove||(this.xPos-=Math.ceil(t),this.draw(),this.isVisible()||(this.remove=!0))},isVisible:function(){return this.xPos+c.config.WIDTH>0}},u.dimensions={WIDTH:10,HEIGHT:13,DEST_WIDTH:11},u.yPos=[0,13,27,40,53,67,80,93,107,120],u.config={MAX_DISTANCE_UNITS:5,ACHIEVEMENT_DISTANCE:100,COEFFICIENT:.025,FLASH_DURATION:250,FLASH_ITERATIONS:3},u.prototype={init:function(t){var i="";this.calcXPos(t),this.maxScore=this.maxScoreUnits;for(var e=0;e<this.maxScoreUnits;e++)this.draw(e,0),this.defaultString+="0",i+="9";this.maxScore=parseInt(i)},calcXPos:function(t){this.x=t-u.dimensions.DEST_WIDTH*(this.maxScoreUnits+1)},draw:function(i,e,s){var n=u.dimensions.WIDTH,o=u.dimensions.HEIGHT,r=u.dimensions.WIDTH*e,a=0,h=i*u.dimensions.DEST_WIDTH,c=this.y,d=u.dimensions.WIDTH,l=u.dimensions.HEIGHT;if(t&&(n*=2,o*=2,r*=2),r+=this.spritePos.x,a+=this.spritePos.y,this.canvasCtx.save(),s){var p=this.x-2*this.maxScoreUnits*u.dimensions.WIDTH;this.canvasCtx.translate(p,this.y)}else this.canvasCtx.translate(this.x,this.y);this.canvasCtx.drawImage(this.image,r,a,n,o,h,c,d,l),this.canvasCtx.restore()},getActualDistance:function(t){return t?Math.round(t*this.config.COEFFICIENT):0},update:function(t,i){var e=!0,s=!1;if(this.acheivement)this.flashIterations<=this.config.FLASH_ITERATIONS?(this.flashTimer+=t,this.flashTimer<this.config.FLASH_DURATION?e=!1:this.flashTimer>2*this.config.FLASH_DURATION&&(this.flashTimer=0,this.flashIterations++)):(this.acheivement=!1,this.flashIterations=0,this.flashTimer=0);else if((i=this.getActualDistance(i))>this.maxScore&&this.maxScoreUnits==this.config.MAX_DISTANCE_UNITS?(this.maxScoreUnits++,this.maxScore=parseInt(this.maxScore+"9")):this.distance=0,i>0){i%this.config.ACHIEVEMENT_DISTANCE==0&&(this.acheivement=!0,this.flashTimer=0,s=!0);var n=(this.defaultString+i).substr(-this.maxScoreUnits);this.digits=n.split("")}else this.digits=this.defaultString.split("");if(e)for(var o=this.digits.length-1;o>=0;o--)this.draw(o,parseInt(this.digits[o]));return this.drawHighScore(),s},drawHighScore:function(){this.canvasCtx.save(),this.canvasCtx.globalAlpha=.8;for(var t=this.highScore.length-1;t>=0;t--)this.draw(t,parseInt(this.highScore[t],10),!0);this.canvasCtx.restore()},setHighScore:function(t){t=this.getActualDistance(t);var i=(this.defaultString+t).substr(-this.maxScoreUnits);this.highScore=["10","11",""].concat(i.split(""))},reset:function(){this.update(0),this.acheivement=!1}},l.dimensions={TEXT_X:0,TEXT_Y:13,TEXT_WIDTH:191,TEXT_HEIGHT:11,RESTART_WIDTH:36,RESTART_HEIGHT:32},l.prototype={updateDimensions:function(t,i){this.canvasDimensions.WIDTH=t,i&&(this.canvasDimensions.HEIGHT=i)},draw:function(){var i=l.dimensions,e=this.canvasDimensions.WIDTH/2,s=i.TEXT_X,n=i.TEXT_Y,o=i.TEXT_WIDTH,r=i.TEXT_HEIGHT,a=Math.round(e-i.TEXT_WIDTH/2),h=Math.round((this.canvasDimensions.HEIGHT-25)/3),c=i.TEXT_WIDTH,d=i.TEXT_HEIGHT,u=i.RESTART_WIDTH,p=i.RESTART_HEIGHT,f=e-i.RESTART_WIDTH/2,m=this.canvasDimensions.HEIGHT/2;t&&(n*=2,s*=2,o*=2,r*=2,u*=2,p*=2),s+=this.textImgPos.x,n+=this.textImgPos.y,this.canvasCtx.drawImage(Runner.imageSprite,s,n,o,r,a,h,c,d),this.canvasCtx.drawImage(Runner.imageSprite,this.restartImgPos.x,this.restartImgPos.y,u,p,f,m,i.RESTART_WIDTH,i.RESTART_HEIGHT)}},p.config={BG_CLOUD_SPEED:.2,BUMPY_THRESHOLD:.3,CLOUD_FREQUENCY:.5,HORIZON_HEIGHT:16,MAX_CLOUDS:6},p.prototype={init:function(){this.addCloud(),this.horizonLine=new f(this.canvas,this.spritePos.HORIZON),this.nightMode=new m(this.canvas,this.spritePos.MOON,this.dimensions.WIDTH)},update:function(t,i,e,s){this.runningTime+=t,this.horizonLine.update(t,i),this.nightMode.update(s),this.updateClouds(t,i),e&&this.updateObstacles(t,i)},updateClouds:function(t,i){var e=this.cloudSpeed/1e3*t*i,s=this.clouds.length;if(s){for(var n=s-1;n>=0;n--)this.clouds[n].update(e);var o=this.clouds[s-1];s<this.config.MAX_CLOUDS&&this.dimensions.WIDTH-o.xPos>o.cloudGap&&this.cloudFrequency>Math.random()&&this.addCloud(),this.clouds=this.clouds.filter((function(t){return!t.remove}))}else this.addCloud()},updateObstacles:function(t,i){for(var e=this.obstacles.slice(0),s=0;s<this.obstacles.length;s++){var n=this.obstacles[s];n.update(t,i),n.remove&&e.shift()}if(this.obstacles=e,this.obstacles.length>0){var o=this.obstacles[this.obstacles.length-1];o&&!o.followingObstacleCreated&&o.isVisible()&&o.xPos+o.width+o.gap<this.dimensions.WIDTH&&(this.addNewObstacle(i),o.followingObstacleCreated=!0)}else this.addNewObstacle(i)},removeFirstObstacle:function(){this.obstacles.shift()},addNewObstacle:function(t){var i=r(0,g.types.length-1),e=g.types[i];if(this.duplicateObstacleCheck(e.type)||t<e.minSpeed)this.addNewObstacle(t);else{var s=this.spritePos[e.type];this.obstacles.push(new g(this.canvasCtx,e,s,this.dimensions,this.gapCoefficient,t,e.width)),this.obstacleHistory.unshift(e.type),this.obstacleHistory.length>1&&this.obstacleHistory.splice(Runner.config.MAX_OBSTACLE_DUPLICATION)}},duplicateObstacleCheck:function(t){for(var i=0,e=0;e<this.obstacleHistory.length;e++)i=this.obstacleHistory[e]==t?i+1:0;return i>=Runner.config.MAX_OBSTACLE_DUPLICATION},reset:function(){this.obstacles=[],this.horizonLine.reset(),this.nightMode.reset()},resize:function(t,i){this.canvas.width=t,this.canvas.height=i},addCloud:function(){this.clouds.push(new c(this.canvas,this.spritePos.CLOUD,this.dimensions.WIDTH))}},f.dimensions={WIDTH:600,HEIGHT:12,YPOS:127},f.prototype={setSourceDimensions:function(){for(var i in f.dimensions)t?"YPOS"!=i&&(this.sourceDimensions[i]=2*f.dimensions[i]):this.sourceDimensions[i]=f.dimensions[i],this.dimensions[i]=f.dimensions[i];this.xPos=[0,f.dimensions.WIDTH],this.yPos=f.dimensions.YPOS},getRandomType:function(){return Math.random()>this.bumpThreshold?this.dimensions.WIDTH:0},draw:function(){this.canvasCtx.drawImage(Runner.imageSprite,this.sourceXPos[0],this.spritePos.y,this.sourceDimensions.WIDTH,this.sourceDimensions.HEIGHT,this.xPos[0],this.yPos,this.dimensions.WIDTH,this.dimensions.HEIGHT),this.canvasCtx.drawImage(Runner.imageSprite,this.sourceXPos[1],this.spritePos.y,this.sourceDimensions.WIDTH,this.sourceDimensions.HEIGHT,this.xPos[1],this.yPos,this.dimensions.WIDTH,this.dimensions.HEIGHT)},updateXPos:function(t,i){var e=t,s=0==t?1:0;this.xPos[e]-=i,this.xPos[s]=this.xPos[e]+this.dimensions.WIDTH,this.xPos[e]<=-this.dimensions.WIDTH&&(this.xPos[e]+=2*this.dimensions.WIDTH,this.xPos[s]=this.xPos[e]-this.dimensions.WIDTH,this.sourceXPos[e]=this.getRandomType()+this.spritePos.x)},update:function(t,i){var e=Math.floor(.06*i*t);this.xPos[0]<=0?this.updateXPos(0,e):this.updateXPos(1,e),this.draw()},reset:function(){this.xPos[0]=0,this.xPos[1]=f.dimensions.WIDTH}},m.config={FADE_SPEED:.035,HEIGHT:40,MOON_SPEED:.25,NUM_STARS:2,STAR_SIZE:9,STAR_SPEED:.3,STAR_MAX_Y:70,WIDTH:20},m.phases=[140,120,100,60,40,20,0],m.prototype={update:function(t,i){if(t&&0==this.opacity&&(this.currentPhase++,this.currentPhase>=m.phases.length&&(this.currentPhase=0)),t&&(this.opacity<1||0==this.opacity)?this.opacity+=m.config.FADE_SPEED:this.opacity>0&&(this.opacity-=m.config.FADE_SPEED),this.opacity>0){if(this.xPos=this.updateXPos(this.xPos,m.config.MOON_SPEED),this.drawStars)for(var e=0;e<m.config.NUM_STARS;e++)this.stars[e].x=this.updateXPos(this.stars[e].x,m.config.STAR_SPEED);this.draw()}else this.opacity=0,this.placeStars();this.drawStars=!0},updateXPos:function(t,i){return t<-m.config.WIDTH?t=this.containerWidth:t-=i,t},draw:function(){var i=3==this.currentPhase?2*m.config.WIDTH:m.config.WIDTH,e=m.config.HEIGHT,s=this.spritePos.x+m.phases[this.currentPhase],n=i,o=m.config.STAR_SIZE,r=Runner.spriteDefinition.LDPI.STAR.x;if(t&&(i*=2,e*=2,s=this.spritePos.x+2*m.phases[this.currentPhase],o*=2,r=Runner.spriteDefinition.HDPI.STAR.x),this.canvasCtx.save(),this.canvasCtx.globalAlpha=this.opacity,this.drawStars)for(var a=0;a<m.config.NUM_STARS;a++)this.canvasCtx.drawImage(Runner.imageSprite,r,this.stars[a].sourceY,o,o,Math.round(this.stars[a].x),this.stars[a].y,m.config.STAR_SIZE,m.config.STAR_SIZE);this.canvasCtx.drawImage(Runner.imageSprite,s,this.spritePos.y,i,e,Math.round(this.xPos),this.yPos,n,m.config.HEIGHT),this.canvasCtx.globalAlpha=1,this.canvasCtx.restore()},placeStars:function(){for(var i=Math.round(this.containerWidth/m.config.NUM_STARS),e=0;e<m.config.NUM_STARS;e++)this.stars[e]={},this.stars[e].x=r(i*e,i*(e+1)),this.stars[e].y=r(0,m.config.STAR_MAX_Y),this.stars[e].sourceY=t?Runner.spriteDefinition.HDPI.STAR.y+2*m.config.STAR_SIZE*e:Runner.spriteDefinition.LDPI.STAR.y+m.config.STAR_SIZE*e},reset:function(){this.currentPhase=0,this.opacity=0,this.update(!1)}},g.MAX_GAP_COEFFICIENT=1.5,g.MAX_OBSTACLE_LENGTH=3,g.prototype={init:function(t){if(this.cloneCollisionBoxes(),this.size>1&&this.typeConfig.multipleSpeed>t&&(this.size=1),this.width=this.typeConfig.width*this.size,Array.isArray(this.typeConfig.yPos)){var i=s?this.typeConfig.yPosMobile:this.typeConfig.yPos;this.yPos=i[r(0,i.length-1)]}else this.yPos=this.typeConfig.yPos;this.draw(),this.size>1&&(this.collisionBoxes[1].width=this.width-this.collisionBoxes[0].width-this.collisionBoxes[2].width,this.collisionBoxes[2].x=this.width-this.collisionBoxes[2].width),this.typeConfig.speedOffset&&(this.speedOffset=Math.random()>.5?this.typeConfig.speedOffset:-this.typeConfig.speedOffset),this.gap=this.getGap(this.gapCoefficient,t)},draw:function(){var i=this.typeConfig.width,e=this.typeConfig.height;t&&(i*=2,e*=2);var s=i*this.size*(.5*(this.size-1))+this.spritePos.x;this.currentFrame>0&&(s+=i*this.currentFrame),this.canvasCtx.drawImage(Runner.imageSprite,s,this.spritePos.y,i*this.size,e,this.xPos,this.yPos,this.typeConfig.width*this.size,this.typeConfig.height)},update:function(t,i){this.remove||(this.typeConfig.speedOffset&&(i+=this.speedOffset),this.xPos-=Math.floor(60*i/1e3*t),this.typeConfig.numFrames&&(this.timer+=t,this.timer>=this.typeConfig.frameRate&&(this.currentFrame=this.currentFrame==this.typeConfig.numFrames-1?0:this.currentFrame+1,this.timer=0)),this.draw(),this.isVisible()||(this.remove=!0))},getGap:function(t,i){var e=Math.round(this.width*i+this.typeConfig.minGap*t);return r(e,Math.round(e*g.MAX_GAP_COEFFICIENT))},isVisible:function(){return this.xPos+this.width>0},cloneCollisionBoxes:function(){for(var t=this.typeConfig.collisionBoxes,i=t.length-1;i>=0;i--)this.collisionBoxes[i]=new d(t[i].x,t[i].y,t[i].width,t[i].height)}},g.types=[{type:"CACTUS_SMALL",width:17,height:35,yPos:105,multipleSpeed:4,minGap:120,minSpeed:0,collisionBoxes:[new d(0,7,5,27),new d(4,0,6,34),new d(10,4,7,14)]},{type:"CACTUS_LARGE",width:25,height:50,yPos:90,multipleSpeed:7,minGap:120,minSpeed:0,collisionBoxes:[new d(0,12,7,38),new d(8,0,7,49),new d(13,10,10,38)]},{type:"PTERODACTYL",width:46,height:40,yPos:[100,75,50],yPosMobile:[100,50],multipleSpeed:999,minSpeed:8.5,minGap:150,collisionBoxes:[new d(15,15,16,5),new d(18,21,24,6),new d(2,14,4,3),new d(6,10,4,7),new d(10,8,6,9)],numFrames:2,frameRate:1e3/6,speedOffset:.8}],window.Runner=T,T.config={ACCELERATION:.001,BG_CLOUD_SPEED:.2,BOTTOM_PAD:10,CLEAR_TIME:3e3,CLOUD_FREQUENCY:.5,GAMEOVER_CLEAR_TIME:750,GAP_COEFFICIENT:.6,GRAVITY:.6,INITIAL_JUMP_VELOCITY:12,INVERT_FADE_DURATION:12e3,INVERT_DISTANCE:700,MAX_BLINK_COUNT:3,MAX_CLOUDS:6,MAX_OBSTACLE_LENGTH:3,MAX_OBSTACLE_DUPLICATION:2,MAX_SPEED:13,MIN_JUMP_HEIGHT:35,MOBILE_SPEED_COEFFICIENT:1.2,RESOURCE_TEMPLATE_ID:"audio-resources",SPEED:6,SPEED_DROP_COEFFICIENT:3},T.defaultDimensions={WIDTH:600,HEIGHT:150},T.classes={CANVAS:"runner-canvas",CONTAINER:"runner-container",CRASHED:"crashed",ICON:"icon-offline",INVERTED:"inverted",SNACKBAR:"snackbar",SNACKBAR_SHOW:"snackbar-show",TOUCH_CONTROLLER:"controller"},T.spriteDefinition={LDPI:{CACTUS_LARGE:{x:332,y:2},CACTUS_SMALL:{x:228,y:2},CLOUD:{x:86,y:2},HORIZON:{x:2,y:54},MOON:{x:484,y:2},PTERODACTYL:{x:134,y:2},RESTART:{x:2,y:2},TEXT_SPRITE:{x:655,y:2},TREX:{x:848,y:2},STAR:{x:645,y:2}},HDPI:{CACTUS_LARGE:{x:652,y:2},CACTUS_SMALL:{x:446,y:2},CLOUD:{x:166,y:2},HORIZON:{x:2,y:104},MOON:{x:954,y:2},PTERODACTYL:{x:260,y:2},RESTART:{x:2,y:2},TEXT_SPRITE:{x:1294,y:2},TREX:{x:1678,y:2},STAR:{x:1276,y:2}}},T.sounds={BUTTON_PRESS:"offline-sound-press",HIT:"offline-sound-hit",SCORE:"offline-sound-reached"},T.keycodes={JUMP:{38:1,32:1},DUCK:{40:1},RESTART:{13:1}},T.events={ANIM_END:"webkitAnimationEnd",CLICK:"click",KEYDOWN:"keydown",KEYUP:"keyup",MOUSEDOWN:"mousedown",MOUSEUP:"mouseup",RESIZE:"resize",TOUCHEND:"touchend",TOUCHSTART:"touchstart",VISIBILITY:"visibilitychange",BLUR:"blur",FOCUS:"focus",LOAD:"load"},T.prototype={isDisabled:function(){return!1},setupDisabledRunner:function(){this.containerEl=document.createElement("div"),this.containerEl.className=T.classes.SNACKBAR,this.containerEl.textContent=loadTimeData.getValue("disabledEasterEgg"),this.outerContainerEl.appendChild(this.containerEl),document.addEventListener(T.events.KEYDOWN,function(t){T.keycodes.JUMP[t.keyCode]&&(this.containerEl.classList.add(T.classes.SNACKBAR_SHOW),document.querySelector(".icon").classList.add("icon-disabled"))}.bind(this))},updateConfigSetting:function(t,i){if(t in this.config&&null!=i)switch(this.config[t]=i,t){case"GRAVITY":case"MIN_JUMP_HEIGHT":case"SPEED_DROP_COEFFICIENT":this.tRex.config[t]=i;break;case"INITIAL_JUMP_VELOCITY":this.tRex.setJumpVelocity(i);break;case"SPEED":this.setSpeed(i)}},loadImages:function(){t?(T.imageSprite=document.getElementById("offline-resources-2x"),this.spriteDef=T.spriteDefinition.HDPI):(T.imageSprite=document.getElementById("offline-resources-1x"),this.spriteDef=T.spriteDefinition.LDPI),T.imageSprite.complete?this.init():T.imageSprite.addEventListener(T.events.LOAD,this.init.bind(this))},loadSounds:function(){if(!i){this.audioContext=new AudioContext;var t=document.getElementById(this.config.RESOURCE_TEMPLATE_ID);for(var e in T.sounds){var s=t.querySelector("#"+T.sounds[e]).src,n=a(s=s.substr(s.indexOf(",")+1));this.audioContext.decodeAudioData(n,function(t,i){this.soundFx[t]=i}.bind(this,e))}}},setSpeed:function(t){var i=t||this.currentSpeed;if(this.dimensions.WIDTH<600){var e=i*this.dimensions.WIDTH/600*this.config.MOBILE_SPEED_COEFFICIENT;this.currentSpeed=e>i?i:e}else t&&(this.currentSpeed=t)},init:function(){var t,i,e,n,o;document.querySelector("."+T.classes.ICON).style.visibility="hidden",this.adjustDimensions(),this.setSpeed(),this.containerEl=document.createElement("div"),this.containerEl.className=T.classes.CONTAINER,this.canvas=(t=this.containerEl,i=this.dimensions.WIDTH,e=this.dimensions.HEIGHT,n=T.classes.PLAYER,(o=document.createElement("canvas")).className=n?Runner.classes.CANVAS+" "+n:Runner.classes.CANVAS,o.width=i,o.height=e,t.appendChild(o),o),this.canvasCtx=this.canvas.getContext("2d"),this.canvasCtx.fillStyle="#f7f7f7",this.canvasCtx.fill(),T.updateCanvasScaling(this.canvas),this.horizon=new p(this.canvas,this.spriteDef,this.dimensions,this.config.GAP_COEFFICIENT),this.distanceMeter=new u(this.canvas,this.spriteDef.TEXT_SPRITE,this.dimensions.WIDTH),this.tRex=new E(this.canvas,this.spriteDef.TREX),this.outerContainerEl.appendChild(this.containerEl),s&&this.createTouchController(),this.startListening(),this.update(),window.addEventListener(T.events.RESIZE,this.debounceResize.bind(this))},createTouchController:function(){this.touchController=document.createElement("div"),this.touchController.className=T.classes.TOUCH_CONTROLLER,this.outerContainerEl.appendChild(this.touchController)},debounceResize:function(){this.resizeTimerId_||(this.resizeTimerId_=setInterval(this.adjustDimensions.bind(this),250))},adjustDimensions:function(){clearInterval(this.resizeTimerId_),this.resizeTimerId_=null;var t=window.getComputedStyle(this.outerContainerEl),i=Number(t.paddingLeft.substr(0,t.paddingLeft.length-2));this.dimensions.WIDTH=this.outerContainerEl.offsetWidth-2*i,this.canvas&&(this.canvas.width=this.dimensions.WIDTH,this.canvas.height=this.dimensions.HEIGHT,T.updateCanvasScaling(this.canvas),this.distanceMeter.calcXPos(this.dimensions.WIDTH),this.clearCanvas(),this.horizon.update(0,0,!0),this.tRex.update(0),this.playing||this.crashed||this.paused?(this.containerEl.style.width=this.dimensions.WIDTH+"px",this.containerEl.style.height=this.dimensions.HEIGHT+"px",this.distanceMeter.update(0,Math.ceil(this.distanceRan)),this.stop()):this.tRex.draw(0,0),this.crashed&&this.gameOverPanel&&(this.gameOverPanel.updateDimensions(this.dimensions.WIDTH),this.gameOverPanel.draw()))},playIntro:function(){if(this.activated||this.crashed)this.crashed&&this.restart();else{this.playingIntro=!0,this.tRex.playingIntro=!0;var t="@-webkit-keyframes intro { from { width:"+E.config.WIDTH+"px }to { width: "+this.dimensions.WIDTH+"px }}",i=document.createElement("style");i.innerHTML=t,document.head.appendChild(i),this.containerEl.addEventListener(T.events.ANIM_END,this.startGame.bind(this)),this.containerEl.style.webkitAnimation="intro .4s ease-out 1 both",this.containerEl.style.width=this.dimensions.WIDTH+"px",this.playing=!0,this.activated=!0}},startGame:function(){this.runningTime=0,this.playingIntro=!1,this.tRex.playingIntro=!1,this.containerEl.style.webkitAnimation="",this.playCount++,document.addEventListener(T.events.VISIBILITY,this.onVisibilityChange.bind(this)),window.addEventListener(T.events.BLUR,this.onVisibilityChange.bind(this)),window.addEventListener(T.events.FOCUS,this.onVisibilityChange.bind(this))},clearCanvas:function(){this.canvasCtx.clearRect(0,0,this.dimensions.WIDTH,this.dimensions.HEIGHT)},update:function(){this.updatePending=!1;var t=h(),i=t-(this.time||t);if(this.time=t,this.playing){this.clearCanvas(),this.tRex.jumping&&this.tRex.updateJump(i),this.runningTime+=i;var e=this.runningTime>this.config.CLEAR_TIME;if(1!=this.tRex.jumpCount||this.playingIntro||this.playIntro(),this.playingIntro?this.horizon.update(0,this.currentSpeed,e):(i=this.activated?i:0,this.horizon.update(i,this.currentSpeed,e,this.inverted)),e&&function(t,i,e){Runner.defaultDimensions.WIDTH,t.xPos;var s=new d(i.xPos+1,i.yPos+1,i.config.WIDTH-2,i.config.HEIGHT-2),r=new d(t.xPos+1,t.yPos+1,t.typeConfig.width*t.size-2,t.typeConfig.height-2);if(o(s,r))for(var a=t.collisionBoxes,h=i.ducking?E.collisionBoxes.DUCKING:E.collisionBoxes.RUNNING,c=0;c<h.length;c++)for(var u=0;u<a.length;u++){var l=n(h[c],s),p=n(a[u],r);if(o(l,p))return[l,p]}return!1}(this.horizon.obstacles[0],this.tRex)?this.gameOver():(this.distanceRan+=this.currentSpeed*i/this.msPerFrame,this.currentSpeed<this.config.MAX_SPEED&&(this.currentSpeed+=this.config.ACCELERATION)),this.distanceMeter.update(i,Math.ceil(this.distanceRan))&&this.playSound(this.soundFx.SCORE),this.invertTimer>this.config.INVERT_FADE_DURATION)this.invertTimer=0,this.invertTrigger=!1,this.invert();else if(this.invertTimer)this.invertTimer+=i;else{var s=this.distanceMeter.getActualDistance(Math.ceil(this.distanceRan));s>0&&(this.invertTrigger=!(s%this.config.INVERT_DISTANCE),this.invertTrigger&&0===this.invertTimer&&(this.invertTimer+=i,this.invert()))}}(this.playing||!this.activated&&this.tRex.blinkCount<T.config.MAX_BLINK_COUNT)&&(this.tRex.update(i),this.scheduleNextUpdate())},handleEvent:function(t){return function(i,e){switch(i){case e.KEYDOWN:case e.TOUCHSTART:case e.MOUSEDOWN:this.onKeyDown(t);break;case e.KEYUP:case e.TOUCHEND:case e.MOUSEUP:this.onKeyUp(t)}}.bind(this)(t.type,T.events)},startListening:function(){document.addEventListener(T.events.KEYDOWN,this),document.addEventListener(T.events.KEYUP,this),s?(this.touchController.addEventListener(T.events.TOUCHSTART,this),this.touchController.addEventListener(T.events.TOUCHEND,this),this.containerEl.addEventListener(T.events.TOUCHSTART,this)):(document.addEventListener(T.events.MOUSEDOWN,this),document.addEventListener(T.events.MOUSEUP,this))},stopListening:function(){document.removeEventListener(T.events.KEYDOWN,this),document.removeEventListener(T.events.KEYUP,this),s?(this.touchController.removeEventListener(T.events.TOUCHSTART,this),this.touchController.removeEventListener(T.events.TOUCHEND,this),this.containerEl.removeEventListener(T.events.TOUCHSTART,this)):(document.removeEventListener(T.events.MOUSEDOWN,this),document.removeEventListener(T.events.MOUSEUP,this))},onKeyDown:function(t){s&&this.playing&&t.preventDefault(),t.target!=this.detailsButton&&(this.crashed||!T.keycodes.JUMP[t.keyCode]&&t.type!=T.events.TOUCHSTART||(this.playing||(this.loadSounds(),this.playing=!0,this.update(),window.errorPageController&&errorPageController.trackEasterEgg()),this.tRex.jumping||this.tRex.ducking||(this.playSound(this.soundFx.BUTTON_PRESS),this.tRex.startJump(this.currentSpeed))),this.crashed&&t.type==T.events.TOUCHSTART&&t.currentTarget==this.containerEl&&this.restart()),this.playing&&!this.crashed&&T.keycodes.DUCK[t.keyCode]&&(t.preventDefault(),this.tRex.jumping?this.tRex.setSpeedDrop():this.tRex.jumping||this.tRex.ducking||this.tRex.setDuck(!0))},onKeyUp:function(t){var i=String(t.keyCode),e=T.keycodes.JUMP[i]||t.type==T.events.TOUCHEND||t.type==T.events.MOUSEDOWN;if(this.isRunning()&&e)this.tRex.endJump();else if(T.keycodes.DUCK[i])this.tRex.speedDrop=!1,this.tRex.setDuck(!1);else if(this.crashed){var s=h()-this.time;(T.keycodes.RESTART[i]||this.isLeftClickOnCanvas(t)||s>=this.config.GAMEOVER_CLEAR_TIME&&T.keycodes.JUMP[i])&&this.restart()}else this.paused&&e&&(this.tRex.reset(),this.play())},isLeftClickOnCanvas:function(t){return null!=t.button&&t.button<2&&t.type==T.events.MOUSEUP&&t.target==this.canvas},scheduleNextUpdate:function(){this.updatePending||(this.updatePending=!0,this.raqId=requestAnimationFrame(this.update.bind(this)))},isRunning:function(){return!!this.raqId},gameOver:function(){this.playSound(this.soundFx.HIT),s&&window.navigator.vibrate&&window.navigator.vibrate(200),this.stop(),this.crashed=!0,this.distanceMeter.acheivement=!1,this.tRex.update(100,E.status.CRASHED),this.gameOverPanel?this.gameOverPanel.draw():this.gameOverPanel=new l(this.canvas,this.spriteDef.TEXT_SPRITE,this.spriteDef.RESTART,this.dimensions),this.distanceRan>this.highestScore&&(this.highestScore=Math.ceil(this.distanceRan),this.distanceMeter.setHighScore(this.highestScore)),this.time=h()},stop:function(){this.playing=!1,this.paused=!0,cancelAnimationFrame(this.raqId),this.raqId=0},play:function(){this.crashed||(this.playing=!0,this.paused=!1,this.tRex.update(0,E.status.RUNNING),this.time=h(),this.update())},restart:function(){this.raqId||(this.playCount++,this.runningTime=0,this.playing=!0,this.crashed=!1,this.distanceRan=0,this.setSpeed(this.config.SPEED),this.time=h(),this.containerEl.classList.remove(T.classes.CRASHED),this.clearCanvas(),this.distanceMeter.reset(this.highestScore),this.horizon.reset(),this.tRex.reset(),this.playSound(this.soundFx.BUTTON_PRESS),this.invert(!0),this.update())},onVisibilityChange:function(t){document.hidden||document.webkitHidden||"blur"==t.type||"visible"!=document.visibilityState?this.stop():this.crashed||(this.tRex.reset(),this.play())},playSound:function(t){if(t){var i=this.audioContext.createBufferSource();i.buffer=t,i.connect(this.audioContext.destination),i.start(0)}},invert:function(t){t?(document.body.classList.toggle(T.classes.INVERTED,!1),this.invertTimer=0,this.inverted=!1):this.inverted=document.body.classList.toggle(T.classes.INVERTED,this.invertTrigger)}},T.updateCanvasScaling=function(t,i,e){var s=t.getContext("2d"),n=Math.floor(window.devicePixelRatio)||1,o=Math.floor(s.webkitBackingStorePixelRatio)||1,r=n/o;if(n!==o){var a=i||t.width,h=e||t.height;return t.width=a*r,t.height=h*r,t.style.width=a+"px",t.style.height=h+"px",s.scale(r,r),!0}return 1==n&&(t.style.width=t.width+"px",t.style.height=t.height+"px"),!1},E.config={DROP_VELOCITY:-5,GRAVITY:.6,HEIGHT:47,HEIGHT_DUCK:25,INIITAL_JUMP_VELOCITY:-10,INTRO_DURATION:1500,MAX_JUMP_HEIGHT:30,MIN_JUMP_HEIGHT:30,SPEED_DROP_COEFFICIENT:3,SPRITE_WIDTH:262,START_X_POS:50,WIDTH:44,WIDTH_DUCK:59},E.collisionBoxes={DUCKING:[new d(1,18,55,25)],RUNNING:[new d(22,0,17,16),new d(1,18,30,9),new d(10,35,14,8),new d(1,24,29,5),new d(5,30,21,4),new d(9,34,15,4)]},E.status={CRASHED:"CRASHED",DUCKING:"DUCKING",JUMPING:"JUMPING",RUNNING:"RUNNING",WAITING:"WAITING"},E.BLINK_TIMING=7e3,E.animFrames={WAITING:{frames:[44,0],msPerFrame:1e3/3},RUNNING:{frames:[88,132],msPerFrame:1e3/12},CRASHED:{frames:[220],msPerFrame:1e3/60},JUMPING:{frames:[0],msPerFrame:1e3/60},DUCKING:{frames:[264,323],msPerFrame:125}},E.prototype={init:function(){this.groundYPos=Runner.defaultDimensions.HEIGHT-this.config.HEIGHT-Runner.config.BOTTOM_PAD,this.yPos=this.groundYPos,this.minJumpHeight=this.groundYPos-this.config.MIN_JUMP_HEIGHT,this.draw(0,0),this.update(0,E.status.WAITING)},setJumpVelocity:function(t){this.config.INIITAL_JUMP_VELOCITY=-t,this.config.DROP_VELOCITY=-t/2},update:function(t,i){this.timer+=t,i&&(this.status=i,this.currentFrame=0,this.msPerFrame=E.animFrames[i].msPerFrame,this.currentAnimFrames=E.animFrames[i].frames,i==E.status.WAITING&&(this.animStartTime=h(),this.setBlinkDelay())),this.playingIntro&&this.xPos<this.config.START_X_POS&&(this.xPos+=Math.round(this.config.START_X_POS/this.config.INTRO_DURATION*t)),this.status==E.status.WAITING?this.blink(h()):this.draw(this.currentAnimFrames[this.currentFrame],0),this.timer>=this.msPerFrame&&(this.currentFrame=this.currentFrame==this.currentAnimFrames.length-1?0:this.currentFrame+1,this.timer=0),this.speedDrop&&this.yPos==this.groundYPos&&(this.speedDrop=!1,this.setDuck(!0))},draw:function(i,e){var s=i,n=e,o=this.ducking&&this.status!=E.status.CRASHED?this.config.WIDTH_DUCK:this.config.WIDTH,r=this.config.HEIGHT;t&&(s*=2,n*=2,o*=2,r*=2),s+=this.spritePos.x,n+=this.spritePos.y,this.ducking&&this.status!=E.status.CRASHED?this.canvasCtx.drawImage(Runner.imageSprite,s,n,o,r,this.xPos,this.yPos,this.config.WIDTH_DUCK,this.config.HEIGHT):(this.ducking&&this.status==E.status.CRASHED&&this.xPos++,this.canvasCtx.drawImage(Runner.imageSprite,s,n,o,r,this.xPos,this.yPos,this.config.WIDTH,this.config.HEIGHT))},setBlinkDelay:function(){this.blinkDelay=Math.ceil(Math.random()*E.BLINK_TIMING)},blink:function(t){t-this.animStartTime>=this.blinkDelay&&(this.draw(this.currentAnimFrames[this.currentFrame],0),1==this.currentFrame&&(this.setBlinkDelay(),this.animStartTime=t,this.blinkCount++))},startJump:function(t){this.jumping||(this.update(0,E.status.JUMPING),this.jumpVelocity=this.config.INIITAL_JUMP_VELOCITY-t/10,this.jumping=!0,this.reachedMinHeight=!1,this.speedDrop=!1)},endJump:function(){this.reachedMinHeight&&this.jumpVelocity<this.config.DROP_VELOCITY&&(this.jumpVelocity=this.config.DROP_VELOCITY)},updateJump:function(t,i){var e=t/E.animFrames[this.status].msPerFrame;this.speedDrop?this.yPos+=Math.round(this.jumpVelocity*this.config.SPEED_DROP_COEFFICIENT*e):this.yPos+=Math.round(this.jumpVelocity*e),this.jumpVelocity+=this.config.GRAVITY*e,(this.yPos<this.minJumpHeight||this.speedDrop)&&(this.reachedMinHeight=!0),(this.yPos<this.config.MAX_JUMP_HEIGHT||this.speedDrop)&&this.endJump(),this.yPos>this.groundYPos&&(this.reset(),this.jumpCount++),this.update(t)},setSpeedDrop:function(){this.speedDrop=!0,this.jumpVelocity=1},setDuck:function(t){t&&this.status!=E.status.DUCKING?(this.update(0,E.status.DUCKING),this.ducking=!0):this.status==E.status.DUCKING&&(this.update(0,E.status.RUNNING),this.ducking=!1)},reset:function(){this.yPos=this.groundYPos,this.jumpVelocity=0,this.jumping=!1,this.ducking=!1,this.update(0,E.status.RUNNING),this.midair=!1,this.speedDrop=!1,this.jumpCount=0}},e(294);var I=e(379),v=e.n(I),C=e(822);v()(C.Z,{insert:"head",singleton:!1}),C.Z.locals,e(375),e(537)})()})();
export { CowGame } from './game/CowGame';
//# sourceMappingURL=lib.js.map
{
"name": "@anxolin/cow-runner-game",
"version": "0.1.0",
"version": "0.1.1",
"description": "Cow runner game",

@@ -13,5 +13,6 @@ "main": "dist/lib.js",

"build": "npm run build:lib",
"build:web": "NODE_ENV=production webpack --config-name web",
"build:lib": "NODE_ENV=production webpack --config-name lib",
"prepare": "npm run build:lib"
"build:web": "NODE_ENV=production webpack",
"build:lib": "tsc",
"prepare": "npm run clean && npm run build:lib",
"clean": "rimraf build"
},

@@ -23,6 +24,12 @@ "devDependencies": {

"@babel/preset-react": "^7.13.13",
"@types/node": "^15.6.0",
"@types/react": "^17.0.6",
"@types/react-dom": "^17.0.5",
"babel-loader": "8.2.2",
"css-loader": "5.2.5",
"html-webpack-plugin": "^5.3.1",
"rimraf": "^3.0.2",
"style-loader": "2.0.0",
"ts-loader": "^9.2.1",
"typescript": "^4.2.4",
"webpack": "5.37.1",

@@ -36,2 +43,2 @@ "webpack-cli": "4.7.0",

}
}
}
## Cow Runner Game
The trex runner game extracted from chrome offline err page, but with Cows! 🐮🐮
The trex runner game extracted from chrome offline error page, but with less dinosaurs and more Cows! 🐮🐮
## Install dependencies
```bash
yarn
```
## Run dev browser
```bash
yarn start
```
## Build library
```bash
yarn build
```
## Build web
```bash
yarn build:web
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc