whisper.cat/weboasis/arcade/racing/js/main.js

313 lines
140 KiB
JavaScript
Raw Normal View History

2023-10-05 23:28:32 +11:00
(function(){var a="undefined"!==typeof window&&"undefined"!==typeof window.document?window.document:{},c="undefined"!==typeof module&&module.exports,b=function(){for(var b,d=["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(" ")],h=0,c=d.length,f={};h<c;h++)if((b=d[h])&&b[1]in a){for(h=0;h<b.length;h++)f[d[0][h]]=b[h];return f}return!1}(),f={change:b.fullscreenchange,error:b.fullscreenerror},g={request:function(e){return new Promise(function(d,h){var c=function(){this.off("change",
c);d()}.bind(this);this.on("change",c);e=e||a.documentElement;Promise.resolve(e[b.requestFullscreen]())["catch"](h)}.bind(this))},exit:function(){return new Promise(function(e,d){if(this.isFullscreen){var h=function(){this.off("change",h);e()}.bind(this);this.on("change",h);Promise.resolve(a[b.exitFullscreen]())["catch"](d)}else e()}.bind(this))},toggle:function(a){return this.isFullscreen?this.exit():this.request(a)},onchange:function(a){this.on("change",a)},onerror:function(a){this.on("error",a)},
on:function(b,d){var h=f[b];h&&a.addEventListener(h,d,!1)},off:function(b,d){var h=f[b];h&&a.removeEventListener(h,d,!1)},raw:b};b?(Object.defineProperties(g,{isFullscreen:{get:function(){return!!a[b.fullscreenElement]}},element:{enumerable:!0,get:function(){return a[b.fullscreenElement]}},isEnabled:{enumerable:!0,get:function(){return!!a[b.fullscreenEnabled]}}}),c?module.exports=g:window.screenfull=g):c?module.exports={isEnabled:!1}:window.screenfull={isEnabled:!1}})();
(function(){function a(a){a=String(a);return a.charAt(0).toUpperCase()+a.slice(1)}function c(a,d){var b=-1,h=a?a.length:0;if("number"==typeof h&&-1<h&&h<=q)for(;++b<h;)d(a[b],b,a);else f(a,d)}function b(d){d=String(d).replace(/^ +| +$/g,"");return/^(?:webOS|i(?:OS|P))/.test(d)?d:a(d)}function f(a,d){for(var b in a)y.call(a,b)&&d(a[b],b,a)}function g(d){return null==d?a(d):u.call(d).slice(8,-1)}function e(a,d){var b=null!=a?typeof a[d]:"number";return!/^(?:boolean|number|string|undefined)$/.test(b)&&
("object"==b?!!a[d]:!0)}function d(a){return String(a).replace(/([ -])(?!$)/g,"$1?")}function h(a,d){var b=null;c(a,function(h,e){b=d(b,h,e,a)});return b}function m(a){function c(e){return h(e,function(h,e){var c=e.pattern||d(e);!h&&(h=RegExp("\\b"+c+" *\\d+[.\\w_]*","i").exec(a)||RegExp("\\b"+c+" *\\w+-[\\w]*","i").exec(a)||RegExp("\\b"+c+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(a))&&((h=String(e.label&&!RegExp(c,"i").test(e.label)?e.label:h).split("/"))[1]&&!/[\d.]+/.test(h[0])&&(h[0]+=
" "+h[1]),e=e.label||e,h=b(h[0].replace(RegExp(c,"i"),e).replace(RegExp("; *(?:"+e+"[_-])?","i")," ").replace(RegExp("("+e+")[-_.]?(\\w)","i"),"$1 $2")));return h})}function k(d){return h(d,function(d,b){return d||(RegExp(b+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(a)||0)[1]||null})}var l=r,n=a&&"object"==typeof a&&"String"!=g(a);n&&(l=a,a=null);var t=l.navigator||{},q=t.userAgent||"";a||(a=q);var y=n?!!t.likeChrome:/\bChrome\b/.test(a)&&!/internal|\n/i.test(u.toString()),
A=n?"Object":"ScriptBridgingProxyObject",Q=n?"Object":"Environment",M=n&&l.java?"JavaPackage":g(l.java),R=n?"Object":"RuntimeObject";Q=(M=/\bJava/.test(M)&&l.java)&&g(l.environment)==Q;var S=M?"a":"\u03b1",T=M?"b":"\u03b2",P=l.document||{},F=l.operamini||l.opera,N=x.test(N=n&&F?F["[[Class]]"]:g(F))?N:F=null,p,G=a;n=[];var z=null,K=a==q;q=K&&F&&"function"==typeof F.version&&F.version();var B=function(b){return h(b,function(b,h){return b||RegExp("\\b"+(h.pattern||d(h))+"\\b","i").exec(a)&&(h.label||
h)})}([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"]),v=function(b){return h(b,function(b,h){return b||RegExp("\\b"+(h.pattern||d(h))+"\\b","i").exec(a)&&(h.label||h)})}(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"Edge"},"Midori","Nook Browser",
"PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Waterfox","WebPositive","Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chrome",{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},
{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),C=c([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad",
"iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),L=function(b){return h(b,function(b,h,e){return b||(h[C]||h[/^[a-z]+(?: +[a-z]+\b)*/i.exec(C)]||RegExp("\\b"+d(e)+"(?:\\b|\\w*\\d)","i").exec(a))&&e})}({Apple:{iPad:1,iPhone:1,iPod:1},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},
"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1}}),w=function(e){return h(e,function(h,e){var c=e.pattern||d(e);if(!h&&(h=RegExp("\\b"+c+"(?:/[\\d.]+|[ \\w.]*)","i").exec(a))){var f=h,g=e.label||e,m={"10.0":"10","6.4":"10 Technical Preview",
"6.3":"8.1","6.2":"8","6.1":"Server 2008 R2 / 7","6.0":"Server 2008 / Vista","5.2":"Server 2003 / XP 64-bit","5.1":"XP","5.01":"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};c&&g&&/^Win/i.test(f)&&!/^Windows Phone /i.test(f)&&(m=m[/[\d.]+$/.exec(f)])&&(f="Windows "+m);f=String(f);c&&g&&(f=f.replace(RegExp(c,"i"),g));h=f=b(f.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/,
" $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}return h})}(["Windows Phone","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian","Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac",
"Windows 98;","Windows "]);B&&(B=[B]);L&&!C&&(C=c([L]));if(p=/\bGoogle TV\b/.exec(C))C=p[0];/\bSimulator\b/i.test(a)&&(C=(C?C+" ":"")+"Simulator");"Opera Mini"==v&&/\bOPiOS\b/.test(a)&&n.push("running in Turbo/Uncompressed mode");"IE"==v&&/\blike iPhone OS\b/.test(a)?(p=m(a.replace(/like iPhone OS/,"")),L=p.manufacturer,C=p.product):/^iP/.test(C)?(v||(v="Safari"),w="iOS"+((p=/ OS ([\d_]+)/i.exec(a))?" "+p[1].replace(/_/g,"."):"")):"Konqueror"!=v||/buntu/i.test(w)?L&&"Google"!=L&&(/Chrome/.test(v)&&
!/\bMobile Safari\b/i.test(a)||/\bVita\b/.test(C))||/\bAndroid\b/.test(w)&&/^Chrome/.test(v)&&/\bVersion\//i.test(a)?(v="Android Browser",w=/\bAndroid\b/.test(w)?w:"Android"):"Silk"==v?(/\bMobi/i.test(a)||(w="Android",n.unshift("desktop mode")),/Accelerated *= *true/i.test(a)&&n.unshift("accelerated")):"PaleMoon"==v&&(p=/\bFirefox\/([\d.]+)\b/.exec(a))?n.push("identifying as Firefox "+p[1]):"Firefox"==v&&(p=/\b(Mobile|Tablet|TV)\b/i.exec(a))?(w||(w="Firefox OS"),C||(C=p[1])):!v||(p=!/\bMinefield\b/i.test(a)&&
/\b(?:Firefox|Safari)\b/.exec(v))?(v&&!C&&/[\/,]|^[^(]+?\)/.test(a.slice(a.indexOf(p+"/")+8))&&(v=null),(p=C||L||w)&&(C||L||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(w))&&(v=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(w)?w:p)+" Browser")):"Electron"==v&&(p=(/\bChrome\/([\d.]+)\b/.exec(a)||0)[1])&&n.push("Chromium "+p):w="Kubuntu";q||(q=k(["(?:Cloud9|CriOS|CrMo|Edge|FxiOS|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$))","Version",d(v),"(?:Firefox|Minefield|NetFront)"]));
if(p="iCab"==B&&3<parseFloat(q)&&"WebKit"||/\bOpera\b/.test(v)&&(/\bOPR\b/.test(a)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(a)&&!/^(?:Trident|EdgeHTML)$/.test(B)&&"WebKit"||!B&&/\bMSIE\b/i.test(a)&&("Mac OS"==w?"Tasman":"Trident")||"WebKit"==B&&/\bPlayStation\b(?! Vita\b)/i.test(v)&&"NetFront")B=[p];"IE"==v&&(p=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(a)||0)[1])?(v+=" Mobile",w="Windows Phone "+(/\+$/.test(p)?p:p+".x"),n.unshift("desktop mode")):/\bWPDesktop\b/i.test(a)?(v="IE Mobile",w="Windows Phone 8.x",
n.unshift("desktop mode"),q||(q=(/\brv:([\d.]+)/.exec(a)||0)[1])):"IE"!=v&&"Trident"==B&&(p=/\brv:([\d.]+)/.exec(a))&&(v&&n.push("identifying as "+v+(q?" "+q:"")),v="IE",q=p[1]);if(K){if(e(l,"global"))if(M&&(p=M.lang.System,G=p.getProperty("os.arch"),w=w||p.getProperty("os.name")+" "+p.getProperty("os.version")),Q){try{q=l.require("ringo/engine").version.join("."),v="RingoJS"}catch(X){(p=l.system)&&p.global.system==l.system&&(v="Narwhal",w||(w=p[0].os||null))}v||(v="Rhino")}else"object"==typeof l.process&&
!l.process.browser&&(p=l.process)&&("object"==typeof p.versions&&("string"==typeof p.versions.electron?(n.push("Node "+p.versions.node),v="Electron",q=p.versions.electron):"string"==typeof p.versions.nw&&(n.push("Chromium "+q,"Node "+p.versions.node),v="NW.js",q=p.versions.nw)),v||(v="Node.js",G=p.arch,w=p.platform,q=(q=/[\d.]+/.exec(p.version))?q[0]:null));else g(p=l.runtime)==A?(v="Adobe AIR",w=p.flash.system.Capabilities.os):g(p=l.phantom)==R?(v="PhantomJS",q=(p=p.version||null)&&p.major+"."+p.minor+
"."+p.patch):"number"==typeof P.documentMode&&(p=/\bTrident\/(\d+)/i.exec(a))?(q=[q,P.documentMode],(p=+p[1]+4)!=q[1]&&(n.push("IE "+q[1]+" mode"),B&&(B[1]=""),q[1]=p),q="IE"==v?String(q[1].toFixed(1)):q[0]):"number"==typeof P.documentMode&&/^(?:Chrome|Firefox)\b/.test(v)&&(n.push("masking as "+v+" "+q),v="IE",q="11.0",B=["Trident"],w="Windows");w=w&&b(w)}q&&(p=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(q)||/(?:alpha|beta)(?: ?\d)?/i.exec(a+";"+(K&&t.appMinorVersion))||/\bMinefield\b/i.test(a)&&
"a")&&(z=/b/i.test(p)?"beta":"alpha",q=q.replace(RegExp(p+"\\+?$"),"")+("beta"==z?T:S)+(/\d+\+?/.exec(p)||""));if("Fennec"==v||"Firefox"==v&&/\b(?:Android|Firefox OS)\b/.test(w))v="Firefox Mobile";else if("Maxthon"==v&&q)q=q.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(C))"Xbox 360"==C&&(w=null),"Xbox 360"==C&&/\bIEMobile\b/.test(a)&&n.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(v)&&(!v||C||/Browser|Mobi/.test(v))||"Windows CE"!=w&&!/Mobi/i.test(a))if("IE"==v&&K)try{null===l.external&&
n.unshift("platform preview")}catch(X){n.unshift("embedded")}else(/\bBlackBerry\b/.test(C)||/\bBB10\b/.test(a))&&(p=(RegExp(C.replace(/ +/g," *")+"/([.\\d]+)","i").exec(a)||0)[1]||q)?(p=[p,/BB10/.test(a)],w=(p[1]?(C=null,L="BlackBerry"):"Device Software")+" "+p[0],q=null):this!=f&&"Wii"!=C&&(K&&F||/Opera/.test(v)&&/\b(?:MSIE|Firefox)\b/i.test(a)||"Firefox"==v&&/\bOS X (?:\d+\.){2,}/.test(w)||"IE"==v&&(w&&!/^Win/.test(w)&&5.5<q||/\bWindows XP\b/.test(w)&&8<q||8==q&&!/\bTrident\b/.test(a)))&&!x.test(p=
m.call(f,a.replace(x,"")+";"))&&p.name&&(p="ing as "+p.name+((p=p.version)?" "+p:""),x.test(v)?(/\bIE\b/.test(p)&&"Mac OS"==w&&(w=null),p="identify"+p):(p="mask"+p,v=N?b(N.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(p)&&(w=null),K||(q=null)),B=["Presto"],n.push(p));else v+=" Mobile";if(p=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(a)||0)[1]){p=[parseFloat(p.replace(/\.(\d)$/,".0$1")),p];if("Safari"==v&&"+"==p[1].slice(-1))v="WebKit Nightly",z="alpha",q=p[1].slice(0,-1);else if(q==p[1]||q==(p[2]=
(/\bSafari\/([\d.]+\+?)/i.exec(a)||0)[1]))q=null;p[1]=(/\bChrome\/([\d.]+)/i.exec(a)||0)[1];537.36==p[0]&&537.36==p[2]&&28<=parseFloat(p[1])&&"WebKit"==B&&(B=["Blink"]);K&&(y||p[1])?(B&&(B[1]="like Chrome"),p=p[1]||(p=p[0],530>p?1:532>p?2:532.05>p?3:533>p?4:534.03>p?5:534.07>p?6:534.1>p?7:534.13>p?8:534.16>p?9:534.24>p?10:534.3>p?11:535.01>p?12:535.02>p?"13+":535.07>p?15:535.11>p?16:535.19>p?17:536.05>p?18:536.1>p?19:537.01>p?20:537.11>p?"21+":537.13>p?23:537.18>p?24:537.24>p?25:537.36>p?26:"Blink"!=
B?"27":"28")):(B&&(B[1]="like Safari"),p=(p=p[0],400>p?1:500>p?2:526>p?3:533>p?4:534>p?"4+":535>p?5:537>p?6:538>p?7:601>p?8:"8"));B&&(B[1]+=" "+(p+="number"==typeof p?".x":/[.+]/.test(p)?"":"+"));"Safari"==v&&(!q||45<parseInt(q))&&(q=p)}"Opera"==v&&(p=/\bzbov|zvav$/.exec(w))?(v+=" ",n.unshift("desktop mode"),"zvav"==p?(v+="Mini",q=null):v+="Mobile",w=w.replace(RegExp(" *"+p+"$"),"")):"Safari"==v&&/\bChrome\b/.exec(B&&B[1])&&(n.unshift("desktop mode"),v="Chrome Mobile",q=null,/\bOS X\b/.test(w)?(L=
"Apple",w="iOS 4.3+"):w=null);q&&0==q.indexOf(p=/[\d.]+$/.exec(w))&&-1<a.indexOf("/"+p+"-")&&(w=String(w.replace(p,"")).replace(/^ +| +$/g,""));B&&!/\b(?:Avant|Nook)\b/.test(v)&&(/Browser|Lunascape|Maxthon/.test(v)||"Safari"!=v&&/^iOS/.test(w)&&/\bSafari\b/.test(B[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|Web)/.test(v)&&B[1])&&(p=B[B.length-1])&&n.push(p);n.length&&(n=["("+n.join("; ")+")"]);L&&C&&0>C.indexOf(L)&&n.push("on "+L);C&&n.push((/^on /.test(n[n.length-
1])?"":"on ")+C);if(w){var W=(p=/ ([\d.+]+)$/.exec(w))&&"/"==w.charAt(w.length-p[0].length-1);w={architecture:32,family:p&&!W?w.replace(p[0],""):w,version:p?p[1]:null,toString:function(){var a=this.version;return this.family+(a&&!W?" "+a:"")+(64==this.architecture?" 64-bit":"")}}}(p=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(G))&&!/\bi686\b/i.test(G)?(w&&(w.architecture=64,w.family=w.family.replace(RegExp(" *"+p),"")),v&&(/\bWOW64\b/i.test(a)||K&&/\w(?:86|32)$/.test(t.cpuClass||t.platform)&&!/\bWin64; x64\b/i.test(a))&&
n.unshift("32-bit")):w&&/^OS X/.test(w.family)&&"Chrome"==v&&39<=parseFloat(q)&&(w.architecture=64);a||(a=null);l={};l.description=a;l.layout=B&&B[0];l.manufacturer=L;l.name=v;l.prerelease=z;l.product=C;l.ua=a;l.version=v&&q;l.os=w||{architecture:null,family:null,version:null,toString:function(){return"null"}};l.parse=m;l.toString=function(){return this.description||""};l.version&&n.unshift(q);l.name&&n.unshift(v);w&&v&&(w!=String(w).split(" ")[0]||w!=v.split(" ")[0]&&!C)&&n.push(C?"("+w+")":"on "+
w);n.length&&(l.description=n.join(" "));return l}var k={"function":!0,object:!0},r=k[typeof window]&&window||this,l=k[typeof exports]&&exports;k=k[typeof module]&&module&&!module.nodeType&&module;var n=l&&k&&"object"==typeof global&&global;!n||n.global!==n&&n.window!==n&&n.self!==n||(r=n);var q=Math.pow(2,53)-1,x=/\bOpera/;n=Object.prototype;var y=n.hasOwnProperty,u=n.toString,t=m();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(r.platform=t,define(function(){return t})):l&&
k?f(t,function(a,d){l[d]=a}):r.platform=t}).call(this);
function buildIOSMeta(){for(var a=[{name:"viewport",content:"width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"},{name:"apple-mobile-web-app-capable",content:"yes"},{name:"apple-mobile-web-app-status-bar-style",content:"black"}],c=0;c<a.length;c++){var b=document.createElement("meta");b.name=a[c].name;b.content=a[c].content;var f=window.document.head.querySelector('meta[name="'+b.name+'"]');f&&f.parentNode.removeChild(f);window.document.head.appendChild(b)}}
function hideIOSFullscreenPanel(){jQuery(".xxx-ios-fullscreen-message").css("display","none");jQuery(".xxx-ios-fullscreen-scroll").css("display","none");jQuery(".xxx-game-iframe-full").removeClass("xxx-game-iframe-iphone-se")}function buildIOSFullscreenPanel(){jQuery("body").append('<div class="xxx-ios-fullscreen-message"><div class="xxx-ios-fullscreen-swipe"></div></div><div class="xxx-ios-fullscreen-scroll"></div>')}
function showIOSFullscreenPanel(){jQuery(".xxx-ios-fullscreen-message").css("display","block");jQuery(".xxx-ios-fullscreen-scroll").css("display","block")}
function __iosResize(){window.scrollTo(0,0);console.log(window.devicePixelRatio);console.log(window.innerWidth);console.log(window.innerHeight);if("iPhone"===platform.product)switch(window.devicePixelRatio){case 2:switch(window.innerWidth){case 568:320!==window.innerHeight&&jQuery(".xxx-game-iframe-full").addClass("xxx-game-iframe-iphone-se");break;case 667:375===window.innerHeight?hideIOSFullscreenPanel():showIOSFullscreenPanel();break;case 808:414===window.innerHeight?hideIOSFullscreenPanel():showIOSFullscreenPanel();
break;default:hideIOSFullscreenPanel()}break;case 3:switch(window.innerWidth){case 736:414===window.innerHeight?hideIOSFullscreenPanel():showIOSFullscreenPanel();break;case 724:375===window.innerHeight?hideIOSFullscreenPanel():showIOSFullscreenPanel();break;case 808:414===window.innerHeight?hideIOSFullscreenPanel():showIOSFullscreenPanel();break;default:hideIOSFullscreenPanel()}break;default:hideIOSFullscreenPanel()}}function iosResize(){__iosResize();setTimeout(function(){__iosResize()},500)}
function iosInIframe(){try{return window.self!==window.top}catch(a){return!0}}function isIOSLessThen13(){var a=platform.os,c=a.family.toLowerCase();a=parseFloat(a.version);return"ios"===c&&13>a?!0:!1}$(document).ready(function(){platform&&"iPhone"===platform.product&&"safari"===platform.name.toLowerCase()&&isIOSLessThen13()&&!iosInIframe()&&(buildIOSFullscreenPanel(),buildIOSMeta())});
jQuery(window).resize(function(){platform&&"iPhone"===platform.product&&"safari"===platform.name.toLowerCase()&&isIOSLessThen13()&&!iosInIframe()&&iosResize()});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,f=b.documentElement;if(void 0===window["inner"+a])a=f["client"+a];else if(window["inner"+a]!=f["client"+a]){var g=b.createElement("body");g.id="vpw-test-b";g.style.cssText="overflow:scroll";var e=b.createElement("div");e.id="vpw-test-d";e.style.cssText="position:absolute;top:-1000px";e.innerHTML="<style>@media("+c+":"+f["client"+a]+"px){body#vpw-test-b div#vpw-test-d{"+c+":7px!important}}</style>";g.appendChild(e);f.insertBefore(g,b.head);
a=7==e["offset"+a]?f["client"+a]:window["inner"+a];f.removeChild(g)}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 isIpad(){var a=-1!==navigator.userAgent.toLowerCase().indexOf("ipad");return!a&&navigator.userAgent.match(/Mac/)&&navigator.maxTouchPoints&&2<navigator.maxTouchPoints?!0:a}function isMobile(){return isIpad()?!0:jQuery.browser.mobile}
function isIOS(){var a="iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";");if(-1!==navigator.userAgent.toLowerCase().indexOf("iphone"))return s_bIsIphone=!0;for(;a.length;)if(navigator.platform===a.pop())return s_bIsIphone=!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 sizeHandler(){window.scrollTo(0,1);if($("#canvas")){var a="safari"===platform.name.toLowerCase()?getIOSWindowHeight():getSize("Height");var c=getSize("Width");_checkOrientation(c,a);var b=Math.min(a/CANVAS_HEIGHT,c/CANVAS_WIDTH),f=Math.round(CANVAS_WIDTH*b);b=Math.round(CANVAS_HEIGHT*b);if(b<a){var g=a-b;b+=g;f+=CANVAS_WIDTH/CANVAS_HEIGHT*g}else f<c&&(g=c-f,f+=g,b+=CANVAS_HEIGHT/CANVAS_WIDTH*g);g=a/2-b/2;var e=c/2-f/2,d=CANVAS_WIDTH/f;if(e*d<-EDGEBOARD_X||g*d<-EDGEBOARD_Y)b=Math.min(a/(CANVAS_HEIGHT-
2*EDGEBOARD_Y),c/(CANVAS_WIDTH-2*EDGEBOARD_X)),f=Math.round(CANVAS_WIDTH*b),b=Math.round(CANVAS_HEIGHT*b),g=(a-b)/2,e=(c-f)/2,d=CANVAS_WIDTH/f;s_iOffsetX=-1*e*d;s_iOffsetY=-1*g*d;0<=g&&(s_iOffsetY=0);0<=e&&(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*f,s_oStage.canvas.height=2*b,canvas.style.width=f+"px",canvas.style.height=b+"px",s_iScaleFactor=2*Math.min(f/CANVAS_WIDTH,b/CANVAS_HEIGHT),s_oStage.scaleX=s_oStage.scaleY=s_iScaleFactor):s_bMobile||isChrome()?($("#canvas").css("width",f+"px"),$("#canvas").css("height",b+"px")):(s_oStage.canvas.width=f,s_oStage.canvas.height=b,s_iScaleFactor=Math.min(f/CANVAS_WIDTH,b/CANVAS_HEIGHT),s_oStage.scaleX=s_oStage.scaleY=s_iScaleFactor);0>g||(g=(a-b)/2);$("#canvas").css("top",g+"px");$("#canvas").css("left",
e+"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,f){!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||a.fade(c,b,f)}
function soundPlaying(a){if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)return a.playing()}function soundSeek(a,c){if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)return a.seek(c)}function soundDuration(a){if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)return a.duration()}function createBitmap(a,c,b){var f=new createjs.Bitmap(a),g=new createjs.Shape;c&&b?g.graphics.beginFill("#fff").drawRect(0,0,c,b):g.graphics.beginFill("#ff0").drawRect(0,0,a.width,a.height);f.hitArea=g;return f}
function createSprite(a,c,b,f,g,e){a=null!==c?new createjs.Sprite(a,c):new createjs.Sprite(a);c=new createjs.Shape;c.graphics.beginFill("#000000").drawRect(-b,-f,g,e);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),f=c.getX()*-Math.sin(a)+c.getY()*Math.cos(a);c.set(b,f)}function tweenVectorsOnX(a,c,b){return a+b*(c-a)}function linearFunction(a,c,b,f,g){return(a-c)*(g-f)/(b-c)+f}function shuffle(a){for(var c=a.length,b,f;0!==c;)f=Math.floor(Math.random()*c),--c,b=a[c],a[c]=a[f],a[f]=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,f){return b*a/f+c}function easeInQuad(a,c,b,f){return b*(a/=f)*a+c}function easeInSine(a,c,b,f){return-b*Math.cos(a/f*(Math.PI/2))+b+c}function easeInCubic(a,c,b,f){return b*(a/=f)*a*a+c}function getTrajectoryPoint(a,c){var b=new createjs.Point,f=(1-a)*(1-a),g=a*a;b.x=f*c.start.x+2*(1-a)*a*c.traj.x+g*c.end.x;b.y=f*c.start.y+2*(1-a)*a*c.traj.y+g*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 f=getBounds(c,.98);return calculateIntersection(b,f)}
function calculateIntersection(a,c){var b,f,g,e;var d=a.x+(b=a.width/2);var h=a.y+(f=a.height/2);var m=c.x+(g=c.width/2);var k=c.y+(e=c.height/2);d=Math.abs(d-m)-(b+g);h=Math.abs(h-k)-(f+e);return 0>d&&0>h?(d=Math.min(Math.min(a.width,c.width),-d),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:d,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 f=a.children,g=f.length,e;for(e=0;e<g;e++){var d=getBounds(f[e],1);d.x<b.x&&(b.x=d.x);d.y<b.y&&(b.y=d.y);d.x+d.width>b.x2&&(b.x2=d.x+d.width);d.y+d.height>b.y2&&(b.y2=d.y+d.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){g=
a.sourceRect||a.image;e=g.width*c;var h=g.height*c}else if(a instanceof createjs.Sprite)if(a.spriteSheet._frames&&a.spriteSheet._frames[a.currentFrame]&&a.spriteSheet._frames[a.currentFrame].image){g=a.spriteSheet.getFrame(a.currentFrame);e=g.rect.width;h=g.rect.height;f=g.regX;var m=g.regY}else b.x=a.x||0,b.y=a.y||0;else b.x=a.x||0,b.y=a.y||0;f=f||0;e=e||0;m=m||0;h=h||0;b.regX=f;b.regY=m;g=a.localToGlobal(0-f,0-m);d=a.localToGlobal(e-f,h-m);e=a.localToGlobal(e-f,0-m);f=a.localToGlobal(0-f,h-m);b.x=
Math.min(Math.min(Math.min(g.x,d.x),e.x),f.x);b.y=Math.min(Math.min(Math.min(g.y,d.y),e.y),f.y);b.width=Math.max(Math.max(Math.max(g.x,d.x),e.x),f.x)-b.x;b.height=Math.max(Math.max(Math.max(g.y,d.y),e.y),f.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,f;0<c;)f=Math.floor(Math.random()*c),c--,b=a[c],a[c]=a[f],a[f]=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 f=c[b].split("=");if(f[0]==a)return f[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,f,g){a.camera.x=-c;a.camera.y=a.world.y-b;a.camera.z=a.world.z-f;a.screen.scale=
g/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,f,g){g=.5*(g||1);return!(a+c*g<b-f*g||a-c*g>b+f*g)}};
function fullscreenHandler(){ENABLE_FULLSCREEN&&screenfull.isEnabled&&(s_bFullscreen=screenfull.isFullscreen,null!==s_oInterface&&s_oInterface.resetFullscreenBut(),null!==s_oWorldMenu&&s_oWorldMenu.resetFullscreenBut(),null!==s_oMenu&&s_oMenu.resetFullscreenBut())}if(screenfull.isEnabled)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 CSpriteLibrary(){var a={},c,b,f,g,e,d;this.init=function(a,m,k){c={};f=b=0;g=a;e=m;d=k};this.addSprite=function(d,e){if(a.hasOwnProperty(d))return!1;var h=new Image;a[d]=c[d]={szPath:e,oSprite:h,bLoaded:!1};b++;return!0};this.getSprite=function(d){return a.hasOwnProperty(d)?a[d].oSprite:null};this._onSpritesLoaded=function(){b=0;e.call(d)};this._onSpriteLoaded=function(){g.call(d);++f===b&&this._onSpritesLoaded()};this.loadSprites=function(){for(var a in c)c[a].oSprite.oSpriteLibrary=this,
c[a].oSprite.szKey=a,c[a].oSprite.onload=function(){this.oSpriteLibrary.setLoaded(this.szKey);this.oSpriteLibrary._onSpriteLoaded(this.szKey)},c[a].oSprite.onerror=function(a){var d=a.currentTarget;setTimeout(function(){c[d.szKey].oSprite.src=c[d.szKey].szPath},500)},c[a].oSprite.src=c[a].szPath};this.setLoaded=function(d){a[d].bLoaded=!0};this.isLoaded=function(d){return a[d].bLoaded};this.getNumSprites=function(){return b}}
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",PRIMARY_FONT_COLOUR="#000000",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,SOUNDTRACK_VOLUME_IN_GAME=.5,POINTS_PER_SECONDS,AD_SHOW_COUNTER;TEXT_PRELOADER_CONTINUE="START";TEXT_GAMEOVER="CONGRATULATIONS! 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_DEVELOPED="DEVELOPED BY";
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,f,g,e,d,h,m,k;this._init=function(){s_oSpriteLibrary.init(this._onImagesLoaded,this._onAllImagesLoaded,this);s_oSpriteLibrary.addSprite("progress_bar","./sprites/progress_bar.png");s_oSpriteLibrary.addSprite("200x200","./sprites/200x200.jpg");s_oSpriteLibrary.addSprite("but_start","./sprites/but_start.png");s_oSpriteLibrary.loadSprites();k=new createjs.Container;s_oStage.addChild(k)};this.unload=function(){k.removeAllChildren();m.unload()};this._onImagesLoaded=function(){};
this._onAllImagesLoaded=function(){this.attachSprites();s_oMain.preloaderReady()};this.attachSprites=function(){var r=new createjs.Shape;r.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);k.addChild(r);r=s_oSpriteLibrary.getSprite("200x200");d=createBitmap(r);d.regX=.5*r.width;d.regY=.5*r.height;d.x=CANVAS_WIDTH/2;d.y=CANVAS_HEIGHT/2-180;k.addChild(d);h=new createjs.Shape;h.graphics.beginFill("rgba(0,0,0,0.01)").drawRoundRect(d.x-100,d.y-100,200,200,10);k.addChild(h);d.mask=h;
r=s_oSpriteLibrary.getSprite("progress_bar");f=createBitmap(r);f.x=CANVAS_WIDTH/2-r.width/2;f.y=CANVAS_HEIGHT/2+50;k.addChild(f);a=r.width;c=r.height;g=new createjs.Shape;g.graphics.beginFill("rgba(0,0,0,0.01)").drawRect(f.x,f.y,1,c);k.addChild(g);f.mask=g;b=new createjs.Text("","30px "+PRIMARY_FONT,"#FFF");b.x=CANVAS_WIDTH/2;b.y=CANVAS_HEIGHT/2+100;b.textBaseline="alphabetic";b.textAlign="center";k.addChild(b);r=s_oSpriteLibrary.getSprite("but_start");m=new CTextButton(CANVAS_WIDTH/2,CANVAS_HEIGHT/
2,r,TEXT_PRELOADER_CONTINUE,"Arial","#000","bold 50",k);m.addEventListener(ON_MOUSE_UP,this._onButStartRelease,this);m.setVisible(!1);e=new createjs.Shape;e.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);k.addChild(e);createjs.Tween.get(e).to({alpha:0},500).call(function(){createjs.Tween.removeTweens(e);k.removeChild(e)})};this._onButStartRelease=function(){s_oMain._onRemovePreloader()};this.refreshLoader=function(d){b.text=d+"%";100===d&&(s_oMain._onRemovePreloader(),b.visible=
!1,f.visible=!1);g.graphics.clear();d=Math.floor(d*a/100);g.graphics.beginFill("rgba(0,0,0,0.01)").drawRect(f.x,f.y,d,c)};this._init()}
function CMain(a){var c,b=0,f=0,g=STATE_LOADING,e,d;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=isMobile();!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.framerate=FPS;navigator.userAgent.match(/Windows Phone/i)&&
(DISABLE_SOUND_MOBILE=!0);s_oSpriteLibrary=new CSpriteLibrary;e=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++;e.refreshLoader(Math.floor(b/f*100))};this._initSounds=function(){Howler.mute(!s_bAudioActive);s_aSoundsInfo=[];s_aSoundsInfo.push({path:"./sounds/",filename:"menu_soundtrack",loop:!0,volume:1,ingamename:"menu_soundtrack"});s_aSoundsInfo.push({path:"./sounds/",
filename:"game_soundtrack",loop:!0,volume:1,ingamename:"game_soundtrack"});s_aSoundsInfo.push({path:"./sounds/",filename:"press_button",loop:!1,volume:1,ingamename:"click"});s_aSoundsInfo.push({path:"./sounds/",filename:"1",loop:!1,volume:1,ingamename:"1"});s_aSoundsInfo.push({path:"./sounds/",filename:"2",loop:!1,volume:1,ingamename:"2"});s_aSoundsInfo.push({path:"./sounds/",filename:"3",loop:!1,volume:1,ingamename:"3"});s_aSoundsInfo.push({path:"./sounds/",filename:"go",loop:!1,volume:1,ingamename:"go"});
s_aSoundsInfo.push({path:"./sounds/",filename:"arrive_lose",loop:!1,volume:1,ingamename:"arrive_lose"});s_aSoundsInfo.push({path:"./sounds/",filename:"arrive_win",loop:!1,volume:1,ingamename:"arrive_win"});s_aSoundsInfo.push({path:"./sounds/",filename:"sprint_start",loop:!1,volume:1,ingamename:"sprint_start"});s_aSoundsInfo.push({path:"./sounds/",filename:"crash",loop:!1,volume:1,ingamename:"crash"});s_aSoundsInfo.push({path:"./sounds/",filename:"brake",loop:!1,volume:1,ingamename:"brake"});s_aSoundsInfo.push({path:"./sounds/",
filename:"engine",loop:!0,volume:1,ingamename:"engine"});s_aSoundsInfo.push({path:"./sounds/",filename:"engine_stall",loop:!0,volume:1,ingamename:"engine_stall"});s_aSoundsInfo.push({path:"./sounds/",filename:"engine_reverse",loop:!0,volume:1,ingamename:"engine_reverse"});f+=s_aSoundsInfo.length;s_aSounds=[];for(var a=0;a<s_aSoundsInfo.length;a++)this.tryToLoadSound(s_aSoundsInfo[a],!1)};this.tryToLoadSound=function(a,d){setTimeout(function(){s_aSounds[a.ingamename]=new Howl({src:[a.path+a.filename+
".mp3"],autoplay:!1,preload:!0,loop:a.loop,volume:a.volume,onload:s_oMain.soundLoaded,onloaderror:function(a,d){for(var b=0;b<s_aSoundsInfo.length;b++)if(a===s_aSounds[s_aSoundsInfo[b].ingamename]._sounds[0]._id){s_oMain.tryToLoadSound(s_aSoundsInfo[b],!0);break}},onplayerror:function(a){for(var d=0;d<s_aSoundsInfo.length;d++)if(a===s_aSounds[s_aSoundsInfo[d].ingamename]._sounds[0]._id){s_aSounds[s_aSoundsInfo[d].ingamename].once("unlock",function(){s_aSounds[s_aSoundsInfo[d].ingamename].play();"soundtrack"===
s_aSoundsInfo[d].ingamename&&null!==s_oGame&&setVolume("soundtrack",SOUNDTRACK_VOLUME_IN_GAME)});break}}})},d?200:0)};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");f+=s_oSpriteLibrary.getNumSprites();s_oSpriteLibrary.loadSprites()};
this._onImagesLoaded=function(){b++;e.refreshLoader(Math.floor(b/f*100))};this._onRemovePreloader=function(){e.unload();playSound("menu_soundtrack",1,!0);this.gotoMenu()};this._onAllImagesLoaded=function(){};this.onAllPreloaderImagesLoaded=function(){this._loadImages()};this.gotoMenu=function(){new CMenu;g=STATE_MENU};this.gotoWorldMenu=function(){new CWorldMenu;g=STATE_MENU};this.gotoGame=function(a){d=new CGame(h,a);g=STATE_GAME};this.gotoHelp=function(){new CHelp;g=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);g===STATE_GAME&&
d.update()}};s_oMain=this;var h=a;ENABLE_FULLSCREEN=a.fullscreen;ENABLE_CHECK_ORIENTATION=a.check_orientation;s_bAudioActive=a.audio_enable_on_startup;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=[],s_aSoundsInfo;
function CCreditsPanel(){var a,c,b,f,g;this._init=function(){c=new createjs.Shape;c.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);c.alpha=0;c.on("click",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"),d=createBitmap(e);d.regX=e.width/2;d.regY=e.height/2;b.addChild(d);b.x=CANVAS_WIDTH/2;b.y=CANVAS_HEIGHT+e.height/2+50;a=b.y;(new createjs.Tween.get(b)).to({y:CANVAS_HEIGHT/
2-40},500,createjs.Ease.quartIn);d=new createjs.Text(TEXT_DEVELOPED," 40px "+PRIMARY_FONT,"#ffffff");d.y=-e.height/2+110;d.textAlign="center";d.textBaseline="middle";d.lineWidth=400;b.addChild(d);e=new createjs.Text("WebOas.is"," 40px "+PRIMARY_FONT,"#ffffff");e.y=90;e.textAlign="center";e.textBaseline="middle";e.lineWidth=400;b.addChild(e);e=s_oSpriteLibrary.getSprite("ctl_logo");g=createBitmap(e);g.on("click",this._onLogoButRelease);g.regX=e.width/2;g.regY=e.height/2;b.addChild(g);e=s_oSpriteLibrary.getSprite("but_exit");
f=new CGfxButton(326,-200,e,b);f.addEventListener(ON_MOUSE_UP,this.unload,this)};this.unload=function(){f.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);f.unload()});c.removeAllEventListeners();g.removeAllEventListeners()};this._onLogoButRelease=function(){window.open("https://WebOas.is")};this._init()}
function CTextButton(a,c,b,f,g,e,d){var h,m,k,r,l,n,q;this._init=function(a,d,b,e,c,f,g){h=[];m=[];var k=createBitmap(b),r=Math.ceil(g/20);q=new createjs.Text(e,g+"px "+c,"#000000");q.textAlign="center";q.textBaseline="alphabetic";var t=q.getBounds();q.x=b.width/2+r;q.y=Math.floor(b.height/2)+t.height/3+r;n=new createjs.Text(e,g+"px "+c,f);n.textAlign="center";n.textBaseline="alphabetic";t=n.getBounds();n.x=b.width/2;n.y=Math.floor(b.height/2)+t.height/3;l=new createjs.Container;l.x=a;l.y=d;l.regX=
b.width/2;l.regY=b.height/2;l.addChild(k,q,n);s_oStage.addChild(l);this._initListener()};this.unload=function(){l.off("mousedown",k);l.off("pressup",r);s_oStage.removeChild(l)};this.setVisible=function(a){l.visible=a};this._initListener=function(){k=l.on("mousedown",this.buttonDown);r=l.on("pressup",this.buttonRelease)};this.addEventListener=function(a,d,b){h[a]=d;m[a]=b};this.buttonRelease=function(){l.scaleX=1;l.scaleY=1;h[ON_MOUSE_UP]&&h[ON_MOUSE_UP].call(m[ON_MOUSE_UP])};this.buttonDown=function(){l.scaleX=
.9;l.scaleY=.9;h[ON_MOUSE_DOWN]&&h[ON_MOUSE_DOWN].call(m[ON_MOUSE_DOWN])};this.setTextPosition=function(a){n.y=a;q.y=a+2};this.setPosition=function(a,d){l.x=a;l.y=d};this.setX=function(a){l.x=a};this.setY=function(a){l.y=a};this.getButtonImage=function(){return l};this.getX=function(){return l.x};this.getY=function(){return l.y};this._init(a,c,b,f,g,e,d);return this}
function CToggle(a,c,b,f){var g,e,d,h,m,k;this._init=function(a,b,h,c){e=[];d=[];var f=new createjs.SpriteSheet({images:[h],frames:{width:h.width/2,height:h.height,regX:h.width/2/2,regY:h.height/2},animations:{state_true:[0],state_false:[1]}});g=c;k=createSprite(f,"state_"+g,h.width/2/2,h.height/2,h.width/2,h.height);k.x=a;k.y=b;k.stop();s_oStage.addChild(k);this._initListener()};this.unload=function(){k.off("mousedown",h);k.off("pressup",m);s_oStage.removeChild(k)};this._initListener=function(){h=
k.on("mousedown",this.buttonDown);m=k.on("pressup",this.buttonRelease)};this.addEventListener=function(a,b,h){e[a]=b;d[a]=h};this.setActive=function(a){g=a;k.gotoAndStop("state_"+g)};this.buttonRelease=function(){k.scaleX=1;k.scaleY=1;playSound("click",1,!1);g=!g;k.gotoAndStop("state_"+g);e[ON_MOUSE_UP]&&e[ON_MOUSE_UP].call(d[ON_MOUSE_UP],g)};this.buttonDown=function(){k.scaleX=.9;k.scaleY=.9;e[ON_MOUSE_DOWN]&&e[ON_MOUSE_DOWN].call(d[ON_MOUSE_DOWN])};this.setPosition=function(a,d){k.x=a;k.y=d};this._init(a,
c,b,f)}
function CGfxButton(a,c,b,f){var g,e,d,h,m=[],k,r,l,n;this._init=function(a,b,c,f){g=!1;e=1;d=[];h=[];n=createBitmap(c);n.x=a;n.y=b;n.scaleX=n.scaleY=e;n.regX=c.width/2;n.regY=c.height/2;f.addChild(n);this._initListener()};this.unload=function(){n.off("mousedown",k);n.off("pressup",r);s_bMobile||n.off("mouseover",l);f.removeChild(n)};this.setVisible=function(a){n.visible=a};this.setClickable=function(a){g=!a};this._initListener=function(){k=n.on("mousedown",this.buttonDown);r=n.on("pressup",this.buttonRelease);
s_bMobile||(l=n.on("mouseover",this.buttonOver))};this.addEventListener=function(a,b,e){d[a]=b;h[a]=e};this.addEventListenerWithParams=function(a,b,e,c){d[a]=b;h[a]=e;m=c};this.buttonRelease=function(){g||(n.scaleX=e,n.scaleY=e,d[ON_MOUSE_UP]&&d[ON_MOUSE_UP].call(h[ON_MOUSE_UP],m))};this.buttonDown=function(){g||(n.scaleX=.9*e,n.scaleY=.9*e,playSound("click",1,!1),d[ON_MOUSE_DOWN]&&d[ON_MOUSE_DOWN].call(h[ON_MOUSE_DOWN],m))};this.buttonOver=function(a){s_bMobile||g||(a.target.cursor="pointer")};this.pulseAnimation=
function(){createjs.Tween.get(n).to({scaleX:1.1*e,scaleY:1.1*e},850,createjs.Ease.quadOut).to({scaleX:e,scaleY:e},650,createjs.Ease.quadIn).call(function(){q.pulseAnimation()})};this.trembleAnimation=function(){createjs.Tween.get(n).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(){q.trebleAnimation()})};this.setPosition=function(a,d){n.x=a;n.y=d};this.setX=function(a){n.x=a};this.setY=function(a){n.y=
a};this.getButtonImage=function(){return n};this.getX=function(){return n.x};this.getY=function(){return n.y};var q=this;this._init(a,c,b,f);return this}
function CMenu(){var a,c,b,f,g,e,d,h,m,k,r,l,n,q,x,y=null,u=null;this._init=function(){m=createBitmap(s_oSpriteLibrary.getSprite("bg_menu"));s_oStage.addChild(m);var t=s_oSpriteLibrary.getSprite("but_play");k=new CGfxButton(CANVAS_WIDTH/2+350,CANVAS_HEIGHT-220,t,s_oStage);k.addEventListener(ON_MOUSE_UP,this._onButPlayRelease,this);k.pulseAnimation();t=s_oSpriteLibrary.getSprite("logo_menu");var A=createBitmap(t);A.regX=t.width/2;A.regY=t.height/2;A.x=CANVAS_WIDTH/2;A.y=CANVAS_HEIGHT/2-150;s_oStage.addChild(A);
t=s_oSpriteLibrary.getSprite("but_credits");g=t.width/2+12;e=t.height/2+16;n=new CGfxButton(g,e,t,s_oStage);n.addEventListener(ON_MOUSE_UP,this._onCreditsBut,this);A=CANVAS_WIDTH;if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)t=s_oSpriteLibrary.getSprite("audio_icon"),d=CANVAS_WIDTH-t.width/4-12,h=t.height/2+16,l=new CToggle(d,h,t,s_bAudioActive),l.addEventListener(ON_MOUSE_UP,this._onAudioToggle,this),A=d-t.width/4;s_oLocalStorage.isDirty()&&(t=s_oSpriteLibrary.getSprite("but_delete_saving"),a=A-t.width/
2-12,c=t.height/2+16,x=new CGfxButton(a,c,t,s_oStage),x.addEventListener(ON_MOUSE_UP,this._onDeleteBut,this));t=window.document;A=t.documentElement;y=A.requestFullscreen||A.mozRequestFullScreen||A.webkitRequestFullScreen||A.msRequestFullscreen;u=t.exitFullscreen||t.mozCancelFullScreen||t.webkitExitFullscreen||t.msExitFullscreen;!1===ENABLE_FULLSCREEN&&(y=!1);y&&screenfull.isEnabled&&(t=s_oSpriteLibrary.getSprite("but_fullscreen"),b=g+t.width/2+12,f=t.height/2+16,q=new CToggle(b,f,t,s_bFullscreen,
s_oStage),q.addEventListener(ON_MOUSE_UP,this._onFullscreenRelease,this));r=new createjs.Shape;r.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);s_oStage.addChild(r);createjs.Tween.get(r).to({alpha:0},1E3).call(function(){r.visible=!1});this.refreshButtonPos(s_iOffsetX,s_iOffsetY);s_oLocalStorage.isUsed()||new CMsgBox(TEXT_IOS_PRIVATE)};this.unload=function(){k.unload();k=null;r.visible=!1;n.unload();x&&s_oLocalStorage.isDirty()&&x.unload();if(!1===DISABLE_SOUND_MOBILE||!1===
s_bMobile)l.unload(),l=null;y&&screenfull.isEnabled&&q.unload();s_oStage.removeChild(m);s_oMenu=m=null};this.refreshButtonPos=function(k,m){!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||l.setPosition(d-k,m+h);n.setPosition(g+k,m+e);y&&screenfull.isEnabled&&q.setPosition(b+k,f+m);x&&s_oLocalStorage.isDirty()&&x.setPosition(a-k,c+m)};this.resetFullscreenBut=function(){y&&screenfull.isEnabled&&q.setActive(s_bFullscreen)};this._onFullscreenRelease=function(){s_bFullscreen?u.call(window.document):y.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.resetData();x.unload()};this._onButPlayRelease=function(){this.unload();$(s_oMain).trigger("start_session");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 f(a){a||(a=window.event);a.preventDefault();s_oGame.onKeyDown(a.keyCode)}var g,e,d,h,m,k,r,l,n,q,x,y=null,u,t,A,D,E,I;this._init=function(a){k=a;q=[];E=new CHorizon(k);A=new createjs.Shape;s_oStage.addChild(A);D=new createjs.Container;s_oStage.addChild(D);t=new CRoad(A,D,k);u=new CPlayer(CANVAS_WIDTH/2,980,s_oStage);q=t.getSegments();TRACK_LENGTH=t.getTrackLength();x=new CInterface;I=[];new CLevelBuilder(u,I,
D,a);this.resetParams()};this.getWorldCameraPos=function(){var a=u.getPosition().z;a=this.findSegment(a);return q[a.index].p1.world};this.onKeyUp=function(a){if(g)switch(a){case KEY_LEFT:u.stopLeft();break;case KEY_UP:u.stopAccelerate();break;case KEY_RIGHT:u.stopRight();break;case KEY_DOWN:u.stopBrake()}};this.onKeyDown=function(a){if(g)switch(a){case KEY_LEFT:u.moveLeft();break;case KEY_UP:u.moveAccelerate();break;case KEY_RIGHT:u.moveRight();break;case KEY_DOWN:u.moveBrake()}};this.resetParams=
function(){g=!1;stopSound(s_aSounds.game_soundtrack);if(0===k)new CHelpPanel;else{g=!0;stopSound(s_aSounds.menu_soundtrack);playSound("game_soundtrack",1,!0);$(s_oMain).trigger("start_level",k);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)})}l=STATE_GAME_START;r=0;m=LEVEL_INFO[k].time;h=START_COUNTDOWN;E.restart();x.refreshTimer(m);
x.refreshCurTime(0);var d=k%NUM_TRACKS_PER_WORLD;x.setLevelInfo(s_oSpriteLibrary.getSprite("but_world"+Math.floor(k/NUM_WORLDS)),d+1);s_aTimeScore[k]<LEVEL_INFO[k].time&&0!==s_aTimeScore[k]?x.setBestTime(s_aTimeScore[k]):x.setBestTime(LEVEL_INFO[k].time);s_bMobile||(document.onkeydown=f,document.onkeyup=b);t.clearVisual(u.getPosition());n=u.getPlayerSegment();u.reset()};this.restartGame=function(){$(s_oMain).trigger("show_interlevel_ad");$(s_oMain).trigger("restart_level",k);this.resetParams()};this.unload=
function(){x.unload();null!==y&&y.unload();stopSound(s_aSounds.menu_soundtrack);stopSound(s_aSounds.game_soundtrack);stopSound(s_aSounds.engine);stopSound(s_aSounds.brake);stopSound(s_aSounds.engine_reverse);stopSound(s_aSounds.engine_stall);createjs.Tween.removeAllTweens();s_oStage.removeAllChildren()};this.checkDamage=function(){u.getCurSpeed()>PLAYER_MIN_SPEED_DAMAGE&&!e&&(e=!0,u.damageAnim(),new CTremble(s_oStage,250,20,5))};this.endDamageTime=function(){e=!1};this.trackCompleted=function(){E.resetPos();
l!==STATE_GAME_END&&($(s_oMain).trigger("end_level",k),$(s_oMain).trigger("show_interlevel_ad"),l=STATE_GAME_END,s_oGame.stopPlayer(),r=Math.floor(m/1E3*POINTS_PER_SECONDS),new CNextLevelPanel(m,r,k))};this._countDown=function(){h-=s_iTimeElaps;x.refreshCountdown(h);0>=h&&(h=0,l=STATE_GAME_RACE,x.countDownGo())};this.nextLevel=function(){k++;k<NUM_TRACKS_PER_WORLD*NUM_WORLDS?(this.unload(),this._init(k)):this.gameOver()};this.trackLose=function(){l=STATE_GAME_END;s_oGame.stopPlayer();$(s_oMain).trigger("end_level",
k);$(s_oMain).trigger("show_interlevel_ad");(new CLosePanel(s_oSpriteLibrary.getSprite("msg_box"))).show(r)};this.stopPlayer=function(){u.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(){g=!0;stopSound(s_aSounds.menu_soundtrack);playSound("game_soundtrack",1,!0);$(s_oMain).trigger("start_level",1)};this.gameOver=function(){y=
new CEndPanel(s_oSpriteLibrary.getSprite("msg_box"));y.show(r)};this.setPause=function(){g=!1;u.stopAll()};this.setResume=function(){g=!0};this.update=function(){var a=1/s_iCurFps;switch(l){case STATE_GAME_START:g&&this._countDown();break;case STATE_GAME_RACE:if(!g)return;m-=s_iTimeElaps;0>m&&(m=0,this.trackLose());x.refreshTimer(m);x.refreshCurTime(LEVEL_INFO[k].time-m);u.update(a);break;case STATE_GAME_END:u.update(a),u.autoPilot()}x.refreshSpeed(u.getCurSpeed()*PLAYER_SPEED_CONVERSION_RATIO);t.update(u.getPosition());
E.move(this.getWorldCameraPos());for(var b=0;b<I.length;b++)I[b].update(a,u);d=!1;this._ambientCollision();this._carsCollision();n=u.getPlayerSegment()};this._ambientCollision=function(){if(u.isOutOfRoad())for(var a=u.getPlayerSegment().index,b=n.index;b<=a;b++)for(var h=q[b],e=0;e<h.sprites.length;e++){var c=h.sprites[e];if(Util.overlap(u.getPosition().x,u.getPlayerWidth(),c.collision.center,c.collision.width)){this.checkDamage();u.setCurSpeed(PLAYER_ACCELERATION);u.setPosition(Util.increase(h.p1.world.z,
-PLAYER_Z_FROMCAMERA,TRACK_LENGTH));d=!0;u.stopEngineSound();break}}};this._carsCollision=function(){for(var a,b,h=u.getPlayerSegment().index,e=n.index;e<=h;e++)for(var c=q[e],f=0;f<c.cars.length;f++)if(a=c.cars[f],b=a.getSprite().width*SPRITES.SCALE,u.getCurSpeed()>a.getSpeed()&&Util.overlap(u.getPosition().x,u.getPlayerWidth(),a.getOffset(),b,.8)){this.checkDamage();u.setCurSpeed(a.getSpeed()*(a.getSpeed()/u.getCurSpeed()));u.setPosition(Util.increase(a.getZ(),-PLAYER_Z_FROMCAMERA,TRACK_LENGTH));
d=!0;u.stopEngineSound();break}};this.playerCollide=function(){return d};this.findSegment=function(a){return t.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,f,g,e,d,h,m,k,r,l,n,q,x,y,u,t,A,D,E,I,O,V,U,J,H,Q,M,R,S,T,P,F,N=null,p=null;this._init=function(){var G,z=s_oSpriteLibrary.getSprite("but_exit");u=CANVAS_WIDTH-z.width/2-12;t=z.height/2+16;D=new CGfxButton(u,t,z,s_oStage);D.addEventListener(ON_MOUSE_UP,this._onExit,this);x=G=u-z.width-12;y=z.height/2+16;if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)z=s_oSpriteLibrary.getSprite("audio_icon"),A=new CToggle(x,y,z,s_bAudioActive),A.addEventListener(ON_MOUSE_UP,this._onAudioToggle,
this),G=x-z.width/2-12;z=window.document;var K=z.documentElement;N=K.requestFullscreen||K.mozRequestFullScreen||K.webkitRequestFullScreen||K.msRequestFullscreen;p=z.exitFullscreen||z.mozCancelFullScreen||z.webkitExitFullscreen||z.msExitFullscreen;!1===ENABLE_FULLSCREEN&&(N=!1);N&&screenfull.isEnabled&&(z=s_oSpriteLibrary.getSprite("but_fullscreen"),g=G,e=z.height/2+16,T=new CToggle(g,e,z,s_bFullscreen,s_oStage),T.addEventListener(ON_MOUSE_UP,this._onFullscreenRelease,this));b=12;f=16;E=new createjs.Container;
s_oStage.addChild(E);z=s_oSpriteLibrary.getSprite("time_panel");G=createBitmap(z);E.addChild(G);O=new CTimer(110,50,E,50,"#ffffff","best_time","#000000");V=new CTimer(110,120,E,50,"#ffffff","timer","#000000");a=CANVAS_WIDTH/2;c=60;I=new CTimer(a,c,s_oStage,100,"#fff000",null,"#000000");I.resetTextRelativePos();I.setAlign("center","middle");U=new CTachometer(152,CANVAS_HEIGHT-12);J=new createjs.Text(""," 300px "+PRIMARY_FONT,"#3e240b");J.x=CANVAS_WIDTH/2;J.y=CANVAS_HEIGHT/2;J.textAlign="center";J.textBaseline=
"middle";J.lineWidth=200;J.outline=20;s_oStage.addChild(J);H=new createjs.Text(""," 300px "+PRIMARY_FONT,"rgba(255,224,0,1)");H.x=CANVAS_WIDTH/2;H.y=CANVAS_HEIGHT/2;H.textAlign="center";H.textBaseline="middle";H.lineWidth=200;s_oStage.addChild(H);s_bMobile&&(G=CANVAS_HEIGHT-270,z=s_oSpriteLibrary.getSprite("key_up"),n=CANVAS_WIDTH-180+z.width/2,q=G,Q=new CGfxButton(n,q,z,s_oStage),Q.addEventListenerWithParams(ON_MOUSE_UP,s_oGame.onKeyUp,this,KEY_UP),Q.addEventListenerWithParams(ON_MOUSE_DOWN,s_oGame.onKeyDown,
this,KEY_UP),z=s_oSpriteLibrary.getSprite("key_down"),r=CANVAS_WIDTH-180-z.width/2,l=G,M=new CGfxButton(r,l,z,s_oStage),M.addEventListenerWithParams(ON_MOUSE_UP,s_oGame.onKeyUp,this,KEY_DOWN),M.addEventListenerWithParams(ON_MOUSE_DOWN,s_oGame.onKeyDown,this,KEY_DOWN),z=s_oSpriteLibrary.getSprite("key_left"),m=180-z.width/2,k=G,R=new CGfxButton(m,k,z,s_oStage),R.addEventListenerWithParams(ON_MOUSE_UP,s_oGame.onKeyUp,this,KEY_LEFT),R.addEventListenerWithParams(ON_MOUSE_DOWN,s_oGame.onKeyDown,this,KEY_LEFT),
z=s_oSpriteLibrary.getSprite("key_right"),d=180+z.width/2,h=G,S=new CGfxButton(d,h,z,s_oStage),S.addEventListenerWithParams(ON_MOUSE_UP,s_oGame.onKeyUp,this,KEY_RIGHT),S.addEventListenerWithParams(ON_MOUSE_DOWN,s_oGame.onKeyDown,this,KEY_RIGHT));F=[];for(G=0;3>=G;G++)F[G]=!1;this.refreshButtonPos(s_iOffsetX,s_iOffsetY)};this.unload=function(){if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)A.unload(),A=null;N&&screenfull.isEnabled&&T.unload();D.unload();s_oInterface=null;s_bMobile&&(Q.unload(),M.unload(),
R.unload(),S.unload())};this.refreshButtonPos=function(p,z){D.setPosition(u-p,z+t);!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||A.setPosition(x-p,z+y);N&&screenfull.isEnabled&&T.setPosition(g-p,e+z);E.x=b+p;E.y=f+z;s_bMobile&&(Q.setPosition(n-p,q-z),M.setPosition(r-p,l-z),R.setPosition(m+p,k-z),S.setPosition(d+p,h-z));I.setPos(a,c+z);U.updateOffset(p,z)};this.resetFullscreenBut=function(){N&&screenfull.isEnabled&&T.setActive(s_bFullscreen)};this._onFullscreenRelease=function(){s_bFullscreen?p.call(window.document):
N.call(window.document.documentElement);sizeHandler()};this.refreshTimer=function(a){I.setIntTime(a)};this.setBestTime=function(a){O.setDecimalTime(a)};this.refreshCurTime=function(a){V.setDecimalTime(a)};this.refreshCountdown=function(a){var d=Math.ceil(a/1E3),b=(1E3*d-a)/1E3;H.alpha=1-b;H.scaleX=H.scaleY=b;H.text=Math.ceil(a/1E3);J.alpha=H.alpha;J.scaleX=J.scaleY=b;J.text=H.text;if(3===d&&!F[3])F[3]=!0,playSound("3",1,0);else if(2===d&&!F[2])F[2]=!0,playSound("2",1,0);else if(1===d&&!F[1])F[1]=
!0,playSound("1",1,0);else if(0===d)for(F[0]=!0,playSound("go",1,0),a=0;a<F.length;a++)F[a]=!1};this.refreshSpeed=function(a){U.setSpeedIndicator(a)};this.countDownGo=function(){H.scaleX=H.scaleY=1;J.scaleX=J.scaleY=H.scaleY;H.text=TEXT_GO;J.text=TEXT_GO;createjs.Tween.get(H).wait(500).to({alpha:0},1E3,createjs.Ease.cubicIn);createjs.Tween.get(J).wait(500).to({alpha:0},1E3,createjs.Ease.cubicIn)};this.setLevelInfo=function(a,d){P&&P.unload();var b=s_oSpriteLibrary.getSprite("time_panel");P=new CLevelBut(a.width/
4*.6+b.width+12,a.height/2*.6,a,!0,0,E);P.setScale(.6);P.setClickable(!1);P.addLevelText(d)};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,f;this._init=function(){b=new createjs.Shape;b.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);b.alpha=1;b.on("mousedown",function(){g._onExitHelp()});s_oStage.addChild(b);(new createjs.Tween.get(b)).to({alpha:.7},500);f=new createjs.Container;f.on("pressup",function(){g._onExitHelp()});s_oStage.addChild(f);var e=s_oSpriteLibrary.getSprite("msg_box"),d=createBitmap(e);d.regX=e.width/2;d.regY=e.height/2;f.addChild(d);f.x=CANVAS_WIDTH/2;f.y=CANVAS_HEIGHT+
e.height/2;a=f.y;(new createjs.Tween.get(f)).to({y:CANVAS_HEIGHT/2-40},500,createjs.Ease.cubicOut);s_bMobile?(new CTLText(f,-250,-160,500,48,24,"center","#fff",PRIMARY_FONT,1,0,0,TEXT_HELP1_MOBILE,!0,!0,!0,!1),e=s_oSpriteLibrary.getSprite("key_left"),d=createBitmap(e),d.x=-170,d.y=-60,d.regX=e.width/2,d.regY=e.height/2,d.scaleX=d.scaleY=.7,f.addChild(d),e=s_oSpriteLibrary.getSprite("key_right"),d=createBitmap(e),d.x=-80,d.y=-60,d.regX=e.width/2,d.regY=e.height/2,d.scaleX=d.scaleY=.7,f.addChild(d),
e=s_oSpriteLibrary.getSprite("key_down"),d=createBitmap(e),d.x=80,d.y=-60,d.regX=e.width/2,d.regY=e.height/2,d.scaleX=d.scaleY=.7,f.addChild(d),e=s_oSpriteLibrary.getSprite("key_up"),d=createBitmap(e),d.x=170,d.y=-60,d.regX=e.width/2,d.regY=e.height/2,d.scaleX=d.scaleY=.7):(new CTLText(f,-250,-150,300,120,24,"center","#fff",PRIMARY_FONT,1,0,0,TEXT_HELP1,!0,!0,!0,!1),e=s_oSpriteLibrary.getSprite("keys"),d=createBitmap(e),d.x=130,d.y=-100,d.regX=e.width/2,d.regY=e.height/2);f.addChild(d);new CTLText(f,
10,24,300,120,24,"left","#fff",PRIMARY_FONT,1,0,0,TEXT_HELP2,!0,!0,!0,!1);d=new createjs.Container;d.x=-130;d.y=130;d.scaleX=d.scaleY=.3;f.addChild(d);e=s_oSpriteLibrary.getSprite("finish");var h=createBitmap(e);h.regX=e.width/2;h.regY=e.height;d.addChild(h);new CPlayer(0,0,d)};this.unload=function(){s_oStage.removeChild(b);s_oStage.removeChild(f);f.off("pressup",function(){g._onExitHelp()});b.off("pressup",function(){g._onExitHelp()})};this._onExitHelp=function(){c||(c=!0,(new createjs.Tween.get(b)).to({alpha:0},
500),(new createjs.Tween.get(f)).to({y:a},400,createjs.Ease.backIn).call(function(){g.unload();s_oGame._onExitHelp()}))};var g=this;this._init()}
function CEndPanel(){var a,c,b;this._init=function(){setVolume(s_aSounds.game_soundtrack,SOUNDTRACK_VOLUME_IN_GAME);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 f=s_oSpriteLibrary.getSprite("msg_box"),g=createBitmap(f);g.regX=f.width/2;g.regY=f.height/2;c.addChild(g);c.x=CANVAS_WIDTH/2;c.y=CANVAS_HEIGHT+
f.height/2;(new createjs.Tween.get(c)).to({y:CANVAS_HEIGHT/2},500,createjs.Ease.quartIn);new CTLText(c,-250,-f.height/2+40,500,120,40,"center","#fff",PRIMARY_FONT,1,0,0,TEXT_GAMEOVER,!0,!0,!0,!1);f=s_oSpriteLibrary.getSprite("finish");g=createBitmap(f);g.regX=f.width/2;g.regY=f.height;g.y=154;g.scaleX=g.scaleY=.6;c.addChild(g);f=s_oSpriteLibrary.getSprite("but_home");b=new CGfxButton(0,100,f,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 f,g,e,d,h,m,k,r,l,n,q,x,y,u,t,A,D,E,I,O;this._init=function(a,d,b){this.reset();n=PLAYER_MAX_SPEED;q=PLAYER_ACCELERATION;x=-n;y=-PLAYER_DECELERATION;u=-n/2;t=n/4;var h=s_oSpriteLibrary.getSprite("baloon_mc");O=createBitmap(h);O.regX=h.width/2;O.regY=h.height/2;O.x=a;O.y=d-260;O.alpha=0;b.addChild(O);h=s_oSpriteLibrary.getSprite("player");var e=h.width/3,c=h.height;h=new createjs.SpriteSheet({images:[h],frames:{width:e,height:c,regX:e/2,regY:c},animations:{left:[0],right:[1],
straight:[2]}});E=createSprite(h,"straight",e/2,c,e,c);E.x=a;E.y=d;b.addChild(E);A=PLAYER_COLLIDER_WIDTH};this.reset=function(){h=m=d=e=g=f=!1;D=l=r=k=0;I=s_oGame.findSegment(k+PLAYER_Z_FROMCAMERA)};this.setAcceleration=function(a){q=a};this.setMaxSpeed=function(a){n=a;x=-n;y=-PLAYER_DECELERATION;u=-n/2;t=n/4};this.stopAll=function(){this.stopLeft();this.stopRight();this.stopAccelerate()};this.stopLeft=function(){f&&(f=!1,E.gotoAndStop("straight"),stopSound(s_aSounds.brake))};this.stopRight=function(){g&&
(g=!1,E.gotoAndStop("straight"),stopSound(s_aSounds.brake))};this.stopAccelerate=function(){e=!1;stopSound(s_aSounds.engine)};this.stopBrake=function(){d=!1};this.moveLeft=function(){0!==l&&(soundPlaying(s_aSounds.brake)||playSound("brake",.5,!1),g=!1,f=!0,E.gotoAndStop("left"))};this.moveRight=function(){0!==l&&(soundPlaying(s_aSounds.brake)||playSound("brake",.5,!1),f=!1,g=!0,E.gotoAndStop("right"))};this.moveAccelerate=function(){d=!1;e=!0};this.moveBrake=function(){e=!1;d=!0};this._increase=function(a,
d,b){for(a+=d;a>=b;)a-=b,s_oGame.trackCompleted();for(;0>a;)a+=b;return a};this._accelerate=function(a,d,b){return a+d*b};this._limit=function(a,d,b){return Math.max(d,Math.min(a,b))};this.getPlayerWidth=function(){return A};this.getPosition=function(){return{x:r,z:k}};this.setPosition=function(a){k=a};this.autoPilot=function(){.5<r?(g=!1,f=!0):-.5>r?(g=!0,f=!1):.1>=r&&-.1<=r&&(g=f=!1)};this.getMaxSpeed=function(){return n};this.getCurSpeed=function(){return l};this.setCurSpeed=function(a){l=a};this.getPlayerSegment=
function(){return I};this.getFrontPlayerSegment=function(){return s_oGame.findSegment(k+SEGMENT_LENGTH+PLAYER_Z_FROMCAMERA)};this.damageAnim=function(){m||(m=!0,playSound("crash",1,!1),createjs.Tween.get(O,{override:!0}).to({alpha:1},250,createjs.Ease.cubicOut).to({alpha:0},250,createjs.Ease.cubicIn).call(function(){m=!1}))};this.isOutOfRoad=function(){return h};this.stopEngineSound=function(){stopSound(s_aSounds.engine);stopSound(s_aSounds.engine_stall)};this._updateXMovement=function(a,d){var b=
a*d*d*I.curve*CENTRIFUGAL_FORCE/TERRAIN_ADHERENCE;f?(D-=TERRAIN_INCREASE_INERTIA*d,D<-TERRAIN_MAX_INERTIA&&(D=-TERRAIN_MAX_INERTIA),r=r-b-a):g?(D+=TERRAIN_INCREASE_INERTIA*d,D>TERRAIN_MAX_INERTIA&&(D=TERRAIN_MAX_INERTIA),r=r-b+a):r=r-b+D;0<D?(D-=TERRAIN_DECREASE_INERTIA,0>D&&(D=0)):0>D&&(D+=TERRAIN_DECREASE_INERTIA,0<D&&(D=0))};this.update=function(a){I=s_oGame.findSegment(k+PLAYER_Z_FROMCAMERA);var b=l/n;k=this._increase(k,a*l,TRACK_LENGTH);this._updateXMovement(2*a*TERRAIN_ADHERENCE*b,b);e?(l=this._accelerate(l,
q,a),1===b?soundPlaying(s_aSounds.engine_stall)||(stopSound(s_aSounds.engine),stopSound(s_aSounds.engine_reverse),playSound("engine_stall",.7,!0)):0<l&&!soundPlaying(s_aSounds.engine)&&!s_oGame.playerCollide()&&(stopSound(s_aSounds.brake),stopSound(s_aSounds.engine_stall),stopSound(s_aSounds.engine_reverse),playSound("engine",.7,!1),b=linearFunction(b,0,1,0,soundDuration(s_aSounds.engine)),soundSeek(s_aSounds.engine,b))):d?(l=this._accelerate(l,x,a),0<l&&(stopSound(s_aSounds.engine),stopSound(s_aSounds.engine_stall),
stopSound(s_aSounds.engine_reverse),soundPlaying(s_aSounds.brake)||playSound("brake",.5,!1))):(l=this._accelerate(l,y,a),0<l&&!soundPlaying(s_aSounds.engine_reverse)&&(stopSound(s_aSounds.brake),stopSound(s_aSounds.engine_stall),stopSound(s_aSounds.engine),playSound("engine_reverse",.7,!1),b=linearFunction(b,0,1,soundDuration(s_aSounds.engine_reverse),0),soundSeek(s_aSounds.engine_reverse,b)));h=!1;if(-1>r||1<r)l>t&&(l=this._accelerate(l,u,a)),h=!0;r=this._limit(r,-ROAD_BOUNDS,ROAD_BOUNDS);l=this._limit(l,
0,n)};this._init(a,c,b)}
var Render={polygon:function(a,c,b,f,g,e,d,h,m,k){a.graphics.beginFill(k);a.graphics.moveTo(c,b);a.graphics.lineTo(f,g);a.graphics.lineTo(e,d);a.graphics.lineTo(h,m)},segment:function(a,c,b,f,g,e,d,h,m,k){var r=Render.rumbleWidth(e,b),l=Render.rumbleWidth(m,b),n=Render.laneMarkerWidth(e,b),q=Render.laneMarkerWidth(m,b);a.graphics.beginFill(k.grass);a.graphics.drawRect(0,h,c,g-h);Render.polygon(a,f-e-r,g,f-e,g,d-m,h,d-m-l,h,k.rumble);Render.polygon(a,f+e+r,g,f+e,g,d+m,h,d+m+l,h,k.rumble);Render.polygon(a,
f-e,g,f+e,g,d+m,h,d-m,h,k.road);if(k.lane)for(c=2*e/b,r=2*m/b,f=f-e+c,d=d-m+r,m=1;m<b;f+=c,d+=r,m++)Render.polygon(a,f-n/2,g,f+n/2,g,d+q/2,h,d-q/2,h,k.lane)},background:function(a,c,b,f,g,e,d){var h=g.w/2;e=g.x+Math.floor(g.w*(e||0));var m=g.y,k=Math.min(h,g.x+g.w-e),r=g.h;d=d||0;var l=Math.floor(k/h*b);a.drawImage(c,e,m,k,r,0,d,l,f);k<h&&a.drawImage(c,g.x,m,h-k,r,l-1,d,b-l,f)},sprite:function(a,c,b,f,g,e,d,h){var m=b*ROAD_PER_SCALE_PER_HALF_CANVAS_WIDTH;b=a.width*m;m*=a.height;var k=m/a.height;g+=
m*(d||0);d=h?Math.max(0,g+m-h):0;d<m?(c.x=f+b*(e||0),c.y=g,c.scaleX=c.scaleY=k,a=new createjs.Rectangle(0,0,a.width,a.height-a.height*d/m),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 f,g,e;this._init=function(a,b,c){f=null;g=CAMERA_DEPTH;e=[];this.resetRoad()};this.findSegment=function(a){return e[Math.floor(a/SEGMENT_LENGTH)%e.length]};this.lastX=function(){return 0===e.length?0:e[e.length-1].p2.world.x};this.lastY=function(){return 0===e.length?0:e[e.length-1].p2.world.y};this.addSegment=function(a,b){var d=e.length;e.push({index:d,p1:{world:{x:this.lastX(),y:this.lastY(),z:d*SEGMENT_LENGTH},camera:{},screen:{}},p2:{world:{x:this.lastX()+a,y:b,z:(d+
1)*SEGMENT_LENGTH},camera:{},screen:{}},curve:a,sprites:[],cars:[],coins:[],color:Math.floor(d/RUMBLE_LENGTH)%2?COLORS.DARK:COLORS.LIGHT})};this.addRoad=function(a,b,e,c,f){var d=this.lastY();f=d+Util.toInt(f,0)*SEGMENT_LENGTH;var h,g=a+b+e;for(h=0;h<a;h++)this.addSegment(Util.easeIn(0,c,h/a),Util.easeInOut(d,f,h/g));for(h=0;h<b;h++)this.addSegment(c,Util.easeInOut(d,f,(a+h)/g));for(h=0;h<e;h++)this.addSegment(Util.easeInOut(c,0,h/e),Util.easeInOut(d,f,(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,e){a=a||ROAD.LENGTH.MEDIUM;b=b||ROAD.CURVE.MEDIUM;this.addRoad(a,a,a,b)};this.addStandardRoad=function(a,b,e){a=a||ROAD.LENGTH.MEDIUM;b=b||ROAD.CURVE.NONE;e=e||ROAD.HILL.NONE;this.addRoad(a,a,a,b,e)};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,e){a=a||ROAD.LENGTH.MEDIUM;b=b||ROAD.CURVE.MEDIUM;e=e||ROAD.HILL.NONE;var d=0<=b?1:-1;var h=0<=e?1:-1;b=Math.abs(b);e=Math.abs(e);switch(b){case ROAD.CURVE.EASY:var c=ROAD.CURVE.NONE;var f=ROAD.CURVE.EASY;break;case ROAD.CURVE.MEDIUM:c=ROAD.CURVE.EASY;f=ROAD.CURVE.MEDIUM;break;case ROAD.CURVE.HARD:c=ROAD.CURVE.MEDIUM,f=ROAD.CURVE.HARD}switch(e){case ROAD.HILL.EASY:var g=
ROAD.HILL.NONE;var m=ROAD.HILL.LOW;break;case ROAD.HILL.MEDIUM:g=ROAD.HILL.LOW;m=ROAD.HILL.MEDIUM;break;case ROAD.HILL.HIGH:g=ROAD.HILL.MEDIUM,m=ROAD.HILL.HIGH}this.addRoad(a,a,a,d*c,ROAD.HILL.NONE);this.addRoad(a,a,a,d*f,h*m);this.addRoad(a,a,a,d*c,-h*g);this.addRoad(a,a,a,-d*c,h*m);this.addRoad(a,a,a,-d*f,-h*g)};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(){e=[];for(var a=ROAD_INFO[b],h=0;h<a.length;h++){var c=a[h];switch(c.roadtype){case ROAD.TYPE.STANDARD:this.addStandardRoad(c.length,c.curve,c.hill);break;case ROAD.TYPE.CURVE_S:this.addSCurves(c.length,c.curve,c.hill);break;
case ROAD.TYPE.BUMPS:this.addBumps(c.length,c.curve);break;case ROAD.TYPE.FINAL:this.addDownhillToEnd(c.length,c.curve)}}e[this.findSegment(PLAYER_Z_FROMCAMERA).index+2].color=COLORS.START;e[this.findSegment(PLAYER_Z_FROMCAMERA).index+3].color=COLORS.START;for(a=0;a<RUMBLE_LENGTH;a++)e[e.length-1-a].color=COLORS.FINISH;f=e.length*SEGMENT_LENGTH};this.setCameraDepth=function(a){g=a};this.clearVisual=function(b){a.graphics.clear();b=this.findSegment(b.z);var d;for(d=DRAW_DISTANCE-1;0<d;d--){var c=e[(b.index+
d)%e.length];for(var f=0;f<c.cars.length;f++){var g=c.cars[f];g.setVisible(!1)}for(f=0;f<c.sprites.length;f++)g=c.sprites[f],g.source.visible=!1}};this.update=function(b){a.graphics.clear();var d=b.z;b=b.x;var m=this.findSegment(d),k=Util.percentRemaining(d,SEGMENT_LENGTH),r=this.findSegment(d+PLAYER_Z_FROMCAMERA),l=Util.percentRemaining(d+PLAYER_Z_FROMCAMERA,SEGMENT_LENGTH);r=Util.interpolate(r.p1.world.y,r.p2.world.y,l);l=CANVAS_HEIGHT;var n=0,q=-(m.curve*k),x=b*ROAD_WIDTH,y=r+CAMERA_HEIGHT;for(r=
0;r<DRAW_DISTANCE;r++){k=e[(m.index+r)%e.length];k.looped=k.index<m.index;k.clip=l;var u=d-(k.looped?f:0);Util.project(k.p1,x-n,y,u,g);Util.project(k.p2,x-n-q,y,u,g);n+=q;q+=k.curve;k.p1.camera.z<=g||k.p2.screen.y>=k.p1.screen.y||k.p2.screen.y>=l||(Render.segment(a,CANVAS_WIDTH,NUM_LANES,k.p1.screen.x,k.p1.screen.y,k.p1.screen.w,k.p2.screen.x,k.p2.screen.y,k.p2.screen.w,k.color),l=k.p2.screen.y)}x=0;for(r=DRAW_DISTANCE-1;0<r;r--){k=e[(m.index+r)%e.length];for(n=0;n<k.cars.length;n++){l=k.cars[n];
q=l.getZ()-d;y=l.getOffset()-b;q>CAR_FARVIEW_OFFSET?k.curve>-CAR_CURVEVIEW_OFFSET&&k.curve<CAR_CURVEVIEW_OFFSET?l.setDirection(CAR_CENTER):k.curve<CAR_CURVEVIEW_OFFSET?l.setDirection(CAR_LEFT):l.setDirection(CAR_RIGHT):y>-CAR_SIDEVIEW_OFFSET&&l.getOffset()-b<CAR_SIDEVIEW_OFFSET?l.setDirection(CAR_CENTER):y<-CAR_SIDEVIEW_OFFSET?l.setDirection(CAR_RIGHT):l.setDirection(CAR_LEFT);q=l.getSprite();y=Util.interpolate(k.p1.screen.scale,k.p2.screen.scale,l.getPercent());u=Util.interpolate(k.p1.screen.x,k.p2.screen.x,
l.getPercent())+y*l.getOffset()*ROAD_PER_HALF_CANVAS_WIDTH;var t=Util.interpolate(k.p1.screen.y,k.p2.screen.y,l.getPercent());l.setVisible(!0);c.setChildIndex(l.getCar(),x++);Render.sprite(q,l.getCar(),y,u,t,-.5,-1,k.clip)}for(n=0;n<k.sprites.length;n++)q=k.sprites[n],y=k.p1.screen.scale,u=k.p1.screen.x+y*q.offset*ROAD_PER_HALF_CANVAS_WIDTH,t=k.p1.screen.y,q.source.visible=!0,c.setChildIndex(q.source,x++),Render.sprite(q.sprite,q.source,y,u,t,0>q.offset?-1:0,-1,k.clip)}d=(m.index-25)%e.length;if(0<
d)for(b=0;25>b;b++){k=e[d+b];for(n=0;n<k.sprites.length;n++)q=k.sprites[n],q.source.visible=!1;for(n=0;n<k.cars.length;n++)l=k.cars[n],l.setVisible(!1)}else for(b=e.length+d-1;b<e.length;b++){k=e[b];for(n=0;n<k.sprites.length;n++)q=k.sprites[n],q.source.visible=!1;for(n=0;n<k.cars.length;n++)l=k.cars[n],l.setVisible(!1)}};this.exponentialFog=function(a,b){return 1/Math.pow(Math.E,a*a*b)};this.getTrackLength=function(){return f};this.getSegments=function(){return e};this._init(a,c,b)}
var CAR_CENTER=0,CAR_LEFT=1,CAR_RIGHT=2;
function CCar(a,c,b,f,g){var e,d,h,m,k,r,l;this._init=function(a,b,c,f,g){e=b;d=c;h=f;k=[];k[CAR_CENTER]=s_oSpriteLibrary.getSprite(a+"_center");k[CAR_LEFT]=s_oSpriteLibrary.getSprite(a+"_left");k[CAR_RIGHT]=s_oSpriteLibrary.getSprite(a+"_right");l=k[CAR_CENTER];r=createBitmap(l);r.x=500;r.visible=!1;g.addChild(r)};this.getCar=function(){return r};this.getSprite=function(){return l};this.getOffset=function(){return e};this.getZ=function(){return d};this.getSpeed=function(){return h};this.getPercent=
function(){return m};this.setDirection=function(a){l=k[a];r.image=k[a]};this.setVisible=function(a){r.visible=a};this.updateCarOffset=function(a,b){var d,c;var f=n.getSprite().width*SPRITES.SCALE;if(a.index-b.getPlayerSegment().index>DRAW_DISTANCE)return r.visible=!1,0;for(d=1;20>d;d++){var g=s_oGame.getSegments();var k=g[(a.index+d)%g.length];if(k===b.getPlayerSegment()&&h>b.getCurSpeed()&&Util.overlap(b.getPosition().x,b.getPlayerWidth(),e,f,1.2))return f=.5<b.getPosition().x?-1:-.5>b.getPosition().x?
1:e>b.getPosition().x?1:-1,1*f/d*(h-b.getCurSpeed())/b.getMaxSpeed();for(c=0;c<k.cars.length;c++){g=k.cars[c];var l=g.getSprite().width*SPRITES.SCALE;if(h>g.getSpeed()&&Util.overlap(e,f,g.getOffset(),l,1.2))return f=.5<g.getOffset()?-1:-.5>g.getOffset()?1:e>g.getOffset()?1:-1,1*f/d*(h-g.getSpeed())/b.getMaxSpeed()}}return-.9>e?.1:.9<e?-.1:0};this.update=function(a,b){var c=s_oGame.findSegment(d);e+=this.updateCarOffset(c,b);d=Util.increase(d,a*h,TRACK_LENGTH);m=Util.percentRemaining(d,SEGMENT_LENGTH);
var f=s_oGame.findSegment(d);if(c!==f){var g=c.cars.indexOf(n);c.cars.splice(g,1);f.cars.push(n)}};var n=this;this._init(a,c,b,f,g)}
function CLevelBuilder(a,c,b,f){var g;this._init=function(a,b,c,f){g=LEVEL_INFO[f].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 d=s_oGame.getSegments()[a].sprites,c=0;c<d.length;c++)b.addChildAt(d[c].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,f,g,r,l){r=r||100;l=l||1;if(a===AMBIENT.SIDE.BOTH)this._addDensityElements(AMBIENT.SIDE.RIGHT,b,c,f,g,r,l),this._addDensityElements(AMBIENT.SIDE.LEFT,
b,c,f,g,r,l);else for(;c<=f;c+=l)if(100*Math.random()<=r){var d=c+Util.randomInt(0,5);this._addSprite(d,b,a+a*g+2*a*Math.random())}};this._addPreciseElements=function(a,b,c,f,g,r,l){r=r||100;l=l||1;if(a===AMBIENT.SIDE.BOTH)this._addPreciseElements(AMBIENT.SIDE.RIGHT,b,c,f,g,r,l),this._addPreciseElements(AMBIENT.SIDE.LEFT,b,c,f,g,r,l);else for(;c<=f;c+=l)100*Math.random()<=r&&this._addSprite(c,b,a+a*g)};this._initSprites=function(){var a,b=AMBIENT_INFO[f];for(a=0;a<b.length;a++){var c=b[a];if(c.segments.constructor===
Array){var g=c.segments[0];var k=c.segments[1]}else k=g=c.segments;switch(c.disposition){case AMBIENT.DISPOSITION.PRECISE:this._addPreciseElements(c.side,c.sprite,g,k,c.position,c.occurrence,c.repetitionevery);break;case AMBIENT.DISPOSITION.DENSITY:this._addDensityElements(c.side,c.sprite,g,k,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 e;for(e=0;e<g;e++){var d=Math.random()*Util.randomChoice([-.8,.8]);var f=Math.floor(Math.random()*s_oGame.getSegments().length)*SEGMENT_LENGTH;var m=Util.randomChoice(SPRITES.CARS);var k=a.getMaxSpeed()/4+Math.random()*a.getMaxSpeed()/(m==SPRITES.SEMI?4:2);d=new CCar(m,d,f,k,b);f=s_oGame.findSegment(f);f.cars.push(d);c.push(d)}};this._initTerrainInfo=function(){COLORS.LIGHT.road=LEVEL_INFO[f].terrain.color.light.road;COLORS.LIGHT.grass=
LEVEL_INFO[f].terrain.color.light.grass;COLORS.LIGHT.rumble=LEVEL_INFO[f].terrain.color.light.rumble;COLORS.LIGHT.lane=LEVEL_INFO[f].terrain.color.light.lane;COLORS.DARK.road=LEVEL_INFO[f].terrain.color.dark.road;COLORS.DARK.grass=LEVEL_INFO[f].terrain.color.dark.grass;COLORS.DARK.rumble=LEVEL_INFO[f].terrain.color.dark.rumble;TERRAIN_ADHERENCE=LEVEL_INFO[f].terrain.adherence;TERRAIN_MAX_INERTIA=LEVEL_INFO[f].terrain.max_inertia;NUM_LANES=LEVEL_INFO[f].terrain.num_lanes;ROAD_BOUNDS=LEVEL_INFO[f].terrain.roadbounds};
this._init(a,c,b,f)}
function CWorldMenu(){var a,c,b,f,g,e,d,h,m,k,r,l,n,q,x,y=null,u=null;this._init=function(){r=createBitmap(s_oSpriteLibrary.getSprite("bg_select"));s_oStage.addChild(r);new CTLText(s_oStage,CANVAS_WIDTH/2-300,CANVAS_HEIGHT/2-230,600,80,40,"center","#ffffff",PRIMARY_FONT,1,0,0,TEXT_SELECT_WORLD,!0,!0,!0,!1);m=[];for(var t=0;t<NUM_WORLDS*NUM_TRACKS_PER_WORLD;t++)m[t]=s_aTimeScore[t];k=[];for(t=0;t<NUM_WORLDS;t++){var A=s_oSpriteLibrary.getSprite("but_world"+t),D=CANVAS_WIDTH/2-250+500/(NUM_WORLDS-1)*
t,E=s_oSpriteLibrary.getSprite("image_"+t),I=s_oSpriteLibrary.getSprite("cover_"+t);k[t]=new CLevelBut(D,CANVAS_HEIGHT/2,A,I,E,s_oStage);k[t].addEventListenerWithParams(ON_MOUSE_UP,this._onLevelBut,this,t);k[t].disable()}this._setLevelActive();t=s_oSpriteLibrary.getSprite("but_exit");d=CANVAS_WIDTH-t.width/2-12;h=t.height/2+16;l=new CGfxButton(d,h,t,s_oStage);l.addEventListener(ON_MOUSE_UP,this._onExit,this);b=d-t.width-12;f=t.height/2+16;if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)t=s_oSpriteLibrary.getSprite("audio_icon"),
q=new CToggle(b,f,t,s_bAudioActive),q.addEventListener(ON_MOUSE_UP,this._onAudioToggle,this);t=window.document;A=t.documentElement;y=A.requestFullscreen||A.mozRequestFullScreen||A.webkitRequestFullScreen||A.msRequestFullscreen;u=t.exitFullscreen||t.mozCancelFullScreen||t.webkitExitFullscreen||t.msExitFullscreen;!1===ENABLE_FULLSCREEN&&(y=!1);y&&screenfull.isEnabled&&(t=s_oSpriteLibrary.getSprite("but_fullscreen"),a=t.width/4+12,c=t.height/2+16,x=new CToggle(a,c,t,s_bFullscreen,s_oStage),x.addEventListener(ON_MOUSE_UP,
this._onFullscreenRelease,this));g=64;e=CANVAS_HEIGHT-40;n=new createjs.Container;n.x=g;n.y=e;s_oStage.addChild(n);t=new createjs.Text(" "+s_iTotalScore,"bold 30px "+PRIMARY_FONT,"#ffffff");t.textAlign="left";t.textBaseline="middle";t.lineWidth=500;n.addChild(t);t=s_oSpriteLibrary.getSprite("star");A=createBitmap(t);A.regX=t.width/2;A.regY=t.height/2;A.x=-t.width/2;n.addChild(A);this.refreshButtonPos(s_iOffsetX,s_iOffsetY)};this.refreshButtonPos=function(k,m){l.setPosition(d-k,m+h);!1!==DISABLE_SOUND_MOBILE&&
!1!==s_bMobile||q.setPosition(b-k,m+f);y&&screenfull.isEnabled&&x.setPosition(a+k,c+m);n.x=g+k;n.y=e-m};this.unload=function(){for(var a=0;a<k.length;a++)k[a].unload();s_oWorldMenu=null;s_oStage.removeAllChildren();if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)q.unload(),q=null;y&&screenfull.isEnabled&&x.unload()};this._setLevelActive=function(){for(var a=0,b=0;b<m.length;b++)0<m[b]&&(a=b+1);if(a===NUM_TRACKS_PER_WORLD*k.length)for(b=0;b<k.length;b++)k[b].enable();else{a=Math.floor(a/NUM_TRACKS_PER_WORLD);
for(b=0;b<a+1;b++)k[b].enable();k[a].pulseAnimation()}};this._onLevelBut=function(a){var b=a*NUM_TRACKS_PER_WORLD;new CTrackMenu(a,[m[b],m[b+1],m[b+2]])};this.resetFullscreenBut=function(){y&&screenfull.isEnabled&&x.setActive(s_bFullscreen)};this._onFullscreenRelease=function(){s_bFullscreen?u.call(window.document):y.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,f,g,e,d;this._init=function(a,c){g=new createjs.Shape;g.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);g.alpha=0;g.on("mousedown",function(){});s_oStage.addChild(g);(new createjs.Tween.get(g)).to({alpha:.7},500);d=new createjs.Container;s_oStage.addChild(d);var h=s_oSpriteLibrary.getSprite("msg_box"),m=createBitmap(h);m.regX=h.width/2;m.regY=h.height/2;d.addChild(m);new CTLText(d,-300,-133,600,40,40,"center","#ffffff",PRIMARY_FONT,1,0,0,TEXT_SELECT_TRACK,
!0,!0,!1,!1);d.x=CANVAS_WIDTH/2;d.y=CANVAS_HEIGHT+h.height/2+70;b=d.y;(new createjs.Tween.get(d)).to({y:CANVAS_HEIGHT/2},500,createjs.Ease.quartIn);h=s_oSpriteLibrary.getSprite("but_level");m=s_oSpriteLibrary.getSprite("image_"+a);var l=s_oSpriteLibrary.getSprite("cover_"+a);f=[];for(var n=0;n<NUM_TRACKS_PER_WORLD;n++){var q=n+1;f[n]=new CLevelBut(-180+180*n,0,h,l,m,d);f[n].addEventListenerWithParams(ON_MOUSE_UP,this._onStageBut,this,n);f[n].addLevelText(q);f[n].disable()}this._setStageInfo();h=s_oSpriteLibrary.getSprite("but_exit");
e=new CGfxButton(326,-200,h,d);e.addEventListener(ON_MOUSE_UP,this._onBack,this)};this.unload=function(){for(var a=0;a<NUM_TRACKS_PER_WORLD;a++)f[a].unload();g.off("mousedown",function(){});s_oStage.removeChild(g);s_oStage.removeChild(d)};this._setStageInfo=function(){for(var b=0,d=0;d<c.length;d++)0<c[d]&&(b=d+1);b<NUM_TRACKS_PER_WORLD&&(f[b].enable(),f[b].addScore(LEVEL_INFO[a*NUM_TRACKS_PER_WORLD+b].time),f[b].pulseAnimation());for(d=0;d<b;d++)f[d].enable(),f[d].addScore(c[d])};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++)f[a].setClickable();e.setClickable();var c=this;(new createjs.Tween.get(g)).to({alpha:0},500);(new createjs.Tween.get(d)).to({y:b},400,createjs.Ease.backIn).call(function(){c.unload()})};this._init(a,c)}
function CLevelBut(a,c,b,f,g,e){var d,h,m,k,r=[],l,n,q,x,y=null,u=null,t;this._init=function(a,b,c,e){d=!1;h=1;m=[];k=[];l=new createjs.Container;l.x=a;l.y=b;l.scaleX=l.scaleY=h;e.addChild(l);n=new createjs.Container;n.x=a;n.y=b;n.scaleX=l.scaleY=h;e.addChild(n);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]}});t=createSprite(c,"on",a/2,b/2,a,b);l.addChild(t);f?t.gotoAndStop("on"):t.gotoAndStop("off");this._initListener()};
this.unload=function(){s_bMobile?l.off("mousedown",this.buttonDown):(l.off("mousedown",this.buttonDown),l.off("mouseover",this.buttonOver));l.off("pressup",this.buttonRelease);e.removeChild(l)};this.setVisible=function(a){l.visible=a};this.enable=function(){t.gotoAndStop("on");d=!1;null!==u&&(y.color="#000000",u.color="#ffffff")};this.disable=function(){d=!0;t.gotoAndStop("off");null!==u&&(y.color="#000000",u.color="#a8a8a8")};this.setClickable=function(a){d=!a};this.addInfo=function(a){q=new createjs.Text(a,
" 24px "+PRIMARY_FONT,"#000000");q.x=b.height/2-24;q.y=-b.height/2+10;q.textAlign="center";q.textBaseline="middle";q.lineWidth=200;q.outline=4;q.rotation=30;l.addChild(q);x=new createjs.Text(a," 24px "+PRIMARY_FONT,"#ffffff");x.x=q.x;x.y=q.y;x.textAlign="center";x.textBaseline="middle";x.lineWidth=200;x.rotation=q.rotation;l.addChild(x)};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;n.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;n.addChild(a)};this.addLevelText=function(a){y=new createjs.Text(a," 80px "+PRIMARY_FONT,"#000000");y.y=2;y.textAlign="center";y.textBaseline="middle";y.lineWidth=200;y.outline=8;l.addChild(y);u=new createjs.Text(a," 80px "+PRIMARY_FONT,"#ffd800");u.y=2;u.textAlign="center";u.textBaseline="middle";u.lineWidth=200;l.addChild(u)};this._initListener=
function(){if(s_bMobile)l.on("mousedown",this.buttonDown);else l.on("mousedown",this.buttonDown),l.on("mouseover",this.buttonOver);l.on("pressup",this.buttonRelease)};this.addEventListener=function(a,b,c){m[a]=b;k[a]=c};this.addEventListenerWithParams=function(a,b,c,d){m[a]=b;k[a]=c;r=d};this.buttonRelease=function(){d||(l.scaleX=h,l.scaleY=h,m[ON_MOUSE_UP]&&m[ON_MOUSE_UP].call(k[ON_MOUSE_UP],r))};this.buttonDown=function(){d||(playSound("click",1,0),l.scaleX=.9*h,l.scaleY=.9*h,m[ON_MOUSE_DOWN]&&
m[ON_MOUSE_DOWN].call(k[ON_MOUSE_DOWN],r))};this.buttonOver=function(a){s_bMobile||d||(a.target.cursor="pointer")};this.pulseAnimation=function(){createjs.Tween.get(l).to({scaleX:1.1*h,scaleY:1.1*h},850,createjs.Ease.quadOut).to({scaleX:h,scaleY:h},650,createjs.Ease.quadIn).call(function(){A.pulseAnimation()})};this.trembleAnimation=function(){createjs.Tween.get(l).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(){A.trebleAnimation()})};
this.setImage=function(a){};this.setPosition=function(a,b){l.x=a;l.y=b};this.setScale=function(a){h=a;l.scaleX=l.scaleY=a};this.setX=function(a){l.x=a};this.setY=function(a){l.y=a};this.getButtonImage=function(){return l};this.getX=function(){return l.x};this.getY=function(){return l.y};var A=this;this._init(a,c,b,e);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,f;this._init=function(a){c=0;f=new createjs.Container;s_oStage.addChild(f);b=[];var e=Math.floor(a/NUM_TRACKS_PER_WORLD);a="w"+e+"_bg1";e=s_oSpriteLibrary.getSprite("w"+e+"_bg0");this._addBG(e);e=s_oSpriteLibrary.getSprite(a);this._addBG(e)};this._addBG=function(a){a=new CBackground(a,f);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 e=c-a.x;b[0].moveX(e);b[1].moveX(e*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,f,g;this._init=function(){b=a.height/2-(CANVAS_HEIGHT-2*s_iOffsetY)/2;g=new createjs.Container;c.addChild(g);f=[];for(var e=0;2>e;e++)f[e]=createBitmap(a),f[e].regY=a.height/2,f[e].x=e*a.width,f[e].y=CANVAS_HEIGHT/2,g.addChild(f[e]),f[e].cache(0,0,a.width,a.height)};this.restart=function(){g.x=0;for(var b=g.y=0;2>b;b++)f[b].x=b*a.width,f[b].y=CANVAS_HEIGHT/2};this.moveX=function(b){g.x+=b;b=Math.floor(-g.x/a.width)*a.width;for(var c=0;2>c;c++)f[c].x=b+c*a.width};this.moveY=
function(a){a<-b&&(a=-b);a>b&&(a=b);g.y=a};this._init()}
function CNextLevelPanel(a,c,b){var f,g,e,d,h;this._init=function(a,b,c){playSound("arrive_win",1,!1);setVolume(s_aSounds.game_soundtrack,SOUNDTRACK_VOLUME_IN_GAME);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);g=new createjs.Container;s_oStage.addChild(g);var k=s_oSpriteLibrary.getSprite("msg_box"),l=createBitmap(k);l.regX=k.width/2;l.regY=k.height/
2;g.addChild(l);new CTLText(g,-300,-180,600,40,40,"center","#fff",PRIMARY_FONT,1,0,0,TEXT_TRACK_COMPLETED,!0,!0,!1,!1);l=new createjs.Container;l.x=-220;l.y=-50;g.addChild(l);k=s_oSpriteLibrary.getSprite("timer");var m=createBitmap(k);m.regX=k.width/2;m.regY=k.height/2;l.addChild(m);new CTLText(l,34,-20,150,50,50,"left","#fff",PRIMARY_FONT,1,0,0,formatTime(LEVEL_INFO[c].time-a),!0,!0,!1,!1);a=new createjs.Container;a.x=120;a.y=l.y;g.addChild(a);k=s_oSpriteLibrary.getSprite("star");c=createBitmap(k);
c.regX=k.width/2;c.regY=k.height/2;a.addChild(c);var r=new CTLText(a,34,-20,150,50,50,"left","#fff",PRIMARY_FONT,1,0,0,"0",!0,!0,!1,!1);g.x=CANVAS_WIDTH/2;g.y=CANVAS_HEIGHT+k.height/2;f=g.y;(new createjs.Tween.get(g)).to({y:CANVAS_HEIGHT/2},500,createjs.Ease.quartIn).call(function(){new CRollingText(r.getText(),b,5E3,!1)});this._sendScore();k=s_oSpriteLibrary.getSprite("but_next");d=new CGfxButton(120,100,k,g);d.addEventListener(ON_MOUSE_UP,this._onContinue,this);d.pulseAnimation();k=s_oSpriteLibrary.getSprite("but_restart");
h=new CGfxButton(-120,100,k,g);h.addEventListener(ON_MOUSE_UP,this._onRestart,this)};this.unload=function(){e.off("mousedown",function(){});s_oStage.removeChild(e);g.removeAllChildren(e);d.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);d.setClickable(!1);(new createjs.Tween.get(e)).to({alpha:0},
500);(new createjs.Tween.get(g)).to({y:f},400,createjs.Ease.backIn).call(function(){m.unload();s_oGame.nextLevel()})};this._onRestart=function(){h.setClickable(!1);d.setClickable(!1);(new createjs.Tween.get(e)).to({alpha:0},500);(new createjs.Tween.get(g)).to({y:f},400,createjs.Ease.backIn).call(function(){m.unload();s_oGame.restartGame()})};this._onFinishRolling=function(){};this._onRollingRemoved=function(){};this._onRollingText=function(a){(void 0).playManualMode(a,STAR_EFFECT_SCALE)};var m=this;
this._init(a,c,b)}function CRollingText(a,c,b,f){var g=null,e;this._init=function(a,b,c){e={value:parseInt(a.text)};g=createjs.Tween.get(e,{override:!0}).to({value:b},c,createjs.Ease.cubicInOut).addEventListener("change",function(){a.text=f?formatTime(e.value):"+"+Math.floor(e.value)}).call(function(){createjs.Tween.removeTweens(g)})};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){try{var b=window.localStorage.getItem(a);this.resetData();null!==b&&void 0!==b&&this.loadData()}catch(g){this.resetData()}};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.resetData=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 g=0;g<c.length;g++)s_aTimeScore[g]=parseInt(c[g]);s_iTotalScore=parseInt(b[LOCALSTORAGE_TOTALSCORE])};this._init(a)}
function CLosePanel(){var a,c,b,f,g;this._init=function(){setVolume(s_aSounds.game_soundtrack,SOUNDTRACK_VOLUME_IN_GAME);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 d=s_oSpriteLibrary.getSprite("msg_box"),e=createBitmap(d);e.regX=d.width/2;e.regY=d.height/2;b.addChild(e);b.x=CANVAS_WIDTH/2;b.y=
CANVAS_HEIGHT+d.height/2;a=b.y;(new createjs.Tween.get(b)).to({y:CANVAS_HEIGHT/2},500,createjs.Ease.quartIn);d=s_oSpriteLibrary.getSprite("baloon_mc");e=createBitmap(d);e.regX=d.width/2;e.regY=d.height/2;e.y=-10;e.scaleX=e.scaleY=.6;b.addChild(e);new CTLText(b,-300,-180,600,100,50,"center","#fff",PRIMARY_FONT,1,0,0,TEXT_TIME_IS_UP,!0,!0,!0,!1);d=s_oSpriteLibrary.getSprite("but_exit");f=new CGfxButton(120,100,d,b);f.addEventListener(ON_MOUSE_UP,this._onExit,this);d=s_oSpriteLibrary.getSprite("but_restart");
g=new CGfxButton(-120,100,d,b);g.addEventListener(ON_MOUSE_UP,this._onRestart,this);g.pulseAnimation()};this.unload=function(){s_oStage.removeChild(b);c.off("mousedown",function(){});f.unload();g.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(){g.setClickable(!1);f.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(){e.unload();s_oGame.restartGame()})};var e=this;this._init();return this}
function CTimer(a,c,b,f,g,e,d){var h,m,k;this._init=function(a,b,c,d,e,f,g){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);m=new createjs.Text("00:00"," "+d+"px "+PRIMARY_FONT,g);m.x=a+10;m.textAlign="left";m.textBaseline="middle";m.lineWidth=500;m.outline=6;h.addChild(m);k=new createjs.Text(m.text," "+d+"px "+PRIMARY_FONT,e);k.x=m.x;k.y=m.y;k.textAlign=m.textAlign;k.textBaseline=m.textBaseline;
k.lineWidth=m.lineWidth;h.addChild(k);h.regX=h.getBounds().width/2};this.setDecimalTime=function(a){a=formatTime(a);m.text=a;k.text=a};this.setIntTime=function(a){a=Math.floor(a/1E3);m.text=a;k.text=a};this.setSpeedIndicator=function(a){a=Math.floor(a);m.text=a;k.text=a};this.setAlign=function(a,b){m.textAlign=a;m.textBaseline=b;k.textAlign=m.textAlign;k.textBaseline=m.textBaseline};this.resetTextRelativePos=function(){m.x=0;m.y=0;k.x=m.x;k.y=m.y;h.regX=0};this.setPos=function(a,b){h.x=a;h.y=b};this._init(a,
c,b,f,g,e,d)}
function CTachometer(a,c){var b,f,g,e;this._init=function(a,c){b=a;f=c;g=new createjs.Container;g.x=b;g.y=f;s_oStage.addChild(g);var d=s_oSpriteLibrary.getSprite("tachometer"),h=createBitmap(d);h.regX=d.width/2;h.regY=d.height;g.addChild(h);new CTLText(g,-70,-115,140,40,40,"center","#ffcc00",PRIMARY_FONT,1,0,0,TEXT_SPEED_INDICATOR,!0,!0,!1,!1);new CTLText(g,-45,-73,90,60,60,"right","#222222",SECONDARY_FONT,1,0,0,"888",!0,!0,!1,!1);e=new CTLText(g,-45,-73,90,60,60,"right","#fff",SECONDARY_FONT,1,0,
0,"0",!0,!0,!1,!1)};this.setSpeedIndicator=function(a){e.refreshText(Math.floor(a))};this.updateOffset=function(a,c){g.x=b+a;g.y=f-c};this._init(a,c)}
function CMsgBox(a,c){var b,f,g,e,d;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);d=new createjs.Container;s_oStage.addChild(d);var h=s_oSpriteLibrary.getSprite("msg_box"),k=createBitmap(h);k.regX=h.width/2;k.regY=h.height/2;d.addChild(k);d.x=CANVAS_WIDTH/2;d.y=CANVAS_HEIGHT+h.height/2;b=d.y;(new createjs.Tween.get(d)).to({y:CANVAS_HEIGHT/
2-40},500,createjs.Ease.quartIn);f=new CTLText(d,-300,-190,600,170,26,"center","#fff",PRIMARY_FONT,1,0,0,a,!0,!0,!0,!1);g=new CGfxButton(0,80,s_oSpriteLibrary.getSprite("but_yes"),d);g.addEventListener(ON_MOUSE_UP,this._onButYes,this);g.pulseAnimation()};this._onButYes=function(){g.setClickable(!1);(new createjs.Tween.get(e)).to({alpha:0},500);(new createjs.Tween.get(d)).to({y:b},400,createjs.Ease.backIn).call(function(){h.unload();c&&c()})};this.changeMessage=function(a){f.refreshText(a)};this.unload=
function(){g.unload();s_oStage.removeChild(e);s_oStage.removeChild(d);e.off("mousedown",function(){})};var h=this;this._init(a,c)}
function CTremble(a,c,b,f){var g,e,d,h,m,k,r;this._init=function(a,b,c,f){h=d=!1;k=0;this._calculateDuration();g=a.x;e=a.y;d||(d=!0,m=setInterval(function(){l._tremble()},c))};this._tremble=function(){if(h=!h){var n=.5>Math.random()?-f:f;var q=.5>Math.random()?-f:f;a.x+=n;a.y+=q}else a.x=g,a.y=e;k++;k>r&&(k=0,d=!1,s_oGame.endDamageTime(),a.x=g,a.y=e,0===c?m=setInterval(function(){l._tremble()},b):clearInterval(m))};this._calculateDuration=function(){r=c/b};this.stopTremble=function(){clearInterval(m)};
var l=this;this._init(a,c,b,f)}
function CAreYouSurePanel(a,c){var b,f,g,e,d,h,m;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);m=new createjs.Container;s_oStage.addChild(m);var k=s_oSpriteLibrary.getSprite("msg_box"),l=createBitmap(k);l.regX=k.width/2;l.regY=k.height/2;m.addChild(l);m.x=CANVAS_WIDTH/2;m.y=CANVAS_HEIGHT+k.height/2;b=m.y;(new createjs.Tween.get(m)).to({y:CANVAS_HEIGHT/
2-40},500,createjs.Ease.cubicOut);f=new CTLText(m,-300,-k.height/2+40,600,140,70,"center","#000",PRIMARY_FONT,1,0,0,TEXT_ARE_SURE,!0,!0,!0,!1);f.setOutline(5);g=new CTLText(m,-300,-k.height/2+40,600,140,70,"center","#fff",PRIMARY_FONT,1,0,0,TEXT_ARE_SURE,!0,!0,!0,!1);e=new CGfxButton(110,80,s_oSpriteLibrary.getSprite("but_yes"),m);e.addEventListener(ON_MOUSE_UP,this._onButYes,this);d=new CGfxButton(-110,80,s_oSpriteLibrary.getSprite("but_exit"),m);d.addEventListener(ON_MOUSE_UP,this._onButNo,this);
d.pulseAnimation()};this._onButYes=function(){d.setClickable(!1);e.setClickable(!1);(new createjs.Tween.get(h)).to({alpha:0},500);(new createjs.Tween.get(m)).to({y:b},400,createjs.Ease.backIn).call(function(){k.unload();a&&a()})};this._onButNo=function(){d.setClickable(!1);e.setClickable(!1);(new createjs.Tween.get(h)).to({alpha:0},500);(new createjs.Tween.get(m)).to({y:b},400,createjs.Ease.backIn).call(function(){k.unload();c&&c()})};this.changeMessage=function(a,b){f.refreshText(a);g.refreshText(a)};
this.unload=function(){d.unload();e.unload();s_oStage.removeChild(h);s_oStage.removeChild(m);h.off("mousedown",function(){})};var k=this;this._init(a,c)}
CTLText.prototype={constructor:CTLText,__autofit:function(){if(this._bFitText){for(var a=this._iFontSize;(this._oText.getBounds().height>this._iHeight-2*this._iPaddingV||this._oText.getBounds().width>this._iWidth-2*this._iPaddingH)&&!(a--,this._oText.font=a+"px "+this._szFont,this._oText.lineHeight=Math.round(a*this._fLineHeightFactor),this.__updateY(),this.__verticalAlign(),8>a););this._iFontSize=a}},__verticalAlign:function(){if(this._bVerticalAlign){var a=this._oText.getBounds().height;this._oText.y-=
(a-this._iHeight)/2+this._iPaddingV}},__updateY:function(){this._oText.y=this._y+this._iPaddingV;switch(this._oText.textBaseline){case "middle":this._oText.y+=this._oText.lineHeight/2+(this._iFontSize*this._fLineHeightFactor-this._iFontSize)}},__createText:function(a){this._bDebug&&(this._oDebugShape=new createjs.Shape,this._oDebugShape.graphics.beginFill("rgba(255,0,0,0.5)").drawRect(this._x,this._y,this._iWidth,this._iHeight),this._oContainer.addChild(this._oDebugShape));this._oText=new createjs.Text(a,
this._iFontSize+"px "+this._szFont,this._szColor);this._oText.textBaseline="middle";this._oText.lineHeight=Math.round(this._iFontSize*this._fLineHeightFactor);this._oText.textAlign=this._szAlign;this._oText.lineWidth=this._bMultiline?this._iWidth-2*this._iPaddingH:null;switch(this._szAlign){case "center":this._oText.x=this._x+this._iWidth/2;break;case "left":this._oText.x=this._x+this._iPaddingH;break;case "right":this._oText.x=this._x+this._iWidth-this._iPaddingH}this._oContainer.addChild(this._oText);
this.refreshText(a)},setVerticalAlign:function(a){this._bVerticalAlign=a},setOutline:function(a){null!==this._oText&&(this._oText.outline=a)},setShadow:function(a,c,b,f){null!==this._oText&&(this._oText.shadow=new createjs.Shadow(a,c,b,f))},setColor:function(a){this._oText.color=a},setAlpha:function(a){this._oText.alpha=a},removeTweens:function(){createjs.Tween.removeTweens(this._oText)},getText:function(){return this._oText},getString:function(){return this._oText.text},getY:function(){return this._y},
getFontSize:function(){return this._iFontSize},refreshText:function(a){""===a&&(a=" ");null===this._oText&&this.__createText(a);this._oText.text=a;this._oText.font=this._iFontSize+"px "+this._szFont;this._oText.lineHeight=Math.round(this._iFontSize*this._fLineHeightFactor);this.__autofit();this.__updateY();this.__verticalAlign()}};
function CTLText(a,c,b,f,g,e,d,h,m,k,r,l,n,q,x,y,u){this._oContainer=a;this._x=c;this._y=b;this._iWidth=f;this._iHeight=g;this._bMultiline=y;this._iFontSize=e;this._szAlign=d;this._szColor=h;this._szFont=m;this._iPaddingH=r;this._iPaddingV=l;this._bVerticalAlign=x;this._bFitText=q;this._bDebug=u;this._oDebugShape=null;this._fLineHeightFactor=k;this._oText=null;n&&this.__createText(n)};