/****************************************************************
 *																*		
 * 						      代码库							*
 *                        www.dmaku.com							*
 *       		  努力创建完善、持续更新插件以及模板			*
 * 																*
****************************************************************/
(function(){var a="undefined"!==typeof window&&"undefined"!==typeof window.document?window.document:{},c="undefined"!==typeof module&&module.exports,b="undefined"!==typeof Element&&"ALLOW_KEYBOARD_INPUT"in Element,d=function(){for(var e,h=["requestFullscreen exitFullscreen fullscreenElement fullscreenEnabled fullscreenchange fullscreenerror".split(" "),"webkitRequestFullscreen webkitExitFullscreen webkitFullscreenElement webkitFullscreenEnabled webkitfullscreenchange webkitfullscreenerror".split(" "),
"webkitRequestFullScreen webkitCancelFullScreen webkitCurrentFullScreenElement webkitCancelFullScreen webkitfullscreenchange webkitfullscreenerror".split(" "),"mozRequestFullScreen mozCancelFullScreen mozFullScreenElement mozFullScreenEnabled mozfullscreenchange mozfullscreenerror".split(" "),"msRequestFullscreen msExitFullscreen msFullscreenElement msFullscreenEnabled MSFullscreenChange MSFullscreenError".split(" ")],b=0,g=h.length,d={};b<g;b++)if((e=h[b])&&e[1]in a){for(b=0;b<e.length;b++)d[h[0][b]]=
e[b];return d}return!1}(),f={change:d.fullscreenchange,error:d.fullscreenerror},k={request:function(e){var h=d.requestFullscreen;e=e||a.documentElement;if(/5\.1[.\d]* Safari/.test(navigator.userAgent))e[h]();else e[h](b&&Element.ALLOW_KEYBOARD_INPUT)},exit:function(){a[d.exitFullscreen]()},toggle:function(a){this.isFullscreen?this.exit():this.request(a)},onchange:function(a){this.on("change",a)},onerror:function(a){this.on("error",a)},on:function(e,b){var h=f[e];h&&a.addEventListener(h,b,!1)},off:function(e,
b){var h=f[e];h&&a.removeEventListener(h,b,!1)},raw:d};d?(Object.defineProperties(k,{isFullscreen:{get:function(){return!!a[d.fullscreenElement]}},element:{enumerable:!0,get:function(){return a[d.fullscreenElement]}},enabled:{enumerable:!0,get:function(){return!!a[d.fullscreenEnabled]}}}),c?module.exports=k:window.screenfull=k):c?module.exports=!1:window.screenfull=!1})();var s_iScaleFactor=1,s_iOffsetX,s_iOffsetY,s_bIsIphone=!1;
(function(a){(jQuery.browser=jQuery.browser||{}).mobile=/android|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(ad|hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|tablet|treo|up\.(browser|link)|vodafone|wap|webos|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,
4))})(navigator.userAgent||navigator.vendor||window.opera);$(window).resize(function(){sizeHandler()});function trace(a){console.log(a)}
function getSize(a){var c=a.toLowerCase(),b=window.document,d=b.documentElement;if(void 0===window["inner"+a])a=d["client"+a];else if(window["inner"+a]!=d["client"+a]){var f=b.createElement("body");f.id="vpw-test-b";f.style.cssText="overflow:scroll";var k=b.createElement("div");k.id="vpw-test-d";k.style.cssText="position:absolute;top:-1000px";k.innerHTML="<style>@media("+c+":"+d["client"+a]+"px){body#vpw-test-b div#vpw-test-d{"+c+":7px!important}}</style>";f.appendChild(k);d.insertBefore(f,b.head);
a=7==k["offset"+a]?d["client"+a]:window["inner"+a];d.removeChild(f)}else a=window["inner"+a];return a}window.addEventListener("orientationchange",onOrientationChange);function onOrientationChange(){window.matchMedia("(orientation: portrait)").matches&&sizeHandler();window.matchMedia("(orientation: landscape)").matches&&sizeHandler()}function isChrome(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}
function isIOS(){var a="iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";");for(-1!==navigator.userAgent.toLowerCase().indexOf("iphone")&&(s_bIsIphone=!0);a.length;)if(navigator.platform===a.pop())return!0;return s_bIsIphone=!1}function getIOSWindowHeight(){return document.documentElement.clientWidth/window.innerWidth*window.innerHeight}function getHeightOfIOSToolbars(){var a=(0===window.orientation?screen.height:screen.width)-getIOSWindowHeight();return 1<a?a:0}
function inIframe(){try{return window.self!==window.top}catch(a){return!0}}
function sizeHandler(){window.scrollTo(0,1);if($("#canvas")){var a=navigator.userAgent.match(/(iPad|iPhone|iPod)/g)?getIOSWindowHeight():getSize("Height");var c=getSize("Width");_checkOrientation(c,a);var b=Math.min(a/CANVAS_HEIGHT,c/CANVAS_WIDTH),d=CANVAS_WIDTH*b;b*=CANVAS_HEIGHT;if(b<a){var f=a-b;b+=f;d+=CANVAS_WIDTH/CANVAS_HEIGHT*f}else d<c&&(f=c-d,d+=f,b+=CANVAS_HEIGHT/CANVAS_WIDTH*f);f=a/2-b/2;var k=c/2-d/2,e=CANVAS_WIDTH/d;if(k*e<-EDGEBOARD_X||f*e<-EDGEBOARD_Y)b=Math.min(a/(CANVAS_HEIGHT-2*
EDGEBOARD_Y),c/(CANVAS_WIDTH-2*EDGEBOARD_X)),d=CANVAS_WIDTH*b,b*=CANVAS_HEIGHT,f=(a-b)/2,k=(c-d)/2,e=CANVAS_WIDTH/d;s_iOffsetX=-1*k*e;s_iOffsetY=-1*f*e;0<=f&&(s_iOffsetY=0);0<=k&&(s_iOffsetX=0);null!==s_oInterface&&s_oInterface.refreshButtonPos(s_iOffsetX,s_iOffsetY);null!==s_oWorldMenu&&s_oWorldMenu.refreshButtonPos(s_iOffsetX,s_iOffsetY);null!==s_oMenu&&s_oMenu.refreshButtonPos(s_iOffsetX,s_iOffsetY);s_bIsIphone?(canvas=document.getElementById("canvas"),s_oStage.canvas.width=2*d,s_oStage.canvas.height=
2*b,canvas.style.width=d+"px",canvas.style.height=b+"px",s_iScaleFactor=2*Math.min(d/CANVAS_WIDTH,b/CANVAS_HEIGHT),s_oStage.scaleX=s_oStage.scaleY=s_iScaleFactor):s_bMobile||isChrome()?($("#canvas").css("width",d+"px"),$("#canvas").css("height",b+"px")):(s_oStage.canvas.width=d,s_oStage.canvas.height=b,s_iScaleFactor=Math.min(d/CANVAS_WIDTH,b/CANVAS_HEIGHT),s_oStage.scaleX=s_oStage.scaleY=s_iScaleFactor);0>f?$("#canvas").css("top",f+"px"):$("#canvas").css("top","0px");$("#canvas").css("left",k+"px");
fullscreenHandler()}}
function _checkOrientation(a,c){s_bMobile&&ENABLE_CHECK_ORIENTATION&&(a>c?"landscape"===$(".orientation-msg-container").attr("data-orientation")?($(".orientation-msg-container").css("display","none"),s_oMain.startUpdate()):($(".orientation-msg-container").css("display","block"),s_oMain.stopUpdate()):"portrait"===$(".orientation-msg-container").attr("data-orientation")?($(".orientation-msg-container").css("display","none"),s_oMain.startUpdate()):($(".orientation-msg-container").css("display","block"),
s_oMain.stopUpdate()))}function playSound(a,c,b){return!1===DISABLE_SOUND_MOBILE||!1===s_bMobile?(s_aSounds[a].play(),s_aSounds[a].volume(c),s_aSounds[a].loop(b),s_aSounds[a]):null}function stopSound(a){!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||a.stop()}function setVolume(a,c){!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||a.volume(c)}function setMute(a,c){!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||a.mute(c)}function fadeSound(a,c,b,d){!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||a.fade(c,b,d)}
function soundPlaying(a){if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)return a.playing()}function createBitmap(a,c,b){var d=new createjs.Bitmap(a),f=new createjs.Shape;c&&b?f.graphics.beginFill("#fff").drawRect(0,0,c,b):f.graphics.beginFill("#ff0").drawRect(0,0,a.width,a.height);d.hitArea=f;return d}function createSprite(a,c,b,d,f,k){a=null!==c?new createjs.Sprite(a,c):new createjs.Sprite(a);c=new createjs.Shape;c.graphics.beginFill("#000000").drawRect(-b,-d,f,k);a.hitArea=c;return a}
function pad(a,c,b){a+="";return a.length>=c?a:Array(c-a.length+1).join(b||"0")+a}function randomFloatBetween(a,c,b){"undefined"===typeof b&&(b=2);return parseFloat(Math.min(a+Math.random()*(c-a),c).toFixed(b))}function rotateVector2D(a,c){var b=c.getX()*Math.cos(a)+c.getY()*Math.sin(a),d=c.getX()*-Math.sin(a)+c.getY()*Math.cos(a);c.set(b,d)}function tweenVectorsOnX(a,c,b){return a+b*(c-a)}
function shuffle(a){for(var c=a.length,b,d;0!==c;)d=Math.floor(Math.random()*c),--c,b=a[c],a[c]=a[d],a[d]=b;return a}function bubbleSort(a){do{var c=!1;for(var b=0;b<a.length-1;b++)a[b]>a[b+1]&&(c=a[b],a[b]=a[b+1],a[b+1]=c,c=!0)}while(c)}function compare(a,c){return a.index>c.index?-1:a.index<c.index?1:0}function easeLinear(a,c,b,d){return b*a/d+c}function easeInQuad(a,c,b,d){return b*(a/=d)*a+c}function easeInSine(a,c,b,d){return-b*Math.cos(a/d*(Math.PI/2))+b+c}
function easeInCubic(a,c,b,d){return b*(a/=d)*a*a+c}function getTrajectoryPoint(a,c){var b=new createjs.Point,d=(1-a)*(1-a),f=a*a;b.x=d*c.start.x+2*(1-a)*a*c.traj.x+f*c.end.x;b.y=d*c.start.y+2*(1-a)*a*c.traj.y+f*c.end.y;return b}function formatTime(a){a/=1E3;var c=Math.floor(a/60);a=parseFloat(a-60*c).toFixed(1);var b="";b=10>c?b+("0"+c+":"):b+(c+":");return 10>a?b+("0"+a):b+a}function degreesToRadians(a){return a*Math.PI/180}
function checkRectCollision(a,c){var b=getBounds(a,.9);var d=getBounds(c,.98);return calculateIntersection(b,d)}function calculateIntersection(a,c){var b,d,f,k;var e=a.x+(b=a.width/2);var h=a.y+(d=a.height/2);var l=c.x+(f=c.width/2);var g=c.y+(k=c.height/2);e=Math.abs(e-l)-(b+f);h=Math.abs(h-g)-(d+k);return 0>e&&0>h?(e=Math.min(Math.min(a.width,c.width),-e),h=Math.min(Math.min(a.height,c.height),-h),{x:Math.max(a.x,c.x),y:Math.max(a.y,c.y),width:e,height:h,rect1:a,rect2:c}):null}
function getBounds(a,c){var b={x:Infinity,y:Infinity,width:0,height:0};if(a instanceof createjs.Container){b.x2=-Infinity;b.y2=-Infinity;var d=a.children,f=d.length,k;for(k=0;k<f;k++){var e=getBounds(d[k],1);e.x<b.x&&(b.x=e.x);e.y<b.y&&(b.y=e.y);e.x+e.width>b.x2&&(b.x2=e.x+e.width);e.y+e.height>b.y2&&(b.y2=e.y+e.height)}Infinity==b.x&&(b.x=0);Infinity==b.y&&(b.y=0);Infinity==b.x2&&(b.x2=0);Infinity==b.y2&&(b.y2=0);b.width=b.x2-b.x;b.height=b.y2-b.y;delete b.x2;delete b.y2}else{if(a instanceof createjs.Bitmap){f=
a.sourceRect||a.image;k=f.width*c;var h=f.height*c}else if(a instanceof createjs.Sprite)if(a.spriteSheet._frames&&a.spriteSheet._frames[a.currentFrame]&&a.spriteSheet._frames[a.currentFrame].image){f=a.spriteSheet.getFrame(a.currentFrame);k=f.rect.width;h=f.rect.height;d=f.regX;var l=f.regY}else b.x=a.x||0,b.y=a.y||0;else b.x=a.x||0,b.y=a.y||0;d=d||0;k=k||0;l=l||0;h=h||0;b.regX=d;b.regY=l;f=a.localToGlobal(0-d,0-l);e=a.localToGlobal(k-d,h-l);k=a.localToGlobal(k-d,0-l);d=a.localToGlobal(0-d,h-l);b.x=
Math.min(Math.min(Math.min(f.x,e.x),k.x),d.x);b.y=Math.min(Math.min(Math.min(f.y,e.y),k.y),d.y);b.width=Math.max(Math.max(Math.max(f.x,e.x),k.x),d.x)-b.x;b.height=Math.max(Math.max(Math.max(f.y,e.y),k.y),d.y)-b.y}return b}function NoClickDelay(a){this.element=a;window.Touch&&this.element.addEventListener("touchstart",this,!1)}function shuffle(a){for(var c=a.length,b,d;0<c;)d=Math.floor(Math.random()*c),c--,b=a[c],a[c]=a[d],a[d]=b;return a}
NoClickDelay.prototype={handleEvent:function(a){switch(a.type){case "touchstart":this.onTouchStart(a);break;case "touchmove":this.onTouchMove(a);break;case "touchend":this.onTouchEnd(a)}},onTouchStart:function(a){a.preventDefault();this.moved=!1;this.element.addEventListener("touchmove",this,!1);this.element.addEventListener("touchend",this,!1)},onTouchMove:function(a){this.moved=!0},onTouchEnd:function(a){this.element.removeEventListener("touchmove",this,!1);this.element.removeEventListener("touchend",
this,!1);if(!this.moved){a=document.elementFromPoint(a.changedTouches[0].clientX,a.changedTouches[0].clientY);3==a.nodeType&&(a=a.parentNode);var c=document.createEvent("MouseEvents");c.initEvent("click",!0,!0);a.dispatchEvent(c)}}};
(function(){function a(a){var b={focus:"visible",focusin:"visible",pageshow:"visible",blur:"hidden",focusout:"hidden",pagehide:"hidden"};a=a||window.event;a.type in b?document.body.className=b[a.type]:(document.body.className=this[c]?"hidden":"visible","hidden"===document.body.className?s_oMain.stopUpdate():s_oMain.startUpdate())}var c="hidden";c in document?document.addEventListener("visibilitychange",a):(c="mozHidden")in document?document.addEventListener("mozvisibilitychange",a):(c="webkitHidden")in
document?document.addEventListener("webkitvisibilitychange",a):(c="msHidden")in document?document.addEventListener("msvisibilitychange",a):"onfocusin"in document?document.onfocusin=document.onfocusout=a:window.onpageshow=window.onpagehide=window.onfocus=window.onblur=a})();function ctlArcadeResume(){null!==s_oMain&&s_oMain.startUpdate()}function ctlArcadePause(){null!==s_oMain&&s_oMain.stopUpdate()}
function getParamValue(a){for(var c=window.location.search.substring(1).split("&"),b=0;b<c.length;b++){var d=c[b].split("=");if(d[0]==a)return d[1]}}
var Util={timestamp:function(){return(new Date).getTime()},toInt:function(a,c){if(null!==a){var b=parseInt(a,10);if(!isNaN(b))return b}return Util.toInt(c,0)},toFloat:function(a,c){if(null!==a){var b=parseFloat(a);if(!isNaN(b))return b}return Util.toFloat(c,0)},limit:function(a,c,b){return Math.max(c,Math.min(a,b))},randomInt:function(a,c){return Math.round(Util.interpolate(a,c,Math.random()))},randomChoice:function(a){return a[Util.randomInt(0,a.length-1)]},percentRemaining:function(a,c){return a%
c/c},accelerate:function(a,c,b){return a+c*b},interpolate:function(a,c,b){return a+(c-a)*b},easeIn:function(a,c,b){return a+(c-a)*Math.pow(b,2)},easeOut:function(a,c,b){return a+(c-a)*(1-Math.pow(1-b,2))},easeInOut:function(a,c,b){return a+(c-a)*(-Math.cos(b*Math.PI)/2+.5)},exponentialFog:function(a,c){return 1/Math.pow(Math.E,a*a*c)},increase:function(a,c,b){for(a+=c;a>=b;)a-=b;for(;0>a;)a+=b;return a},project:function(a,c,b,d,f){a.camera.x=-c;a.camera.y=a.world.y-b;a.camera.z=a.world.z-d;a.screen.scale=
f/a.camera.z;a.screen.x=Math.round(HALF_CANVAS_WIDTH+a.screen.scale*a.camera.x*HALF_CANVAS_WIDTH);a.screen.y=Math.round(HALF_CANVAS_HEIGHT-a.screen.scale*a.camera.y*HALF_CANVAS_HEIGHT);a.screen.w=Math.round(a.screen.scale*ROAD_PER_HALF_CANVAS_WIDTH)},overlap:function(a,c,b,d,f){f=.5*(f||1);return!(a+c*f<b-d*f||a-c*f>b+d*f)}};
function fullscreenHandler(){ENABLE_FULLSCREEN&&screenfull.enabled&&(s_bFullscreen=screen.height<window.innerHeight+3&&screen.height>window.innerHeight-3?!0:!1,null!==s_oInterface&&s_oInterface.resetFullscreenBut(),null!==s_oWorldMenu&&s_oWorldMenu.resetFullscreenBut(),null!==s_oMenu&&s_oMenu.resetFullscreenBut())}
if(screenfull.enabled)screenfull.on("change",function(){s_bFullscreen=screenfull.isFullscreen;null!==s_oInterface&&s_oInterface.resetFullscreenBut();null!==s_oWorldMenu&&s_oWorldMenu.resetFullscreenBut();null!==s_oMenu&&s_oMenu.resetFullscreenBut()});function extractHostname(a){a=-1<a.indexOf("://")?a.split("/")[2]:a.split("/")[0];a=a.split(":")[0];return a=a.split("?")[0]}function extractRootDomain(a){a=extractHostname(a);var c=a.split("."),b=c.length;2<b&&(a=c[b-2]+"."+c[b-1]);return a}
var getClosestTop=function(){var a=window,c=!1;try{for(;a.parent.document!==a.document;)if(a.parent.document)a=a.parent;else{c=!0;break}}catch(b){c=!0}return{topFrame:a,err:c}},getBestPageUrl=function(a){var c=a.topFrame,b="";if(a.err)try{try{b=window.top.location.href}catch(f){var d=window.location.ancestorOrigins;b=d[d.length-1]}}catch(f){b=c.document.referrer}else b=c.location.href;return b},TOPFRAMEOBJ=getClosestTop(),PAGE_URL=getBestPageUrl(TOPFRAMEOBJ);
function seekAndDestroy(){for(var a=extractRootDomain(PAGE_URL),c=[String.fromCharCode(99,111,100,101,116,104,105,115,108,97,98,46,99,111,109),String.fromCharCode(101,110,118,97,116,111,46,99,111,109),String.fromCharCode(99,111,100,101,99,97,110,121,111,110,46,99,111,109),String.fromCharCode(99,111,100,101,99,97,110,121,111,110,46,110,101,116)],b=0;b<c.length;b++)if(c[b]===a)return!0;return!1}
function CSpriteLibrary(){var a,c,b,d,f,k;this.init=function(e,h,l){b=c=0;d=e;f=h;k=l;a={}};this.addSprite=function(e,b){a.hasOwnProperty(e)||(a[e]={szPath:b,oSprite:new Image},c++)};this.getSprite=function(e){return a.hasOwnProperty(e)?a[e].oSprite:null};this._onSpritesLoaded=function(){f.call(k)};this._onSpriteLoaded=function(){d.call(k);++b==c&&this._onSpritesLoaded()};this.loadSprites=function(){for(var e in a)a[e].oSprite.oSpriteLibrary=this,a[e].oSprite.onload=function(){this.oSpriteLibrary._onSpriteLoaded()},
a[e].oSprite.src=a[e].szPath};this.getNumSprites=function(){return c}}
var CANVAS_WIDTH=1600,CANVAS_HEIGHT=960,EDGEBOARD_X=256,EDGEBOARD_Y=100,FPS=60,FPS_DT=1/FPS,FPS_TIME=1E3/FPS,DISABLE_SOUND_MOBILE=!1,GAME_NAME="car_rush",PRIMARY_FONT="ArialBold",SECONDARY_FONT="Digital",STATE_LOADING=0,STATE_MENU=1,STATE_HELP=1,STATE_GAME=3,ON_MOUSE_DOWN=0,ON_MOUSE_UP=1,ON_MOUSE_OVER=2,ON_MOUSE_OUT=3,ON_DRAG_START=4,ON_DRAG_END=5,STATE_GAME_START=0,STATE_GAME_RACE=1,STATE_GAME_END=2,KEY_UP=38,KEY_DOWN=40,KEY_RIGHT=39,KEY_LEFT=37,KEY_SPACE=32,NUM_WORLDS=3,NUM_TRACKS_PER_WORLD=3,START_COUNTDOWN=
3E3,FOV=100,CAMERA_HEIGHT=1E3,CAMERA_DEPTH=1/Math.tan(FOV/2*Math.PI/180),PLAYER_Z_FROMCAMERA=CAMERA_HEIGHT*CAMERA_DEPTH,CAR_SIDEVIEW_OFFSET=.2,CAR_FARVIEW_OFFSET=2600,CAR_CURVEVIEW_OFFSET=.4,PARALLAX_RATIO_X=2,PARALLAX_RATIO_Y_0=.004,PARALLAX_RATIO_Y_1=.005,PLAYER_MAX_SPEED,PLAYER_ACCELERATION,PLAYER_DECELERATION,PLAYER_REAL_MAX_SPEED,CENTRIFUGAL_FORCE=.3,PLAYER_COLLIDER_WIDTH=.22,PLAYER_MIN_SPEED_DAMAGE,TERRAIN_MAX_INERTIA=.03,TERRAIN_INCREASE_INERTIA=.005,TERRAIN_DECREASE_INERTIA=.002,TERRAIN_ADHERENCE=
1,DRAW_DISTANCE=300,ROAD_WIDTH=2E3,NUM_LANES=4,SEGMENT_LENGTH=200,RUMBLE_LENGTH=3,TRACK_LENGTH,ROAD_BOUNDS=2,FOG_DENSITY=5,ROAD={TYPE:{STANDARD:0,CURVE_S:1,BUMPS:2,FINAL:3},LENGTH:{NONE:0,SHORT:25,MEDIUM:50,LONG:100,EXTRALONG:200},HILL:{NONE:0,LOW:20,MEDIUM:40,HIGH:60,VERYHIGH:80},CURVE:{NONE:0,EASY:2,MEDIUM:4,HARD:6,VERYHARD:8}},AMBIENT={DISPOSITION:{PRECISE:0,DENSITY:1},SIDE:{LEFT:-1,RIGHT:1,BOTH:2}},COLORS={LIGHT:{road:"#6B6B6B",grass:"#96a54b",rumble:"#555555",lane:"#CCCCCC"},DARK:{road:"#696969",
grass:"#7e8b3e",rumble:"#BBBBBB"},START:{road:"white",grass:"white",rumble:"white"},FINISH:{road:"black",grass:"black",rumble:"black"}},SPRITES={TREE1:{name:"tree1",collision:{center:240,width:70}},TREE2:{name:"tree2",collision:{center:170,width:140}},DEAD_TREE:{name:"dead_tree",collision:{center:90,width:15}},BUSH1:{name:"bush1",collision:{width:50}},BUSH2:{name:"bush2",collision:{width:50}},STUMP:{name:"stump",collision:{width:70}},PALM_TREE:{name:"palm_tree",collision:{center:156,width:6}},COLUMN:{name:"column"},
CACTUS1:{name:"cactus1",collision:{width:100}},CACTUS2:{name:"cactus2",collision:{center:48,width:70}},SIGN_CURVE_RIGHT:{name:"sign_curve_right"},SIGN_CURVE_LEFT:{name:"sign_curve_left"},SIGN_INDICATION:{name:"sign_indication"},LAMP_LEFT:{name:"lamp_left",collision:{center:5,width:1}},LAMP_RIGHT:{name:"lamp_right",collision:{center:75,width:1}},HOUSE1:{name:"house1",collision:{width:300}},HOUSE2:{name:"house2",collision:{width:300}},BILLBOARD01:{name:"billboard01"},BILLBOARD02:{name:"billboard02"},
BILLBOARD03:{name:"billboard03"},BILLBOARD04:{name:"billboard04"},BILLBOARD05:{name:"billboard05"},BOULDER:{name:"boulder",collision:{width:600}},SEMI:{name:"semi"},BUS:{name:"bus"},CAR01:{name:"car01"},CAR02:{name:"car02"},CAR03:{name:"car03"},SCALE:.00375};SPRITES.BILLBOARDS=[SPRITES.BILLBOARD01.name,SPRITES.BILLBOARD02.name,SPRITES.BILLBOARD03.name,SPRITES.BILLBOARD04.name,SPRITES.BILLBOARD05.name];
SPRITES.PLANTS=[SPRITES.TREE1.name,SPRITES.TREE2.name,SPRITES.DEAD_TREE.name,SPRITES.PALM_TREE.name,SPRITES.BUSH1.name,SPRITES.BUSH2.name,SPRITES.CACTUS1.name,SPRITES.STUMP.name,SPRITES.BOULDER.name];SPRITES.CARS=[SPRITES.CAR01.name,SPRITES.CAR02.name,SPRITES.CAR03.name,SPRITES.SEMI.name,SPRITES.BUS.name];
var HALF_CANVAS_WIDTH=CANVAS_WIDTH/2,HALF_CANVAS_HEIGHT=CANVAS_HEIGHT/2,ROAD_PER_HALF_CANVAS_WIDTH=HALF_CANVAS_WIDTH*ROAD_WIDTH,ROAD_PER_SCALE_PER_HALF_CANVAS_WIDTH=SPRITES.SCALE*ROAD_PER_HALF_CANVAS_WIDTH,PLAYER_SPEED_CONVERSION_RATIO=PLAYER_REAL_MAX_SPEED/PLAYER_MAX_SPEED,ENABLE_FULLSCREEN,ENABLE_CHECK_ORIENTATION,POINTS_PER_SECONDS,AD_SHOW_COUNTER;TEXT_GAMEOVER="CONGRATULATION! YOU COMPLETED ALL TRACKS!";TEXT_TIME_IS_UP="TIME IS UP!";TEXT_SCORE="SCORE";TEXT_GO="GO!";TEXT_SPEED_INDICATOR="Km/h";
TEXT_SAVE_REMOVE="THIS WILL REMOVE ALL YOUR ACHIEVEMENTS! DO YOU WANT TO PROCEED?";TEXT_ARE_SURE="ARE YOU SURE?";TEXT_TRACK_COMPLETED="TRACK COMPLETED";TEXT_SELECT_WORLD="SELECT THE WORLD YOU WANT TO PLAY";TEXT_SELECT_TRACK="SELECT TRACK";TEXT_HELP1="USE ARROW KEY TO MOVE THE CAR: UP FOR ACCELERATION AND DOWN FOR BRAKE";TEXT_HELP1_MOBILE="USE BUTTONS TO MOVE THE CAR";TEXT_HELP2="REACH THE END, BEFORE TIME GOES UP";TEXT_IOS_PRIVATE='Your web browser does not support storing settings locally. In Safari, the most common cause of this is using "Private Browsing Mode". Some info may not save or some features may not work properly';
TEXT_SHARE_IMAGE="200x200.jpg";TEXT_SHARE_TITLE="Congratulations!";TEXT_SHARE_MSG1="You collected <strong>";TEXT_SHARE_MSG2=" points</strong>!<br><br>Share your score with your friends!";TEXT_SHARE_SHARE1="My score is ";TEXT_SHARE_SHARE2=" points! Can you do better";
function CPreloader(){var a,c,b,d,f,k,e;this._init=function(){s_oSpriteLibrary.init(this._onImagesLoaded,this._onAllImagesLoaded,this);s_oSpriteLibrary.addSprite("bg_menu","./sprites/bg_menu.jpg");s_oSpriteLibrary.addSprite("progress_bar","./sprites/progress_bar.png");s_oSpriteLibrary.loadSprites();e=new createjs.Container;s_oStage.addChild(e)};this.unload=function(){e.removeAllChildren()};this.hide=function(){var a=this;setTimeout(function(){createjs.Tween.get(k).to({alpha:1},500).call(function(){a.unload();
s_oMain.gotoMenu()})},1E3)};this._onImagesLoaded=function(){};this._onAllImagesLoaded=function(){this.attachSprites();s_oMain.preloaderReady()};this.attachSprites=function(){var h=createBitmap(s_oSpriteLibrary.getSprite("bg_menu"));e.addChild(h);h=s_oSpriteLibrary.getSprite("progress_bar");d=createBitmap(h);d.x=CANVAS_WIDTH/2-h.width/2;d.y=CANVAS_HEIGHT-170;e.addChild(d);a=h.width;c=h.height;f=new createjs.Shape;f.graphics.beginFill("rgba(255,255,255,0.01)").drawRect(d.x,d.y,1,c);e.addChild(f);d.mask=
f;b=new createjs.Text("","30px Arial","#fff");b.x=CANVAS_WIDTH/2;b.y=CANVAS_HEIGHT-125;b.shadow=new createjs.Shadow("#000",2,2,2);b.textBaseline="alphabetic";b.textAlign="center";e.addChild(b);k=new createjs.Shape;k.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);k.alpha=0;e.addChild(k)};this.refreshLoader=function(e){b.text=e+"%";f.graphics.clear();e=Math.floor(e*a/100);f.graphics.beginFill("rgba(255,255,255,0.01)").drawRect(d.x,d.y,e,c)};this._init()}
function CMain(a){var c,b=0,d=0,f=STATE_LOADING,k,e;this.initContainer=function(){s_oCanvas=document.getElementById("canvas");s_oStage=new createjs.Stage(s_oCanvas);s_oStage.preventSelection=!1;createjs.Touch.enable(s_oStage);s_bMobile=jQuery.browser.mobile;!1===s_bMobile&&(s_oStage.enableMouseOver(20),$("body").on("contextmenu","#canvas",function(a){return!1}));s_iPrevTime=(new Date).getTime();createjs.Ticker.addEventListener("tick",this._update);createjs.Ticker.setFPS(FPS);navigator.userAgent.match(/Windows Phone/i)&&
(DISABLE_SOUND_MOBILE=!0);s_oSpriteLibrary=new CSpriteLibrary;seekAndDestroy()?k=new CPreloader:k=new CPreloader;s_oLocalStorage=new CLocalStorage(GAME_NAME)};this.preloaderReady=function(){this._loadImages();!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||this._initSounds();c=!0};this.soundLoaded=function(){b++;k.refreshLoader(Math.floor(b/d*100));b===d&&(k.unload(),isIOS()||playSound("menu_soundtrack",1,!0),s_oMain.gotoMenu())};this._initSounds=function(){var a=
[];a.push({path:"./sounds/",filename:"menu_soundtrack",loop:!0,volume:1,ingamename:"menu_soundtrack"});a.push({path:"./sounds/",filename:"game_soundtrack",loop:!0,volume:1,ingamename:"game_soundtrack"});a.push({path:"./sounds/",filename:"press_button",loop:!1,volume:1,ingamename:"click"});a.push({path:"./sounds/",filename:"1",loop:!1,volume:1,ingamename:"1"});a.push({path:"./sounds/",filename:"2",loop:!1,volume:1,ingamename:"2"});a.push({path:"./sounds/",filename:"3",loop:!1,volume:1,ingamename:"3"});
a.push({path:"./sounds/",filename:"go",loop:!1,volume:1,ingamename:"go"});a.push({path:"./sounds/",filename:"arrive_lose",loop:!1,volume:1,ingamename:"arrive_lose"});a.push({path:"./sounds/",filename:"arrive_win",loop:!1,volume:1,ingamename:"arrive_win"});a.push({path:"./sounds/",filename:"sprint_start",loop:!1,volume:1,ingamename:"sprint_start"});a.push({path:"./sounds/",filename:"crash",loop:!1,volume:1,ingamename:"crash"});a.push({path:"./sounds/",filename:"brake",loop:!1,volume:1,ingamename:"brake"});
a.push({path:"./sounds/",filename:"engine",loop:!0,volume:1,ingamename:"engine"});d+=a.length;s_aSounds=[];for(var e=0;e<a.length;e++)s_aSounds[a[e].ingamename]=new Howl({src:[a[e].path+a[e].filename+".mp3",a[e].path+a[e].filename+".ogg"],autoplay:!1,preload:!0,loop:a[e].loop,volume:a[e].volume,onload:s_oMain.soundLoaded})};this._loadImages=function(){s_oSpriteLibrary.init(this._onImagesLoaded,this._onAllImagesLoaded,this);s_oSpriteLibrary.addSprite("but_play","./sprites/but_play.png");s_oSpriteLibrary.addSprite("msg_box",
"./sprites/msg_box.png");s_oSpriteLibrary.addSprite("keys","./sprites/keys.png");s_oSpriteLibrary.addSprite("star","./sprites/star.png");s_oSpriteLibrary.addSprite("best_time","./sprites/best_time.png");s_oSpriteLibrary.addSprite("timer","./sprites/timer.png");s_oSpriteLibrary.addSprite("but_home","./sprites/but_home.png");s_oSpriteLibrary.addSprite("logo_menu","./sprites/logo_menu.png");s_oSpriteLibrary.addSprite("bg_select","./sprites/bg_select.jpg");s_oSpriteLibrary.addSprite("but_credits","./sprites/but_credits.png");
s_oSpriteLibrary.addSprite("ctl_logo","./sprites/ctl_logo.png");s_oSpriteLibrary.addSprite("but_fullscreen","./sprites/but_fullscreen.png");s_oSpriteLibrary.addSprite("but_yes","./sprites/but_yes.png");s_oSpriteLibrary.addSprite("but_delete_saving","./sprites/but_delete_saving.png");s_oSpriteLibrary.addSprite("bg_menu","./sprites/bg_menu.jpg");s_oSpriteLibrary.addSprite("but_level","./sprites/but_level.png");s_oSpriteLibrary.addSprite("but_world0","./sprites/but_world0.png");s_oSpriteLibrary.addSprite("but_world1",
"./sprites/but_world1.png");s_oSpriteLibrary.addSprite("but_world2","./sprites/but_world2.png");s_oSpriteLibrary.addSprite("w0_bg0","./sprites/backgrounds/world_0/bg0.png");s_oSpriteLibrary.addSprite("w0_bg1","./sprites/backgrounds/world_0/bg1.png");s_oSpriteLibrary.addSprite("w1_bg0","./sprites/backgrounds/world_1/bg0.png");s_oSpriteLibrary.addSprite("w1_bg1","./sprites/backgrounds/world_1/bg1.png");s_oSpriteLibrary.addSprite("w2_bg0","./sprites/backgrounds/world_2/bg0.png");s_oSpriteLibrary.addSprite("w2_bg1",
"./sprites/backgrounds/world_2/bg1.png");s_oSpriteLibrary.addSprite("key_up","./sprites/key_up.png");s_oSpriteLibrary.addSprite("key_down","./sprites/key_down.png");s_oSpriteLibrary.addSprite("key_left","./sprites/key_left.png");s_oSpriteLibrary.addSprite("key_right","./sprites/key_right.png");s_oSpriteLibrary.addSprite("but_exit","./sprites/but_exit.png");s_oSpriteLibrary.addSprite("audio_icon","./sprites/audio_icon.png");s_oSpriteLibrary.addSprite("but_restart","./sprites/but_restart.png");s_oSpriteLibrary.addSprite("but_next",
"./sprites/but_next.png");s_oSpriteLibrary.addSprite("time_panel","./sprites/time_panel.png");s_oSpriteLibrary.addSprite("tachometer","./sprites/tachometer.png");s_oSpriteLibrary.addSprite("baloon_mc","./sprites/baloon_mc.png");for(var a=1;5>=a;a++)s_oSpriteLibrary.addSprite("billboard0"+a,"./sprites/elements/billboard0"+a+".png");s_oSpriteLibrary.addSprite("boulder","./sprites/elements/boulder.png");s_oSpriteLibrary.addSprite("finish","./sprites/elements/finish.png");s_oSpriteLibrary.addSprite("bush1",
"./sprites/elements/world_0/bush1.png");s_oSpriteLibrary.addSprite("bush2","./sprites/elements/world_0/bush2.png");s_oSpriteLibrary.addSprite("dead_tree","./sprites/elements/world_0/dead_tree.png");s_oSpriteLibrary.addSprite("stump","./sprites/elements/world_0/stump.png");s_oSpriteLibrary.addSprite("tree1","./sprites/elements/world_0/tree1.png");s_oSpriteLibrary.addSprite("tree2","./sprites/elements/world_0/tree2.png");s_oSpriteLibrary.addSprite("cactus1","./sprites/elements/world_1/cactus1.png");
s_oSpriteLibrary.addSprite("cactus2","./sprites/elements/world_1/cactus2.png");s_oSpriteLibrary.addSprite("palm_tree","./sprites/elements/world_1/palm_tree.png");s_oSpriteLibrary.addSprite("column","./sprites/elements/world_1/column.png");s_oSpriteLibrary.addSprite("sign_curve_left","./sprites/elements/world_2/sign_curve_left.png");s_oSpriteLibrary.addSprite("sign_curve_right","./sprites/elements/world_2/sign_curve_right.png");s_oSpriteLibrary.addSprite("sign_indication","./sprites/elements/world_2/sign_indication.png");
s_oSpriteLibrary.addSprite("lamp_left","./sprites/elements/world_2/lamp_left.png");s_oSpriteLibrary.addSprite("lamp_right","./sprites/elements/world_2/lamp_right.png");s_oSpriteLibrary.addSprite("house1","./sprites/elements/world_2/house1.png");s_oSpriteLibrary.addSprite("house2","./sprites/elements/world_2/house2.png");for(a=1;3>=a;a++)s_oSpriteLibrary.addSprite("car0"+a+"_center","./sprites/cars/car0"+a+"/car0"+a+"_center.png"),s_oSpriteLibrary.addSprite("car0"+a+"_left","./sprites/cars/car0"+a+
"/car0"+a+"_left.png"),s_oSpriteLibrary.addSprite("car0"+a+"_right","./sprites/cars/car0"+a+"/car0"+a+"_right.png");s_oSpriteLibrary.addSprite("semi_center","./sprites/cars/semi/semi_center.png");s_oSpriteLibrary.addSprite("semi_left","./sprites/cars/semi/semi_left.png");s_oSpriteLibrary.addSprite("semi_right","./sprites/cars/semi/semi_right.png");s_oSpriteLibrary.addSprite("bus_center","./sprites/cars/bus/bus_center.png");s_oSpriteLibrary.addSprite("bus_left","./sprites/cars/bus/bus_left.png");s_oSpriteLibrary.addSprite("bus_right",
"./sprites/cars/bus/bus_right.png");s_oSpriteLibrary.addSprite("player","./sprites/player.png");d+=s_oSpriteLibrary.getNumSprites();s_oSpriteLibrary.loadSprites()};this._onImagesLoaded=function(){b++;k.refreshLoader(Math.floor(b/d*100));b===d&&(k.unload(),isIOS()||playSound("menu_soundtrack",1,!0),this.gotoMenu())};this._onAllImagesLoaded=function(){};this.onAllPreloaderImagesLoaded=function(){this._loadImages()};this.gotoMenu=function(){new CMenu;f=STATE_MENU};this.gotoWorldMenu=function(){new CWorldMenu;
f=STATE_MENU};this.gotoGame=function(a){e=new CGame(h,a);f=STATE_GAME};this.gotoHelp=function(){new CHelp;f=STATE_HELP};this.stopUpdate=function(){c=!1;createjs.Ticker.paused=!0;$("#block_game").css("display","block");Howler.mute(!0)};this.startUpdate=function(){s_iPrevTime=(new Date).getTime();c=!0;createjs.Ticker.paused=!1;$("#block_game").css("display","none");s_bAudioActive&&Howler.mute(!1)};this._update=function(a){if(!1!==c){var b=(new Date).getTime();s_iTimeElaps=b-s_iPrevTime;s_iCntTime+=
s_iTimeElaps;s_iCntFps++;s_iPrevTime=b;1E3<=s_iCntTime&&(s_iCurFps=s_iCntFps,s_iCntTime-=1E3,s_iCntFps=0);s_oStage.update(a);f===STATE_GAME&&e.update()}};s_oMain=this;var h=a;ENABLE_FULLSCREEN=a.fullscreen;ENABLE_CHECK_ORIENTATION=a.check_orientation;this.initContainer()}var s_bMobile,s_bAudioActive=!0,s_iCntTime=0,s_iTimeElaps=0,s_iPrevTime=0,s_iCntFps=0,s_iCurFps=1/FPS_DT,s_bFullscreen=!1,s_oDrawLayer,s_oStage,s_oMain,s_oSpriteLibrary,s_oSoundTrack,s_oCanvas,s_oLocalStorage,s_aSounds=[];
function CCreditsPanel(){var a,c,b,d,f;this._init=function(){c=new createjs.Shape;c.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);c.alpha=0;c.on("mousedown",function(){});s_oStage.addChild(c);(new createjs.Tween.get(c)).to({alpha:.7},500);b=new createjs.Container;s_oStage.addChild(b);var k=s_oSpriteLibrary.getSprite("msg_box"),e=createBitmap(k);e.regX=k.width/2;e.regY=k.height/2;b.addChild(e);b.x=CANVAS_WIDTH/2;b.y=CANVAS_HEIGHT+k.height/2+50;a=b.y;(new createjs.Tween.get(b)).to({y:CANVAS_HEIGHT/
2-40},500,createjs.Ease.quartIn);e=new createjs.Text("DEVELOPED BY"," 40px "+PRIMARY_FONT,"#ffffff");e.y=-k.height/2+110;e.textAlign="center";e.textBaseline="middle";e.lineWidth=400;b.addChild(e);k=new createjs.Text("www.dmaku.com"," 40px "+PRIMARY_FONT,"#ffffff");k.y=90;k.textAlign="center";k.textBaseline="middle";k.lineWidth=400;b.addChild(k);k=s_oSpriteLibrary.getSprite("ctl_logo");f=createBitmap(k);f.on("mousedown",this._onLogoButRelease);f.regX=k.width/2;f.regY=k.height/2;b.addChild(f);
k=s_oSpriteLibrary.getSprite("but_exit");d=new CGfxButton(326,-200,k,b);d.addEventListener(ON_MOUSE_UP,this.unload,this)};this.unload=function(){d.setClickable(!1);(new createjs.Tween.get(c)).to({alpha:0},500);(new createjs.Tween.get(b)).to({y:a},400,createjs.Ease.backIn).call(function(){s_oStage.removeChild(c);s_oStage.removeChild(b);d.unload()});c.off("mousedown",function(){});f.off("mousedown",this._onLogoButRelease)};this._onLogoButRelease=function(){window.open("http://www.dmaku.com")};
this._onMoreGamesReleased=function(){window.open("http://codecanyon.net/collections/5409142-games")};this._init()}
function CTextButton(a,c,b,d,f,k,e){var h,l,g,p,m;this._init=function(a,e,b,d,k,f,c){h=[];l=[];var q=createBitmap(b),n=Math.ceil(c/20);m=new createjs.Text(d,"bold "+c+"px "+k,"#000000");m.textAlign="center";m.textBaseline="alphabetic";var t=m.getBounds();m.x=b.width/2+n;m.y=Math.floor(b.height/2)+t.height/3+n;p=new createjs.Text(d,"bold "+c+"px "+k,f);p.textAlign="center";p.textBaseline="alphabetic";t=p.getBounds();p.x=b.width/2;p.y=Math.floor(b.height/2)+t.height/3;g=new createjs.Container;g.x=a;
g.y=e;g.regX=b.width/2;g.regY=b.height/2;g.addChild(q,m,p);s_oStage.addChild(g);this._initListener()};this.unload=function(){g.off("mousedown");g.off("pressup");s_oStage.removeChild(g)};this.setVisible=function(a){g.visible=a};this._initListener=function(){oParent=this;g.on("mousedown",this.buttonDown);g.on("pressup",this.buttonRelease)};this.addEventListener=function(a,e,b){h[a]=e;l[a]=b};this.buttonRelease=function(){g.scaleX=1;g.scaleY=1;h[ON_MOUSE_UP]&&h[ON_MOUSE_UP].call(l[ON_MOUSE_UP])};this.buttonDown=
function(){g.scaleX=.9;g.scaleY=.9;h[ON_MOUSE_DOWN]&&h[ON_MOUSE_DOWN].call(l[ON_MOUSE_DOWN])};this.setTextPosition=function(a){p.y=a;m.y=a+2};this.setPosition=function(a,e){g.x=a;g.y=e};this.setX=function(a){g.x=a};this.setY=function(a){g.y=a};this.getButtonImage=function(){return g};this.getX=function(){return g.x};this.getY=function(){return g.y};this._init(a,c,b,d,f,k,e);return this}
function CToggle(a,c,b,d){var f,k,e,h;this._init=function(a,b,d,c){k=[];e=[];var g=new createjs.SpriteSheet({images:[d],frames:{width:d.width/2,height:d.height,regX:d.width/2/2,regY:d.height/2},animations:{state_true:[0],state_false:[1]}});f=c;h=createSprite(g,"state_"+f,d.width/2/2,d.height/2,d.width/2,d.height);h.x=a;h.y=b;h.stop();s_oStage.addChild(h);this._initListener()};this.unload=function(){h.off("mousedown",this.buttonDown);h.off("pressup",this.buttonRelease);s_oStage.removeChild(h)};this._initListener=
function(){h.on("mousedown",this.buttonDown);h.on("pressup",this.buttonRelease)};this.addEventListener=function(a,b,h){k[a]=b;e[a]=h};this.setActive=function(a){f=a;h.gotoAndStop("state_"+f)};this.buttonRelease=function(){h.scaleX=1;h.scaleY=1;playSound("click",1,!1);f=!f;h.gotoAndStop("state_"+f);k[ON_MOUSE_UP]&&k[ON_MOUSE_UP].call(e[ON_MOUSE_UP],f)};this.buttonDown=function(){h.scaleX=.9;h.scaleY=.9;k[ON_MOUSE_DOWN]&&k[ON_MOUSE_DOWN].call(e[ON_MOUSE_DOWN])};this.setPosition=function(a,e){h.x=a;
h.y=e};this._init(a,c,b,d)}
function CGfxButton(a,c,b,d){var f,k,e,h,l=[],g;this._init=function(a,b,d,c){f=!1;k=1;e=[];h=[];g=createBitmap(d);g.x=a;g.y=b;g.scaleX=g.scaleY=k;g.regX=d.width/2;g.regY=d.height/2;c.addChild(g);this._initListener()};this.unload=function(){s_bMobile?g.off("mousedown",this.buttonDown):(g.off("mousedown",this.buttonDown),g.off("mouseover",this.buttonOver));g.off("pressup",this.buttonRelease);d.removeChild(g)};this.setVisible=function(a){g.visible=a};this.setClickable=function(a){f=!a};this._initListener=
function(){if(s_bMobile)g.on("mousedown",this.buttonDown);else g.on("mousedown",this.buttonDown),g.on("mouseover",this.buttonOver);g.on("pressup",this.buttonRelease)};this.addEventListener=function(a,b,d){e[a]=b;h[a]=d};this.addEventListenerWithParams=function(a,b,d,g){e[a]=b;h[a]=d;l=g};this.buttonRelease=function(){f||(g.scaleX=k,g.scaleY=k,e[ON_MOUSE_UP]&&e[ON_MOUSE_UP].call(h[ON_MOUSE_UP],l))};this.buttonDown=function(){f||(g.scaleX=.9*k,g.scaleY=.9*k,playSound("click",1,!1),e[ON_MOUSE_DOWN]&&
e[ON_MOUSE_DOWN].call(h[ON_MOUSE_DOWN],l))};this.buttonOver=function(a){s_bMobile||f||(a.target.cursor="pointer")};this.pulseAnimation=function(){createjs.Tween.get(g).to({scaleX:1.1*k,scaleY:1.1*k},850,createjs.Ease.quadOut).to({scaleX:k,scaleY:k},650,createjs.Ease.quadIn).call(function(){p.pulseAnimation()})};this.trembleAnimation=function(){createjs.Tween.get(g).to({rotation:5},75,createjs.Ease.quadOut).to({rotation:-5},140,createjs.Ease.quadIn).to({rotation:0},75,createjs.Ease.quadIn).wait(750).call(function(){p.trebleAnimation()})};
this.setPosition=function(a,e){g.x=a;g.y=e};this.setX=function(a){g.x=a};this.setY=function(a){g.y=a};this.getButtonImage=function(){return g};this.getX=function(){return g.x};this.getY=function(){return g.y};var p=this;this._init(a,c,b,d);return this}
function CMenu(){var a,c,b,d,f,k,e,h,l,g,p,m,q,t,v,r=null,x=null;this._init=function(){l=createBitmap(s_oSpriteLibrary.getSprite("bg_menu"));s_oStage.addChild(l);var n=s_oSpriteLibrary.getSprite("but_play");g=new CGfxButton(CANVAS_WIDTH/2+350,CANVAS_HEIGHT-220,n,s_oStage);g.addEventListener(ON_MOUSE_UP,this._onButPlayRelease,this);g.pulseAnimation();n=s_oSpriteLibrary.getSprite("logo_menu");var u=createBitmap(n);u.regX=n.width/2;u.regY=n.height/2;u.x=CANVAS_WIDTH/2;u.y=CANVAS_HEIGHT/2-150;s_oStage.addChild(u);
n=s_oSpriteLibrary.getSprite("but_credits");f=n.width/2+12;k=n.height/2+16;q=new CGfxButton(f,k,n,s_oStage);q.addEventListener(ON_MOUSE_UP,this._onCreditsBut,this);u=CANVAS_WIDTH;if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)n=s_oSpriteLibrary.getSprite("audio_icon"),e=CANVAS_WIDTH-n.width/4-12,h=n.height/2+16,m=new CToggle(e,h,n,s_bAudioActive),m.addEventListener(ON_MOUSE_UP,this._onAudioToggle,this),u=e-n.width/4;s_oLocalStorage.isDirty()&&(n=s_oSpriteLibrary.getSprite("but_delete_saving"),a=u-n.width/
2-12,c=n.height/2+16,v=new CGfxButton(a,c,n,s_oStage),v.addEventListener(ON_MOUSE_UP,this._onDeleteBut,this));n=window.document;u=n.documentElement;r=u.requestFullscreen||u.mozRequestFullScreen||u.webkitRequestFullScreen||u.msRequestFullscreen;x=n.exitFullscreen||n.mozCancelFullScreen||n.webkitExitFullscreen||n.msExitFullscreen;!1===ENABLE_FULLSCREEN&&(r=!1);r&&screenfull.enabled&&(n=s_oSpriteLibrary.getSprite("but_fullscreen"),b=f+n.width/2+12,d=n.height/2+16,t=new CToggle(b,d,n,s_bFullscreen,s_oStage),
t.addEventListener(ON_MOUSE_UP,this._onFullscreenRelease,this));p=new createjs.Shape;p.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);s_oStage.addChild(p);createjs.Tween.get(p).to({alpha:0},1E3).call(function(){p.visible=!1});this.refreshButtonPos(s_iOffsetX,s_iOffsetY);s_oLocalStorage.isUsed()||new CMsgBox(TEXT_IOS_PRIVATE)};this.unload=function(){g.unload();g=null;p.visible=!1;q.unload();v&&s_oLocalStorage.isDirty()&&v.unload();if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)m.unload(),
m=null;r&&screenfull.enabled&&t.unload();s_oStage.removeChild(l);s_oMenu=l=null};this.refreshButtonPos=function(g,l){!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||m.setPosition(e-g,l+h);q.setPosition(f+g,l+k);r&&!inIframe()&&t.setPosition(b+g,d+l);v&&s_oLocalStorage.isDirty()&&v.setPosition(a-g,c+l)};this.resetFullscreenBut=function(){r&&screenfull.enabled&&t.setActive(s_bFullscreen)};this._onFullscreenRelease=function(){s_bFullscreen?x.call(window.document):r.call(window.document.documentElement);sizeHandler()};
this._onCreditsBut=function(){new CCreditsPanel};this._onAudioToggle=function(){Howler.mute(s_bAudioActive);s_bAudioActive=!s_bAudioActive};this._onDeleteBut=function(){(new CAreYouSurePanel(s_oMenu.deleteSavings)).changeMessage(TEXT_SAVE_REMOVE,24)};this.deleteSavings=function(){s_oLocalStorage.deleteData();s_oLocalStorage.resetAllData();v.unload()};this._onButPlayRelease=function(){this.unload();$(s_oMain).trigger("start_session");isIOS()&&!soundPlaying(s_aSounds.menu_soundtrack)&&playSound("menu_soundtrack",
1,!0);s_oMain.gotoWorldMenu()};s_oMenu=this;this._init()}var s_oMenu=null;
function CGame(a,c){function b(a){a.preventDefault();s_oGame.onKeyUp(a.keyCode)}function d(a){a||(a=window.event);a.preventDefault();s_oGame.onKeyDown(a.keyCode)}var f,k,e,h,l,g,p,m,q,t,v=null,r,x,n,u,y,z;this._init=function(a){l=a;q=[];y=new CHorizon(l);n=new createjs.Shape;s_oStage.addChild(n);u=new createjs.Container;s_oStage.addChild(u);x=new CRoad(n,u,l);r=new CPlayer(CANVAS_WIDTH/2,980,s_oStage);q=x.getSegments();TRACK_LENGTH=x.getTrackLength();t=new CInterface;z=[];new CLevelBuilder(r,z,u,
a);this.resetParams()};this.getWorldCameraPos=function(){var a=r.getPosition().z;a=this.findSegment(a);return q[a.index].p1.world};this.onKeyUp=function(a){if(f)switch(a){case KEY_LEFT:r.stopLeft();break;case KEY_UP:r.stopAccelerate();break;case KEY_RIGHT:r.stopRight();break;case KEY_DOWN:r.stopBrake()}};this.onKeyDown=function(a){if(f)switch(a){case KEY_LEFT:r.moveLeft();break;case KEY_UP:r.moveAccelerate();break;case KEY_RIGHT:r.moveRight();break;case KEY_DOWN:r.moveBrake()}};this.resetParams=function(){f=
!1;stopSound(s_aSounds.game_soundtrack);if(0===l)new CHelpPanel;else{f=!0;stopSound(s_aSounds.menu_soundtrack);playSound("game_soundtrack",1,!0);$(s_oMain).trigger("start_level",l);var a=new createjs.Shape;a.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);a.alpha=1;s_oStage.addChild(a);(new createjs.Tween.get(a)).to({alpha:0},750).call(function(){s_oStage.removeChild(a)})}p=STATE_GAME_START;g=0;h=LEVEL_INFO[l].time;e=START_COUNTDOWN;y.restart();t.refreshTimer(h);t.refreshCurTime(0);
var c=l%NUM_TRACKS_PER_WORLD;t.setLevelInfo(s_oSpriteLibrary.getSprite("but_world"+Math.floor(l/NUM_WORLDS)),c+1);s_aTimeScore[l]<LEVEL_INFO[l].time&&0!==s_aTimeScore[l]?t.setBestTime(s_aTimeScore[l]):t.setBestTime(LEVEL_INFO[l].time);s_bMobile||(document.onkeydown=d,document.onkeyup=b);x.clearVisual(r.getPosition());m=r.getPlayerSegment();r.reset()};this.restartGame=function(){$(s_oMain).trigger("show_interlevel_ad");$(s_oMain).trigger("restart_level",l);this.resetParams()};this.unload=function(){t.unload();
null!==v&&v.unload();stopSound(s_aSounds.menu_soundtrack);stopSound(s_aSounds.game_soundtrack);stopSound(s_aSounds.engine);stopSound(s_aSounds.brake);createjs.Tween.removeAllTweens();s_oStage.removeAllChildren()};this.checkDamage=function(){r.getCurSpeed()>PLAYER_MIN_SPEED_DAMAGE&&!k&&(k=!0,r.damageAnim(),new CTremble(s_oStage,250,20,5))};this.endDamageTime=function(){k=!1};this.trackCompleted=function(){y.resetPos();p!==STATE_GAME_END&&($(s_oMain).trigger("end_level",l),$(s_oMain).trigger("show_interlevel_ad"),
p=STATE_GAME_END,s_oGame.stopPlayer(),g=Math.floor(h/1E3*POINTS_PER_SECONDS),new CNextLevelPanel(h,g,l))};this._countDown=function(){e-=s_iTimeElaps;t.refreshCountdown(e);0>=e&&(e=0,p=STATE_GAME_RACE,t.countDownGo())};this.nextLevel=function(){l++;l<NUM_TRACKS_PER_WORLD*NUM_WORLDS?(this.unload(),this._init(l)):this.gameOver()};this.trackLose=function(){p=STATE_GAME_END;s_oGame.stopPlayer();$(s_oMain).trigger("end_level",l);$(s_oMain).trigger("show_interlevel_ad");(new CLosePanel(s_oSpriteLibrary.getSprite("msg_box"))).show(g)};
this.stopPlayer=function(){r.stopAll();s_bMobile||(document.onkeydown=null,document.onkeyup=null)};this.onExit=function(){s_oGame.unload();$(s_oMain).trigger("end_session");playSound("menu_soundtrack",1,!0);s_oMain.gotoMenu()};this._onExitHelp=function(){f=!0;stopSound(s_aSounds.menu_soundtrack);playSound("game_soundtrack",1,!0);$(s_oMain).trigger("start_level",1)};this.gameOver=function(){v=new CEndPanel(s_oSpriteLibrary.getSprite("msg_box"));v.show(g)};this.setPause=function(){f=!1;r.stopAll()};
this.setResume=function(){f=!0};this.update=function(){var a=1/s_iCurFps;switch(p){case STATE_GAME_START:f&&this._countDown();break;case STATE_GAME_RACE:if(!f)return;h-=s_iTimeElaps;0>h&&(h=0,this.trackLose());t.refreshTimer(h);t.refreshCurTime(LEVEL_INFO[l].time-h);r.update(a);break;case STATE_GAME_END:r.update(a),r.autoPilot()}t.refreshSpeed(r.getCurSpeed()*PLAYER_SPEED_CONVERSION_RATIO);x.update(r.getPosition());y.move(this.getWorldCameraPos());for(var e=0;e<z.length;e++)z[e].update(a,r);this._ambientCollision();
this._carsCollision();m=r.getPlayerSegment()};this._ambientCollision=function(){if(r.isOutOfRoad())for(var a=r.getPlayerSegment().index,e=m.index;e<=a;e++)for(var b=q[e],h=0;h<b.sprites.length;h++){var d=b.sprites[h];if(Util.overlap(r.getPosition().x,r.getPlayerWidth(),d.collision.center,d.collision.width)){this.checkDamage();r.setCurSpeed(PLAYER_ACCELERATION);r.setPosition(Util.increase(b.p1.world.z,-PLAYER_Z_FROMCAMERA,TRACK_LENGTH));break}}};this._carsCollision=function(){for(var a,e,b=r.getPlayerSegment().index,
h=m.index;h<=b;h++)for(var d=q[h],g=0;g<d.cars.length;g++)if(a=d.cars[g],e=a.getSprite().width*SPRITES.SCALE,r.getCurSpeed()>a.getSpeed()&&Util.overlap(r.getPosition().x,r.getPlayerWidth(),a.getOffset(),e,.8)){this.checkDamage();r.setCurSpeed(a.getSpeed()*(a.getSpeed()/r.getCurSpeed()));r.setPosition(Util.increase(a.getZ(),-PLAYER_Z_FROMCAMERA,TRACK_LENGTH));break}};this.findSegment=function(a){return x.findSegment(a)};this.getSegments=function(){return q};s_oGame=this;PLAYER_MAX_SPEED=a.player_max_speed;
PLAYER_ACCELERATION=PLAYER_MAX_SPEED/5;PLAYER_DECELERATION=PLAYER_MAX_SPEED/8;PLAYER_MIN_SPEED_DAMAGE=PLAYER_MAX_SPEED/3;PLAYER_REAL_MAX_SPEED=a.player_maxspeed_indicator;PLAYER_SPEED_CONVERSION_RATIO=PLAYER_REAL_MAX_SPEED/PLAYER_MAX_SPEED;CENTRIFUGAL_FORCE=a.player_centrifugal_force;POINTS_PER_SECONDS=a.points_per_seconds_remaining;this._init(c)}var s_oGame;
function CInterface(){var a,c,b,d,f,k,e,h,l,g,p,m,q,t,v,r,x,n,u,y,z,D,E,P,O,C,B,I,J,K,L,M,H,F,G=null,Q=null;this._init=function(){var A,w=s_oSpriteLibrary.getSprite("but_exit");x=CANVAS_WIDTH-w.width/2-12;n=w.height/2+16;y=new CGfxButton(x,n,w,s_oStage);y.addEventListener(ON_MOUSE_UP,this._onExit,this);v=A=x-w.width-12;r=w.height/2+16;if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)w=s_oSpriteLibrary.getSprite("audio_icon"),u=new CToggle(v,r,w,s_bAudioActive),u.addEventListener(ON_MOUSE_UP,this._onAudioToggle,
this),A=v-w.width/2-12;w=window.document;var N=w.documentElement;G=N.requestFullscreen||N.mozRequestFullScreen||N.webkitRequestFullScreen||N.msRequestFullscreen;Q=w.exitFullscreen||w.mozCancelFullScreen||w.webkitExitFullscreen||w.msExitFullscreen;!1===ENABLE_FULLSCREEN&&(G=!1);G&&screenfull.enabled&&(w=s_oSpriteLibrary.getSprite("but_fullscreen"),f=A,k=w.height/2+16,M=new CToggle(f,k,w,s_bFullscreen,s_oStage),M.addEventListener(ON_MOUSE_UP,this._onFullscreenRelease,this));b=12;d=16;z=new createjs.Container;
s_oStage.addChild(z);w=s_oSpriteLibrary.getSprite("time_panel");A=createBitmap(w);z.addChild(A);E=new CTimer(110,50,z,50,"#ffffff","best_time","#000000");P=new CTimer(110,120,z,50,"#ffffff","timer","#000000");a=CANVAS_WIDTH/2;c=60;D=new CTimer(a,c,s_oStage,100,"#fff000",null,"#000000");D.resetTextRelativePos();D.setAlign("center","middle");O=new CTachometer(152,CANVAS_HEIGHT-12);C=new createjs.Text(""," 300px "+PRIMARY_FONT,"#3e240b");C.x=CANVAS_WIDTH/2;C.y=CANVAS_HEIGHT/2;C.textAlign="center";C.textBaseline=
"middle";C.lineWidth=200;C.outline=20;s_oStage.addChild(C);B=new createjs.Text(""," 300px "+PRIMARY_FONT,"rgba(255,224,0,1)");B.x=CANVAS_WIDTH/2;B.y=CANVAS_HEIGHT/2;B.textAlign="center";B.textBaseline="middle";B.lineWidth=200;s_oStage.addChild(B);s_bMobile&&(A=CANVAS_HEIGHT-270,w=s_oSpriteLibrary.getSprite("key_up"),q=CANVAS_WIDTH-180+w.width/2,t=A,I=new CGfxButton(q,t,w,s_oStage),I.addEventListenerWithParams(ON_MOUSE_UP,s_oGame.onKeyUp,this,KEY_UP),I.addEventListenerWithParams(ON_MOUSE_DOWN,s_oGame.onKeyDown,
this,KEY_UP),w=s_oSpriteLibrary.getSprite("key_down"),p=CANVAS_WIDTH-180-w.width/2,m=A,J=new CGfxButton(p,m,w,s_oStage),J.addEventListenerWithParams(ON_MOUSE_UP,s_oGame.onKeyUp,this,KEY_DOWN),J.addEventListenerWithParams(ON_MOUSE_DOWN,s_oGame.onKeyDown,this,KEY_DOWN),w=s_oSpriteLibrary.getSprite("key_left"),l=180-w.width/2,g=A,K=new CGfxButton(l,g,w,s_oStage),K.addEventListenerWithParams(ON_MOUSE_UP,s_oGame.onKeyUp,this,KEY_LEFT),K.addEventListenerWithParams(ON_MOUSE_DOWN,s_oGame.onKeyDown,this,KEY_LEFT),
w=s_oSpriteLibrary.getSprite("key_right"),e=180+w.width/2,h=A,L=new CGfxButton(e,h,w,s_oStage),L.addEventListenerWithParams(ON_MOUSE_UP,s_oGame.onKeyUp,this,KEY_RIGHT),L.addEventListenerWithParams(ON_MOUSE_DOWN,s_oGame.onKeyDown,this,KEY_RIGHT));F=[];for(A=0;3>=A;A++)F[A]=!1;this.refreshButtonPos(s_iOffsetX,s_iOffsetY)};this.unload=function(){if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)u.unload(),u=null;G&&screenfull.enabled&&M.unload();y.unload();s_oInterface=null;s_bMobile&&(I.unload(),J.unload(),
K.unload(),L.unload())};this.refreshButtonPos=function(A,w){y.setPosition(x-A,w+n);!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||u.setPosition(v-A,w+r);G&&screenfull.enabled&&M.setPosition(f-A,k+w);z.x=b+A;z.y=d+w;s_bMobile&&(I.setPosition(q-A,t-w),J.setPosition(p-A,m-w),K.setPosition(l+A,g-w),L.setPosition(e+A,h-w));D.setPos(a,c+w);O.updateOffset(A,w)};this.resetFullscreenBut=function(){G&&screenfull.enabled&&M.setActive(s_bFullscreen)};this._onFullscreenRelease=function(){s_bFullscreen?Q.call(window.document):
G.call(window.document.documentElement);sizeHandler()};this.refreshTimer=function(a){D.setIntTime(a)};this.setBestTime=function(a){E.setDecimalTime(a)};this.refreshCurTime=function(a){P.setDecimalTime(a)};this.refreshCountdown=function(a){var e=Math.ceil(a/1E3),b=(1E3*e-a)/1E3;B.alpha=1-b;B.scaleX=B.scaleY=b;B.text=Math.ceil(a/1E3);C.alpha=B.alpha;C.scaleX=C.scaleY=b;C.text=B.text;3!==e||F[3]?2!==e||F[2]?1!==e||F[1]?0===e&&(F[0]=!0,playSound("go",1,0)):(F[1]=!0,playSound("1",1,0)):(F[2]=!0,playSound("2",
1,0)):(F[3]=!0,playSound("3",1,0))};this.refreshSpeed=function(a){O.setSpeedIndicator(a)};this.countDownGo=function(){B.scaleX=B.scaleY=1;C.scaleX=C.scaleY=B.scaleY;B.text=TEXT_GO;C.text=TEXT_GO;createjs.Tween.get(B).wait(500).to({alpha:0},1E3,createjs.Ease.cubicIn);createjs.Tween.get(C).wait(500).to({alpha:0},1E3,createjs.Ease.cubicIn)};this.setLevelInfo=function(a,e){H&&H.unload();var b=s_oSpriteLibrary.getSprite("time_panel");H=new CLevelBut(a.width/4*.6+b.width+12,a.height/2*.6,a,!0,0,z);H.setScale(.6);
H.setClickable(!1);H.addLevelText(e)};this._onNitro=function(){_oButNitro.setVisible(!1);s_oGame.setNitro(!0)};this._onButRestartRelease=function(){F=[];for(var a=0;3>=a;a++)F[a]=!1;s_oGame.restartGame()};this.onExitFromHelp=function(){_oHelpPanel.unload()};this._onAudioToggle=function(){Howler.mute(s_bAudioActive);s_bAudioActive=!s_bAudioActive};this._onExit=function(){s_oGame.setPause();new CAreYouSurePanel(s_oGame.onExit,s_oGame.setResume)};s_oInterface=this;this._init();return this}
var s_oInterface=null;
function CHelpPanel(){var a,c,b,d,f,k,e,h;this._init=function(){e=new createjs.Shape;e.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);e.alpha=1;e.on("mousedown",function(){l._onExitHelp()});s_oStage.addChild(e);(new createjs.Tween.get(e)).to({alpha:.7},500);h=new createjs.Container;h.on("pressup",function(){l._onExitHelp()});s_oStage.addChild(h);var g=s_oSpriteLibrary.getSprite("msg_box");var c=createBitmap(g);c.regX=g.width/2;c.regY=g.height/2;h.addChild(c);h.x=CANVAS_WIDTH/
2;h.y=CANVAS_HEIGHT+g.height/2;a=h.y;(new createjs.Tween.get(h)).to({y:CANVAS_HEIGHT/2-40},500,createjs.Ease.cubicOut);s_bMobile?(g=0,c=-130,d=new createjs.Text(TEXT_HELP1_MOBILE," 24px "+PRIMARY_FONT,"#3e240b"),d.x=g,d.y=c,d.textAlign="center",d.textBaseline="middle",d.lineWidth=500,d.outline=4,h.addChild(d),b=new createjs.Text(TEXT_HELP1_MOBILE," 24px "+PRIMARY_FONT,"#ffffff"),b.x=g,b.y=c,b.textAlign=d.textAlign,b.textBaseline=d.textBaseline,b.lineWidth=d.lineWidth,h.addChild(b),g=s_oSpriteLibrary.getSprite("key_left"),
c=createBitmap(g),c.x=-170,c.y=-60,c.regX=g.width/2,c.regY=g.height/2,c.scaleX=c.scaleY=.7,h.addChild(c),g=s_oSpriteLibrary.getSprite("key_right"),c=createBitmap(g),c.x=-80,c.y=-60,c.regX=g.width/2,c.regY=g.height/2,c.scaleX=c.scaleY=.7,h.addChild(c),g=s_oSpriteLibrary.getSprite("key_down"),c=createBitmap(g),c.x=80,c.y=-60,c.regX=g.width/2,c.regY=g.height/2,c.scaleX=c.scaleY=.7,h.addChild(c),g=s_oSpriteLibrary.getSprite("key_up"),c=createBitmap(g),c.x=170,c.y=-60,c.regX=g.width/2,c.regY=g.height/
2,c.scaleX=c.scaleY=.7):(g=-280,c=-130,d=new createjs.Text(TEXT_HELP1," 24px "+PRIMARY_FONT,"#3e240b"),d.x=g,d.y=c,d.textAlign="left",d.textBaseline="alphabetic",d.lineWidth=300,d.outline=4,h.addChild(d),b=new createjs.Text(TEXT_HELP1," 24px "+PRIMARY_FONT,"#ffffff"),b.x=g,b.y=c,b.textAlign="left",b.textBaseline="alphabetic",b.lineWidth=300,h.addChild(b),g=s_oSpriteLibrary.getSprite("keys"),c=createBitmap(g),c.x=130,c.y=-100,c.regX=g.width/2,c.regY=g.height/2);h.addChild(c);k=new createjs.Text(TEXT_HELP2,
" 24px "+PRIMARY_FONT,"#3e240b");k.x=80;k.y=74;k.textAlign="left";k.textBaseline="alphabetic";k.lineWidth=200;k.outline=4;h.addChild(k);f=new createjs.Text(TEXT_HELP2," 24px "+PRIMARY_FONT,"#ffffff");f.x=80;f.y=74;f.textAlign="left";f.textBaseline="alphabetic";f.lineWidth=200;h.addChild(f);c=new createjs.Container;c.x=-130;c.y=130;c.scaleX=c.scaleY=.3;h.addChild(c);g=s_oSpriteLibrary.getSprite("finish");var m=createBitmap(g);m.regX=g.width/2;m.regY=g.height;c.addChild(m);new CPlayer(0,0,c)};this.unload=
function(){s_oStage.removeChild(e);s_oStage.removeChild(h);h.off("pressup",function(){l._onExitHelp()});e.off("pressup",function(){l._onExitHelp()})};this._onExitHelp=function(){c||(c=!0,(new createjs.Tween.get(e)).to({alpha:0},500),(new createjs.Tween.get(h)).to({y:a},400,createjs.Ease.backIn).call(function(){l.unload();s_oGame._onExitHelp()}))};var l=this;this._init()}
function CEndPanel(){var a,c,b;this._init=function(){setVolume(s_aSounds.game_soundtrack,.5);a=new createjs.Shape;a.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);a.alpha=0;a.on("mousedown",function(){});s_oStage.addChild(a);(new createjs.Tween.get(a)).to({alpha:.7},500);c=new createjs.Container;s_oStage.addChild(c);var d=s_oSpriteLibrary.getSprite("msg_box"),f=createBitmap(d);f.regX=d.width/2;f.regY=d.height/2;c.addChild(f);c.x=CANVAS_WIDTH/2;c.y=CANVAS_HEIGHT+d.height/2;(new createjs.Tween.get(c)).to({y:CANVAS_HEIGHT/
2},500,createjs.Ease.quartIn);f=new createjs.Text(TEXT_GAMEOVER," 40px "+PRIMARY_FONT,"#000000");f.y=-d.height/2+50;f.textAlign="center";f.textBaseline="middle";f.lineWidth=400;f.outline=5;c.addChild(f);d=new createjs.Text(TEXT_GAMEOVER," 40px "+PRIMARY_FONT,"#ffffff");d.y=f.y;d.textAlign="center";d.textBaseline="middle";d.lineWidth=400;c.addChild(d);d=s_oSpriteLibrary.getSprite("finish");f=createBitmap(d);f.regX=d.width/2;f.regY=d.height;f.y=154;f.scaleX=f.scaleY=.6;c.addChild(f);d=s_oSpriteLibrary.getSprite("but_home");
b=new CGfxButton(0,100,d,c);b.addEventListener(ON_MOUSE_UP,this._onHome,this);b.pulseAnimation()};this.unload=function(){s_oStage.removeChild(c);a.off("mousedown",function(){});b.unload()};this.show=function(){playSound("arrive_win",1,0);$(s_oMain).trigger("share_event",s_iTotalScore)};this._onHome=function(){a.off("mousedown",function(){});s_oStage.removeChild(c);s_oGame.onExit()};this._init();return this}
function CPlayer(a,c,b){var d,f,k,e,h,l,g,p,m,q,t,v,r,x,n,u,y,z,D,E;this._init=function(a,e,b){this.reset();q=PLAYER_MAX_SPEED;t=PLAYER_ACCELERATION;v=-q;r=-PLAYER_DECELERATION;x=-q/2;n=q/4;var h=s_oSpriteLibrary.getSprite("baloon_mc");E=createBitmap(h);E.regX=h.width/2;E.regY=h.height/2;E.x=a;E.y=e-260;E.alpha=0;b.addChild(E);h=s_oSpriteLibrary.getSprite("player");var c=h.width/3,d=h.height;h=new createjs.SpriteSheet({images:[h],frames:{width:c,height:d,regX:c/2,regY:d},animations:{left:[0],right:[1],
straight:[2]}});z=createSprite(h,"straight",c/2,d,c,d);z.x=a;z.y=e;b.addChild(z);u=PLAYER_COLLIDER_WIDTH};this.reset=function(){h=l=e=k=f=d=!1;y=m=p=g=0;D=s_oGame.findSegment(g+PLAYER_Z_FROMCAMERA)};this.setAcceleration=function(a){t=a};this.setMaxSpeed=function(a){q=a;v=-q;r=-PLAYER_DECELERATION;x=-q/2;n=q/4};this.stopAll=function(){this.stopLeft();this.stopRight();this.stopAccelerate()};this.stopLeft=function(){d&&(d=!1,z.gotoAndStop("straight"),stopSound(s_aSounds.brake))};this.stopRight=function(){f&&
(f=!1,z.gotoAndStop("straight"),stopSound(s_aSounds.brake))};this.stopAccelerate=function(){k=!1;stopSound(s_aSounds.engine)};this.stopBrake=function(){e=!1};this.moveLeft=function(){0!==m&&(soundPlaying(s_aSounds.brake)||playSound("brake",.5,!1),f=!1,d=!0,z.gotoAndStop("left"))};this.moveRight=function(){0!==m&&(soundPlaying(s_aSounds.brake)||playSound("brake",.5,!1),d=!1,f=!0,z.gotoAndStop("right"))};this.moveAccelerate=function(){e=!1;k=!0;0<m&&!soundPlaying(s_aSounds.engine)&&(stopSound(s_aSounds.brake),
playSound("engine",.5,!0))};this.moveBrake=function(){k=!1;e=!0;0<m&&(stopSound(s_aSounds.engine),soundPlaying(s_aSounds.brake)||playSound("brake",.5,!1))};this._increase=function(a,e,b){for(a+=e;a>=b;)a-=b,s_oGame.trackCompleted();for(;0>a;)a+=b;return a};this._accelerate=function(a,e,b){return a+e*b};this._limit=function(a,e,b){return Math.max(e,Math.min(a,b))};this.getPlayerWidth=function(){return u};this.getPosition=function(){return{x:p,z:g}};this.setPosition=function(a){g=a};this.autoPilot=
function(){.5<p?(f=!1,d=!0):-.5>p?(f=!0,d=!1):.1>=p&&-.1<=p&&(f=d=!1)};this.getMaxSpeed=function(){return q};this.getCurSpeed=function(){return m};this.setCurSpeed=function(a){m=a};this.getPlayerSegment=function(){return D};this.getFrontPlayerSegment=function(){return s_oGame.findSegment(g+SEGMENT_LENGTH+PLAYER_Z_FROMCAMERA)};this.damageAnim=function(){l||(l=!0,playSound("crash",1,!1),createjs.Tween.get(E,{override:!0}).to({alpha:1},250,createjs.Ease.cubicOut).to({alpha:0},250,createjs.Ease.cubicIn).call(function(){l=
!1}))};this.isOutOfRoad=function(){return h};this._updateXMovement=function(a,e){var b=a*e*e*D.curve*CENTRIFUGAL_FORCE/TERRAIN_ADHERENCE;d?(y-=TERRAIN_INCREASE_INERTIA*e,y<-TERRAIN_MAX_INERTIA&&(y=-TERRAIN_MAX_INERTIA),p=p-b-a):f?(y+=TERRAIN_INCREASE_INERTIA*e,y>TERRAIN_MAX_INERTIA&&(y=TERRAIN_MAX_INERTIA),p=p-b+a):p=p-b+y;0<y?(y-=TERRAIN_DECREASE_INERTIA,0>y&&(y=0)):0>y&&(y+=TERRAIN_DECREASE_INERTIA,0<y&&(y=0))};this.update=function(a){D=s_oGame.findSegment(g+PLAYER_Z_FROMCAMERA);var b=m/q;g=this._increase(g,
a*m,TRACK_LENGTH);this._updateXMovement(2*a*TERRAIN_ADHERENCE*b,b);m=k?this._accelerate(m,t,a):e?this._accelerate(m,v,a):this._accelerate(m,r,a);h=!1;if(-1>p||1<p)m>n&&(m=this._accelerate(m,x,a)),h=!0;p=this._limit(p,-ROAD_BOUNDS,ROAD_BOUNDS);m=this._limit(m,0,q)};this._init(a,c,b)}
var Render={polygon:function(a,c,b,d,f,k,e,h,l,g){a.graphics.beginFill(g);a.graphics.moveTo(c,b);a.graphics.lineTo(d,f);a.graphics.lineTo(k,e);a.graphics.lineTo(h,l)},segment:function(a,c,b,d,f,k,e,h,l,g){var p=Render.rumbleWidth(k,b),m=Render.rumbleWidth(l,b),q=Render.laneMarkerWidth(k,b),t=Render.laneMarkerWidth(l,b);a.graphics.beginFill(g.grass);a.graphics.drawRect(0,h,c,f-h);Render.polygon(a,d-k-p,f,d-k,f,e-l,h,e-l-m,h,g.rumble);Render.polygon(a,d+k+p,f,d+k,f,e+l,h,e+l+m,h,g.rumble);Render.polygon(a,
d-k,f,d+k,f,e+l,h,e-l,h,g.road);if(g.lane)for(c=2*k/b,p=2*l/b,d=d-k+c,e=e-l+p,l=1;l<b;d+=c,e+=p,l++)Render.polygon(a,d-q/2,f,d+q/2,f,e+t/2,h,e-t/2,h,g.lane)},background:function(a,c,b,d,f,k,e){var h=f.w/2;k=f.x+Math.floor(f.w*(k||0));var l=f.y,g=Math.min(h,f.x+f.w-k),p=f.h;e=e||0;var m=Math.floor(g/h*b);a.drawImage(c,k,l,g,p,0,e,m,d);g<h&&a.drawImage(c,f.x,l,h-g,p,m-1,e,b-m,d)},sprite:function(a,c,b,d,f,k,e,h){var l=b*ROAD_PER_SCALE_PER_HALF_CANVAS_WIDTH;b=a.width*l;l*=a.height;var g=l/a.height;f+=
l*(e||0);e=h?Math.max(0,f+l-h):0;e<l?(c.x=d+b*(k||0),c.y=f,c.scaleX=c.scaleY=g,a=new createjs.Rectangle(0,0,a.width,a.height-a.height*e/l),c.sourceRect=a):c.visible=!1},rumbleWidth:function(a,c){return a/Math.max(6,2*c)},laneMarkerWidth:function(a,c){return a/Math.max(32,8*c)}};
function CRoad(a,c,b){var d,f,k;this._init=function(a,b,c){d=null;f=CAMERA_DEPTH;k=[];this.resetRoad()};this.findSegment=function(a){return k[Math.floor(a/SEGMENT_LENGTH)%k.length]};this.lastX=function(){return 0===k.length?0:k[k.length-1].p2.world.x};this.lastY=function(){return 0===k.length?0:k[k.length-1].p2.world.y};this.addSegment=function(a,b){var e=k.length;k.push({index:e,p1:{world:{x:this.lastX(),y:this.lastY(),z:e*SEGMENT_LENGTH},camera:{},screen:{}},p2:{world:{x:this.lastX()+a,y:b,z:(e+
1)*SEGMENT_LENGTH},camera:{},screen:{}},curve:a,sprites:[],cars:[],coins:[],color:Math.floor(e/RUMBLE_LENGTH)%2?COLORS.DARK:COLORS.LIGHT})};this.addRoad=function(a,b,c,d,k){var e=this.lastY();k=e+Util.toInt(k,0)*SEGMENT_LENGTH;var h,g=a+b+c;for(h=0;h<a;h++)this.addSegment(Util.easeIn(0,d,h/a),Util.easeInOut(e,k,h/g));for(h=0;h<b;h++)this.addSegment(d,Util.easeInOut(e,k,(a+h)/g));for(h=0;h<c;h++)this.addSegment(Util.easeInOut(d,0,h/c),Util.easeInOut(e,k,(a+b+h)/g))};this.addStraight=function(a){a=
a||ROAD.LENGTH.MEDIUM;this.addRoad(a,a,a,0)};this.addHill=function(a,b){a=a||ROAD.LENGTH.MEDIUM;b=b||ROAD.HILL.MEDIUM;this.addRoad(a,a,a,0,b)};this.addCurve=function(a,b,c){a=a||ROAD.LENGTH.MEDIUM;b=b||ROAD.CURVE.MEDIUM;this.addRoad(a,a,a,b)};this.addStandardRoad=function(a,b,c){a=a||ROAD.LENGTH.MEDIUM;b=b||ROAD.CURVE.NONE;c=c||ROAD.HILL.NONE;this.addRoad(a,a,a,b,c)};this.addLowRollingHills=function(a,b){a=a||ROAD.LENGTH.SHORT;b=b||ROAD.HILL.LOW;this.addRoad(a,a,a,0,b/2);this.addRoad(a,a,a,0,-b);
this.addRoad(a,a,a,ROAD.CURVE.EASY,b);this.addRoad(a,a,a,0,0);this.addRoad(a,a,a,-ROAD.CURVE.EASY,b/2);this.addRoad(a,a,a,0,0)};this.addSCurves=function(a,b,c){a=a||ROAD.LENGTH.MEDIUM;b=b||ROAD.CURVE.MEDIUM;c=c||ROAD.HILL.NONE;var e=0<=b?1:-1;var h=0<=c?1:-1;b=Math.abs(b);c=Math.abs(c);switch(b){case ROAD.CURVE.EASY:var d=ROAD.CURVE.NONE;var k=ROAD.CURVE.EASY;break;case ROAD.CURVE.MEDIUM:d=ROAD.CURVE.EASY;k=ROAD.CURVE.MEDIUM;break;case ROAD.CURVE.HARD:d=ROAD.CURVE.MEDIUM,k=ROAD.CURVE.HARD}switch(c){case ROAD.HILL.EASY:var f=
ROAD.HILL.NONE;var l=ROAD.HILL.LOW;break;case ROAD.HILL.MEDIUM:f=ROAD.HILL.LOW;l=ROAD.HILL.MEDIUM;break;case ROAD.HILL.HIGH:f=ROAD.HILL.MEDIUM,l=ROAD.HILL.HIGH}this.addRoad(a,a,a,e*d,ROAD.HILL.NONE);this.addRoad(a,a,a,e*k,h*l);this.addRoad(a,a,a,e*d,-h*f);this.addRoad(a,a,a,-e*d,h*l);this.addRoad(a,a,a,-e*k,-h*f)};this.addBumps=function(a,b){a=a||ROAD.LENGTH.SHORT/2;b=b||ROAD.CURVE.NONE;this.addRoad(a,a,a,0,a/2.5);this.addRoad(a,a,a,0,-a/6.25);this.addRoad(a,a,a,b,-a/2.5);this.addRoad(a,a,a,0,a/1,
5625);this.addRoad(a,a,a,0,a/2.5);this.addRoad(a,a,a,-b,-a/1.785);this.addRoad(a,a,a,0,a/2.5);this.addRoad(a,a,a,0,-a/6.25)};this.addDownhillToEnd=function(a,b){a=a||200;b=b||ROAD.CURVE.NONE;this.addRoad(a,a,a,b,-Math.round(this.lastY()/SEGMENT_LENGTH))};this.resetRoad=function(){k=[];for(var a=ROAD_INFO[b],c=0;c<a.length;c++){var f=a[c];switch(f.roadtype){case ROAD.TYPE.STANDARD:this.addStandardRoad(f.length,f.curve,f.hill);break;case ROAD.TYPE.CURVE_S:this.addSCurves(f.length,f.curve,f.hill);break;
case ROAD.TYPE.BUMPS:this.addBumps(f.length,f.curve);break;case ROAD.TYPE.FINAL:this.addDownhillToEnd(f.length,f.curve)}}k[this.findSegment(PLAYER_Z_FROMCAMERA).index+2].color=COLORS.START;k[this.findSegment(PLAYER_Z_FROMCAMERA).index+3].color=COLORS.START;for(a=0;a<RUMBLE_LENGTH;a++)k[k.length-1-a].color=COLORS.FINISH;d=k.length*SEGMENT_LENGTH};this.setCameraDepth=function(a){f=a};this.clearVisual=function(b){a.graphics.clear();b=this.findSegment(b.z);var c;for(c=DRAW_DISTANCE-1;0<c;c--){var e=k[(b.index+
c)%k.length];for(var d=0;d<e.cars.length;d++){var f=e.cars[d];f.setVisible(!1)}for(d=0;d<e.sprites.length;d++)f=e.sprites[d],f.source.visible=!1}};this.update=function(b){a.graphics.clear();var e=b.z;b=b.x;var l=this.findSegment(e),g=Util.percentRemaining(e,SEGMENT_LENGTH),p=this.findSegment(e+PLAYER_Z_FROMCAMERA),m=Util.percentRemaining(e+PLAYER_Z_FROMCAMERA,SEGMENT_LENGTH);p=Util.interpolate(p.p1.world.y,p.p2.world.y,m);m=CANVAS_HEIGHT;var q=0,t=-(l.curve*g),v=b*ROAD_WIDTH,r=p+CAMERA_HEIGHT;for(p=
0;p<DRAW_DISTANCE;p++){g=k[(l.index+p)%k.length];g.looped=g.index<l.index;g.clip=m;var x=e-(g.looped?d:0);Util.project(g.p1,v-q,r,x,f);Util.project(g.p2,v-q-t,r,x,f);q+=t;t+=g.curve;g.p1.camera.z<=f||g.p2.screen.y>=g.p1.screen.y||g.p2.screen.y>=m||(Render.segment(a,CANVAS_WIDTH,NUM_LANES,g.p1.screen.x,g.p1.screen.y,g.p1.screen.w,g.p2.screen.x,g.p2.screen.y,g.p2.screen.w,g.color),m=g.p2.screen.y)}v=0;for(p=DRAW_DISTANCE-1;0<p;p--){g=k[(l.index+p)%k.length];for(q=0;q<g.cars.length;q++){m=g.cars[q];
t=m.getZ()-e;r=m.getOffset()-b;t>CAR_FARVIEW_OFFSET?g.curve>-CAR_CURVEVIEW_OFFSET&&g.curve<CAR_CURVEVIEW_OFFSET?m.setDirection(CAR_CENTER):g.curve<CAR_CURVEVIEW_OFFSET?m.setDirection(CAR_LEFT):m.setDirection(CAR_RIGHT):r>-CAR_SIDEVIEW_OFFSET&&m.getOffset()-b<CAR_SIDEVIEW_OFFSET?m.setDirection(CAR_CENTER):r<-CAR_SIDEVIEW_OFFSET?m.setDirection(CAR_RIGHT):m.setDirection(CAR_LEFT);t=m.getSprite();r=Util.interpolate(g.p1.screen.scale,g.p2.screen.scale,m.getPercent());x=Util.interpolate(g.p1.screen.x,g.p2.screen.x,
m.getPercent())+r*m.getOffset()*ROAD_PER_HALF_CANVAS_WIDTH;var n=Util.interpolate(g.p1.screen.y,g.p2.screen.y,m.getPercent());m.setVisible(!0);c.setChildIndex(m.getCar(),v++);Render.sprite(t,m.getCar(),r,x,n,-.5,-1,g.clip)}for(q=0;q<g.sprites.length;q++)t=g.sprites[q],r=g.p1.screen.scale,x=g.p1.screen.x+r*t.offset*ROAD_PER_HALF_CANVAS_WIDTH,n=g.p1.screen.y,t.source.visible=!0,c.setChildIndex(t.source,v++),Render.sprite(t.sprite,t.source,r,x,n,0>t.offset?-1:0,-1,g.clip)}e=(l.index-25)%k.length;if(0<
e)for(b=0;25>b;b++){g=k[e+b];for(q=0;q<g.sprites.length;q++)t=g.sprites[q],t.source.visible=!1;for(q=0;q<g.cars.length;q++)m=g.cars[q],m.setVisible(!1)}else for(b=k.length+e-1;b<k.length;b++){g=k[b];for(q=0;q<g.sprites.length;q++)t=g.sprites[q],t.source.visible=!1;for(q=0;q<g.cars.length;q++)m=g.cars[q],m.setVisible(!1)}};this.exponentialFog=function(a,b){return 1/Math.pow(Math.E,a*a*b)};this.getTrackLength=function(){return d};this.getSegments=function(){return k};this._init(a,c,b)}
var CAR_CENTER=0,CAR_LEFT=1,CAR_RIGHT=2;
function CCar(a,c,b,d,f){var k,e,h,l,g,p,m;this._init=function(a,b,c,d,f){k=b;e=c;h=d;g=[];g[CAR_CENTER]=s_oSpriteLibrary.getSprite(a+"_center");g[CAR_LEFT]=s_oSpriteLibrary.getSprite(a+"_left");g[CAR_RIGHT]=s_oSpriteLibrary.getSprite(a+"_right");m=g[CAR_CENTER];p=createBitmap(m);p.x=500;p.visible=!1;f.addChild(p)};this.getCar=function(){return p};this.getSprite=function(){return m};this.getOffset=function(){return k};this.getZ=function(){return e};this.getSpeed=function(){return h};this.getPercent=
function(){return l};this.setDirection=function(a){m=g[a];p.image=g[a]};this.setVisible=function(a){p.visible=a};this.updateCarOffset=function(a,b){var c,e;var d=q.getSprite().width*SPRITES.SCALE;if(a.index-b.getPlayerSegment().index>DRAW_DISTANCE)return p.visible=!1,0;for(c=1;20>c;c++){var f=s_oGame.getSegments();var g=f[(a.index+c)%f.length];if(g===b.getPlayerSegment()&&h>b.getCurSpeed()&&Util.overlap(b.getPosition().x,b.getPlayerWidth(),k,d,1.2))return d=.5<b.getPosition().x?-1:-.5>b.getPosition().x?
1:k>b.getPosition().x?1:-1,1*d/c*(h-b.getCurSpeed())/b.getMaxSpeed();for(e=0;e<g.cars.length;e++){f=g.cars[e];var l=f.getSprite().width*SPRITES.SCALE;if(h>f.getSpeed()&&Util.overlap(k,d,f.getOffset(),l,1.2))return d=.5<f.getOffset()?-1:-.5>f.getOffset()?1:k>f.getOffset()?1:-1,1*d/c*(h-f.getSpeed())/b.getMaxSpeed()}}return-.9>k?.1:.9<k?-.1:0};this.update=function(a,b){var c=s_oGame.findSegment(e);k+=this.updateCarOffset(c,b);e=Util.increase(e,a*h,TRACK_LENGTH);l=Util.percentRemaining(e,SEGMENT_LENGTH);
var d=s_oGame.findSegment(e);if(c!==d){var f=c.cars.indexOf(q);c.cars.splice(f,1);d.cars.push(q)}};var q=this;this._init(a,c,b,d,f)}
function CLevelBuilder(a,c,b,d){var f;this._init=function(a,b,c,d){f=LEVEL_INFO[d].num_cars;this._initTerrainInfo();this._initFinishLane();this._initSprites();this._initCars()};this._attachSprites=function(){for(var a=0;a<s_oGame.getSegments().length;a++)for(var c=s_oGame.getSegments()[a].sprites,d=0;d<c.length;d++)b.addChildAt(c[d].source,0)};this._addSprite=function(a,b,c){if(void 0!==s_oGame.getSegments()[a]){var d=s_oSpriteLibrary.getSprite(b.name),e=createBitmap(d);e.visible=!1;b.name===SPRITES.SIGN_INDICATION.name&&
(e.regX=d.width/2);var f=d.width*SPRITES.SCALE,h=c+f/2*(0<c?1:-1);b.collision&&(b.collision.center&&(h=c+(0<c?b.collision.center:-(d.width-b.collision.center))*SPRITES.SCALE),b.collision.width&&(f=b.collision.width*SPRITES.SCALE));s_oGame.getSegments()[a].sprites.push({source:e,offset:c,sprite:d,collision:{center:h,width:f}})}};this._addDensityElements=function(a,b,c,d,f,p,m){p=p||100;m=m||1;if(a===AMBIENT.SIDE.BOTH)this._addDensityElements(AMBIENT.SIDE.RIGHT,b,c,d,f,p,m),this._addDensityElements(AMBIENT.SIDE.LEFT,
b,c,d,f,p,m);else for(;c<=d;c+=m)if(100*Math.random()<=p){var e=c+Util.randomInt(0,5);this._addSprite(e,b,a+a*f+2*a*Math.random())}};this._addPreciseElements=function(a,b,c,d,f,p,m){p=p||100;m=m||1;if(a===AMBIENT.SIDE.BOTH)this._addPreciseElements(AMBIENT.SIDE.RIGHT,b,c,d,f,p,m),this._addPreciseElements(AMBIENT.SIDE.LEFT,b,c,d,f,p,m);else for(;c<=d;c+=m)100*Math.random()<=p&&this._addSprite(c,b,a+a*f)};this._initSprites=function(){var a,b=AMBIENT_INFO[d];for(a=0;a<b.length;a++){var c=b[a];if(c.segments.constructor===
Array){var f=c.segments[0];var g=c.segments[1]}else g=f=c.segments;switch(c.disposition){case AMBIENT.DISPOSITION.PRECISE:this._addPreciseElements(c.side,c.sprite,f,g,c.position,c.occurrence,c.repetitionevery);break;case AMBIENT.DISPOSITION.DENSITY:this._addDensityElements(c.side,c.sprite,f,g,c.position,c.occurrence,c.repetitionevery)}}this._attachSprites()};this._initFinishLane=function(){var a=s_oSpriteLibrary.getSprite("finish"),b=createBitmap(a);b.visible=!1;b.regX=a.width/2;s_oGame.getSegments()[s_oGame.getSegments().length-
1].sprites.push({source:b,offset:0,sprite:a})};this._initCars=function(){var d;for(d=0;d<f;d++){var e=Math.random()*Util.randomChoice([-.8,.8]);var h=Math.floor(Math.random()*s_oGame.getSegments().length)*SEGMENT_LENGTH;var l=Util.randomChoice(SPRITES.CARS);var g=a.getMaxSpeed()/4+Math.random()*a.getMaxSpeed()/(l==SPRITES.SEMI?4:2);e=new CCar(l,e,h,g,b);h=s_oGame.findSegment(h);h.cars.push(e);c.push(e)}};this._initTerrainInfo=function(){COLORS.LIGHT.road=LEVEL_INFO[d].terrain.color.light.road;COLORS.LIGHT.grass=
LEVEL_INFO[d].terrain.color.light.grass;COLORS.LIGHT.rumble=LEVEL_INFO[d].terrain.color.light.rumble;COLORS.LIGHT.lane=LEVEL_INFO[d].terrain.color.light.lane;COLORS.DARK.road=LEVEL_INFO[d].terrain.color.dark.road;COLORS.DARK.grass=LEVEL_INFO[d].terrain.color.dark.grass;COLORS.DARK.rumble=LEVEL_INFO[d].terrain.color.dark.rumble;TERRAIN_ADHERENCE=LEVEL_INFO[d].terrain.adherence;TERRAIN_MAX_INERTIA=LEVEL_INFO[d].terrain.max_inertia;NUM_LANES=LEVEL_INFO[d].terrain.num_lanes;ROAD_BOUNDS=LEVEL_INFO[d].terrain.roadbounds};
this._init(a,c,b,d)}
function CWorldMenu(){var a,c,b,d,f,k,e,h,l,g,p,m,q,t,v,r=null,x=null;this._init=function(){p=createBitmap(s_oSpriteLibrary.getSprite("bg_select"));s_oStage.addChild(p);var n=new createjs.Text(TEXT_SELECT_WORLD," 40px "+PRIMARY_FONT,"#000000");n.x=CANVAS_WIDTH/2;n.y=250;n.textAlign="center";n.textBaseline="middle";n.lineWidth=600;n.outline=5;s_oStage.addChild(n);var u=new createjs.Text(TEXT_SELECT_WORLD," 40px "+PRIMARY_FONT,"#ffffff");u.x=n.x;u.y=n.y;u.textAlign="center";u.textBaseline="middle";
u.lineWidth=600;s_oStage.addChild(u);l=[];for(n=0;n<NUM_WORLDS*NUM_TRACKS_PER_WORLD;n++)l[n]=s_aTimeScore[n];g=[];for(n=0;n<NUM_WORLDS;n++){u=s_oSpriteLibrary.getSprite("but_world"+n);var y=CANVAS_WIDTH/2-250+500/(NUM_WORLDS-1)*n,z=s_oSpriteLibrary.getSprite("image_"+n),D=s_oSpriteLibrary.getSprite("cover_"+n);g[n]=new CLevelBut(y,CANVAS_HEIGHT/2,u,D,z,s_oStage);g[n].addEventListenerWithParams(ON_MOUSE_UP,this._onLevelBut,this,n);g[n].disable()}this._setLevelActive();n=s_oSpriteLibrary.getSprite("but_exit");
e=CANVAS_WIDTH-n.width/2-12;h=n.height/2+16;m=new CGfxButton(e,h,n,s_oStage);m.addEventListener(ON_MOUSE_UP,this._onExit,this);b=e-n.width-12;d=n.height/2+16;if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)n=s_oSpriteLibrary.getSprite("audio_icon"),t=new CToggle(b,d,n,s_bAudioActive),t.addEventListener(ON_MOUSE_UP,this._onAudioToggle,this);n=window.document;u=n.documentElement;r=u.requestFullscreen||u.mozRequestFullScreen||u.webkitRequestFullScreen||u.msRequestFullscreen;x=n.exitFullscreen||n.mozCancelFullScreen||
n.webkitExitFullscreen||n.msExitFullscreen;!1===ENABLE_FULLSCREEN&&(r=!1);r&&screenfull.enabled&&(n=s_oSpriteLibrary.getSprite("but_fullscreen"),a=n.width/4+12,c=n.height/2+16,v=new CToggle(a,c,n,s_bFullscreen,s_oStage),v.addEventListener(ON_MOUSE_UP,this._onFullscreenRelease,this));f=64;k=CANVAS_HEIGHT-40;q=new createjs.Container;q.x=f;q.y=k;s_oStage.addChild(q);n=new createjs.Text(" "+s_iTotalScore,"bold 30px "+PRIMARY_FONT,"#000000");n.textAlign="left";n.textBaseline="middle";n.lineWidth=500;n.outline=
5;q.addChild(n);n=new createjs.Text(" "+s_iTotalScore,"bold 30px "+PRIMARY_FONT,"#ffffff");n.textAlign="left";n.textBaseline="middle";n.lineWidth=500;q.addChild(n);n=s_oSpriteLibrary.getSprite("star");u=createBitmap(n);u.regX=n.width/2;u.regY=n.height/2;u.x=-n.width/2;q.addChild(u);this.refreshButtonPos(s_iOffsetX,s_iOffsetY)};this.refreshButtonPos=function(g,l){m.setPosition(e-g,l+h);!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||t.setPosition(b-g,l+d);r&&screenfull.enabled&&v.setPosition(a+g,c+l);q.x=
f+g;q.y=k-l};this.unload=function(){for(var a=0;a<g.length;a++)g[a].unload();s_oWorldMenu=null;s_oStage.removeAllChildren();if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)t.unload(),t=null;r&&screenfull.enabled&&v.unload()};this._setLevelActive=function(){for(var a=0,b=0;b<l.length;b++)0<l[b]&&(a=b+1);if(a===NUM_TRACKS_PER_WORLD*g.length)for(b=0;b<g.length;b++)g[b].enable();else{a=Math.floor(a/NUM_TRACKS_PER_WORLD);for(b=0;b<a+1;b++)g[b].enable();g[a].pulseAnimation()}};this._onLevelBut=function(a){var b=
a*NUM_TRACKS_PER_WORLD;new CTrackMenu(a,[l[b],l[b+1],l[b+2]])};this.resetFullscreenBut=function(){r&&screenfull.enabled&&v.setActive(s_bFullscreen)};this._onFullscreenRelease=function(){s_bFullscreen?x.call(window.document):r.call(window.document.documentElement);sizeHandler()};this._onAudioToggle=function(){Howler.mute(s_bAudioActive);s_bAudioActive=!s_bAudioActive};this._onExit=function(){$(s_oMain).trigger("end_session");this.unload();s_oMain.gotoMenu()};s_oWorldMenu=this;this._init()}
var s_oWorldMenu=null;
function CTrackMenu(a,c){var b,d,f,k,e;this._init=function(a,c){f=new createjs.Shape;f.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);f.alpha=0;f.on("mousedown",function(){});s_oStage.addChild(f);(new createjs.Tween.get(f)).to({alpha:.7},500);e=new createjs.Container;s_oStage.addChild(e);var g=s_oSpriteLibrary.getSprite("msg_box"),h=createBitmap(g);h.regX=g.width/2;h.regY=g.height/2;e.addChild(h);h=new createjs.Text(TEXT_SELECT_TRACK,"bold 40px "+PRIMARY_FONT,"#000000");h.y=
-g.height/2+90;h.textAlign="center";h.textBaseline="middle";h.lineWidth=400;h.outline=5;e.addChild(h);var l=new createjs.Text(TEXT_SELECT_TRACK,"bold 40px "+PRIMARY_FONT,"#ffffff");l.y=h.y;l.textAlign="center";l.textBaseline="middle";l.lineWidth=400;e.addChild(l);e.x=CANVAS_WIDTH/2;e.y=CANVAS_HEIGHT+g.height/2+70;b=e.y;(new createjs.Tween.get(e)).to({y:CANVAS_HEIGHT/2},500,createjs.Ease.quartIn);g=s_oSpriteLibrary.getSprite("but_level");h=s_oSpriteLibrary.getSprite("image_"+a);l=s_oSpriteLibrary.getSprite("cover_"+
a);d=[];for(var q=0;q<NUM_TRACKS_PER_WORLD;q++){var t=q+1;d[q]=new CLevelBut(-180+180*q,0,g,l,h,e);d[q].addEventListenerWithParams(ON_MOUSE_UP,this._onStageBut,this,q);d[q].addLevelText(t);d[q].disable()}this._setStageInfo();g=s_oSpriteLibrary.getSprite("but_exit");k=new CGfxButton(326,-200,g,e);k.addEventListener(ON_MOUSE_UP,this._onBack,this)};this.unload=function(){for(var a=0;a<NUM_TRACKS_PER_WORLD;a++)d[a].unload();f.off("mousedown",function(){});s_oStage.removeChild(f);s_oStage.removeChild(e)};
this._setStageInfo=function(){for(var b=0,e=0;e<c.length;e++)0<c[e]&&(b=e+1);b<NUM_TRACKS_PER_WORLD&&(d[b].enable(),d[b].addScore(LEVEL_INFO[a*NUM_TRACKS_PER_WORLD+b].time),d[b].pulseAnimation());for(e=0;e<b;e++)d[e].enable(),d[e].addScore(c[e])};this._onStageBut=function(b){this.unload();s_oWorldMenu.unload();s_oMain.gotoGame(a*NUM_TRACKS_PER_WORLD+b)};this._onBack=function(){for(var a=0;3>a;a++)d[a].setClickable();k.setClickable();var c=this;(new createjs.Tween.get(f)).to({alpha:0},500);(new createjs.Tween.get(e)).to({y:b},
400,createjs.Ease.backIn).call(function(){c.unload()})};this._init(a,c)}
function CLevelBut(a,c,b,d,f,k){var e,h,l,g,p=[],m,q,t,v,r=null,x=null,n;this._init=function(a,b,c,f){e=!1;h=1;l=[];g=[];m=new createjs.Container;m.x=a;m.y=b;m.scaleX=m.scaleY=h;f.addChild(m);q=new createjs.Container;q.x=a;q.y=b;q.scaleX=m.scaleY=h;f.addChild(q);a=c.width/2;b=c.height;c=new createjs.SpriteSheet({images:[c],frames:{width:a,height:b,regX:a/2,regY:b/2},animations:{on:[0],off:[1]}});n=createSprite(c,"on",a/2,b/2,a,b);m.addChild(n);d?n.gotoAndStop("on"):n.gotoAndStop("off");this._initListener()};
this.unload=function(){s_bMobile?m.off("mousedown",this.buttonDown):(m.off("mousedown",this.buttonDown),m.off("mouseover",this.buttonOver));m.off("pressup",this.buttonRelease);k.removeChild(m)};this.setVisible=function(a){m.visible=a};this.enable=function(){n.gotoAndStop("on");e=!1;null!==x&&(r.color="#000000",x.color="#ffffff")};this.disable=function(){e=!0;n.gotoAndStop("off");null!==x&&(r.color="#000000",x.color="#a8a8a8")};this.setClickable=function(a){e=!a};this.addInfo=function(a){t=new createjs.Text(a,
" 24px "+PRIMARY_FONT,"#000000");t.x=b.height/2-24;t.y=-b.height/2+10;t.textAlign="center";t.textBaseline="middle";t.lineWidth=200;t.outline=4;t.rotation=30;m.addChild(t);v=new createjs.Text(a," 24px "+PRIMARY_FONT,"#ffffff");v.x=t.x;v.y=t.y;v.textAlign="center";v.textBaseline="middle";v.lineWidth=200;v.rotation=t.rotation;m.addChild(v)};this.addScore=function(a){var c=new createjs.Text(formatTime(a)," 30px "+PRIMARY_FONT,"#000000");c.y=b.height/2+12;c.textAlign="center";c.textBaseline="middle";c.lineWidth=
200;c.outline=4;q.addChild(c);a=new createjs.Text(formatTime(a)," 30px "+PRIMARY_FONT,"#ffffff");a.y=c.y;a.textAlign="center";a.textBaseline="middle";a.lineWidth=200;q.addChild(a)};this.addLevelText=function(a){r=new createjs.Text(a," 80px "+PRIMARY_FONT,"#000000");r.y=2;r.textAlign="center";r.textBaseline="middle";r.lineWidth=200;r.outline=8;m.addChild(r);x=new createjs.Text(a," 80px "+PRIMARY_FONT,"#ffd800");x.y=2;x.textAlign="center";x.textBaseline="middle";x.lineWidth=200;m.addChild(x)};this._initListener=
function(){if(s_bMobile)m.on("mousedown",this.buttonDown);else m.on("mousedown",this.buttonDown),m.on("mouseover",this.buttonOver);m.on("pressup",this.buttonRelease)};this.addEventListener=function(a,b,c){l[a]=b;g[a]=c};this.addEventListenerWithParams=function(a,b,c,d){l[a]=b;g[a]=c;p=d};this.buttonRelease=function(){e||(m.scaleX=h,m.scaleY=h,l[ON_MOUSE_UP]&&l[ON_MOUSE_UP].call(g[ON_MOUSE_UP],p))};this.buttonDown=function(){e||(playSound("click",1,0),m.scaleX=.9*h,m.scaleY=.9*h,l[ON_MOUSE_DOWN]&&
l[ON_MOUSE_DOWN].call(g[ON_MOUSE_DOWN],p))};this.buttonOver=function(a){s_bMobile||e||(a.target.cursor="pointer")};this.pulseAnimation=function(){createjs.Tween.get(m).to({scaleX:1.1*h,scaleY:1.1*h},850,createjs.Ease.quadOut).to({scaleX:h,scaleY:h},650,createjs.Ease.quadIn).call(function(){u.pulseAnimation()})};this.trembleAnimation=function(){createjs.Tween.get(m).to({rotation:5},75,createjs.Ease.quadOut).to({rotation:-5},140,createjs.Ease.quadIn).to({rotation:0},75,createjs.Ease.quadIn).wait(750).call(function(){u.trebleAnimation()})};
this.setImage=function(a){};this.setPosition=function(a,b){m.x=a;m.y=b};this.setScale=function(a){h=a;m.scaleX=m.scaleY=a};this.setX=function(a){m.x=a};this.setY=function(a){m.y=a};this.getButtonImage=function(){return m};this.getX=function(){return m.x};this.getY=function(){return m.y};var u=this;this._init(a,c,b,k);return this}var ROAD_INFO=[],AMBIENT_INFO=[],LEVEL_INFO=[];
ROAD_INFO[0]=[{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:ROAD.CURVE.EASY},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.EASY},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:-ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,
curve:ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:-ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:-ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:ROAD.CURVE.EASY},{roadtype:ROAD.TYPE.FINAL,length:ROAD.LENGTH.MEDIUM}];
LEVEL_INFO[0]={time:65E3,num_cars:10,terrain:{roadbounds:2,num_lanes:3,adherence:1,max_inertia:.03,color:{light:{road:"#6B6B6B",grass:"#96a54b",rumble:"#555555",lane:"#CCCCCC"},dark:{road:"#696969",grass:"#7e8b3e",rumble:"#BBBBBB"}}}};
AMBIENT_INFO[0]=[{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.TREE1,segments:[0,800],position:0,occurrence:30,repetitionevery:1,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.TREE1,segments:[800,1200],position:0,occurrence:30,repetitionevery:2,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BUSH1,segments:[1E3,1200],position:0,occurrence:10,repetitionevery:1,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BUSH1,
segments:[1200,2E3],position:0,occurrence:10,repetitionevery:3,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BUSH2,segments:[1600,2600],position:0,occurrence:10,repetitionevery:3,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.TREE1,segments:[1200,4E3],position:.5,occurrence:10,repetitionevery:3,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.TREE1,segments:[2E3,4E3],position:.5,occurrence:30,repetitionevery:3,
disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BILLBOARD03,segments:400,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BILLBOARD01,segments:1200,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BILLBOARD01,segments:[3E3,3200],position:0,repetitionevery:30,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BOULDER,segments:1800,position:1,disposition:AMBIENT.DISPOSITION.PRECISE}];
ROAD_INFO[1]=[{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:ROAD.CURVE.EASY},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:-ROAD.CURVE.EASY},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG},{roadtype:ROAD.TYPE.CURVE_S,length:ROAD.LENGTH.LONG,curve:ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,
curve:ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.CURVE_S,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.FINAL,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.MEDIUM}];LEVEL_INFO[1]={time:7E4,num_cars:15,terrain:{roadbounds:2,num_lanes:3,adherence:1,max_inertia:.03,color:{light:{road:"#6B6B6B",grass:"#96a54b",rumble:"#555555",lane:"#CCCCCC"},dark:{road:"#696969",grass:"#7e8b3e",rumble:"#BBBBBB"}}}};
AMBIENT_INFO[1]=[{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.TREE2,segments:[0,450],position:0,occurrence:30,repetitionevery:2,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BUSH2,segments:[0,450],position:0,occurrence:30,repetitionevery:2,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BOULDER,segments:[0,450],position:0,occurrence:10,repetitionevery:3,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BILLBOARD02,
segments:[350,450],position:0,repetitionevery:30,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.TREE2,segments:[450,1500],position:0,occurrence:40,repetitionevery:2,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BUSH2,segments:[450,1500],position:0,occurrence:30,repetitionevery:4,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BILLBOARD04,segments:[900,1200],position:0,repetitionevery:50,disposition:AMBIENT.DISPOSITION.PRECISE},
{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BILLBOARD04,segments:[925,1225],position:0,repetitionevery:50,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.TREE2,segments:[1500,3800],position:1,occurrence:20,repetitionevery:4,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BOULDER,segments:[1500,2800],position:0,occurrence:10,repetitionevery:10,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.STUMP,segments:[1500,
2800],position:0,occurrence:10,repetitionevery:15,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.TREE1,segments:[2400,3200],position:0,occurrence:30,repetitionevery:5,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BUSH2,segments:[3200,3800],position:0,occurrence:20,repetitionevery:4,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BILLBOARD03,segments:1700,position:5,disposition:AMBIENT.DISPOSITION.PRECISE},
{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BILLBOARD01,segments:2E3,position:4,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BILLBOARD04,segments:2300,position:5,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BILLBOARD02,segments:2600,position:6,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BILLBOARD03,segments:2900,position:3,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BILLBOARD03,
segments:3650,position:0,disposition:AMBIENT.DISPOSITION.PRECISE}];
ROAD_INFO[2]=[{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,curve:-ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,curve:ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,curve:-ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.HARD},
{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:-ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:-ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,curve:ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,
curve:-ROAD.CURVE.EASY},{roadtype:ROAD.TYPE.FINAL,length:ROAD.LENGTH.MEDIUM}];LEVEL_INFO[2]={time:7E4,num_cars:15,terrain:{roadbounds:2,num_lanes:3,adherence:1,max_inertia:.03,color:{light:{road:"#6B6B6B",grass:"#96a54b",rumble:"#555555",lane:"#CCCCCC"},dark:{road:"#696969",grass:"#7e8b3e",rumble:"#BBBBBB"}}}};
AMBIENT_INFO[2]=[{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.TREE2,segments:[0,700],position:0,occurrence:30,repetitionevery:3,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.TREE1,segments:[0,1700],position:0,occurrence:30,repetitionevery:4,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BUSH1,segments:[480,1700],position:0,occurrence:30,repetitionevery:4,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.TREE1,
segments:[1700,2300],position:0,occurrence:20,repetitionevery:5,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.DEAD_TREE,segments:[1700,2700],position:0,occurrence:40,repetitionevery:5,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.DEAD_TREE,segments:[2300,3700],position:0,occurrence:40,repetitionevery:5,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.TREE1,segments:[3400,3700],position:0,occurrence:20,
repetitionevery:6,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BOULDER,segments:[1500,3700],position:0,occurrence:10,repetitionevery:16,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BILLBOARD01,segments:[1700,2E3],position:0,repetitionevery:60,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BILLBOARD01,segments:[1725,2025],position:0,repetitionevery:60,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,
sprite:SPRITES.BILLBOARD03,segments:1300,position:0,repetitionevery:60,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BILLBOARD05,segments:[2400,2800],position:0,repetitionevery:60,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BILLBOARD01,segments:[3100,3400],position:.5,repetitionevery:50,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BILLBOARD05,segments:2300,position:0,repetitionevery:60,disposition:AMBIENT.DISPOSITION.PRECISE}];
ROAD_INFO[3]=[{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,curve:-ROAD.CURVE.EASY},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,curve:ROAD.CURVE.EASY,hill:ROAD.HILL.LOW},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,curve:-ROAD.CURVE.EASY,hill:ROAD.HILL.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,curve:-ROAD.CURVE.MEDIUM,hill:ROAD.HILL.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,
curve:ROAD.CURVE.MEDIUM,hill:ROAD.HILL.MEDIUM},{roadtype:ROAD.TYPE.FINAL,length:ROAD.LENGTH.LONG}];LEVEL_INFO[3]={time:73E3,num_cars:20,terrain:{roadbounds:2,num_lanes:2,adherence:.5,max_inertia:0,color:{light:{road:"#d5c95f",grass:"#f4e77a",rumble:"#a76b24",lane:"#a76b24"},dark:{road:"#dbce64",grass:"#ebde6f",rumble:"#a76b24"}}}};
AMBIENT_INFO[3]=[{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.PALM_TREE,segments:[0,800],position:0,repetitionevery:16,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.PALM_TREE,segments:[0,800],position:0,repetitionevery:13,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.PALM_TREE,segments:[800,1600],position:2,occurrence:20,repetitionevery:20,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.CACTUS1,segments:[1400,
2600],position:.5,occurrence:20,repetitionevery:5,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BOULDER,segments:[0,2800],position:2,occurrence:10,repetitionevery:13,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BILLBOARD01,segments:[2200,2500],position:0,repetitionevery:60,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BILLBOARD02,segments:[2800,3200],position:0,repetitionevery:60,disposition:AMBIENT.DISPOSITION.PRECISE}];
ROAD_INFO[4]=[{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,hill:ROAD.HILL.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.BUMPS,length:ROAD.LENGTH.SHORT/2,curve:-ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.BUMPS,length:ROAD.LENGTH.SHORT/2,curve:ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.CURVE_S,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.HARD,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.CURVE_S,length:ROAD.LENGTH.LONG,curve:-ROAD.CURVE.MEDIUM,
hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.FINAL,length:ROAD.LENGTH.LONG}];LEVEL_INFO[4]={time:78E3,num_cars:20,terrain:{roadbounds:2,num_lanes:2,adherence:.5,max_inertia:0,color:{light:{road:"#f4e77a",grass:"#f4e77a",rumble:"#a76b24",lane:"#a76b24"},dark:{road:"#ebde6f",grass:"#ebde6f",rumble:"#a76b24"}}}};
AMBIENT_INFO[4]=[{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BOULDER,segments:[0,3900],position:2,occurrence:10,repetitionevery:20,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BOULDER,segments:[0,3900],position:5,occurrence:5,repetitionevery:60,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BILLBOARD04,segments:770,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.COLUMN,segments:[780,1400],position:0,
repetitionevery:14,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.CACTUS1,segments:[1800,3200],position:5,occurrence:30,repetitionevery:15,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BILLBOARD04,segments:1650,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BILLBOARD02,segments:2E3,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.CACTUS1,segments:[2400,
3600],position:0,occurrence:70,repetitionevery:15,disposition:AMBIENT.DISPOSITION.DENSITY}];
ROAD_INFO[5]=[{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,hill:ROAD.HILL.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,hill:ROAD.HILL.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT/2,curve:-ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT/2,curve:ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT/2,curve:-ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,curve:ROAD.CURVE.HARD,hill:-ROAD.HILL.MEDIUM},
{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT/2,curve:ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT/2,curve:-ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT/2,curve:ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,curve:-ROAD.CURVE.HARD,hill:ROAD.HILL.MEDIUM},{roadtype:ROAD.TYPE.BUMPS,length:ROAD.LENGTH.SHORT/2},{roadtype:ROAD.TYPE.BUMPS,length:ROAD.LENGTH.SHORT,curve:-ROAD.CURVE.EASY},
{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.EASY},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:-ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,curve:-ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.FINAL,length:ROAD.LENGTH.LONG}];
LEVEL_INFO[5]={time:6E4,num_cars:25,terrain:{roadbounds:2,num_lanes:2,adherence:.5,max_inertia:0,color:{light:{road:"#f4e77a",grass:"#f4e77a",rumble:"#a76b24",lane:"#a76b24"},dark:{road:"#ebde6f",grass:"#ebde6f",rumble:"#a76b24"}}}};
AMBIENT_INFO[5]=[{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BILLBOARD05,segments:20,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BOULDER,segments:[0,3900],position:2,occurrence:10,repetitionevery:20,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BOULDER,segments:[0,3900],position:5,occurrence:5,repetitionevery:60,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.CACTUS2,segments:[40,1600],position:0,
occurrence:70,repetitionevery:10,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.CACTUS2,segments:[1600,3900],position:1,occurrence:35,repetitionevery:20,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BILLBOARD03,segments:[1500,1700],position:0,repetitionevery:40,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BILLBOARD04,segments:[1525,1725],position:0,repetitionevery:40,disposition:AMBIENT.DISPOSITION.PRECISE},
{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BOULDER,segments:[2200,2650],position:0,occurrence:70,repetitionevery:10,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BOULDER,segments:[2200,2650],position:0,occurrence:40,repetitionevery:8,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BOULDER,segments:[2200,2650],position:0,occurrence:30,repetitionevery:7,disposition:AMBIENT.DISPOSITION.DENSITY}];
ROAD_INFO[6]=[{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,curve:ROAD.CURVE.HARD,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.MEDIUM,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.HARD,hill:-ROAD.HILL.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,
length:ROAD.LENGTH.MEDIUM,hill:-ROAD.HILL.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,curve:ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,curve:ROAD.CURVE.VERYHARD,hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,curve:-ROAD.CURVE.VERYHARD,hill:-ROAD.HILL.LOW},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,hill:-ROAD.HILL.LOW},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,curve:ROAD.CURVE.VERYHARD,hill:-ROAD.HILL.MEDIUM},
{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG},{roadtype:ROAD.TYPE.FINAL,length:ROAD.LENGTH.LONG}];LEVEL_INFO[6]={time:9E4,num_cars:60,terrain:{roadbounds:2,num_lanes:4,adherence:1,max_inertia:.03,color:{light:{road:"#2a2a2a",grass:"#010e18",rumble:"#2a2a2a",lane:"#ffffff"},dark:{road:"#2a2a2a",grass:"#00080e",rumble:"#ffffff"}}}};
AMBIENT_INFO[6]=[{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.HOUSE1,segments:[0,5E3],position:5,occurrence:20,repetitionevery:100,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.SIGN_INDICATION,segments:[900,5E3],position:-1,repetitionevery:900,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.SIGN_CURVE_RIGHT,segments:[3845,3900],position:.3,repetitionevery:10,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.SIGN_CURVE_RIGHT,
segments:[2100,2550],position:.3,repetitionevery:10,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.SIGN_CURVE_LEFT,segments:[2700,3150],position:.3,repetitionevery:10,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.LAMP_LEFT,segments:[300,850],position:0,repetitionevery:30,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.LAMP_RIGHT,segments:[300,850],position:0,repetitionevery:30,disposition:AMBIENT.DISPOSITION.PRECISE},
{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.LAMP_LEFT,segments:[3950,4500],position:0,repetitionevery:30,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.LAMP_RIGHT,segments:[3965,4500],position:0,repetitionevery:30,disposition:AMBIENT.DISPOSITION.PRECISE}];
ROAD_INFO[7]=[{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:ROAD.CURVE.MEDIUM,hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.MEDIUM},
{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.HARD},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.HARD,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.HARD,hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.VERYHARD,
hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.VERYHARD,hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.VERYHARD,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.VERYHARD,hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.VERYHARD,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.VERYHARD,
hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:-ROAD.CURVE.VERYHARD,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:ROAD.CURVE.VERYHARD,hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,curve:-ROAD.CURVE.VERYHARD,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,curve:ROAD.CURVE.VERYHARD,hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.FINAL,length:ROAD.LENGTH.LONG}];
LEVEL_INFO[7]={time:11E4,num_cars:70,terrain:{roadbounds:2,num_lanes:4,adherence:1,max_inertia:.03,color:{light:{road:"#2a2a2a",grass:"#010e18",rumble:"#2a2a2a",lane:"#ffffff"},dark:{road:"#2a2a2a",grass:"#00080e",rumble:"#ffffff"}}}};
AMBIENT_INFO[7]=[{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.LAMP_LEFT,segments:[0,5E3],position:0,repetitionevery:30,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.LAMP_RIGHT,segments:[15,5E3],position:0,repetitionevery:30,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.HOUSE1,segments:[50,5E3],position:5,occurrence:20,repetitionevery:100,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.HOUSE2,segments:[0,
5E3],position:5,occurrence:20,repetitionevery:100,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.SIGN_INDICATION,segments:[1100,5E3],position:-1,repetitionevery:1100,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BILLBOARD01,segments:[10,650],position:0,repetitionevery:60,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.SIGN_CURVE_LEFT,segments:[3070,3270],position:.3,repetitionevery:10,disposition:AMBIENT.DISPOSITION.PRECISE},
{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.SIGN_CURVE_RIGHT,segments:[3400,3570],position:.3,repetitionevery:10,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.SIGN_CURVE_LEFT,segments:[3700,4100],position:.3,repetitionevery:10,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.SIGN_CURVE_RIGHT,segments:[4300,4700],position:.3,repetitionevery:10,disposition:AMBIENT.DISPOSITION.PRECISE}];
ROAD_INFO[8]=[{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.MEDIUM,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,curve:-ROAD.CURVE.MEDIUM,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,
curve:ROAD.CURVE.HARD,hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.MEDIUM,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.MEDIUM,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,hill:ROAD.HILL.VERYHIGH},{roadtype:ROAD.TYPE.STANDARD,
length:ROAD.LENGTH.SHORT,curve:ROAD.CURVE.MEDIUM,hill:ROAD.HILL.VERYHIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:ROAD.CURVE.HARD,hill:ROAD.HILL.VERYHIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.VERYHARD,hill:-ROAD.HILL.VERYHIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,curve:-ROAD.CURVE.VERYHARD,hill:ROAD.HILL.VERYHIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,curve:-ROAD.CURVE.EASY,hill:ROAD.HILL.VERYHIGH},{roadtype:ROAD.TYPE.STANDARD,
length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.VERYHARD,hill:-ROAD.HILL.VERYHIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,curve:-ROAD.CURVE.EASY},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.MEDIUM},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.MEDIUM,hill:-ROAD.HILL.HIGH},
{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,curve:ROAD.CURVE.MEDIUM,hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,curve:-ROAD.CURVE.HARD,hill:ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.MEDIUM,hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:-ROAD.CURVE.MEDIUM,hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,
length:ROAD.LENGTH.SHORT,hill:-ROAD.HILL.HIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,hill:-ROAD.HILL.VERYHIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,curve:-ROAD.CURVE.MEDIUM,hill:-ROAD.HILL.VERYHIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.LONG,curve:-ROAD.CURVE.HARD,hill:-ROAD.HILL.VERYHIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.VERYHARD,hill:ROAD.HILL.VERYHIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.EXTRALONG,curve:ROAD.CURVE.VERYHARD,
hill:-ROAD.HILL.VERYHIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.SHORT,curve:ROAD.CURVE.EASY,hill:-ROAD.HILL.VERYHIGH},{roadtype:ROAD.TYPE.STANDARD,length:ROAD.LENGTH.MEDIUM,curve:ROAD.CURVE.VERYHARD,hill:ROAD.HILL.VERYHIGH},{roadtype:ROAD.TYPE.FINAL,length:ROAD.LENGTH.EXTRALONG}];
LEVEL_INFO[8]={time:13E4,num_cars:80,terrain:{roadbounds:4,num_lanes:4,adherence:1,max_inertia:.03,color:{light:{road:"#2a2a2a",grass:"#010e18",rumble:"#2a2a2a",lane:"#ffffff"},dark:{road:"#2a2a2a",grass:"#00080e",rumble:"#ffffff"}}}};
AMBIENT_INFO[8]=[{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.HOUSE2,segments:[0,7E3],position:5,occurrence:20,repetitionevery:50,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.HOUSE1,segments:[2500,3700],position:1,occurrence:40,repetitionevery:12,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.HOUSE2,segments:[2505,3700],position:1,occurrence:40,repetitionevery:12,disposition:AMBIENT.DISPOSITION.DENSITY},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.LAMP_LEFT,
segments:[0,2400],position:0,repetitionevery:30,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.LAMP_RIGHT,segments:[15,2400],position:0,repetitionevery:30,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BILLBOARD04,segments:2480,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.LAMP_LEFT,segments:[2500,3680],position:0,repetitionevery:30,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,
sprite:SPRITES.LAMP_RIGHT,segments:[2500,3680],position:0,repetitionevery:30,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.BOTH,sprite:SPRITES.BILLBOARD04,segments:3700,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.LAMP_LEFT,segments:[3750,6570],position:0,repetitionevery:30,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.LAMP_RIGHT,segments:[3765,6585],position:0,repetitionevery:30,disposition:AMBIENT.DISPOSITION.PRECISE},
{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.SIGN_INDICATION,segments:[900,6E3],position:-1,repetitionevery:900,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.SIGN_CURVE_RIGHT,segments:[1500,1700],position:.3,repetitionevery:10,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.SIGN_CURVE_LEFT,segments:[2E3,2400],position:.3,repetitionevery:10,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.SIGN_CURVE_LEFT,
segments:[4800,5E3],position:.3,repetitionevery:10,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.SIGN_CURVE_RIGHT,segments:[5100,5200],position:.3,repetitionevery:10,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.SIGN_CURVE_RIGHT,segments:[5300,5700],position:.3,repetitionevery:10,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BILLBOARD01,segments:6100,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},
{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BILLBOARD02,segments:6200,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BILLBOARD03,segments:6300,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BILLBOARD04,segments:6400,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.LEFT,sprite:SPRITES.BILLBOARD05,segments:6500,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BILLBOARD01,
segments:6150,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BILLBOARD02,segments:6250,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BILLBOARD03,segments:6350,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BILLBOARD04,segments:6450,position:0,disposition:AMBIENT.DISPOSITION.PRECISE},{side:AMBIENT.SIDE.RIGHT,sprite:SPRITES.BILLBOARD05,segments:6550,position:0,disposition:AMBIENT.DISPOSITION.PRECISE}];
function CHorizon(a){var c,b,d;this._init=function(a){c=0;d=new createjs.Container;s_oStage.addChild(d);b=[];var f=Math.floor(a/NUM_TRACKS_PER_WORLD);a="w"+f+"_bg1";f=s_oSpriteLibrary.getSprite("w"+f+"_bg0");this._addBG(f);f=s_oSpriteLibrary.getSprite(a);this._addBG(f)};this._addBG=function(a){a=new CBackground(a,d);b.push(a)};this.resetPos=function(){c=0};this.restart=function(){for(var a=0;a<b.length;a++)b[a].restart()};this.move=function(a){var d=c-a.x;b[0].moveX(d);b[1].moveX(d*PARALLAX_RATIO_X);
b[0].moveY(a.y*PARALLAX_RATIO_Y_0);b[1].moveY(a.y*PARALLAX_RATIO_Y_1);c=a.x};this._init(a)}
function CBackground(a,c){var b,d,f;this._init=function(){b=a.height/2-(CANVAS_HEIGHT-2*s_iOffsetY)/2;f=new createjs.Container;c.addChild(f);d=[];for(var k=0;2>k;k++)d[k]=createBitmap(a),d[k].regY=a.height/2,d[k].x=k*a.width,d[k].y=CANVAS_HEIGHT/2,f.addChild(d[k]),d[k].cache(0,0,a.width,a.height)};this.restart=function(){f.x=0;for(var b=f.y=0;2>b;b++)d[b].x=b*a.width,d[b].y=CANVAS_HEIGHT/2};this.moveX=function(b){f.x+=b;b=Math.floor(-f.x/a.width)*a.width;for(var c=0;2>c;c++)d[c].x=b+c*a.width};this.moveY=
function(a){a<-b&&(a=-b);a>b&&(a=b);f.y=a};this._init()}
function CNextLevelPanel(a,c,b){var d,f,k,e,h;this._init=function(a,b,c){playSound("arrive_win",1,!1);setVolume(s_aSounds.game_soundtrack,.5);k=new createjs.Shape;k.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);k.alpha=0;k.on("mousedown",function(){});s_oStage.addChild(k);(new createjs.Tween.get(k)).to({alpha:.7},500);f=new createjs.Container;s_oStage.addChild(f);var g=s_oSpriteLibrary.getSprite("msg_box"),l=createBitmap(g);l.regX=g.width/2;l.regY=g.height/2;f.addChild(l);l=
new createjs.Text(TEXT_TRACK_COMPLETED," 40px "+PRIMARY_FONT,"#000000");l.y=-g.height/2+80;l.textAlign="center";l.textBaseline="middle";l.lineWidth=500;l.outline=5;f.addChild(l);g=new createjs.Text(TEXT_TRACK_COMPLETED," 40px "+PRIMARY_FONT,"#ffffff");g.y=l.y;g.textAlign="center";g.textBaseline="middle";g.lineWidth=500;f.addChild(g);l=new createjs.Container;l.x=-220;l.y=-30;f.addChild(l);g=s_oSpriteLibrary.getSprite("timer");var m=createBitmap(g);m.regX=g.width/2;m.regY=g.height/2;l.addChild(m);g=
new createjs.Text(formatTime(LEVEL_INFO[c].time-a)," 50px "+PRIMARY_FONT,"#ffffff");g.x=34;g.textAlign="left";g.textBaseline="middle";g.lineWidth=200;l.addChild(g);a=new createjs.Container;a.x=120;a.y=l.y;f.addChild(a);g=s_oSpriteLibrary.getSprite("star");c=createBitmap(g);c.regX=g.width/2;c.regY=g.height/2;a.addChild(c);var p=new createjs.Text(0," 50px "+PRIMARY_FONT,"#ffffff");p.x=34;p.textAlign="left";p.textBaseline="middle";p.lineWidth=200;a.addChild(p);f.x=CANVAS_WIDTH/2;f.y=CANVAS_HEIGHT+g.height/
2;d=f.y;(new createjs.Tween.get(f)).to({y:CANVAS_HEIGHT/2},500,createjs.Ease.quartIn).call(function(){new CRollingText(p,b,5E3,!1)});this._sendScore();g=s_oSpriteLibrary.getSprite("but_next");e=new CGfxButton(120,100,g,f);e.addEventListener(ON_MOUSE_UP,this._onContinue,this);e.pulseAnimation();g=s_oSpriteLibrary.getSprite("but_restart");h=new CGfxButton(-120,100,g,f);h.addEventListener(ON_MOUSE_UP,this._onRestart,this)};this.unload=function(){k.off("mousedown",function(){});s_oStage.removeChild(k);
f.removeAllChildren(k);e.unload();h.unload()};this._sendScore=function(){var d=LEVEL_INFO[b].time-a;s_iTotalScore+=c;if(d<s_aTimeScore[b]||0===s_aTimeScore[b])s_aTimeScore[b]=d;s_oLocalStorage.saveData();$(s_oMain).trigger("save_score",s_iTotalScore)};this._onContinue=function(){h.setClickable(!1);e.setClickable(!1);(new createjs.Tween.get(k)).to({alpha:0},500);(new createjs.Tween.get(f)).to({y:d},400,createjs.Ease.backIn).call(function(){l.unload();s_oGame.nextLevel()})};this._onRestart=function(){h.setClickable(!1);
e.setClickable(!1);(new createjs.Tween.get(k)).to({alpha:0},500);(new createjs.Tween.get(f)).to({y:d},400,createjs.Ease.backIn).call(function(){l.unload();s_oGame.restartGame()})};this._onFinishRolling=function(){};this._onRollingRemoved=function(){};this._onRollingText=function(a){(void 0).playManualMode(a,STAR_EFFECT_SCALE)};var l=this;this._init(a,c,b)}
function CRollingText(a,c,b,d){var f=null,k;this._init=function(a,b,c){k={value:a.text};f=createjs.Tween.get(k,{override:!0}).to({value:b},c,createjs.Ease.cubicInOut).addEventListener("change",function(){a.text=d?formatTime(k.value):"+"+Math.floor(k.value)}).call(function(){createjs.Tween.removeTweens(f)})};this._init(a,c,b);return this}var LOCALSTORAGE_TIMES="times",LOCALSTORAGE_TOTALSCORE="totalscore",s_aTimeScore=[],s_iTotalScore=0;
function CLocalStorage(a){var c=!0;this._init=function(a){a=window.localStorage.getItem(a);this.resetAllData();null!==a&&void 0!==a&&this.loadData()};this.isDirty=function(){for(var a=0;a<s_aTimeScore.length;a++)if(0<s_aTimeScore[a])return!0;return!1};this.isUsed=function(){try{window.localStorage.setItem("ls_available","ok")}catch(b){c=!1}return c};this.resetAllData=function(){s_aTimeScore=[];for(var a=0;a<NUM_TRACKS_PER_WORLD*NUM_WORLDS;a++)s_aTimeScore[a]=0;s_iTotalScore=0};this.deleteData=function(){window.localStorage.removeItem(a)};
this.saveData=function(){var b={};b[LOCALSTORAGE_TIMES]=s_aTimeScore;b[LOCALSTORAGE_TOTALSCORE]=s_iTotalScore;window.localStorage.setItem(a,JSON.stringify(b))};this.loadData=function(){var b=JSON.parse(window.localStorage.getItem(a)),c=b[LOCALSTORAGE_TIMES];s_aTimeScore=[];for(var f=0;f<c.length;f++)s_aTimeScore[f]=parseInt(c[f]);s_iTotalScore=parseInt(b[LOCALSTORAGE_TOTALSCORE])};this._init(a)}
function CLosePanel(){var a,c,b,d,f;this._init=function(){setVolume(s_aSounds.game_soundtrack,.5);c=new createjs.Shape;c.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);c.alpha=0;c.on("mousedown",function(){});s_oStage.addChild(c);(new createjs.Tween.get(c)).to({alpha:.7},500);b=new createjs.Container;s_oStage.addChild(b);var e=s_oSpriteLibrary.getSprite("msg_box"),h=createBitmap(e);h.regX=e.width/2;h.regY=e.height/2;b.addChild(h);b.x=CANVAS_WIDTH/2;b.y=CANVAS_HEIGHT+e.height/
2;a=b.y;(new createjs.Tween.get(b)).to({y:CANVAS_HEIGHT/2},500,createjs.Ease.quartIn);e=s_oSpriteLibrary.getSprite("baloon_mc");h=createBitmap(e);h.regX=e.width/2;h.regY=e.height/2;h.y=-10;h.scaleX=h.scaleY=.6;b.addChild(h);h=new createjs.Text(TEXT_TIME_IS_UP," 50px "+PRIMARY_FONT,"#000000");h.y=-e.height/2+60;h.textAlign="center";h.textBaseline="middle";h.lineWidth=400;h.outline=5;b.addChild(h);e=new createjs.Text(TEXT_TIME_IS_UP," 50px "+PRIMARY_FONT,"#ffffff");e.y=h.y;e.textAlign="center";e.textBaseline=
"middle";e.lineWidth=400;b.addChild(e);e=s_oSpriteLibrary.getSprite("but_exit");d=new CGfxButton(120,100,e,b);d.addEventListener(ON_MOUSE_UP,this._onExit,this);e=s_oSpriteLibrary.getSprite("but_restart");f=new CGfxButton(-120,100,e,b);f.addEventListener(ON_MOUSE_UP,this._onRestart,this);f.pulseAnimation()};this.unload=function(){s_oStage.removeChild(b);c.off("mousedown",function(){});d.unload();f.unload()};this.show=function(){playSound("arrive_lose",1,0)};this._onExit=function(){c.off("mousedown",
function(){});s_oStage.removeChild(b);s_oGame.onExit()};this._onRestart=function(){f.setClickable(!1);d.setClickable(!1);(new createjs.Tween.get(c)).to({alpha:0},500);(new createjs.Tween.get(b)).to({y:a},400,createjs.Ease.backIn).call(function(){k.unload();s_oGame.restartGame()})};var k=this;this._init();return this}
function CTimer(a,c,b,d,f,k,e){var h,l,g;this._init=function(a,b,c,d,e,f,k){h=new createjs.Container;h.x=a;h.y=b;c.addChild(h);a=0;f&&(f=s_oSpriteLibrary.getSprite(f),a=createBitmap(f),a.regY=f.height/2,h.addChild(a),a=f.width);l=new createjs.Text("00:00"," "+d+"px "+PRIMARY_FONT,k);l.x=a+10;l.textAlign="left";l.textBaseline="middle";l.lineWidth=500;l.outline=6;h.addChild(l);g=new createjs.Text(l.text," "+d+"px "+PRIMARY_FONT,e);g.x=l.x;g.y=l.y;g.textAlign=l.textAlign;g.textBaseline=l.textBaseline;
g.lineWidth=l.lineWidth;h.addChild(g);h.regX=h.getBounds().width/2};this.setDecimalTime=function(a){a=formatTime(a);l.text=a;g.text=a};this.setIntTime=function(a){a=Math.floor(a/1E3);l.text=a;g.text=a};this.setSpeedIndicator=function(a){a=Math.floor(a);l.text=a;g.text=a};this.setAlign=function(a,b){l.textAlign=a;l.textBaseline=b;g.textAlign=l.textAlign;g.textBaseline=l.textBaseline};this.resetTextRelativePos=function(){l.x=0;l.y=0;g.x=l.x;g.y=l.y;h.regX=0};this.setPos=function(a,b){h.x=a;h.y=b};this._init(a,
c,b,d,f,k,e)}
function CTachometer(a,c){var b,d,f,k;this._init=function(a,c){b=a;d=c;f=new createjs.Container;f.x=b;f.y=d;s_oStage.addChild(f);var e=s_oSpriteLibrary.getSprite("tachometer"),g=createBitmap(e);g.regX=e.width/2;g.regY=e.height;f.addChild(g);e=new createjs.Text(TEXT_SPEED_INDICATOR," 40px "+PRIMARY_FONT,"#ffcc00");e.textAlign="center";e.textBaseline="alphabetic";e.lineWidth=300;e.y=-90;f.addChild(e);g=new createjs.Text(TEXT_SPEED_INDICATOR," 40px "+PRIMARY_FONT,"#ffcc00");g.textAlign="center";g.textBaseline=
"alphabetic";g.lineWidth=300;g.y=e.y;f.addChild(g);e=new createjs.Text("888"," 58px "+SECONDARY_FONT,"#222222");e.textAlign="right";e.textBaseline="alphabetic";e.lineWidth=300;e.x=40;e.y=-26;f.addChild(e);k=new createjs.Text(TEXT_SPEED_INDICATOR," 58px "+SECONDARY_FONT,"#ffffff");k.textAlign=e.textAlign;k.textBaseline=e.textBaseline;k.lineWidth=e.lineWidth;k.x=e.x;k.y=e.y;f.addChild(k)};this.setSpeedIndicator=function(a){k.text=Math.floor(a)};this.updateOffset=function(a,c){f.x=b+a;f.y=d-c};this._init(a,
c)}
function CMsgBox(a,c){var b,d,f,k,e,h;this._init=function(a,c){e=new createjs.Shape;e.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);e.alpha=0;e.on("mousedown",function(){});s_oStage.addChild(e);(new createjs.Tween.get(e)).to({alpha:.7},500);h=new createjs.Container;s_oStage.addChild(h);var g=s_oSpriteLibrary.getSprite("msg_box"),l=createBitmap(g);l.regX=g.width/2;l.regY=g.height/2;h.addChild(l);h.x=CANVAS_WIDTH/2;h.y=CANVAS_HEIGHT+g.height/2;b=h.y;(new createjs.Tween.get(h)).to({y:CANVAS_HEIGHT/2-
40},500,createjs.Ease.quartIn);d=new createjs.Text(a," 26px "+PRIMARY_FONT,"#000000");d.y=-g.height/2+60;d.textAlign="center";d.textBaseline="middle";d.lineWidth=550;d.outline=5;h.addChild(d);f=new createjs.Text(a," 26px "+PRIMARY_FONT,"#ffffff");f.y=d.y;f.textAlign="center";f.textBaseline="middle";f.lineWidth=550;h.addChild(f);k=new CGfxButton(0,80,s_oSpriteLibrary.getSprite("but_yes"),h);k.addEventListener(ON_MOUSE_UP,this._onButYes,this);k.pulseAnimation()};this._onButYes=function(){k.setClickable(!1);
(new createjs.Tween.get(e)).to({alpha:0},500);(new createjs.Tween.get(h)).to({y:b},400,createjs.Ease.backIn).call(function(){l.unload();c&&c()})};this.changeMessage=function(a){d.text=a;f.text=a};this.unload=function(){k.unload();s_oStage.removeChild(e);s_oStage.removeChild(h);e.off("mousedown",function(){})};var l=this;this._init(a,c)}
function CTremble(a,c,b,d){var f,k,e,h,l,g,p;this._init=function(a,b,c,d){h=e=!1;g=0;this._calculateDuration();f=a.x;k=a.y;e||(e=!0,l=setInterval(function(){m._tremble()},c))};this._tremble=function(){if(h=!h){var q=.5>Math.random()?-d:d;var t=.5>Math.random()?-d:d;a.x+=q;a.y+=t}else a.x=f,a.y=k;g++;g>p&&(g=0,e=!1,s_oGame.endDamageTime(),a.x=f,a.y=k,0===c?l=setInterval(function(){m._tremble()},b):clearInterval(l))};this._calculateDuration=function(){p=c/b};this.stopTremble=function(){clearInterval(l)};
var m=this;this._init(a,c,b,d)}
function CAreYouSurePanel(a,c){var b,d,f,k,e,h,l;this._init=function(a,c){h=new createjs.Shape;h.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);h.alpha=0;h.on("mousedown",function(){});s_oStage.addChild(h);(new createjs.Tween.get(h)).to({alpha:.7},500);l=new createjs.Container;s_oStage.addChild(l);var g=s_oSpriteLibrary.getSprite("msg_box"),m=createBitmap(g);m.regX=g.width/2;m.regY=g.height/2;l.addChild(m);l.x=CANVAS_WIDTH/2;l.y=CANVAS_HEIGHT+g.height/2;b=l.y;(new createjs.Tween.get(l)).to({y:CANVAS_HEIGHT/
2-40},500,createjs.Ease.cubicOut);d=new createjs.Text(TEXT_ARE_SURE," 50px "+PRIMARY_FONT,"#000000");d.y=-g.height/2+120;d.textAlign="center";d.textBaseline="middle";d.lineWidth=600;d.outline=5;l.addChild(d);f=new createjs.Text(TEXT_ARE_SURE," 50px "+PRIMARY_FONT,"#ffffff");f.y=d.y;f.textAlign="center";f.textBaseline="middle";f.lineWidth=600;l.addChild(f);k=new CGfxButton(110,80,s_oSpriteLibrary.getSprite("but_yes"),l);k.addEventListener(ON_MOUSE_UP,this._onButYes,this);e=new CGfxButton(-110,80,s_oSpriteLibrary.getSprite("but_exit"),
l);e.addEventListener(ON_MOUSE_UP,this._onButNo,this);e.pulseAnimation()};this._onButYes=function(){e.setClickable(!1);k.setClickable(!1);(new createjs.Tween.get(h)).to({alpha:0},500);(new createjs.Tween.get(l)).to({y:b},400,createjs.Ease.backIn).call(function(){g.unload();a&&a()})};this._onButNo=function(){e.setClickable(!1);k.setClickable(!1);(new createjs.Tween.get(h)).to({alpha:0},500);(new createjs.Tween.get(l)).to({y:b},400,createjs.Ease.backIn).call(function(){g.unload();c&&c()})};this.changeMessage=
function(a,b){d.text=a;f.text=a;b&&(d.font=" "+b+"px "+PRIMARY_FONT,f.font=" "+b+"px "+PRIMARY_FONT)};this.unload=function(){e.unload();k.unload();s_oStage.removeChild(h);s_oStage.removeChild(l);h.off("mousedown",function(){})};var g=this;this._init(a,c)};
