game.min.js 474 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912
  1. var gStorageAvailable = false;
  2. var gSFXMuted = false;
  3. var gMusicMuted = false;
  4. var gMenuMusicTimer = -1;
  5. var gFocused = true;
  6. var globalScale = 0.66;
  7. var BRAND = {
  8. NONE: 0,
  9. FGL: 1,
  10. ADDICTING: 2,
  11. MRG: 3,
  12. MELODI: 4
  13. };
  14. var gCurrentBrand = BRAND.MRG;
  15. /*!
  16. * VERSION: 1.11.4
  17. * DATE: 2014-01-18
  18. * UPDATES AND DOCS AT: http://www.greensock.com
  19. *
  20. * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
  21. * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
  22. * Club GreenSock members, the software agreement that was issued with your membership.
  23. *
  24. * @author: Jack Doyle, jack@greensock.com
  25. */
  26. (function(ap) {
  27. var aF = ap.GreenSockGlobals || ap;
  28. if (!aF.TweenLite) {
  29. var aB, aq, ar, aw, aJ, av = function(b) {
  30. var a, c = b.split("."),
  31. d = aF;
  32. for (a = 0; c.length > a; a++) {
  33. d[c[a]] = d = d[c[a]] || {}
  34. }
  35. return d
  36. },
  37. ay = av("com.greensock"),
  38. aC = 1e-10,
  39. aK = [].slice,
  40. ao = function() {},
  41. ax = function() {
  42. var a = Object.prototype.toString,
  43. b = a.call([]);
  44. return function(c) {
  45. return null != c && (c instanceof Array || "object" == typeof c && !!c.push && a.call(c) === b)
  46. }
  47. }(),
  48. aE = {},
  49. au = function(c, d, e, f) {
  50. this.sc = aE[c] ? aE[c].sc : [], aE[c] = this, this.gsClass = null, this.func = e;
  51. var b = [];
  52. this.check = function(g) {
  53. for (var k, j, i, a, o = d.length, n = o; --o > -1;) {
  54. (k = aE[d[o]] || new au(d[o], [])).gsClass ? (b[o] = k.gsClass, n--) : g && k.sc.push(this)
  55. }
  56. if (0 === n && e) {
  57. for (j = ("com.greensock." + c).split("."), i = j.pop(), a = av(j.join("."))[i] = this.gsClass = e.apply(e, b), f && (aF[i] = a, "function" == typeof define && define.amd ? define((ap.GreenSockAMDPath ? ap.GreenSockAMDPath + "/" : "") + c.split(".").join("/"), [], function() {
  58. return a
  59. }) : "undefined" != typeof module && module.exports && (module.exports = a)), o = 0; this.sc.length > o; o++) {
  60. this.sc[o].check()
  61. }
  62. }
  63. }, this.check(!0)
  64. },
  65. aH = ap._gsDefine = function(b, d, a, c) {
  66. return new au(b, d, a, c)
  67. },
  68. aG = ay._class = function(b, c, a) {
  69. return c = c || function() {}, aH(b, [], function() {
  70. return c
  71. }, a), c
  72. };
  73. aH.globals = aF;
  74. var an = [0, 0, 1, 1],
  75. aD = [],
  76. H = aG("easing.Ease", function(b, d, a, c) {
  77. this._func = b, this._type = a || 0, this._power = c || 0, this._params = d ? an.concat(d) : an
  78. }, !0),
  79. am = H.map = {},
  80. W = H.register = function(p, j, f, q) {
  81. for (var b, d, k, c, g = j.split(","), l = g.length, m = (f || "easeIn,easeOut,easeInOut").split(","); --l > -1;) {
  82. for (d = g[l], b = q ? aG("easing." + d, null, !0) : ay.easing[d] || {}, k = m.length; --k > -1;) {
  83. c = m[k], am[d + "." + c] = am[c + d] = b[c] = p.getRatio ? p : p[c] || new p
  84. }
  85. }
  86. };
  87. for (ar = H.prototype, ar._calcEnd = !1, ar.getRatio = function(b) {
  88. if (this._func) {
  89. return this._params[0] = b, this._func.apply(null, this._params)
  90. }
  91. var d = this._type,
  92. a = this._power,
  93. c = 1 === d ? 1 - b : 2 === d ? b : 0.5 > b ? 2 * b : 2 * (1 - b);
  94. return 1 === a ? c *= c : 2 === a ? c *= c * c : 3 === a ? c *= c * c * c : 4 === a && (c *= c * c * c * c), 1 === d ? 1 - c : 2 === d ? c : 0.5 > b ? c / 2 : 1 - c / 2
  95. }, aB = ["Linear", "Quad", "Cubic", "Quart", "Quint,Strong"], aq = aB.length; --aq > -1;) {
  96. ar = aB[aq] + ",Power" + aq, W(new H(null, null, 1, aq), ar, "easeOut", !0), W(new H(null, null, 2, aq), ar, "easeIn" + (0 === aq ? ",easeNone" : "")), W(new H(null, null, 3, aq), ar, "easeInOut")
  97. }
  98. am.linear = ay.easing.Linear.easeIn, am.swing = ay.easing.Quad.easeInOut;
  99. var ak = aG("events.EventDispatcher", function(a) {
  100. this._listeners = {}, this._eventTarget = a || this
  101. });
  102. ar = ak.prototype, ar.addEventListener = function(k, g, d, m, a) {
  103. a = a || 0;
  104. var b, c, f = this._listeners[k],
  105. j = 0;
  106. for (null == f && (this._listeners[k] = f = []), c = f.length; --c > -1;) {
  107. b = f[c], b.c === g && b.s === d ? f.splice(c, 1) : 0 === j && a > b.pr && (j = c + 1)
  108. }
  109. f.splice(j, 0, {
  110. c: g,
  111. s: d,
  112. up: m,
  113. pr: a
  114. }), this !== aw || aJ || aw.wake()
  115. }, ar.removeEventListener = function(b, d) {
  116. var a, c = this._listeners[b];
  117. if (c) {
  118. for (a = c.length; --a > -1;) {
  119. if (c[a].c === d) {
  120. return c.splice(a, 1), void 0
  121. }
  122. }
  123. }
  124. }, ar.dispatchEvent = function(b) {
  125. var f, a, c, d = this._listeners[b];
  126. if (d) {
  127. for (f = d.length, a = this._eventTarget; --f > -1;) {
  128. c = d[f], c.up ? c.c.call(c.s || a, {
  129. type: b,
  130. target: a
  131. }) : c.c.call(c.s || a)
  132. }
  133. }
  134. };
  135. var aI = ap.requestAnimationFrame,
  136. az = ap.cancelAnimationFrame,
  137. ai = Date.now || function() {
  138. return (new Date).getTime()
  139. },
  140. J = ai();
  141. for (aB = ["ms", "moz", "webkit", "o"], aq = aB.length; --aq > -1 && !aI;) {
  142. aI = ap[aB[aq] + "RequestAnimationFrame"], az = ap[aB[aq] + "CancelAnimationFrame"] || ap[aB[aq] + "CancelRequestAnimationFrame"]
  143. }
  144. aG("Ticker", function(q, n) {
  145. var g, u, a, b, d, j = this,
  146. p = ai(),
  147. c = n !== !1 && aI,
  148. k = function(f) {
  149. J = ai(), j.time = (J - p) / 1000;
  150. var h, i = j.time - d;
  151. (!g || i > 0 || f === !0) && (j.frame++, d += i + (i >= b ? 0.004 : b - i), h = !0), f !== !0 && (a = u(k)), h && j.dispatchEvent("tick")
  152. };
  153. ak.call(j), j.time = j.frame = 0, j.tick = function() {
  154. k(!0)
  155. }, j.sleep = function() {
  156. null != a && (c && az ? az(a) : clearTimeout(a), u = ao, a = null, j === aw && (aJ = !1))
  157. }, j.wake = function() {
  158. null !== a && j.sleep(), u = 0 === g ? ao : c && aI ? aI : function(e) {
  159. return setTimeout(e, 0 | 1000 * (d - j.time) + 1)
  160. }, j === aw && (aJ = !0), k(2)
  161. }, j.fps = function(e) {
  162. return arguments.length ? (g = e, b = 1 / (g || 60), d = this.time + b, j.wake(), void 0) : g
  163. }, j.useRAF = function(e) {
  164. return arguments.length ? (j.sleep(), c = e, j.fps(g), void 0) : c
  165. }, j.fps(q), setTimeout(function() {
  166. c && (!a || 5 > j.frame) && j.useRAF(!1)
  167. }, 1500)
  168. }), ar = ay.Ticker.prototype = new ay.events.EventDispatcher, ar.constructor = ay.Ticker;
  169. var al = aG("core.Animation", function(b, c) {
  170. if (this.vars = c = c || {}, this._duration = this._totalDuration = b || 0, this._delay = Number(c.delay) || 0, this._timeScale = 1, this._active = c.immediateRender === !0, this.data = c.data, this._reversed = c.reversed === !0, V) {
  171. aJ || aw.wake();
  172. var a = this.vars.useFrames ? ac : V;
  173. a.add(this, a._time), this.vars.paused && this.paused(!0)
  174. }
  175. });
  176. aw = al.ticker = new ay.Ticker, ar = al.prototype, ar._dirty = ar._gc = ar._initted = ar._paused = !1, ar._totalTime = ar._time = 0, ar._rawPrevTime = -1, ar._next = ar._last = ar._onUpdate = ar._timeline = ar.timeline = null, ar._paused = !1;
  177. var ag = function() {
  178. aJ && ai() - J > 2000 && aw.wake(), setTimeout(ag, 2000)
  179. };
  180. ag(), ar.play = function(a, b) {
  181. return arguments.length && this.seek(a, b), this.reversed(!1).paused(!1)
  182. }, ar.pause = function(a, b) {
  183. return arguments.length && this.seek(a, b), this.paused(!0)
  184. }, ar.resume = function(a, b) {
  185. return arguments.length && this.seek(a, b), this.paused(!1)
  186. }, ar.seek = function(a, b) {
  187. return this.totalTime(Number(a), b !== !1)
  188. }, ar.restart = function(a, b) {
  189. return this.reversed(!1).paused(!1).totalTime(a ? -this._delay : 0, b !== !1, !0)
  190. }, ar.reverse = function(a, b) {
  191. return arguments.length && this.seek(a || this.totalDuration(), b), this.reversed(!0).paused(!1)
  192. }, ar.render = function() {}, ar.invalidate = function() {
  193. return this
  194. }, ar.isActive = function() {
  195. var b, c = this._timeline,
  196. a = this._startTime;
  197. return !c || !this._gc && !this._paused && c.isActive() && (b = c.rawTime()) >= a && a + this.totalDuration() / this._timeScale > b
  198. }, ar._enabled = function(a, b) {
  199. return aJ || aw.wake(), this._gc = !a, this._active = this.isActive(), b !== !0 && (a && !this.timeline ? this._timeline.add(this, this._startTime - this._delay) : !a && this.timeline && this._timeline._remove(this, !0)), !1
  200. }, ar._kill = function() {
  201. return this._enabled(!1, !1)
  202. }, ar.kill = function(a, b) {
  203. return this._kill(a, b), this
  204. }, ar._uncache = function(a) {
  205. for (var b = a ? this : this.timeline; b;) {
  206. b._dirty = !0, b = b.timeline
  207. }
  208. return this
  209. }, ar._swapSelfInParams = function(b) {
  210. for (var c = b.length, a = b.concat(); --c > -1;) {
  211. "{self}" === b[c] && (a[c] = this)
  212. }
  213. return a
  214. }, ar.eventCallback = function(b, f, a, c) {
  215. if ("on" === (b || "").substr(0, 2)) {
  216. var d = this.vars;
  217. if (1 === arguments.length) {
  218. return d[b]
  219. }
  220. null == f ? delete d[b] : (d[b] = f, d[b + "Params"] = ax(a) && -1 !== a.join("").indexOf("{self}") ? this._swapSelfInParams(a) : a, d[b + "Scope"] = c), "onUpdate" === b && (this._onUpdate = f)
  221. }
  222. return this
  223. }, ar.delay = function(a) {
  224. return arguments.length ? (this._timeline.smoothChildTiming && this.startTime(this._startTime + a - this._delay), this._delay = a, this) : this._delay
  225. }, ar.duration = function(a) {
  226. return arguments.length ? (this._duration = this._totalDuration = a, this._uncache(!0), this._timeline.smoothChildTiming && this._time > 0 && this._time < this._duration && 0 !== a && this.totalTime(this._totalTime * (a / this._duration), !0), this) : (this._dirty = !1, this._duration)
  227. }, ar.totalDuration = function(a) {
  228. return this._dirty = !1, arguments.length ? this.duration(a) : this._totalDuration
  229. }, ar.time = function(a, b) {
  230. return arguments.length ? (this._dirty && this.totalDuration(), this.totalTime(a > this._duration ? this._duration : a, b)) : this._time
  231. }, ar.totalTime = function(b, f, a) {
  232. if (aJ || aw.wake(), !arguments.length) {
  233. return this._totalTime
  234. }
  235. if (this._timeline) {
  236. if (0 > b && !a && (b += this.totalDuration()), this._timeline.smoothChildTiming) {
  237. this._dirty && this.totalDuration();
  238. var c = this._totalDuration,
  239. d = this._timeline;
  240. if (b > c && !a && (b = c), this._startTime = (this._paused ? this._pauseTime : d._time) - (this._reversed ? c - b : b) / this._timeScale, d._dirty || this._uncache(!1), d._timeline) {
  241. for (; d._timeline;) {
  242. d._timeline._time !== (d._startTime + d._totalTime) / d._timeScale && d.totalTime(d._totalTime, !0), d = d._timeline
  243. }
  244. }
  245. }
  246. this._gc && this._enabled(!0, !1), (this._totalTime !== b || 0 === this._duration) && this.render(b, f, !1)
  247. }
  248. return this
  249. }, ar.progress = ar.totalProgress = function(a, b) {
  250. return arguments.length ? this.totalTime(this.duration() * a, b) : this._time / this.duration()
  251. }, ar.startTime = function(a) {
  252. return arguments.length ? (a !== this._startTime && (this._startTime = a, this.timeline && this.timeline._sortChildren && this.timeline.add(this, a - this._delay)), this) : this._startTime
  253. }, ar.timeScale = function(b) {
  254. if (!arguments.length) {
  255. return this._timeScale
  256. }
  257. if (b = b || aC, this._timeline && this._timeline.smoothChildTiming) {
  258. var c = this._pauseTime,
  259. a = c || 0 === c ? c : this._timeline.totalTime();
  260. this._startTime = a - (a - this._startTime) * this._timeScale / b
  261. }
  262. return this._timeScale = b, this._uncache(!1)
  263. }, ar.reversed = function(a) {
  264. return arguments.length ? (a != this._reversed && (this._reversed = a, this.totalTime(this._timeline && !this._timeline.smoothChildTiming ? this.totalDuration() - this._totalTime : this._totalTime, !0)), this) : this._reversed
  265. }, ar.paused = function(b) {
  266. if (!arguments.length) {
  267. return this._paused
  268. }
  269. if (b != this._paused && this._timeline) {
  270. aJ || b || aw.wake();
  271. var d = this._timeline,
  272. a = d.rawTime(),
  273. c = a - this._pauseTime;
  274. !b && d.smoothChildTiming && (this._startTime += c, this._uncache(!1)), this._pauseTime = b ? a : null, this._paused = b, this._active = this.isActive(), !b && 0 !== c && this._initted && this.duration() && this.render(d.smoothChildTiming ? this._totalTime : (a - this._startTime) / this._timeScale, !0, !0)
  275. }
  276. return this._gc && !b && this._enabled(!0, !1), this
  277. };
  278. var K = aG("core.SimpleTimeline", function(a) {
  279. al.call(this, 0, a), this.autoRemoveChildren = this.smoothChildTiming = !0
  280. });
  281. ar = K.prototype = new al, ar.constructor = K, ar.kill()._gc = !1, ar._first = ar._last = null, ar._sortChildren = !1, ar.add = ar.insert = function(b, d) {
  282. var a, c;
  283. if (b._startTime = Number(d || 0) + b._delay, b._paused && this !== b._timeline && (b._pauseTime = b._startTime + (this.rawTime() - b._startTime) / b._timeScale), b.timeline && b.timeline._remove(b, !0), b.timeline = b._timeline = this, b._gc && b._enabled(!0, !0), a = this._last, this._sortChildren) {
  284. for (c = b._startTime; a && a._startTime > c;) {
  285. a = a._prev
  286. }
  287. }
  288. return a ? (b._next = a._next, a._next = b) : (b._next = this._first, this._first = b), b._next ? b._next._prev = b : this._last = b, b._prev = a, this._timeline && this._uncache(!0), this
  289. }, ar._remove = function(a, b) {
  290. return a.timeline === this && (b || a._enabled(!1, !0), a.timeline = null, a._prev ? a._prev._next = a._next : this._first === a && (this._first = a._next), a._next ? a._next._prev = a._prev : this._last === a && (this._last = a._prev), this._timeline && this._uncache(!0)), this
  291. }, ar.render = function(b, f, a) {
  292. var c, d = this._first;
  293. for (this._totalTime = this._time = this._rawPrevTime = b; d;) {
  294. c = d._next, (d._active || b >= d._startTime && !d._paused) && (d._reversed ? d.render((d._dirty ? d.totalDuration() : d._totalDuration) - (b - d._startTime) * d._timeScale, f, a) : d.render((b - d._startTime) * d._timeScale, f, a)), d = c
  295. }
  296. }, ar.rawTime = function() {
  297. return aJ || aw.wake(), this._totalTime
  298. };
  299. var af = aG("TweenLite", function(h, d, f) {
  300. if (al.call(this, d, f), this.render = af.prototype.render, null == h) {
  301. throw "Cannot tween a null target."
  302. }
  303. this.target = h = "string" != typeof h ? h : af.selector(h) || h;
  304. var g, k, c, j = h.jquery || h.length && h !== ap && h[0] && (h[0] === ap || h[0].nodeType && h[0].style && !h.nodeType),
  305. b = this.vars.overwrite;
  306. if (this._overwrite = b = null == b ? aA[af.defaultOverwrite] : "number" == typeof b ? b >> 0 : aA[b], (j || h instanceof Array || h.push && ax(h)) && "number" != typeof h[0]) {
  307. for (this._targets = c = aK.call(h, 0), this._propLookup = [], this._siblings = [], g = 0; c.length > g; g++) {
  308. k = c[g], k ? "string" != typeof k ? k.length && k !== ap && k[0] && (k[0] === ap || k[0].nodeType && k[0].style && !k.nodeType) ? (c.splice(g--, 1), this._targets = c = c.concat(aK.call(k, 0))) : (this._siblings[g] = ah(k, this, !1), 1 === b && this._siblings[g].length > 1 && at(k, this, null, 1, this._siblings[g])) : (k = c[g--] = af.selector(k), "string" == typeof k && c.splice(g + 1, 1)) : c.splice(g--, 1)
  309. }
  310. } else {
  311. this._propLookup = {}, this._siblings = ah(h, this, !1), 1 === b && this._siblings.length > 1 && at(h, this, null, 1, this._siblings)
  312. }(this.vars.immediateRender || 0 === d && 0 === this._delay && this.vars.immediateRender !== !1) && this.render(-this._delay, !1, !0)
  313. }, !0),
  314. ae = function(a) {
  315. return a.length && a !== ap && a[0] && (a[0] === ap || a[0].nodeType && a[0].style && !a.nodeType)
  316. },
  317. ab = function(b, d) {
  318. var a, c = {};
  319. for (a in b) {
  320. ad[a] || a in d && "x" !== a && "y" !== a && "width" !== a && "height" !== a && "className" !== a && "border" !== a || !(!Y[a] || Y[a] && Y[a]._autoCSS) || (c[a] = b[a], delete b[a])
  321. }
  322. b.css = c
  323. };
  324. ar = af.prototype = new al, ar.constructor = af, ar.kill()._gc = !1, ar.ratio = 0, ar._firstPT = ar._targets = ar._overwrittenProps = ar._startAt = null, ar._notifyPluginsOfEnabled = !1, af.version = "1.11.4", af.defaultEase = ar._ease = new H(null, null, 1, 1), af.defaultOverwrite = "auto", af.ticker = aw, af.autoSleep = !0, af.selector = ap.$ || ap.jQuery || function(a) {
  325. return ap.$ ? (af.selector = ap.$, ap.$(a)) : ap.document ? ap.document.getElementById("#" === a.charAt(0) ? a.substr(1) : a) : a
  326. };
  327. var X = af._internals = {
  328. isArray: ax,
  329. isSelector: ae
  330. },
  331. Y = af._plugins = {},
  332. aa = af._tweenLookup = {},
  333. z = 0,
  334. ad = X.reservedProps = {
  335. ease: 1,
  336. delay: 1,
  337. overwrite: 1,
  338. onComplete: 1,
  339. onCompleteParams: 1,
  340. onCompleteScope: 1,
  341. useFrames: 1,
  342. runBackwards: 1,
  343. startAt: 1,
  344. onUpdate: 1,
  345. onUpdateParams: 1,
  346. onUpdateScope: 1,
  347. onStart: 1,
  348. onStartParams: 1,
  349. onStartScope: 1,
  350. onReverseComplete: 1,
  351. onReverseCompleteParams: 1,
  352. onReverseCompleteScope: 1,
  353. onRepeat: 1,
  354. onRepeatParams: 1,
  355. onRepeatScope: 1,
  356. easeParams: 1,
  357. yoyo: 1,
  358. immediateRender: 1,
  359. repeat: 1,
  360. repeatDelay: 1,
  361. data: 1,
  362. paused: 1,
  363. reversed: 1,
  364. autoCSS: 1
  365. },
  366. aA = {
  367. none: 0,
  368. all: 1,
  369. auto: 2,
  370. concurrent: 3,
  371. allOnStart: 4,
  372. preexisting: 5,
  373. "true": 1,
  374. "false": 0
  375. },
  376. ac = al._rootFramesTimeline = new K,
  377. V = al._rootTimeline = new K;
  378. V._startTime = aw.time, ac._startTime = aw.frame, V._active = ac._active = !0, al._updateRoot = function() {
  379. if (V.render((aw.time - V._startTime) * V._timeScale, !1, !1), ac.render((aw.frame - ac._startTime) * ac._timeScale, !1, !1), !(aw.frame % 120)) {
  380. var b, c, a;
  381. for (a in aa) {
  382. for (c = aa[a].tweens, b = c.length; --b > -1;) {
  383. c[b]._gc && c.splice(b, 1)
  384. }
  385. 0 === c.length && delete aa[a]
  386. }
  387. if (a = V._first, (!a || a._paused) && af.autoSleep && !ac._first && 1 === aw._listeners.tick.length) {
  388. for (; a && a._paused;) {
  389. a = a._next
  390. }
  391. a || aw.sleep()
  392. }
  393. }
  394. }, aw.addEventListener("tick", al._updateRoot);
  395. var ah = function(b, f, a) {
  396. var c, d, g = b._gsTweenID;
  397. if (aa[g || (b._gsTweenID = g = "t" + z++)] || (aa[g] = {
  398. target: b,
  399. tweens: []
  400. }), f && (c = aa[g].tweens, c[d = c.length] = f, a)) {
  401. for (; --d > -1;) {
  402. c[d] === f && c.splice(d, 1)
  403. }
  404. }
  405. return aa[g].tweens
  406. },
  407. at = function(A, v, k, B, b) {
  408. var g, w, d, j;
  409. if (1 === B || B >= 4) {
  410. for (j = b.length, g = 0; j > g; g++) {
  411. if ((d = b[g]) !== v) {
  412. d._gc || d._enabled(!1, !1) && (w = !0)
  413. } else {
  414. if (5 === B) {
  415. break
  416. }
  417. }
  418. }
  419. return w
  420. }
  421. var x, y = v._startTime + aC,
  422. h = [],
  423. q = 0,
  424. c = 0 === v._duration;
  425. for (g = b.length; --g > -1;) {
  426. (d = b[g]) === v || d._gc || d._paused || (d._timeline !== v._timeline ? (x = x || aj(v, 0, c), 0 === aj(d, x, c) && (h[q++] = d)) : y >= d._startTime && d._startTime + d.totalDuration() / d._timeScale > y && ((c || !d._initted) && 2e-10 >= y - d._startTime || (h[q++] = d)))
  427. }
  428. for (g = q; --g > -1;) {
  429. d = h[g], 2 === B && d._kill(k, A) && (w = !0), (2 !== B || !d._firstPT && d._initted) && d._enabled(!1, !1) && (w = !0)
  430. }
  431. return w
  432. },
  433. aj = function(b, f, a) {
  434. for (var c = b._timeline, d = c._timeScale, g = b._startTime; c._timeline;) {
  435. if (g += c._startTime, d *= c._timeScale, c._paused) {
  436. return -100
  437. }
  438. c = c._timeline
  439. }
  440. return g /= d, g > f ? g - f : a && g === f || !b._initted && 2 * aC > g - f ? aC : (g += b.totalDuration() / b._timeScale / d) > f + aC ? 0 : g - f - aC
  441. };
  442. ar._init = function() {
  443. var k, h, g, m, b = this.vars,
  444. d = this._overwrittenProps,
  445. j = this._duration,
  446. c = b.immediateRender,
  447. f = b.ease;
  448. if (b.startAt) {
  449. if (this._startAt && this._startAt.render(-1, !0), b.startAt.overwrite = 0, b.startAt.immediateRender = !0, this._startAt = af.to(this.target, 0, b.startAt), c) {
  450. if (this._time > 0) {
  451. this._startAt = null
  452. } else {
  453. if (0 !== j) {
  454. return
  455. }
  456. }
  457. }
  458. } else {
  459. if (b.runBackwards && 0 !== j) {
  460. if (this._startAt) {
  461. this._startAt.render(-1, !0), this._startAt = null
  462. } else {
  463. g = {};
  464. for (m in b) {
  465. ad[m] && "autoCSS" !== m || (g[m] = b[m])
  466. }
  467. if (g.overwrite = 0, g.data = "isFromStart", this._startAt = af.to(this.target, 0, g), b.immediateRender) {
  468. if (0 === this._time) {
  469. return
  470. }
  471. } else {
  472. this._startAt.render(-1, !0)
  473. }
  474. }
  475. }
  476. } if (this._ease = f ? f instanceof H ? b.easeParams instanceof Array ? f.config.apply(f, b.easeParams) : f : "function" == typeof f ? new H(f, b.easeParams) : am[f] || af.defaultEase : af.defaultEase, this._easeType = this._ease._type, this._easePower = this._ease._power, this._firstPT = null, this._targets) {
  477. for (k = this._targets.length; --k > -1;) {
  478. this._initProps(this._targets[k], this._propLookup[k] = {}, this._siblings[k], d ? d[k] : null) && (h = !0)
  479. }
  480. } else {
  481. h = this._initProps(this.target, this._propLookup, this._siblings, d)
  482. } if (h && af._onPluginEvent("_onInitAllProps", this), d && (this._firstPT || "function" != typeof this.target && this._enabled(!1, !1)), b.runBackwards) {
  483. for (g = this._firstPT; g;) {
  484. g.s += g.c, g.c = -g.c, g = g._next
  485. }
  486. }
  487. this._onUpdate = b.onUpdate, this._initted = !0
  488. }, ar._initProps = function(k, g, q, b) {
  489. var d, m, c, f, j, p;
  490. if (null == k) {
  491. return !1
  492. }
  493. this.vars.css || k.style && k !== ap && k.nodeType && Y.css && this.vars.autoCSS !== !1 && ab(this.vars, k);
  494. for (d in this.vars) {
  495. if (p = this.vars[d], ad[d]) {
  496. p && (p instanceof Array || p.push && ax(p)) && -1 !== p.join("").indexOf("{self}") && (this.vars[d] = p = this._swapSelfInParams(p, this))
  497. } else {
  498. if (Y[d] && (f = new Y[d])._onInitTween(k, this.vars[d], this)) {
  499. for (this._firstPT = j = {
  500. _next: this._firstPT,
  501. t: f,
  502. p: "setRatio",
  503. s: 0,
  504. c: 1,
  505. f: !0,
  506. n: d,
  507. pg: !0,
  508. pr: f._priority
  509. }, m = f._overwriteProps.length; --m > -1;) {
  510. g[f._overwriteProps[m]] = this._firstPT
  511. }(f._priority || f._onInitAllProps) && (c = !0), (f._onDisable || f._onEnable) && (this._notifyPluginsOfEnabled = !0)
  512. } else {
  513. this._firstPT = g[d] = j = {
  514. _next: this._firstPT,
  515. t: k,
  516. p: d,
  517. f: "function" == typeof k[d],
  518. n: d,
  519. pg: !1,
  520. pr: 0
  521. }, j.s = j.f ? k[d.indexOf("set") || "function" != typeof k["get" + d.substr(3)] ? d : "get" + d.substr(3)]() : parseFloat(k[d]), j.c = "string" == typeof p && "=" === p.charAt(1) ? parseInt(p.charAt(0) + "1", 10) * Number(p.substr(2)) : Number(p) - j.s || 0
  522. }
  523. }
  524. j && j._next && (j._next._prev = j)
  525. }
  526. return b && this._kill(b, k) ? this._initProps(k, g, q, b) : this._overwrite > 1 && this._firstPT && q.length > 1 && at(k, this, g, this._overwrite, q) ? (this._kill(g, k), this._initProps(k, g, q, b)) : c
  527. }, ar.render = function(v, j, h) {
  528. var w, b, d, k, c = this._time,
  529. g = this._duration;
  530. if (v >= g) {
  531. this._totalTime = this._time = g, this.ratio = this._ease._calcEnd ? this._ease.getRatio(1) : 1, this._reversed || (w = !0, b = "onComplete"), 0 === g && (k = this._rawPrevTime, (0 === v || 0 > k || k === aC) && k !== v && (h = !0, k > aC && (b = "onReverseComplete")), this._rawPrevTime = k = !j || v || 0 === k ? v : aC)
  532. } else {
  533. if (1e-7 > v) {
  534. this._totalTime = this._time = 0, this.ratio = this._ease._calcEnd ? this._ease.getRatio(0) : 0, (0 !== c || 0 === g && this._rawPrevTime > aC) && (b = "onReverseComplete", w = this._reversed), 0 > v ? (this._active = !1, 0 === g && (this._rawPrevTime >= 0 && (h = !0), this._rawPrevTime = k = !j || v || 0 === this._rawPrevTime ? v : aC)) : this._initted || (h = !0)
  535. } else {
  536. if (this._totalTime = this._time = v, this._easeType) {
  537. var p = v / g,
  538. q = this._easeType,
  539. f = this._easePower;
  540. (1 === q || 3 === q && p >= 0.5) && (p = 1 - p), 3 === q && (p *= 2), 1 === f ? p *= p : 2 === f ? p *= p * p : 3 === f ? p *= p * p * p : 4 === f && (p *= p * p * p * p), this.ratio = 1 === q ? 1 - p : 2 === q ? p : 0.5 > v / g ? p / 2 : 1 - p / 2
  541. } else {
  542. this.ratio = this._ease.getRatio(v / g)
  543. }
  544. }
  545. } if (this._time !== c || h) {
  546. if (!this._initted) {
  547. if (this._init(), !this._initted || this._gc) {
  548. return
  549. }
  550. this._time && !w ? this.ratio = this._ease.getRatio(this._time / g) : w && this._ease._calcEnd && (this.ratio = this._ease.getRatio(0 === this._time ? 0 : 1))
  551. }
  552. for (this._active || !this._paused && this._time !== c && v >= 0 && (this._active = !0), 0 === c && (this._startAt && (v >= 0 ? this._startAt.render(v, j, h) : b || (b = "_dummyGS")), this.vars.onStart && (0 !== this._time || 0 === g) && (j || this.vars.onStart.apply(this.vars.onStartScope || this, this.vars.onStartParams || aD))), d = this._firstPT; d;) {
  553. d.f ? d.t[d.p](d.c * this.ratio + d.s) : d.t[d.p] = d.c * this.ratio + d.s, d = d._next
  554. }
  555. this._onUpdate && (0 > v && this._startAt && this._startTime && this._startAt.render(v, j, h), j || (this._time !== c || w) && this._onUpdate.apply(this.vars.onUpdateScope || this, this.vars.onUpdateParams || aD)), b && (this._gc || (0 > v && this._startAt && !this._onUpdate && this._startTime && this._startAt.render(v, j, h), w && (this._timeline.autoRemoveChildren && this._enabled(!1, !1), this._active = !1), !j && this.vars[b] && this.vars[b].apply(this.vars[b + "Scope"] || this, this.vars[b + "Params"] || aD), 0 === g && this._rawPrevTime === aC && k !== aC && (this._rawPrevTime = 0)))
  556. }
  557. }, ar._kill = function(p, k) {
  558. if ("all" === p && (p = null), null == p && (null == k || k === this.target)) {
  559. return this._enabled(!1, !1)
  560. }
  561. k = "string" != typeof k ? k || this._targets || this.target : af.selector(k) || k;
  562. var g, q, b, d, m, c, f, j;
  563. if ((ax(k) || ae(k)) && "number" != typeof k[0]) {
  564. for (g = k.length; --g > -1;) {
  565. this._kill(p, k[g]) && (c = !0)
  566. }
  567. } else {
  568. if (this._targets) {
  569. for (g = this._targets.length; --g > -1;) {
  570. if (k === this._targets[g]) {
  571. m = this._propLookup[g] || {}, this._overwrittenProps = this._overwrittenProps || [], q = this._overwrittenProps[g] = p ? this._overwrittenProps[g] || {} : "all";
  572. break
  573. }
  574. }
  575. } else {
  576. if (k !== this.target) {
  577. return !1
  578. }
  579. m = this._propLookup, q = this._overwrittenProps = p ? this._overwrittenProps || {} : "all"
  580. } if (m) {
  581. f = p || m, j = p !== q && "all" !== q && p !== m && ("object" != typeof p || !p._tempKill);
  582. for (b in f) {
  583. (d = m[b]) && (d.pg && d.t._kill(f) && (c = !0), d.pg && 0 !== d.t._overwriteProps.length || (d._prev ? d._prev._next = d._next : d === this._firstPT && (this._firstPT = d._next), d._next && (d._next._prev = d._prev), d._next = d._prev = null), delete m[b]), j && (q[b] = 1)
  584. }!this._firstPT && this._initted && this._enabled(!1, !1)
  585. }
  586. }
  587. return c
  588. }, ar.invalidate = function() {
  589. return this._notifyPluginsOfEnabled && af._onPluginEvent("_onDisable", this), this._firstPT = null, this._overwrittenProps = null, this._onUpdate = null, this._startAt = null, this._initted = this._active = this._notifyPluginsOfEnabled = !1, this._propLookup = this._targets ? {} : [], this
  590. }, ar._enabled = function(b, d) {
  591. if (aJ || aw.wake(), b && this._gc) {
  592. var a, c = this._targets;
  593. if (c) {
  594. for (a = c.length; --a > -1;) {
  595. this._siblings[a] = ah(c[a], this, !0)
  596. }
  597. } else {
  598. this._siblings = ah(this.target, this, !0)
  599. }
  600. }
  601. return al.prototype._enabled.call(this, b, d), this._notifyPluginsOfEnabled && this._firstPT ? af._onPluginEvent(b ? "_onEnable" : "_onDisable", this) : !1
  602. }, af.to = function(b, c, a) {
  603. return new af(b, c, a)
  604. }, af.from = function(b, c, a) {
  605. return a.runBackwards = !0, a.immediateRender = 0 != a.immediateRender, new af(b, c, a)
  606. }, af.fromTo = function(b, d, a, c) {
  607. return c.startAt = a, c.immediateRender = 0 != c.immediateRender && 0 != a.immediateRender, new af(b, d, c)
  608. }, af.delayedCall = function(b, f, a, c, d) {
  609. return new af(f, 0, {
  610. delay: b,
  611. onComplete: f,
  612. onCompleteParams: a,
  613. onCompleteScope: c,
  614. onReverseComplete: f,
  615. onReverseCompleteParams: a,
  616. onReverseCompleteScope: c,
  617. immediateRender: !1,
  618. useFrames: d,
  619. overwrite: 0
  620. })
  621. }, af.set = function(a, b) {
  622. return new af(a, 0, b)
  623. }, af.getTweensOf = function(b, f) {
  624. if (null == b) {
  625. return []
  626. }
  627. b = "string" != typeof b ? b : af.selector(b) || b;
  628. var a, c, d, g;
  629. if ((ax(b) || ae(b)) && "number" != typeof b[0]) {
  630. for (a = b.length, c = []; --a > -1;) {
  631. c = c.concat(af.getTweensOf(b[a], f))
  632. }
  633. for (a = c.length; --a > -1;) {
  634. for (g = c[a], d = a; --d > -1;) {
  635. g === c[d] && c.splice(a, 1)
  636. }
  637. }
  638. } else {
  639. for (c = ah(b).concat(), a = c.length; --a > -1;) {
  640. (c[a]._gc || f && !c[a].isActive()) && c.splice(a, 1)
  641. }
  642. }
  643. return c
  644. }, af.killTweensOf = af.killDelayedCallsTo = function(b, f, a) {
  645. "object" == typeof f && (a = f, f = !1);
  646. for (var c = af.getTweensOf(b, f), d = c.length; --d > -1;) {
  647. c[d]._kill(a, b)
  648. }
  649. };
  650. var Z = aG("plugins.TweenPlugin", function(a, b) {
  651. this._overwriteProps = (a || "").split(","), this._propName = this._overwriteProps[0], this._priority = b || 0, this._super = Z.prototype
  652. }, !0);
  653. if (ar = Z.prototype, Z.version = "1.10.1", Z.API = 2, ar._firstPT = null, ar._addTween = function(d, h, c, f, g, k) {
  654. var b, j;
  655. return null != f && (b = "number" == typeof f || "=" !== f.charAt(1) ? Number(f) - c : parseInt(f.charAt(0) + "1", 10) * Number(f.substr(2))) ? (this._firstPT = j = {
  656. _next: this._firstPT,
  657. t: d,
  658. p: h,
  659. s: c,
  660. c: b,
  661. f: "function" == typeof d[h],
  662. n: g || h,
  663. r: k
  664. }, j._next && (j._next._prev = j), j) : void 0
  665. }, ar.setRatio = function(b) {
  666. for (var d, a = this._firstPT, c = 0.000001; a;) {
  667. d = a.c * b + a.s, a.r ? d = 0 | d + (d > 0 ? 0.5 : -0.5) : c > d && d > -c && (d = 0), a.f ? a.t[a.p](d) : a.t[a.p] = d, a = a._next
  668. }
  669. }, ar._kill = function(b) {
  670. var d, a = this._overwriteProps,
  671. c = this._firstPT;
  672. if (null != b[this._propName]) {
  673. this._overwriteProps = []
  674. } else {
  675. for (d = a.length; --d > -1;) {
  676. null != b[a[d]] && a.splice(d, 1)
  677. }
  678. }
  679. for (; c;) {
  680. null != b[c.n] && (c._next && (c._next._prev = c._prev), c._prev ? (c._prev._next = c._next, c._prev = null) : this._firstPT === c && (this._firstPT = c._next)), c = c._next
  681. }
  682. return !1
  683. }, ar._roundProps = function(b, c) {
  684. for (var a = this._firstPT; a;) {
  685. (b[this._propName] || null != a.n && b[a.n.split(this._propName + "_").join("")]) && (a.r = c), a = a._next
  686. }
  687. }, af._onPluginEvent = function(d, h) {
  688. var c, f, g, k, b, j = h._firstPT;
  689. if ("_onInitAllProps" === d) {
  690. for (; j;) {
  691. for (b = j._next, f = g; f && f.pr > j.pr;) {
  692. f = f._next
  693. }(j._prev = f ? f._prev : k) ? j._prev._next = j: g = j, (j._next = f) ? f._prev = j : k = j, j = b
  694. }
  695. j = h._firstPT = g
  696. }
  697. for (; j;) {
  698. j.pg && "function" == typeof j.t[d] && j.t[d]() && (c = !0), j = j._next
  699. }
  700. return c
  701. }, Z.activate = function(a) {
  702. for (var b = a.length; --b > -1;) {
  703. a[b].API === Z.API && (Y[(new a[b])._propName] = a[b])
  704. }
  705. return !0
  706. }, aH.plugin = function(d) {
  707. if (!(d && d.propName && d.init && d.API)) {
  708. throw "illegal plugin definition."
  709. }
  710. var h, c = d.propName,
  711. f = d.priority || 0,
  712. g = d.overwriteProps,
  713. k = {
  714. init: "_onInitTween",
  715. set: "setRatio",
  716. kill: "_kill",
  717. round: "_roundProps",
  718. initAll: "_onInitAllProps"
  719. },
  720. b = aG("plugins." + c.charAt(0).toUpperCase() + c.substr(1) + "Plugin", function() {
  721. Z.call(this, c, f), this._overwriteProps = g || []
  722. }, d.global === !0),
  723. j = b.prototype = new Z(c);
  724. j.constructor = b, b.API = d.API;
  725. for (h in k) {
  726. "function" == typeof d[h] && (j[k[h]] = d[h])
  727. }
  728. return b.version = d.version, Z.activate([b]), b
  729. }, aB = ap._gsQueue) {
  730. for (aq = 0; aB.length > aq; aq++) {
  731. aB[aq]()
  732. }
  733. for (ar in aE) {
  734. aE[ar].func || ap.console.log("GSAP encountered missing dependency: com.greensock." + ar)
  735. }
  736. }
  737. aJ = !1
  738. }
  739. })(window);
  740. /*!
  741. * VERSION: beta 1.9.3
  742. * DATE: 2013-04-02
  743. * UPDATES AND DOCS AT: http://www.greensock.com
  744. *
  745. * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
  746. * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
  747. * Club GreenSock members, the software agreement that was issued with your membership.
  748. *
  749. * @author: Jack Doyle, jack@greensock.com
  750. **/
  751. (window._gsQueue || (window._gsQueue = [])).push(function() {
  752. window._gsDefine("easing.Back", ["easing.Ease"], function(F) {
  753. var z, w, G, b = window.GreenSockGlobals || window,
  754. k = b.com.greensock,
  755. C = 2 * Math.PI,
  756. j = Math.PI / 2,
  757. x = k._class,
  758. v = function(f, a) {
  759. var c = x("easing." + f, function() {}, !0),
  760. d = c.prototype = new F;
  761. return d.constructor = c, d.getRatio = a, c
  762. },
  763. D = F.register || function() {},
  764. E = function(c, h, a, d) {
  765. var f = x("easing." + c, {
  766. easeOut: new h,
  767. easeIn: new a,
  768. easeInOut: new d
  769. }, !0);
  770. return D(f, c), f
  771. },
  772. B = function(c, d, a) {
  773. this.t = c, this.v = d, a && (this.next = a, a.prev = this, this.c = a.v - d, this.gap = a.t - c)
  774. },
  775. g = function(f, a) {
  776. var c = x("easing." + f, function(e) {
  777. this._p1 = e || 0 === e ? e : 1.70158, this._p2 = 1.525 * this._p1
  778. }, !0),
  779. d = c.prototype = new F;
  780. return d.constructor = c, d.getRatio = a, d.config = function(e) {
  781. return new c(e)
  782. }, c
  783. },
  784. y = E("Back", g("BackOut", function(a) {
  785. return (a -= 1) * a * ((this._p1 + 1) * a + this._p1) + 1
  786. }), g("BackIn", function(a) {
  787. return a * a * ((this._p1 + 1) * a - this._p1)
  788. }), g("BackInOut", function(a) {
  789. return 1 > (a *= 2) ? 0.5 * a * a * ((this._p2 + 1) * a - this._p2) : 0.5 * ((a -= 2) * a * ((this._p2 + 1) * a + this._p2) + 2)
  790. })),
  791. q = x("easing.SlowMo", function(c, d, a) {
  792. d = d || 0 === d ? d : 0.7, null == c ? c = 0.7 : c > 1 && (c = 1), this._p = 1 !== c ? d : 0, this._p1 = (1 - c) / 2, this._p2 = c, this._p3 = this._p1 + this._p2, this._calcEnd = a === !0
  793. }, !0),
  794. A = q.prototype = new F;
  795. return A.constructor = q, A.getRatio = function(a) {
  796. var c = a + (0.5 - a) * this._p;
  797. return this._p1 > a ? this._calcEnd ? 1 - (a = 1 - a / this._p1) * a : c - (a = 1 - a / this._p1) * a * a * a * c : a > this._p3 ? this._calcEnd ? 1 - (a = (a - this._p3) / this._p1) * a : c + (a - c) * (a = (a - this._p3) / this._p1) * a * a * a : this._calcEnd ? 1 : c
  798. }, q.ease = new q(0.7, 0.7), A.config = q.config = function(c, d, a) {
  799. return new q(c, d, a)
  800. }, z = x("easing.SteppedEase", function(a) {
  801. a = a || 1, this._p1 = 1 / a, this._p2 = a + 1
  802. }, !0), A = z.prototype = new F, A.constructor = z, A.getRatio = function(a) {
  803. return 0 > a ? a = 0 : a >= 1 && (a = 0.999999999), (this._p2 * a >> 0) * this._p1
  804. }, A.config = z.config = function(a) {
  805. return new z(a)
  806. }, w = x("easing.RoughEase", function(P) {
  807. P = P || {};
  808. for (var L, U, c, I, R, H, M = P.taper || "none", K = [], S = 0, T = 0 | (P.points || 20), t = T, O = P.randomize !== !1, J = P.clamp === !0, Q = P.template instanceof F ? P.template : null, N = "number" == typeof P.strength ? 0.4 * P.strength : 0.4; --t > -1;) {
  809. L = O ? Math.random() : 1 / T * t, U = Q ? Q.getRatio(L) : L, "none" === M ? c = N : "out" === M ? (I = 1 - L, c = I * I * N) : "in" === M ? c = L * L * N : 0.5 > L ? (I = 2 * L, c = 0.5 * I * I * N) : (I = 2 * (1 - L), c = 0.5 * I * I * N), O ? U += Math.random() * c - 0.5 * c : t % 2 ? U += 0.5 * c : U -= 0.5 * c, J && (U > 1 ? U = 1 : 0 > U && (U = 0)), K[S++] = {
  810. x: L,
  811. y: U
  812. }
  813. }
  814. for (K.sort(function(a, d) {
  815. return a.x - d.x
  816. }), H = new B(1, 1, null), t = T; --t > -1;) {
  817. R = K[t], H = new B(R.x, R.y, H)
  818. }
  819. this._prev = new B(0, 0, 0 !== H.t ? H : H.next)
  820. }, !0), A = w.prototype = new F, A.constructor = w, A.getRatio = function(a) {
  821. var c = this._prev;
  822. if (a > c.t) {
  823. for (; c.next && a >= c.t;) {
  824. c = c.next
  825. }
  826. c = c.prev
  827. } else {
  828. for (; c.prev && c.t >= a;) {
  829. c = c.prev
  830. }
  831. }
  832. return this._prev = c, c.v + (a - c.t) / c.gap * c.c
  833. }, A.config = function(a) {
  834. return new w(a)
  835. }, w.ease = new w, E("Bounce", v("BounceOut", function(a) {
  836. return 1 / 2.75 > a ? 7.5625 * a * a : 2 / 2.75 > a ? 7.5625 * (a -= 1.5 / 2.75) * a + 0.75 : 2.5 / 2.75 > a ? 7.5625 * (a -= 2.25 / 2.75) * a + 0.9375 : 7.5625 * (a -= 2.625 / 2.75) * a + 0.984375
  837. }), v("BounceIn", function(a) {
  838. return 1 / 2.75 > (a = 1 - a) ? 1 - 7.5625 * a * a : 2 / 2.75 > a ? 1 - (7.5625 * (a -= 1.5 / 2.75) * a + 0.75) : 2.5 / 2.75 > a ? 1 - (7.5625 * (a -= 2.25 / 2.75) * a + 0.9375) : 1 - (7.5625 * (a -= 2.625 / 2.75) * a + 0.984375)
  839. }), v("BounceInOut", function(a) {
  840. var c = 0.5 > a;
  841. return a = c ? 1 - 2 * a : 2 * a - 1, a = 1 / 2.75 > a ? 7.5625 * a * a : 2 / 2.75 > a ? 7.5625 * (a -= 1.5 / 2.75) * a + 0.75 : 2.5 / 2.75 > a ? 7.5625 * (a -= 2.25 / 2.75) * a + 0.9375 : 7.5625 * (a -= 2.625 / 2.75) * a + 0.984375, c ? 0.5 * (1 - a) : 0.5 * a + 0.5
  842. })), E("Circ", v("CircOut", function(a) {
  843. return Math.sqrt(1 - (a -= 1) * a)
  844. }), v("CircIn", function(a) {
  845. return -(Math.sqrt(1 - a * a) - 1)
  846. }), v("CircInOut", function(a) {
  847. return 1 > (a *= 2) ? -0.5 * (Math.sqrt(1 - a * a) - 1) : 0.5 * (Math.sqrt(1 - (a -= 2) * a) + 1)
  848. })), G = function(f, a, c) {
  849. var d = x("easing." + f, function(i, l) {
  850. this._p1 = i || 1, this._p2 = l || c, this._p3 = this._p2 / C * (Math.asin(1 / this._p1) || 0)
  851. }, !0),
  852. h = d.prototype = new F;
  853. return h.constructor = d, h.getRatio = a, h.config = function(i, l) {
  854. return new d(i, l)
  855. }, d
  856. }, E("Elastic", G("ElasticOut", function(a) {
  857. return this._p1 * Math.pow(2, -10 * a) * Math.sin((a - this._p3) * C / this._p2) + 1
  858. }, 0.3), G("ElasticIn", function(a) {
  859. return -(this._p1 * Math.pow(2, 10 * (a -= 1)) * Math.sin((a - this._p3) * C / this._p2))
  860. }, 0.3), G("ElasticInOut", function(a) {
  861. return 1 > (a *= 2) ? -0.5 * this._p1 * Math.pow(2, 10 * (a -= 1)) * Math.sin((a - this._p3) * C / this._p2) : 0.5 * this._p1 * Math.pow(2, -10 * (a -= 1)) * Math.sin((a - this._p3) * C / this._p2) + 1
  862. }, 0.45)), E("Expo", v("ExpoOut", function(a) {
  863. return 1 - Math.pow(2, -10 * a)
  864. }), v("ExpoIn", function(a) {
  865. return Math.pow(2, 10 * (a - 1)) - 0.001
  866. }), v("ExpoInOut", function(a) {
  867. return 1 > (a *= 2) ? 0.5 * Math.pow(2, 10 * (a - 1)) : 0.5 * (2 - Math.pow(2, -10 * (a - 1)))
  868. })), E("Sine", v("SineOut", function(a) {
  869. return Math.sin(a * j)
  870. }), v("SineIn", function(a) {
  871. return -Math.cos(a * j) + 1
  872. }), v("SineInOut", function(a) {
  873. return -0.5 * (Math.cos(Math.PI * a) - 1)
  874. })), x("easing.EaseLookup", {
  875. find: function(a) {
  876. return F.map[a]
  877. }
  878. }, !0), D(b.SlowMo, "SlowMo", "ease,"), D(w, "RoughEase", "ease,"), D(z, "SteppedEase", "ease,"), y
  879. }, !0)
  880. }), window._gsDefine && window._gsQueue.pop()();
  881. /*!
  882. * @license SoundJS
  883. * Visit http://createjs.com/ for documentation, updates and examples.
  884. *
  885. * Copyright (c) 2011-2013 gskinner.com, inc.
  886. *
  887. * Distributed under the terms of the MIT license.
  888. * http://www.opensource.org/licenses/mit-license.html
  889. *
  890. * This notice shall be included in all copies or substantial portions of the Software.
  891. */
  892. ;
  893. this.createjs = this.createjs || {},
  894. function() {
  895. var b = createjs.SoundJS = createjs.SoundJS || {};
  896. b.version = "0.5.2", b.buildDate = "Thu, 12 Dec 2013 23:33:37 GMT"
  897. }(), this.createjs = this.createjs || {},
  898. function() {
  899. var d = function() {},
  900. c = d.prototype;
  901. d.initialize = function(b) {
  902. b.addEventListener = c.addEventListener, b.on = c.on, b.removeEventListener = b.off = c.removeEventListener, b.removeAllEventListeners = c.removeAllEventListeners, b.hasEventListener = c.hasEventListener, b.dispatchEvent = c.dispatchEvent, b._dispatchEvent = c._dispatchEvent, b.willTrigger = c.willTrigger
  903. }, c._listeners = null, c._captureListeners = null, c.initialize = function() {}, c.addEventListener = function(g, f, j) {
  904. var i;
  905. i = j ? this._captureListeners = this._captureListeners || {} : this._listeners = this._listeners || {};
  906. var h = i[g];
  907. return h && this.removeEventListener(g, f, j), h = i[g], h ? h.push(f) : i[g] = [f], f
  908. }, c.on = function(h, g, l, k, j, i) {
  909. return g.handleEvent && (l = l || g, g = g.handleEvent), l = l || this, this.addEventListener(h, function(b) {
  910. g.call(l, b, j), k && b.remove()
  911. }, i)
  912. }, c.removeEventListener = function(i, h, n) {
  913. var m = n ? this._captureListeners : this._listeners;
  914. if (m) {
  915. var l = m[i];
  916. if (l) {
  917. for (var k = 0, j = l.length; j > k; k++) {
  918. if (l[k] == h) {
  919. 1 == j ? delete m[i] : l.splice(k, 1);
  920. break
  921. }
  922. }
  923. }
  924. }
  925. }, c.off = c.removeEventListener, c.removeAllEventListeners = function(b) {
  926. b ? (this._listeners && delete this._listeners[b], this._captureListeners && delete this._captureListeners[b]) : this._listeners = this._captureListeners = null
  927. }, c.dispatchEvent = function(i, h) {
  928. if ("string" == typeof i) {
  929. var n = this._listeners;
  930. if (!n || !n[i]) {
  931. return !1
  932. }
  933. i = new createjs.Event(i)
  934. }
  935. if (i.target = h || this, i.bubbles && this.parent) {
  936. for (var m = this, l = [m]; m.parent;) {
  937. l.push(m = m.parent)
  938. }
  939. var k, j = l.length;
  940. for (k = j - 1; k >= 0 && !i.propagationStopped; k--) {
  941. l[k]._dispatchEvent(i, 1 + (0 == k))
  942. }
  943. for (k = 1; j > k && !i.propagationStopped; k++) {
  944. l[k]._dispatchEvent(i, 3)
  945. }
  946. } else {
  947. this._dispatchEvent(i, 2)
  948. }
  949. return i.defaultPrevented
  950. }, c.hasEventListener = function(f) {
  951. var e = this._listeners,
  952. g = this._captureListeners;
  953. return !!(e && e[f] || g && g[f])
  954. }, c.willTrigger = function(f) {
  955. for (var e = this; e;) {
  956. if (e.hasEventListener(f)) {
  957. return !0
  958. }
  959. e = e.parent
  960. }
  961. return !1
  962. }, c.toString = function() {
  963. return "[EventDispatcher]"
  964. }, c._dispatchEvent = function(i, h) {
  965. var n, m = 1 == h ? this._captureListeners : this._listeners;
  966. if (i && m) {
  967. var l = m[i.type];
  968. if (!l || !(n = l.length)) {
  969. return
  970. }
  971. i.currentTarget = this, i.eventPhase = h, i.removed = !1, l = l.slice();
  972. for (var k = 0; n > k && !i.immediatePropagationStopped; k++) {
  973. var j = l[k];
  974. j.handleEvent ? j.handleEvent(i) : j(i), i.removed && (this.off(i.type, j, 1 == h), i.removed = !1)
  975. }
  976. }
  977. }, createjs.EventDispatcher = d
  978. }(), this.createjs = this.createjs || {},
  979. function() {
  980. var d = function(f, e, g) {
  981. this.initialize(f, e, g)
  982. },
  983. c = d.prototype;
  984. c.type = null, c.target = null, c.currentTarget = null, c.eventPhase = 0, c.bubbles = !1, c.cancelable = !1, c.timeStamp = 0, c.defaultPrevented = !1, c.propagationStopped = !1, c.immediatePropagationStopped = !1, c.removed = !1, c.initialize = function(f, e, g) {
  985. this.type = f, this.bubbles = e, this.cancelable = g, this.timeStamp = (new Date).getTime()
  986. }, c.preventDefault = function() {
  987. this.defaultPrevented = !0
  988. }, c.stopPropagation = function() {
  989. this.propagationStopped = !0
  990. }, c.stopImmediatePropagation = function() {
  991. this.immediatePropagationStopped = this.propagationStopped = !0
  992. }, c.remove = function() {
  993. this.removed = !0
  994. }, c.clone = function() {
  995. return new d(this.type, this.bubbles, this.cancelable)
  996. }, c.toString = function() {
  997. return "[Event (type=" + this.type + ")]"
  998. }, createjs.Event = d
  999. }(), this.createjs = this.createjs || {},
  1000. function() {
  1001. createjs.indexOf = function(f, e) {
  1002. for (var h = 0, g = f.length; g > h; h++) {
  1003. if (e === f[h]) {
  1004. return h
  1005. }
  1006. }
  1007. return -1
  1008. }
  1009. }(), this.createjs = this.createjs || {},
  1010. function() {
  1011. createjs.proxy = function(e, d) {
  1012. var f = Array.prototype.slice.call(arguments, 2);
  1013. return function() {
  1014. return e.apply(d, Array.prototype.slice.call(arguments, 0).concat(f))
  1015. }
  1016. }
  1017. }(), this.createjs = this.createjs || {},
  1018. function() {
  1019. function h() {
  1020. throw "Sound cannot be instantiated"
  1021. }
  1022. function g(d, c) {
  1023. this.init(d, c)
  1024. }
  1025. function l() {
  1026. this.isDefault = !0, this.addEventListener = this.removeEventListener = this.removeAllEventListeners = this.dispatchEvent = this.hasEventListener = this._listeners = this._interrupt = this._playFailed = this.pause = this.resume = this.play = this._beginPlaying = this._cleanUp = this.stop = this.setMasterVolume = this.setVolume = this.mute = this.setMute = this.getMute = this.setPan = this.getPosition = this.setPosition = this.playFailed = function() {
  1027. return !1
  1028. }, this.getVolume = this.getPan = this.getDuration = function() {
  1029. return 0
  1030. }, this.playState = h.PLAY_FAILED, this.toString = function() {
  1031. return "[Sound Default Sound Instance]"
  1032. }
  1033. }
  1034. function k() {}
  1035. var j = h;
  1036. j.DELIMITER = "|", j.INTERRUPT_ANY = "any", j.INTERRUPT_EARLY = "early", j.INTERRUPT_LATE = "late", j.INTERRUPT_NONE = "none", j.PLAY_INITED = "playInited", j.PLAY_SUCCEEDED = "playSucceeded", j.PLAY_INTERRUPTED = "playInterrupted", j.PLAY_FINISHED = "playFinished", j.PLAY_FAILED = "playFailed", j.SUPPORTED_EXTENSIONS = ["mp3", "ogg", "mpeg", "wav", "m4a", "mp4", "aiff", "wma", "mid"], j.EXTENSION_MAP = {
  1037. m4a: "mp4"
  1038. }, j.FILE_PATTERN = /^(?:(\w+:)\/{2}(\w+(?:\.\w+)*\/?))?([/.]*?(?:[^?]+)?\/)?((?:[^/?]+)\.(\w+))(?:\?(\S+)?)?$/, j.defaultInterruptBehavior = j.INTERRUPT_NONE, j.alternateExtensions = [], j._lastID = 0, j.activePlugin = null, j._pluginsRegistered = !1, j._masterVolume = 1, j._masterMute = !1, j._instances = [], j._idHash = {}, j._preloadHash = {}, j._defaultSoundInstance = null, j.addEventListener = null, j.removeEventListener = null, j.removeAllEventListeners = null, j.dispatchEvent = null, j.hasEventListener = null, j._listeners = null, createjs.EventDispatcher.initialize(j), j._sendFileLoadEvent = function(m) {
  1039. if (j._preloadHash[m]) {
  1040. for (var e = 0, p = j._preloadHash[m].length; p > e; e++) {
  1041. var o = j._preloadHash[m][e];
  1042. if (j._preloadHash[m][e] = !0, j.hasEventListener("fileload")) {
  1043. var n = new createjs.Event("fileload");
  1044. n.src = o.src, n.id = o.id, n.data = o.data, j.dispatchEvent(n)
  1045. }
  1046. }
  1047. }
  1048. }, j.getPreloadHandlers = function() {
  1049. return {
  1050. callback: createjs.proxy(j.initLoad, j),
  1051. types: ["sound"],
  1052. extensions: j.SUPPORTED_EXTENSIONS
  1053. }
  1054. }, j.registerPlugin = function(d) {
  1055. try {
  1056. console.log("createjs.Sound.registerPlugin has been deprecated. Please use registerPlugins.")
  1057. } catch (c) {}
  1058. return j._registerPlugin(d)
  1059. }, j._registerPlugin = function(b) {
  1060. return j._pluginsRegistered = !0, null == b ? !1 : b.isSupported() ? (j.activePlugin = new b, !0) : !1
  1061. }, j.registerPlugins = function(f) {
  1062. for (var e = 0, n = f.length; n > e; e++) {
  1063. var m = f[e];
  1064. if (j._registerPlugin(m)) {
  1065. return !0
  1066. }
  1067. }
  1068. return !1
  1069. }, j.initializeDefaultPlugins = function() {
  1070. return null != j.activePlugin ? !0 : j._pluginsRegistered ? !1 : j.registerPlugins([createjs.WebAudioPlugin, createjs.HTMLAudioPlugin]) ? !0 : !1
  1071. }, j.isReady = function() {
  1072. return null != j.activePlugin
  1073. }, j.getCapabilities = function() {
  1074. return null == j.activePlugin ? null : j.activePlugin._capabilities
  1075. }, j.getCapability = function(b) {
  1076. return null == j.activePlugin ? null : j.activePlugin._capabilities[b]
  1077. }, j.initLoad = function(m, e, q, p, o) {
  1078. m = m.replace(o, "");
  1079. var n = j.registerSound(m, q, p, !1, o);
  1080. return null == n ? !1 : n
  1081. }, j.registerSound = function(b, r, q, p, o) {
  1082. if (!j.initializeDefaultPlugins()) {
  1083. return !1
  1084. }
  1085. if (b instanceof Object && (o = r, r = b.id, q = b.data, b = b.src), j.alternateExtensions.length) {
  1086. var n = j._parsePath2(b, "sound", r, q)
  1087. } else {
  1088. var n = j._parsePath(b, "sound", r, q)
  1089. } if (null == n) {
  1090. return !1
  1091. }
  1092. null != o && (b = o + b, n.src = o + n.src), null != r && (j._idHash[r] = n.src);
  1093. var m = null;
  1094. null != q && (isNaN(q.channels) ? isNaN(q) || (m = parseInt(q)) : m = parseInt(q.channels));
  1095. var e = j.activePlugin.register(n.src, m);
  1096. if (null != e && (null != e.numChannels && (m = e.numChannels), g.create(n.src, m), null != q && isNaN(q) ? q.channels = n.data.channels = m || g.maxPerChannel() : q = n.data = m || g.maxPerChannel(), null != e.tag ? n.tag = e.tag : e.src && (n.src = e.src), null != e.completeHandler && (n.completeHandler = e.completeHandler), e.type && (n.type = e.type)), 0 != p) {
  1097. if (j._preloadHash[n.src] || (j._preloadHash[n.src] = []), j._preloadHash[n.src].push({
  1098. src: b,
  1099. id: r,
  1100. data: q
  1101. }), 1 == j._preloadHash[n.src].length) {
  1102. j.activePlugin.preload(n.src, e)
  1103. } else {
  1104. if (1 == j._preloadHash[n.src][0]) {
  1105. return !0
  1106. }
  1107. }
  1108. }
  1109. return n
  1110. }, j.registerManifest = function(m, f) {
  1111. for (var p = [], o = 0, n = m.length; n > o; o++) {
  1112. p[o] = createjs.Sound.registerSound(m[o].src, m[o].id, m[o].data, m[o].preload, f)
  1113. }
  1114. return p
  1115. }, j.removeSound = function(b, n) {
  1116. if (null == j.activePlugin) {
  1117. return !1
  1118. }
  1119. if (b instanceof Object && (b = b.src), b = j._getSrcById(b), j.alternateExtensions.length) {
  1120. var m = j._parsePath2(b)
  1121. } else {
  1122. var m = j._parsePath(b)
  1123. } if (null == m) {
  1124. return !1
  1125. }
  1126. null != n && (m.src = n + m.src), b = m.src;
  1127. for (var e in j._idHash) {
  1128. j._idHash[e] == b && delete j._idHash[e]
  1129. }
  1130. return g.removeSrc(b), delete j._preloadHash[b], j.activePlugin.removeSound(b), !0
  1131. }, j.removeManifest = function(m, f) {
  1132. for (var p = [], o = 0, n = m.length; n > o; o++) {
  1133. p[o] = createjs.Sound.removeSound(m[o].src, f)
  1134. }
  1135. return p
  1136. }, j.removeAllSounds = function() {
  1137. j._idHash = {}, j._preloadHash = {}, g.removeAll(), j.activePlugin.removeAllSounds()
  1138. }, j.loadComplete = function(d) {
  1139. if (j.alternateExtensions.length) {
  1140. var c = j._parsePath2(d, "sound")
  1141. } else {
  1142. var c = j._parsePath(d, "sound")
  1143. }
  1144. return d = c ? j._getSrcById(c.src) : j._getSrcById(d), 1 == j._preloadHash[d][0]
  1145. }, j._parsePath = function(B, A, z, y) {
  1146. "string" != typeof B && (B = B.toString());
  1147. var x = B.split(j.DELIMITER);
  1148. if (x.length > 1) {
  1149. try {
  1150. console.log('createjs.Sound.DELIMITER "|" loading approach has been deprecated. Please use the new alternateExtensions property.')
  1151. } catch (w) {}
  1152. }
  1153. for (var v = {
  1154. type: A || "sound",
  1155. id: z,
  1156. data: y
  1157. }, u = j.getCapabilities(), t = 0, s = x.length; s > t; t++) {
  1158. var r = x[t],
  1159. q = r.match(j.FILE_PATTERN);
  1160. if (null == q) {
  1161. return !1
  1162. }
  1163. var p = q[4],
  1164. e = q[5];
  1165. if (u[e] && createjs.indexOf(j.SUPPORTED_EXTENSIONS, e) > -1) {
  1166. return v.name = p, v.src = r, v.extension = e, v
  1167. }
  1168. }
  1169. return null
  1170. }, j._parsePath2 = function(u, t, s, r) {
  1171. "string" != typeof u && (u = u.toString());
  1172. var q = u.match(j.FILE_PATTERN);
  1173. if (null == q) {
  1174. return !1
  1175. }
  1176. for (var p = q[4], o = q[5], n = j.getCapabilities(), m = 0; !n[o];) {
  1177. if (o = j.alternateExtensions[m++], m > j.alternateExtensions.length) {
  1178. return null
  1179. }
  1180. }
  1181. u = u.replace("." + q[5], "." + o);
  1182. var e = {
  1183. type: t || "sound",
  1184. id: s,
  1185. data: r
  1186. };
  1187. return e.name = p, e.src = u, e.extension = o, e
  1188. }, j.play = function(t, s, r, q, p, o, n) {
  1189. var m = j.createInstance(t),
  1190. e = j._playInstance(m, s, r, q, p, o, n);
  1191. return e || m.playFailed(), m
  1192. }, j.createInstance = function(e) {
  1193. if (!j.initializeDefaultPlugins()) {
  1194. return j._defaultSoundInstance
  1195. }
  1196. if (e = j._getSrcById(e), j.alternateExtensions.length) {
  1197. var b = j._parsePath2(e, "sound")
  1198. } else {
  1199. var b = j._parsePath(e, "sound")
  1200. }
  1201. var a = null;
  1202. return null != b && null != b.src ? (g.create(b.src), a = j.activePlugin.create(b.src)) : a = h._defaultSoundInstance, a.uniqueId = j._lastID++, a
  1203. }, j.setVolume = function(f) {
  1204. if (null == Number(f)) {
  1205. return !1
  1206. }
  1207. if (f = Math.max(0, Math.min(1, f)), j._masterVolume = f, !this.activePlugin || !this.activePlugin.setVolume || !this.activePlugin.setVolume(f)) {
  1208. for (var e = this._instances, n = 0, m = e.length; m > n; n++) {
  1209. e[n].setMasterVolume(f)
  1210. }
  1211. }
  1212. }, j.getVolume = function() {
  1213. return j._masterVolume
  1214. }, j.setMute = function(f) {
  1215. if (null == f || void 0 == f) {
  1216. return !1
  1217. }
  1218. if (this._masterMute = f, !this.activePlugin || !this.activePlugin.setMute || !this.activePlugin.setMute(f)) {
  1219. for (var e = this._instances, n = 0, m = e.length; m > n; n++) {
  1220. e[n].setMasterMute(f)
  1221. }
  1222. }
  1223. return !0
  1224. }, j.getMute = function() {
  1225. return this._masterMute
  1226. }, j.stop = function() {
  1227. for (var d = this._instances, c = d.length; c--;) {
  1228. d[c].stop()
  1229. }
  1230. }, j._playInstance = function(t, s, r, q, p, o, n) {
  1231. if (s instanceof Object && (r = s.delay, q = s.offset, p = s.loop, o = s.volume, n = s.pan, s = s.interrupt), s = s || j.defaultInterruptBehavior, null == r && (r = 0), null == q && (q = t.getPosition()), null == p && (p = 0), null == o && (o = t.volume), null == n && (n = t.pan), 0 == r) {
  1232. var m = j._beginPlaying(t, s, q, p, o, n);
  1233. if (!m) {
  1234. return !1
  1235. }
  1236. } else {
  1237. var e = setTimeout(function() {
  1238. j._beginPlaying(t, s, q, p, o, n)
  1239. }, r);
  1240. t._delayTimeoutId = e
  1241. }
  1242. return this._instances.push(t), !0
  1243. }, j._beginPlaying = function(b, s, r, q, p, o) {
  1244. if (!g.add(b, s)) {
  1245. return !1
  1246. }
  1247. var n = b._beginPlaying(r, q, p, o);
  1248. if (!n) {
  1249. var m = createjs.indexOf(this._instances, b);
  1250. return m > -1 && this._instances.splice(m, 1), !1
  1251. }
  1252. return !0
  1253. }, j._getSrcById = function(b) {
  1254. return null == j._idHash || null == j._idHash[b] ? b : j._idHash[b]
  1255. }, j._playFinished = function(b) {
  1256. g.remove(b);
  1257. var d = createjs.indexOf(this._instances, b);
  1258. d > -1 && this._instances.splice(d, 1)
  1259. }, createjs.Sound = h, g.channels = {}, g.create = function(b, f) {
  1260. var e = g.get(b);
  1261. return null == e ? (g.channels[b] = new g(b, f), !0) : !1
  1262. }, g.removeSrc = function(b) {
  1263. var d = g.get(b);
  1264. return null == d ? !1 : (d.removeAll(), delete g.channels[b], !0)
  1265. }, g.removeAll = function() {
  1266. for (var b in g.channels) {
  1267. g.channels[b].removeAll()
  1268. }
  1269. g.channels = {}
  1270. }, g.add = function(b, f) {
  1271. var e = g.get(b.src);
  1272. return null == e ? !1 : e.add(b, f)
  1273. }, g.remove = function(b) {
  1274. var d = g.get(b.src);
  1275. return null == d ? !1 : (d.remove(b), !0)
  1276. }, g.maxPerChannel = function() {
  1277. return i.maxDefault
  1278. }, g.get = function(b) {
  1279. return g.channels[b]
  1280. };
  1281. var i = g.prototype;
  1282. i.src = null, i.max = null, i.maxDefault = 100, i.length = 0, i.init = function(d, c) {
  1283. this.src = d, this.max = c || this.maxDefault, -1 == this.max && (this.max = this.maxDefault), this._instances = []
  1284. }, i.get = function(b) {
  1285. return this._instances[b]
  1286. }, i.add = function(d, c) {
  1287. return this.getSlot(c, d) ? (this._instances.push(d), this.length++, !0) : !1
  1288. }, i.remove = function(d) {
  1289. var c = createjs.indexOf(this._instances, d);
  1290. return -1 == c ? !1 : (this._instances.splice(c, 1), this.length--, !0)
  1291. }, i.removeAll = function() {
  1292. for (var b = this.length - 1; b >= 0; b--) {
  1293. this._instances[b].stop()
  1294. }
  1295. }, i.getSlot = function(a) {
  1296. for (var p, o, n = 0, m = this.max; m > n; n++) {
  1297. if (p = this.get(n), null == p) {
  1298. return !0
  1299. }(a != h.INTERRUPT_NONE || p.playState == h.PLAY_FINISHED) && (0 != n ? p.playState == h.PLAY_FINISHED || p.playState == h.PLAY_INTERRUPTED || p.playState == h.PLAY_FAILED ? o = p : (a == h.INTERRUPT_EARLY && p.getPosition() < o.getPosition() || a == h.INTERRUPT_LATE && p.getPosition() > o.getPosition()) && (o = p) : o = p)
  1300. }
  1301. return null != o ? (o._interrupt(), this.remove(o), !0) : !1
  1302. }, i.toString = function() {
  1303. return "[Sound SoundChannel]"
  1304. }, h._defaultSoundInstance = new l, k.init = function() {
  1305. var b = window.navigator.userAgent;
  1306. k.isFirefox = b.indexOf("Firefox") > -1, k.isOpera = null != window.opera, k.isChrome = b.indexOf("Chrome") > -1, k.isIOS = b.indexOf("iPod") > -1 || b.indexOf("iPhone") > -1 || b.indexOf("iPad") > -1, k.isAndroid = b.indexOf("Android") > -1, k.isBlackberry = b.indexOf("Blackberry") > -1
  1307. }, k.init(), createjs.Sound.BrowserDetect = k
  1308. }(), this.createjs = this.createjs || {},
  1309. function() {
  1310. function e() {
  1311. this._init()
  1312. }
  1313. var d = e;
  1314. d._capabilities = null, d.isSupported = function() {
  1315. var b = createjs.Sound.BrowserDetect.isIOS || createjs.Sound.BrowserDetect.isAndroid || createjs.Sound.BrowserDetect.isBlackberry;
  1316. return "file:" != location.protocol || b || this._isFileXHRSupported() ? (d._generateCapabilities(), null == d.context ? !1 : !0) : !1
  1317. }, d._isFileXHRSupported = function() {
  1318. var h = !0,
  1319. g = new XMLHttpRequest;
  1320. try {
  1321. g.open("GET", "fail.fail", !1)
  1322. } catch (i) {
  1323. return h = !1
  1324. }
  1325. g.onerror = function() {
  1326. h = !1
  1327. }, g.onload = function() {
  1328. h = 404 == this.status || 200 == this.status || 0 == this.status && "" != this.response
  1329. };
  1330. try {
  1331. g.send()
  1332. } catch (i) {
  1333. h = !1
  1334. }
  1335. return h
  1336. }, d._generateCapabilities = function() {
  1337. if (null == d._capabilities) {
  1338. var b = document.createElement("audio");
  1339. if (null == b.canPlayType) {
  1340. return null
  1341. }
  1342. if (window.webkitAudioContext) {
  1343. d.context = new webkitAudioContext
  1344. } else {
  1345. if (!window.AudioContext) {
  1346. return null
  1347. }
  1348. d.context = new AudioContext
  1349. }
  1350. d._compatibilitySetUp(), d.playEmptySound(), d._capabilities = {
  1351. panning: !0,
  1352. volume: !0,
  1353. tracks: -1
  1354. };
  1355. for (var n = createjs.Sound.SUPPORTED_EXTENSIONS, m = createjs.Sound.EXTENSION_MAP, l = 0, k = n.length; k > l; l++) {
  1356. var j = n[l],
  1357. i = m[j] || j;
  1358. d._capabilities[j] = "no" != b.canPlayType("audio/" + j) && "" != b.canPlayType("audio/" + j) || "no" != b.canPlayType("audio/" + i) && "" != b.canPlayType("audio/" + i)
  1359. }
  1360. d.context.destination.numberOfChannels < 2 && (d._capabilities.panning = !1), d.dynamicsCompressorNode = d.context.createDynamicsCompressor(), d.dynamicsCompressorNode.connect(d.context.destination), d.gainNode = d.context.createGain(), d.gainNode.connect(d.dynamicsCompressorNode)
  1361. }
  1362. }, d._compatibilitySetUp = function() {
  1363. if (!d.context.createGain) {
  1364. d.context.createGain = d.context.createGainNode;
  1365. var b = d.context.createBufferSource();
  1366. b.__proto__.start = b.__proto__.noteGrainOn, b.__proto__.stop = b.__proto__.noteOff, this._panningModel = 0
  1367. }
  1368. }, d.playEmptySound = function() {
  1369. var g = this.context.createBuffer(1, 1, 22050),
  1370. c = this.context.createBufferSource();
  1371. c.buffer = g, c.connect(this.context.destination), c.start(0, 0, 0)
  1372. };
  1373. var f = e.prototype;
  1374. f._capabilities = null, f._volume = 1, f.context = null, f._panningModel = "equalpower", f.dynamicsCompressorNode = null, f.gainNode = null, f._arrayBuffers = null, f._init = function() {
  1375. this._capabilities = d._capabilities, this._arrayBuffers = {}, this.context = d.context, this.gainNode = d.gainNode, this.dynamicsCompressorNode = d.dynamicsCompressorNode
  1376. }, f.register = function(g) {
  1377. this._arrayBuffers[g] = !0;
  1378. var c = new createjs.WebAudioPlugin.Loader(g, this);
  1379. return {
  1380. tag: c
  1381. }
  1382. }, f.isPreloadStarted = function(b) {
  1383. return null != this._arrayBuffers[b]
  1384. }, f.isPreloadComplete = function(b) {
  1385. return !(null == this._arrayBuffers[b] || 1 == this._arrayBuffers[b])
  1386. }, f.removeSound = function(b) {
  1387. delete this._arrayBuffers[b]
  1388. }, f.removeAllSounds = function() {
  1389. this._arrayBuffers = {}
  1390. }, f.addPreloadResults = function(g, c) {
  1391. this._arrayBuffers[g] = c
  1392. }, f._handlePreloadComplete = function() {
  1393. createjs.Sound._sendFileLoadEvent(this.src)
  1394. }, f.preload = function(g) {
  1395. this._arrayBuffers[g] = !0;
  1396. var c = new createjs.WebAudioPlugin.Loader(g, this);
  1397. c.onload = this._handlePreloadComplete, c.load()
  1398. }, f.create = function(b) {
  1399. return this.isPreloadStarted(b) || this.preload(b), new createjs.WebAudioPlugin.SoundInstance(b, this)
  1400. }, f.setVolume = function(b) {
  1401. return this._volume = b, this._updateVolume(), !0
  1402. }, f._updateVolume = function() {
  1403. var b = createjs.Sound._masterMute ? 0 : this._volume;
  1404. b != this.gainNode.gain.value && (this.gainNode.gain.value = b)
  1405. }, f.getVolume = function() {
  1406. return this._volume
  1407. }, f.setMute = function() {
  1408. return this._updateVolume(), !0
  1409. }, f.toString = function() {
  1410. return "[WebAudioPlugin]"
  1411. }, createjs.WebAudioPlugin = e
  1412. }(),
  1413. function() {
  1414. function e(g, c) {
  1415. this._init(g, c)
  1416. }
  1417. var d = e.prototype = new createjs.EventDispatcher;
  1418. d.src = null, d.uniqueId = -1, d.playState = null, d._owner = null, d._offset = 0, d._delay = 0, d._volume = 1;
  1419. try {
  1420. Object.defineProperty(d, "volume", {
  1421. get: function() {
  1422. return this._volume
  1423. },
  1424. set: function(b) {
  1425. return null == Number(b) ? !1 : (b = Math.max(0, Math.min(1, b)), this._volume = b, this._updateVolume(), void 0)
  1426. }
  1427. })
  1428. } catch (f) {}
  1429. d._pan = 0;
  1430. try {
  1431. Object.defineProperty(d, "pan", {
  1432. get: function() {
  1433. return this._pan
  1434. },
  1435. set: function(b) {
  1436. return this._owner._capabilities.panning && null != Number(b) ? (b = Math.max(-1, Math.min(1, b)), this._pan = b, this.panNode.setPosition(b, 0, -0.5), void 0) : !1
  1437. }
  1438. })
  1439. } catch (f) {}
  1440. d._duration = 0, d._remainingLoops = 0, d._delayTimeoutId = null, d._soundCompleteTimeout = null, d.gainNode = null, d.panNode = null, d.sourceNode = null, d._sourceNodeNext = null, d._muted = !1, d._paused = !1, d._startTime = 0, d._endedHandler = null, d._sendEvent = function(g) {
  1441. var c = new createjs.Event(g);
  1442. this.dispatchEvent(c)
  1443. }, d._init = function(g, c) {
  1444. this._owner = c, this.src = g, this.gainNode = this._owner.context.createGain(), this.panNode = this._owner.context.createPanner(), this.panNode.panningModel = this._owner._panningModel, this.panNode.connect(this.gainNode), this._owner.isPreloadComplete(this.src) && (this._duration = 1000 * this._owner._arrayBuffers[this.src].duration), this._endedHandler = createjs.proxy(this._handleSoundComplete, this)
  1445. }, d._cleanUp = function() {
  1446. this.sourceNode && this.playState == createjs.Sound.PLAY_SUCCEEDED && (this.sourceNode = this._cleanUpAudioNode(this.sourceNode), this._sourceNodeNext = this._cleanUpAudioNode(this._sourceNodeNext)), 0 != this.gainNode.numberOfOutputs && this.gainNode.disconnect(0), clearTimeout(this._delayTimeoutId), clearTimeout(this._soundCompleteTimeout), this._startTime = 0, null != window.createjs && createjs.Sound._playFinished(this)
  1447. }, d._cleanUpAudioNode = function(b) {
  1448. return b && (b.stop(0), b.disconnect(this.panNode), b = null), b
  1449. }, d._interrupt = function() {
  1450. this._cleanUp(), this.playState = createjs.Sound.PLAY_INTERRUPTED, this._paused = !1, this._sendEvent("interrupted")
  1451. }, d._handleSoundReady = function() {
  1452. if (null != window.createjs) {
  1453. if (1000 * this._offset > this.getDuration()) {
  1454. return this.playFailed(), void 0
  1455. }
  1456. this._offset < 0 && (this._offset = 0), this.playState = createjs.Sound.PLAY_SUCCEEDED, this._paused = !1, this.gainNode.connect(this._owner.gainNode);
  1457. var b = this._owner._arrayBuffers[this.src].duration;
  1458. this.sourceNode = this._createAndPlayAudioNode(this._owner.context.currentTime - b, this._offset), this._duration = 1000 * b, this._startTime = this.sourceNode.startTime - this._offset, this._soundCompleteTimeout = setTimeout(this._endedHandler, 1000 * (b - this._offset)), 0 != this._remainingLoops && (this._sourceNodeNext = this._createAndPlayAudioNode(this._startTime, 0))
  1459. }
  1460. }, d._createAndPlayAudioNode = function(h, g) {
  1461. var i = this._owner.context.createBufferSource();
  1462. return i.buffer = this._owner._arrayBuffers[this.src], i.connect(this.panNode), this._owner.context.currentTime, i.startTime = h + i.buffer.duration, i.start(i.startTime, g, i.buffer.duration - g), i
  1463. }, d.play = function(h, g, l, k, j, i) {
  1464. this._cleanUp(), createjs.Sound._playInstance(this, h, g, l, k, j, i)
  1465. }, d._beginPlaying = function(h, g, j, i) {
  1466. return null != window.createjs && this.src ? (this._offset = h / 1000, this._remainingLoops = g, this.volume = j, this.pan = i, this._owner.isPreloadComplete(this.src) ? (this._handleSoundReady(null), this._sendEvent("succeeded"), 1) : (this.playFailed(), void 0)) : void 0
  1467. }, d.pause = function() {
  1468. return this._paused || this.playState != createjs.Sound.PLAY_SUCCEEDED ? !1 : (this._paused = !0, this._offset = this._owner.context.currentTime - this._startTime, this._cleanUpAudioNode(this.sourceNode), this._cleanUpAudioNode(this._sourceNodeNext), 0 != this.gainNode.numberOfOutputs && this.gainNode.disconnect(), clearTimeout(this._delayTimeoutId), clearTimeout(this._soundCompleteTimeout), !0)
  1469. }, d.resume = function() {
  1470. return this._paused ? (this._handleSoundReady(null), !0) : !1
  1471. }, d.stop = function() {
  1472. return this._cleanUp(), this.playState = createjs.Sound.PLAY_FINISHED, this._offset = 0, !0
  1473. }, d.setVolume = function(b) {
  1474. return this.volume = b, !0
  1475. }, d._updateVolume = function() {
  1476. var b = this._muted ? 0 : this._volume;
  1477. return b != this.gainNode.gain.value ? (this.gainNode.gain.value = b, !0) : !1
  1478. }, d.getVolume = function() {
  1479. return this.volume
  1480. }, d.setMute = function(b) {
  1481. return null == b || void 0 == b ? !1 : (this._muted = b, this._updateVolume(), !0)
  1482. }, d.getMute = function() {
  1483. return this._muted
  1484. }, d.setPan = function(b) {
  1485. return this.pan = b, this.pan != b ? !1 : void 0
  1486. }, d.getPan = function() {
  1487. return this.pan
  1488. }, d.getPosition = function() {
  1489. if (this._paused || null == this.sourceNode) {
  1490. var b = this._offset
  1491. } else {
  1492. var b = this._owner.context.currentTime - this._startTime
  1493. }
  1494. return 1000 * b
  1495. }, d.setPosition = function(b) {
  1496. return this._offset = b / 1000, this.sourceNode && this.playState == createjs.Sound.PLAY_SUCCEEDED && (this._cleanUpAudioNode(this.sourceNode), this._cleanUpAudioNode(this._sourceNodeNext), clearTimeout(this._soundCompleteTimeout)), this._paused || this.playState != createjs.Sound.PLAY_SUCCEEDED || this._handleSoundReady(null), !0
  1497. }, d.getDuration = function() {
  1498. return this._duration
  1499. }, d._handleSoundComplete = function() {
  1500. return this._offset = 0, 0 != this._remainingLoops ? (this._remainingLoops--, this._sourceNodeNext ? (this._cleanUpAudioNode(this.sourceNode), this.sourceNode = this._sourceNodeNext, this._startTime = this.sourceNode.startTime, this._sourceNodeNext = this._createAndPlayAudioNode(this._startTime, 0), this._soundCompleteTimeout = setTimeout(this._endedHandler, this._duration)) : this._handleSoundReady(null), this._sendEvent("loop"), void 0) : (null != window.createjs && (this._cleanUp(), this.playState = createjs.Sound.PLAY_FINISHED, this._sendEvent("complete")), void 0)
  1501. }, d.playFailed = function() {
  1502. null != window.createjs && (this._cleanUp(), this.playState = createjs.Sound.PLAY_FAILED, this._sendEvent("failed"))
  1503. }, d.toString = function() {
  1504. return "[WebAudioPlugin SoundInstance]"
  1505. }, createjs.WebAudioPlugin.SoundInstance = e
  1506. }(),
  1507. function() {
  1508. function d(f, e) {
  1509. this._init(f, e)
  1510. }
  1511. var c = d.prototype;
  1512. c.request = null, c.owner = null, c.progress = -1, c.src = null, c.originalSrc = null, c.result = null, c.onload = null, c.onprogress = null, c.onError = null, c._init = function(f, e) {
  1513. this.src = f, this.originalSrc = f, this.owner = e
  1514. }, c.load = function(b) {
  1515. null != b && (this.src = b), this.request = new XMLHttpRequest, this.request.open("GET", this.src, !0), this.request.responseType = "arraybuffer", this.request.onload = createjs.proxy(this.handleLoad, this), this.request.onError = createjs.proxy(this.handleError, this), this.request.onprogress = createjs.proxy(this.handleProgress, this), this.request.send()
  1516. }, c.handleProgress = function(f, e) {
  1517. this.progress = f / e, null != this.onprogress && this.onprogress({
  1518. loaded: f,
  1519. total: e,
  1520. progress: this.progress
  1521. })
  1522. }, c.handleLoad = function() {
  1523. this.owner.context.decodeAudioData(this.request.response, createjs.proxy(this.handleAudioDecoded, this), createjs.proxy(this.handleError, this))
  1524. }, c.handleAudioDecoded = function(b) {
  1525. this.progress = 1, this.result = b, this.src = this.originalSrc, this.owner.addPreloadResults(this.src, this.result), this.onload && this.onload()
  1526. }, c.handleError = function(b) {
  1527. this.owner.removeSound(this.src), this.onerror && this.onerror(b)
  1528. }, c.toString = function() {
  1529. return "[WebAudioPlugin Loader]"
  1530. }, createjs.WebAudioPlugin.Loader = d
  1531. }(), this.createjs = this.createjs || {},
  1532. function() {
  1533. function e() {
  1534. this._init()
  1535. }
  1536. var d = e;
  1537. d.MAX_INSTANCES = 30, d._AUDIO_READY = "canplaythrough", d._AUDIO_ENDED = "ended", d._AUDIO_SEEKED = "seeked", d._AUDIO_STALLED = "stalled", d._capabilities = null, d.enableIOS = !1, d.isSupported = function() {
  1538. if (createjs.Sound.BrowserDetect.isIOS && !d.enableIOS) {
  1539. return !1
  1540. }
  1541. d._generateCapabilities();
  1542. var b = d.tag;
  1543. return null == b || null == d._capabilities ? !1 : !0
  1544. }, d._generateCapabilities = function() {
  1545. if (null == d._capabilities) {
  1546. var b = d.tag = document.createElement("audio");
  1547. if (null == b.canPlayType) {
  1548. return null
  1549. }
  1550. d._capabilities = {
  1551. panning: !0,
  1552. volume: !0,
  1553. tracks: -1
  1554. };
  1555. for (var n = createjs.Sound.SUPPORTED_EXTENSIONS, m = createjs.Sound.EXTENSION_MAP, l = 0, k = n.length; k > l; l++) {
  1556. var j = n[l],
  1557. i = m[j] || j;
  1558. d._capabilities[j] = "no" != b.canPlayType("audio/" + j) && "" != b.canPlayType("audio/" + j) || "no" != b.canPlayType("audio/" + i) && "" != b.canPlayType("audio/" + i)
  1559. }
  1560. }
  1561. };
  1562. var f = e.prototype;
  1563. f._capabilities = null, f._audioSources = null, f.defaultNumChannels = 2, f.loadedHandler = null, f._init = function() {
  1564. this._capabilities = d._capabilities, this._audioSources = {}
  1565. }, f.register = function(i, h) {
  1566. this._audioSources[i] = !0;
  1567. for (var n = createjs.HTMLAudioPlugin.TagPool.get(i), m = null, l = h || this.defaultNumChannels, k = 0; l > k; k++) {
  1568. m = this._createTag(i), n.add(m)
  1569. }
  1570. if (m.id = i, this.loadedHandler = createjs.proxy(this._handleTagLoad, this), m.addEventListener && m.addEventListener("canplaythrough", this.loadedHandler), null == m.onreadystatechange) {
  1571. m.onreadystatechange = this.loadedHandler
  1572. } else {
  1573. var j = m.onreadystatechange;
  1574. m.onreadystatechange = function() {
  1575. j(), this.loadedHandler()
  1576. }
  1577. }
  1578. return {
  1579. tag: m,
  1580. numChannels: l
  1581. }
  1582. }, f._handleTagLoad = function(b) {
  1583. b.target.removeEventListener && b.target.removeEventListener("canplaythrough", this.loadedHandler), b.target.onreadystatechange = null, b.target.src != b.target.id && createjs.HTMLAudioPlugin.TagPool.checkSrc(b.target.id)
  1584. }, f._createTag = function(g) {
  1585. var c = document.createElement("audio");
  1586. return c.autoplay = !1, c.preload = "none", c.src = g, c
  1587. }, f.removeSound = function(b) {
  1588. delete this._audioSources[b], createjs.HTMLAudioPlugin.TagPool.remove(b)
  1589. }, f.removeAllSounds = function() {
  1590. this._audioSources = {}, createjs.HTMLAudioPlugin.TagPool.removeAll()
  1591. }, f.create = function(h) {
  1592. if (!this.isPreloadStarted(h)) {
  1593. var g = createjs.HTMLAudioPlugin.TagPool.get(h),
  1594. i = this._createTag(h);
  1595. i.id = h, g.add(i), this.preload(h, {
  1596. tag: i
  1597. })
  1598. }
  1599. return new createjs.HTMLAudioPlugin.SoundInstance(h, this)
  1600. }, f.isPreloadStarted = function(b) {
  1601. return null != this._audioSources[b]
  1602. }, f.preload = function(g, c) {
  1603. this._audioSources[g] = !0, new createjs.HTMLAudioPlugin.Loader(g, c.tag)
  1604. }, f.toString = function() {
  1605. return "[HTMLAudioPlugin]"
  1606. }, createjs.HTMLAudioPlugin = e
  1607. }(),
  1608. function() {
  1609. function e(g, c) {
  1610. this._init(g, c)
  1611. }
  1612. var d = e.prototype = new createjs.EventDispatcher;
  1613. d.src = null, d.uniqueId = -1, d.playState = null, d._owner = null, d.loaded = !1, d._offset = 0, d._delay = 0, d._volume = 1;
  1614. try {
  1615. Object.defineProperty(d, "volume", {
  1616. get: function() {
  1617. return this._volume
  1618. },
  1619. set: function(b) {
  1620. null != Number(b) && (b = Math.max(0, Math.min(1, b)), this._volume = b, this._updateVolume())
  1621. }
  1622. })
  1623. } catch (f) {}
  1624. d.pan = 0, d._duration = 0, d._remainingLoops = 0, d._delayTimeoutId = null, d.tag = null, d._muted = !1, d._paused = !1, d._endedHandler = null, d._readyHandler = null, d._stalledHandler = null, d.loopHandler = null, d._init = function(g, c) {
  1625. this.src = g, this._owner = c, this._endedHandler = createjs.proxy(this._handleSoundComplete, this), this._readyHandler = createjs.proxy(this._handleSoundReady, this), this._stalledHandler = createjs.proxy(this._handleSoundStalled, this), this.loopHandler = createjs.proxy(this.handleSoundLoop, this)
  1626. }, d._sendEvent = function(g) {
  1627. var c = new createjs.Event(g);
  1628. this.dispatchEvent(c)
  1629. }, d._cleanUp = function() {
  1630. var g = this.tag;
  1631. if (null != g) {
  1632. g.pause(), g.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_ENDED, this._endedHandler, !1), g.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_READY, this._readyHandler, !1), g.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED, this.loopHandler, !1);
  1633. try {
  1634. g.currentTime = 0
  1635. } catch (c) {}
  1636. createjs.HTMLAudioPlugin.TagPool.setInstance(this.src, g), this.tag = null
  1637. }
  1638. clearTimeout(this._delayTimeoutId), null != window.createjs && createjs.Sound._playFinished(this)
  1639. }, d._interrupt = function() {
  1640. null != this.tag && (this.playState = createjs.Sound.PLAY_INTERRUPTED, this._cleanUp(), this._paused = !1, this._sendEvent("interrupted"))
  1641. }, d.play = function(h, g, l, k, j, i) {
  1642. this._cleanUp(), createjs.Sound._playInstance(this, h, g, l, k, j, i)
  1643. }, d._beginPlaying = function(h, g, k, j) {
  1644. if (null == window.createjs) {
  1645. return -1
  1646. }
  1647. var i = this.tag = createjs.HTMLAudioPlugin.TagPool.getInstance(this.src);
  1648. return null == i ? (this.playFailed(), -1) : (i.addEventListener(createjs.HTMLAudioPlugin._AUDIO_ENDED, this._endedHandler, !1), this._offset = h, this.volume = k, this.pan = j, this._updateVolume(), this._remainingLoops = g, 4 !== i.readyState ? (i.addEventListener(createjs.HTMLAudioPlugin._AUDIO_READY, this._readyHandler, !1), i.addEventListener(createjs.HTMLAudioPlugin._AUDIO_STALLED, this._stalledHandler, !1), i.preload = "auto", i.load()) : this._handleSoundReady(null), this._sendEvent("succeeded"), 1)
  1649. }, d._handleSoundStalled = function() {
  1650. this._cleanUp(), this._sendEvent("failed")
  1651. }, d._handleSoundReady = function() {
  1652. if (null != window.createjs) {
  1653. if (this._duration = 1000 * this.tag.duration, this.playState = createjs.Sound.PLAY_SUCCEEDED, this._paused = !1, this.tag.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_READY, this._readyHandler, !1), this._offset >= this.getDuration()) {
  1654. return this.playFailed(), void 0
  1655. }
  1656. this._offset > 0 && (this.tag.currentTime = 0.001 * this._offset), -1 == this._remainingLoops && (this.tag.loop = !0), 0 != this._remainingLoops && (this.tag.addEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED, this.loopHandler, !1), this.tag.loop = !0), this.tag.play()
  1657. }
  1658. }, d.pause = function() {
  1659. return this._paused || this.playState != createjs.Sound.PLAY_SUCCEEDED || null == this.tag ? !1 : (this._paused = !0, this.tag.pause(), clearTimeout(this._delayTimeoutId), !0)
  1660. }, d.resume = function() {
  1661. return this._paused && null != this.tag ? (this._paused = !1, this.tag.play(), !0) : !1
  1662. }, d.stop = function() {
  1663. return this._offset = 0, this.pause(), this.playState = createjs.Sound.PLAY_FINISHED, this._cleanUp(), !0
  1664. }, d.setMasterVolume = function() {
  1665. return this._updateVolume(), !0
  1666. }, d.setVolume = function(b) {
  1667. return this.volume = b, !0
  1668. }, d._updateVolume = function() {
  1669. if (null != this.tag) {
  1670. var b = this._muted || createjs.Sound._masterMute ? 0 : this._volume * createjs.Sound._masterVolume;
  1671. return b != this.tag.volume && (this.tag.volume = b), !0
  1672. }
  1673. return !1
  1674. }, d.getVolume = function() {
  1675. return this.volume
  1676. }, d.setMasterMute = function() {
  1677. return this._updateVolume(), !0
  1678. }, d.setMute = function(b) {
  1679. return null == b || void 0 == b ? !1 : (this._muted = b, this._updateVolume(), !0)
  1680. }, d.getMute = function() {
  1681. return this._muted
  1682. }, d.setPan = function() {
  1683. return !1
  1684. }, d.getPan = function() {
  1685. return 0
  1686. }, d.getPosition = function() {
  1687. return null == this.tag ? this._offset : 1000 * this.tag.currentTime
  1688. }, d.setPosition = function(g) {
  1689. if (null == this.tag) {
  1690. this._offset = g
  1691. } else {
  1692. this.tag.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED, this.loopHandler, !1);
  1693. try {
  1694. this.tag.currentTime = 0.001 * g
  1695. } catch (c) {
  1696. return !1
  1697. }
  1698. this.tag.addEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED, this.loopHandler, !1)
  1699. }
  1700. return !0
  1701. }, d.getDuration = function() {
  1702. return this._duration
  1703. }, d._handleSoundComplete = function() {
  1704. this._offset = 0, null != window.createjs && (this.playState = createjs.Sound.PLAY_FINISHED, this._cleanUp(), this._sendEvent("complete"))
  1705. }, d.handleSoundLoop = function() {
  1706. this._offset = 0, this._remainingLoops--, 0 == this._remainingLoops && (this.tag.loop = !1, this.tag.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED, this.loopHandler, !1)), this._sendEvent("loop")
  1707. }, d.playFailed = function() {
  1708. null != window.createjs && (this.playState = createjs.Sound.PLAY_FAILED, this._cleanUp(), this._sendEvent("failed"))
  1709. }, d.toString = function() {
  1710. return "[HTMLAudioPlugin SoundInstance]"
  1711. }, createjs.HTMLAudioPlugin.SoundInstance = e
  1712. }(),
  1713. function() {
  1714. function d(f, e) {
  1715. this._init(f, e)
  1716. }
  1717. var c = d.prototype;
  1718. c.src = null, c.tag = null, c.preloadTimer = null, c.loadedHandler = null, c._init = function(f, e) {
  1719. if (this.src = f, this.tag = e, this.preloadTimer = setInterval(createjs.proxy(this.preloadTick, this), 200), this.loadedHandler = createjs.proxy(this.sendLoadedEvent, this), this.tag.addEventListener && this.tag.addEventListener("canplaythrough", this.loadedHandler), null == this.tag.onreadystatechange) {
  1720. this.tag.onreadystatechange = createjs.proxy(this.sendLoadedEvent, this)
  1721. } else {
  1722. var g = this.tag.onreadystatechange;
  1723. this.tag.onreadystatechange = function() {
  1724. g(), this.tag.onreadystatechange = createjs.proxy(this.sendLoadedEvent, this)
  1725. }
  1726. }
  1727. this.tag.preload = "auto", this.tag.load()
  1728. }, c.preloadTick = function() {
  1729. var f = this.tag.buffered,
  1730. e = this.tag.duration;
  1731. f.length > 0 && f.end(0) >= e - 1 && this.handleTagLoaded()
  1732. }, c.handleTagLoaded = function() {
  1733. clearInterval(this.preloadTimer)
  1734. }, c.sendLoadedEvent = function() {
  1735. this.tag.removeEventListener && this.tag.removeEventListener("canplaythrough", this.loadedHandler), this.tag.onreadystatechange = null, createjs.Sound._sendFileLoadEvent(this.src)
  1736. }, c.toString = function() {
  1737. return "[HTMLAudioPlugin Loader]"
  1738. }, createjs.HTMLAudioPlugin.Loader = d
  1739. }(),
  1740. function() {
  1741. function e(b) {
  1742. this._init(b)
  1743. }
  1744. var d = e;
  1745. d.tags = {}, d.get = function(b) {
  1746. var a = d.tags[b];
  1747. return null == a && (a = d.tags[b] = new e(b)), a
  1748. }, d.remove = function(b) {
  1749. var g = d.tags[b];
  1750. return null == g ? !1 : (g.removeAll(), delete d.tags[b], !0)
  1751. }, d.removeAll = function() {
  1752. for (var b in d.tags) {
  1753. d.tags[b].removeAll()
  1754. }
  1755. d.tags = {}
  1756. }, d.getInstance = function(b) {
  1757. var g = d.tags[b];
  1758. return null == g ? null : g.get()
  1759. }, d.setInstance = function(b, h) {
  1760. var g = d.tags[b];
  1761. return null == g ? null : g.set(h)
  1762. }, d.checkSrc = function(b) {
  1763. var g = d.tags[b];
  1764. return null == g ? null : (g.checkSrcChange(), void 0)
  1765. };
  1766. var f = e.prototype;
  1767. f.src = null, f.length = 0, f.available = 0, f.tags = null, f._init = function(b) {
  1768. this.src = b, this.tags = []
  1769. }, f.add = function(b) {
  1770. this.tags.push(b), this.length++, this.available++
  1771. }, f.removeAll = function() {
  1772. for (; this.length--;) {
  1773. delete this.tags[this.length]
  1774. }
  1775. this.src = null, this.tags.length = 0
  1776. }, f.get = function() {
  1777. if (0 == this.tags.length) {
  1778. return null
  1779. }
  1780. this.available = this.tags.length;
  1781. var b = this.tags.pop();
  1782. return null == b.parentNode && document.body.appendChild(b), b
  1783. }, f.set = function(g) {
  1784. var c = createjs.indexOf(this.tags, g); - 1 == c && this.tags.push(g), this.available = this.tags.length
  1785. }, f.checkSrcChange = function() {
  1786. for (var g = this.tags.length - 1, c = this.tags[g].src; g--;) {
  1787. this.tags[g].src = c
  1788. }
  1789. }, f.toString = function() {
  1790. return "[HTMLAudioPlugin TagPool]"
  1791. }, createjs.HTMLAudioPlugin.TagPool = e
  1792. }();
  1793. /*!
  1794. * @license PreloadJS
  1795. * Visit http://createjs.com/ for documentation, updates and examples.
  1796. *
  1797. * Copyright (c) 2011-2013 gskinner.com, inc.
  1798. *
  1799. * Distributed under the terms of the MIT license.
  1800. * http://www.opensource.org/licenses/mit-license.html
  1801. *
  1802. * This notice shall be included in all copies or substantial portions of the Software.
  1803. */
  1804. ;
  1805. this.createjs = this.createjs || {},
  1806. function() {
  1807. var b = createjs.PreloadJS = createjs.PreloadJS || {};
  1808. b.version = "0.4.1", b.buildDate = "Thu, 12 Dec 2013 23:33:38 GMT"
  1809. }(), this.createjs = this.createjs || {},
  1810. function() {
  1811. var d = function(f, e, g) {
  1812. this.initialize(f, e, g)
  1813. },
  1814. c = d.prototype;
  1815. c.type = null, c.target = null, c.currentTarget = null, c.eventPhase = 0, c.bubbles = !1, c.cancelable = !1, c.timeStamp = 0, c.defaultPrevented = !1, c.propagationStopped = !1, c.immediatePropagationStopped = !1, c.removed = !1, c.initialize = function(f, e, g) {
  1816. this.type = f, this.bubbles = e, this.cancelable = g, this.timeStamp = (new Date).getTime()
  1817. }, c.preventDefault = function() {
  1818. this.defaultPrevented = !0
  1819. }, c.stopPropagation = function() {
  1820. this.propagationStopped = !0
  1821. }, c.stopImmediatePropagation = function() {
  1822. this.immediatePropagationStopped = this.propagationStopped = !0
  1823. }, c.remove = function() {
  1824. this.removed = !0
  1825. }, c.clone = function() {
  1826. return new d(this.type, this.bubbles, this.cancelable)
  1827. }, c.toString = function() {
  1828. return "[Event (type=" + this.type + ")]"
  1829. }, createjs.Event = d
  1830. }(), this.createjs = this.createjs || {},
  1831. function() {
  1832. var d = function() {},
  1833. c = d.prototype;
  1834. d.initialize = function(b) {
  1835. b.addEventListener = c.addEventListener, b.on = c.on, b.removeEventListener = b.off = c.removeEventListener, b.removeAllEventListeners = c.removeAllEventListeners, b.hasEventListener = c.hasEventListener, b.dispatchEvent = c.dispatchEvent, b._dispatchEvent = c._dispatchEvent, b.willTrigger = c.willTrigger
  1836. }, c._listeners = null, c._captureListeners = null, c.initialize = function() {}, c.addEventListener = function(g, f, j) {
  1837. var i;
  1838. i = j ? this._captureListeners = this._captureListeners || {} : this._listeners = this._listeners || {};
  1839. var h = i[g];
  1840. return h && this.removeEventListener(g, f, j), h = i[g], h ? h.push(f) : i[g] = [f], f
  1841. }, c.on = function(h, g, l, k, j, i) {
  1842. return g.handleEvent && (l = l || g, g = g.handleEvent), l = l || this, this.addEventListener(h, function(b) {
  1843. g.call(l, b, j), k && b.remove()
  1844. }, i)
  1845. }, c.removeEventListener = function(i, h, n) {
  1846. var m = n ? this._captureListeners : this._listeners;
  1847. if (m) {
  1848. var l = m[i];
  1849. if (l) {
  1850. for (var k = 0, j = l.length; j > k; k++) {
  1851. if (l[k] == h) {
  1852. 1 == j ? delete m[i] : l.splice(k, 1);
  1853. break
  1854. }
  1855. }
  1856. }
  1857. }
  1858. }, c.off = c.removeEventListener, c.removeAllEventListeners = function(b) {
  1859. b ? (this._listeners && delete this._listeners[b], this._captureListeners && delete this._captureListeners[b]) : this._listeners = this._captureListeners = null
  1860. }, c.dispatchEvent = function(i, h) {
  1861. if ("string" == typeof i) {
  1862. var n = this._listeners;
  1863. if (!n || !n[i]) {
  1864. return !1
  1865. }
  1866. i = new createjs.Event(i)
  1867. }
  1868. if (i.target = h || this, i.bubbles && this.parent) {
  1869. for (var m = this, l = [m]; m.parent;) {
  1870. l.push(m = m.parent)
  1871. }
  1872. var k, j = l.length;
  1873. for (k = j - 1; k >= 0 && !i.propagationStopped; k--) {
  1874. l[k]._dispatchEvent(i, 1 + (0 == k))
  1875. }
  1876. for (k = 1; j > k && !i.propagationStopped; k++) {
  1877. l[k]._dispatchEvent(i, 3)
  1878. }
  1879. } else {
  1880. this._dispatchEvent(i, 2)
  1881. }
  1882. return i.defaultPrevented
  1883. }, c.hasEventListener = function(f) {
  1884. var e = this._listeners,
  1885. g = this._captureListeners;
  1886. return !!(e && e[f] || g && g[f])
  1887. }, c.willTrigger = function(f) {
  1888. for (var e = this; e;) {
  1889. if (e.hasEventListener(f)) {
  1890. return !0
  1891. }
  1892. e = e.parent
  1893. }
  1894. return !1
  1895. }, c.toString = function() {
  1896. return "[EventDispatcher]"
  1897. }, c._dispatchEvent = function(i, h) {
  1898. var n, m = 1 == h ? this._captureListeners : this._listeners;
  1899. if (i && m) {
  1900. var l = m[i.type];
  1901. if (!l || !(n = l.length)) {
  1902. return
  1903. }
  1904. i.currentTarget = this, i.eventPhase = h, i.removed = !1, l = l.slice();
  1905. for (var k = 0; n > k && !i.immediatePropagationStopped; k++) {
  1906. var j = l[k];
  1907. j.handleEvent ? j.handleEvent(i) : j(i), i.removed && (this.off(i.type, j, 1 == h), i.removed = !1)
  1908. }
  1909. }
  1910. }, createjs.EventDispatcher = d
  1911. }(), this.createjs = this.createjs || {},
  1912. function() {
  1913. createjs.indexOf = function(f, e) {
  1914. for (var h = 0, g = f.length; g > h; h++) {
  1915. if (e === f[h]) {
  1916. return h
  1917. }
  1918. }
  1919. return -1
  1920. }
  1921. }(), this.createjs = this.createjs || {},
  1922. function() {
  1923. createjs.proxy = function(e, d) {
  1924. var f = Array.prototype.slice.call(arguments, 2);
  1925. return function() {
  1926. return e.apply(d, Array.prototype.slice.call(arguments, 0).concat(f))
  1927. }
  1928. }
  1929. }(), this.createjs = this.createjs || {},
  1930. function() {
  1931. var e = function() {
  1932. this.init()
  1933. };
  1934. e.prototype = new createjs.EventDispatcher;
  1935. var d = e.prototype,
  1936. f = e;
  1937. f.FILE_PATTERN = /^(?:(\w+:)\/{2}(\w+(?:\.\w+)*\/?)|(.{0,2}\/{1}))?([/.]*?(?:[^?]+)?\/)?((?:[^/?]+)\.(\w+))(?:\?(\S+)?)?$/, f.PATH_PATTERN = /^(?:(\w+:)\/{2})|(.{0,2}\/{1})?([/.]*?(?:[^?]+)?\/?)?$/, d.loaded = !1, d.canceled = !1, d.progress = 0, d._item = null, d.getItem = function() {
  1938. return this._item
  1939. }, d.init = function() {}, d.load = function() {}, d.close = function() {}, d._sendLoadStart = function() {
  1940. this._isCanceled() || this.dispatchEvent("loadstart")
  1941. }, d._sendProgress = function(g) {
  1942. if (!this._isCanceled()) {
  1943. var c = null;
  1944. "number" == typeof g ? (this.progress = g, c = new createjs.Event("progress"), c.loaded = this.progress, c.total = 1) : (c = g, this.progress = g.loaded / g.total, (isNaN(this.progress) || 1 / 0 == this.progress) && (this.progress = 0)), c.progress = this.progress, this.hasEventListener("progress") && this.dispatchEvent(c)
  1945. }
  1946. }, d._sendComplete = function() {
  1947. this._isCanceled() || this.dispatchEvent("complete")
  1948. }, d._sendError = function(b) {
  1949. !this._isCanceled() && this.hasEventListener("error") && (null == b && (b = new createjs.Event("error")), this.dispatchEvent(b))
  1950. }, d._isCanceled = function() {
  1951. return null == window.createjs || this.canceled ? !0 : !1
  1952. }, d._parseURI = function(b) {
  1953. return b ? b.match(f.FILE_PATTERN) : null
  1954. }, d._parsePath = function(b) {
  1955. return b ? b.match(f.PATH_PATTERN) : null
  1956. }, d._formatQueryString = function(h, g) {
  1957. if (null == h) {
  1958. throw new Error("You must specify data.")
  1959. }
  1960. var j = [];
  1961. for (var i in h) {
  1962. j.push(i + "=" + escape(h[i]))
  1963. }
  1964. return g && (j = j.concat(g)), j.join("&")
  1965. }, d.buildPath = function(h, g) {
  1966. if (null == g) {
  1967. return h
  1968. }
  1969. var k = [],
  1970. j = h.indexOf("?");
  1971. if (-1 != j) {
  1972. var i = h.slice(j + 1);
  1973. k = k.concat(i.split("&"))
  1974. }
  1975. return -1 != j ? h.slice(0, j) + "?" + this._formatQueryString(g, k) : h + "?" + this._formatQueryString(g, k)
  1976. }, d._isCrossDomain = function(h) {
  1977. var g = document.createElement("a");
  1978. g.href = h.src;
  1979. var j = document.createElement("a");
  1980. j.href = location.href;
  1981. var i = "" != g.hostname && (g.port != j.port || g.protocol != j.protocol || g.hostname != j.hostname);
  1982. return i
  1983. }, d._isLocal = function(g) {
  1984. var c = document.createElement("a");
  1985. return c.href = g.src, "" == c.hostname && "file:" == c.protocol
  1986. }, d.toString = function() {
  1987. return "[PreloadJS AbstractLoader]"
  1988. }, createjs.AbstractLoader = e
  1989. }(), this.createjs = this.createjs || {},
  1990. function() {
  1991. var f = function(i, d, j) {
  1992. this.init(i, d, j)
  1993. },
  1994. e = f.prototype = new createjs.AbstractLoader,
  1995. h = f;
  1996. h.loadTimeout = 8000, h.LOAD_TIMEOUT = 0, h.BINARY = "binary", h.CSS = "css", h.IMAGE = "image", h.JAVASCRIPT = "javascript", h.JSON = "json", h.JSONP = "jsonp", h.MANIFEST = "manifest", h.SOUND = "sound", h.SVG = "svg", h.TEXT = "text", h.XML = "xml", h.POST = "POST", h.GET = "GET", e._basePath = null, e._crossOrigin = "", e.useXHR = !0, e.stopOnError = !1, e.maintainScriptOrder = !0, e.next = null, e._typeCallbacks = null, e._extensionCallbacks = null, e._loadStartWasDispatched = !1, e._maxConnections = 1, e._currentlyLoadingScript = null, e._currentLoads = null, e._loadQueue = null, e._loadQueueBackup = null, e._loadItemsById = null, e._loadItemsBySrc = null, e._loadedResults = null, e._loadedRawResults = null, e._numItems = 0, e._numItemsLoaded = 0, e._scriptOrder = null, e._loadedScripts = null, e.init = function(i, d, j) {
  1997. this._numItems = this._numItemsLoaded = 0, this._paused = !1, this._loadStartWasDispatched = !1, this._currentLoads = [], this._loadQueue = [], this._loadQueueBackup = [], this._scriptOrder = [], this._loadedScripts = [], this._loadItemsById = {}, this._loadItemsBySrc = {}, this._loadedResults = {}, this._loadedRawResults = {}, this._typeCallbacks = {}, this._extensionCallbacks = {}, this._basePath = d, this.setUseXHR(i), this._crossOrigin = j === !0 ? "Anonymous" : j === !1 || null == j ? "" : j
  1998. }, e.setUseXHR = function(b) {
  1999. return this.useXHR = 0 != b && null != window.XMLHttpRequest, this.useXHR
  2000. }, e.removeAll = function() {
  2001. this.remove()
  2002. }, e.remove = function(j) {
  2003. var i = null;
  2004. if (!j || j instanceof Array) {
  2005. if (j) {
  2006. i = j
  2007. } else {
  2008. if (arguments.length > 0) {
  2009. return
  2010. }
  2011. }
  2012. } else {
  2013. i = [j]
  2014. }
  2015. var p = !1;
  2016. if (i) {
  2017. for (; i.length;) {
  2018. var o = i.pop(),
  2019. n = this.getResult(o);
  2020. for (m = this._loadQueue.length - 1; m >= 0; m--) {
  2021. if (l = this._loadQueue[m].getItem(), l.id == o || l.src == o) {
  2022. this._loadQueue.splice(m, 1)[0].cancel();
  2023. break
  2024. }
  2025. }
  2026. for (m = this._loadQueueBackup.length - 1; m >= 0; m--) {
  2027. if (l = this._loadQueueBackup[m].getItem(), l.id == o || l.src == o) {
  2028. this._loadQueueBackup.splice(m, 1)[0].cancel();
  2029. break
  2030. }
  2031. }
  2032. if (n) {
  2033. delete this._loadItemsById[n.id], delete this._loadItemsBySrc[n.src], this._disposeItem(n)
  2034. } else {
  2035. for (var m = this._currentLoads.length - 1; m >= 0; m--) {
  2036. var l = this._currentLoads[m].getItem();
  2037. if (l.id == o || l.src == o) {
  2038. this._currentLoads.splice(m, 1)[0].cancel(), p = !0;
  2039. break
  2040. }
  2041. }
  2042. }
  2043. }
  2044. p && this._loadNext()
  2045. } else {
  2046. this.close();
  2047. for (var k in this._loadItemsById) {
  2048. this._disposeItem(this._loadItemsById[k])
  2049. }
  2050. this.init(this.useXHR)
  2051. }
  2052. }, e.reset = function() {
  2053. this.close();
  2054. for (var j in this._loadItemsById) {
  2055. this._disposeItem(this._loadItemsById[j])
  2056. }
  2057. for (var i = [], l = 0, k = this._loadQueueBackup.length; k > l; l++) {
  2058. i.push(this._loadQueueBackup[l].getItem())
  2059. }
  2060. this.loadManifest(i, !1)
  2061. }, h.isBinary = function(b) {
  2062. switch (b) {
  2063. case createjs.LoadQueue.IMAGE:
  2064. case createjs.LoadQueue.BINARY:
  2065. return !0;
  2066. default:
  2067. return !1
  2068. }
  2069. }, h.isText = function(b) {
  2070. switch (b) {
  2071. case createjs.LoadQueue.TEXT:
  2072. case createjs.LoadQueue.JSON:
  2073. case createjs.LoadQueue.MANIFEST:
  2074. case createjs.LoadQueue.XML:
  2075. case createjs.LoadQueue.HTML:
  2076. case createjs.LoadQueue.CSS:
  2077. case createjs.LoadQueue.SVG:
  2078. case createjs.LoadQueue.JAVASCRIPT:
  2079. return !0;
  2080. default:
  2081. return !1
  2082. }
  2083. }, e.installPlugin = function(j) {
  2084. if (null != j && null != j.getPreloadHandlers) {
  2085. var i = j.getPreloadHandlers();
  2086. if (i.scope = j, null != i.types) {
  2087. for (var l = 0, k = i.types.length; k > l; l++) {
  2088. this._typeCallbacks[i.types[l]] = i
  2089. }
  2090. }
  2091. if (null != i.extensions) {
  2092. for (l = 0, k = i.extensions.length; k > l; l++) {
  2093. this._extensionCallbacks[i.extensions[l]] = i
  2094. }
  2095. }
  2096. }
  2097. }, e.setMaxConnections = function(b) {
  2098. this._maxConnections = b, !this._paused && this._loadQueue.length > 0 && this._loadNext()
  2099. }, e.loadFile = function(j, i, l) {
  2100. if (null == j) {
  2101. var k = new createjs.Event("error");
  2102. return k.text = "PRELOAD_NO_FILE", this._sendError(k), void 0
  2103. }
  2104. this._addItem(j, null, l), i !== !1 ? this.setPaused(!1) : this.setPaused(!0)
  2105. }, e.loadManifest = function(j, c, p) {
  2106. var o = null,
  2107. n = null;
  2108. if (j instanceof Array) {
  2109. if (0 == j.length) {
  2110. var m = new createjs.Event("error");
  2111. return m.text = "PRELOAD_MANIFEST_EMPTY", this._sendError(m), void 0
  2112. }
  2113. o = j
  2114. } else {
  2115. if ("string" == typeof j) {
  2116. o = [{
  2117. src: j,
  2118. type: h.MANIFEST
  2119. }]
  2120. } else {
  2121. if ("object" != typeof j) {
  2122. var m = new createjs.Event("error");
  2123. return m.text = "PRELOAD_MANIFEST_NULL", this._sendError(m), void 0
  2124. }
  2125. if (void 0 !== j.src) {
  2126. if (null == j.type) {
  2127. j.type = h.MANIFEST
  2128. } else {
  2129. if (j.type != h.MANIFEST) {
  2130. var m = new createjs.Event("error");
  2131. m.text = "PRELOAD_MANIFEST_ERROR", this._sendError(m)
  2132. }
  2133. }
  2134. o = [j]
  2135. } else {
  2136. void 0 !== j.manifest && (o = j.manifest, n = j.path)
  2137. }
  2138. }
  2139. }
  2140. for (var l = 0, k = o.length; k > l; l++) {
  2141. this._addItem(o[l], n, p)
  2142. }
  2143. c !== !1 ? this.setPaused(!1) : this.setPaused(!0)
  2144. }, e.load = function() {
  2145. this.setPaused(!1)
  2146. }, e.getItem = function(b) {
  2147. return this._loadItemsById[b] || this._loadItemsBySrc[b]
  2148. }, e.getResult = function(j, i) {
  2149. var l = this._loadItemsById[j] || this._loadItemsBySrc[j];
  2150. if (null == l) {
  2151. return null
  2152. }
  2153. var k = l.id;
  2154. return i && this._loadedRawResults[k] ? this._loadedRawResults[k] : this._loadedResults[k]
  2155. }, e.setPaused = function(b) {
  2156. this._paused = b, this._paused || this._loadNext()
  2157. }, e.close = function() {
  2158. for (; this._currentLoads.length;) {
  2159. this._currentLoads.pop().cancel()
  2160. }
  2161. this._scriptOrder.length = 0, this._loadedScripts.length = 0, this.loadStartWasDispatched = !1
  2162. }, e._addItem = function(j, i, m) {
  2163. var l = this._createLoadItem(j, i, m);
  2164. if (null != l) {
  2165. var k = this._createLoader(l);
  2166. null != k && (this._loadQueue.push(k), this._loadQueueBackup.push(k), this._numItems++, this._updateProgress(), this.maintainScriptOrder && l.type == createjs.LoadQueue.JAVASCRIPT && k instanceof createjs.XHRLoader && (this._scriptOrder.push(l), this._loadedScripts.push(null)))
  2167. }
  2168. }, e._createLoadItem = function(v, u, t) {
  2169. var s = null;
  2170. switch (typeof v) {
  2171. case "string":
  2172. s = {
  2173. src: v
  2174. };
  2175. break;
  2176. case "object":
  2177. s = window.HTMLAudioElement && v instanceof window.HTMLAudioElement ? {
  2178. tag: v,
  2179. src: s.tag.src,
  2180. type: createjs.LoadQueue.SOUND
  2181. } : v;
  2182. break;
  2183. default:
  2184. return null
  2185. }
  2186. var r = this._parseURI(s.src);
  2187. null != r && (s.ext = r[6]), null == s.type && (s.type = this._getTypeByExtension(s.ext));
  2188. var q = "",
  2189. p = t || this._basePath,
  2190. o = s.src;
  2191. if (r && null == r[1] && null == r[3]) {
  2192. if (u) {
  2193. q = u;
  2194. var n = this._parsePath(u);
  2195. o = u + o, null != p && n && null == n[1] && null == n[2] && (q = p + q)
  2196. } else {
  2197. null != p && (q = p)
  2198. }
  2199. }
  2200. if (s.src = q + s.src, s.path = q, (s.type == createjs.LoadQueue.JSON || s.type == createjs.LoadQueue.MANIFEST) && (s._loadAsJSONP = null != s.callback), s.type == createjs.LoadQueue.JSONP && null == s.callback) {
  2201. throw new Error("callback is required for loading JSONP requests.")
  2202. }(void 0 === s.tag || null === s.tag) && (s.tag = this._createTag(s)), (void 0 === s.id || null === s.id || "" === s.id) && (s.id = o);
  2203. var m = this._typeCallbacks[s.type] || this._extensionCallbacks[s.ext];
  2204. if (m) {
  2205. var l = m.callback.call(m.scope, s.src, s.type, s.id, s.data, q, this);
  2206. if (l === !1) {
  2207. return null
  2208. }
  2209. l === !0 || (null != l.src && (s.src = l.src), null != l.id && (s.id = l.id), null != l.tag && (s.tag = l.tag), null != l.completeHandler && (s.completeHandler = l.completeHandler), l.type && (s.type = l.type), r = this._parseURI(s.src), null != r && null != r[6] && (s.ext = r[6].toLowerCase()))
  2210. }
  2211. return this._loadItemsById[s.id] = s, this._loadItemsBySrc[s.src] = s, s
  2212. }, e._createLoader = function(d) {
  2213. var c = this.useXHR;
  2214. switch (d.type) {
  2215. case createjs.LoadQueue.JSON:
  2216. case createjs.LoadQueue.MANIFEST:
  2217. c = !d._loadAsJSONP;
  2218. break;
  2219. case createjs.LoadQueue.XML:
  2220. case createjs.LoadQueue.TEXT:
  2221. c = !0;
  2222. break;
  2223. case createjs.LoadQueue.SOUND:
  2224. case createjs.LoadQueue.JSONP:
  2225. c = !1;
  2226. break;
  2227. case null:
  2228. return null
  2229. }
  2230. return c ? new createjs.XHRLoader(d, this._crossOrigin) : new createjs.TagLoader(d)
  2231. }, e._loadNext = function() {
  2232. if (!this._paused) {
  2233. this._loadStartWasDispatched || (this._sendLoadStart(), this._loadStartWasDispatched = !0), this._numItems == this._numItemsLoaded ? (this.loaded = !0, this._sendComplete(), this.next && this.next.load && this.next.load()) : this.loaded = !1;
  2234. for (var d = 0; d < this._loadQueue.length && !(this._currentLoads.length >= this._maxConnections); d++) {
  2235. var c = this._loadQueue[d];
  2236. if (this.maintainScriptOrder && c instanceof createjs.TagLoader && c.getItem().type == createjs.LoadQueue.JAVASCRIPT) {
  2237. if (this._currentlyLoadingScript) {
  2238. continue
  2239. }
  2240. this._currentlyLoadingScript = !0
  2241. }
  2242. this._loadQueue.splice(d, 1), d--, this._loadItem(c)
  2243. }
  2244. }
  2245. }, e._loadItem = function(b) {
  2246. b.on("progress", this._handleProgress, this), b.on("complete", this._handleFileComplete, this), b.on("error", this._handleFileError, this), this._currentLoads.push(b), this._sendFileStart(b.getItem()), b.load()
  2247. }, e._handleFileError = function(i) {
  2248. var d = i.target;
  2249. this._numItemsLoaded++, this._updateProgress();
  2250. var j = new createjs.Event("error");
  2251. j.text = "FILE_LOAD_ERROR", j.item = d.getItem(), this._sendError(j), this.stopOnError || (this._removeLoadItem(d), this._loadNext())
  2252. }, e._handleFileComplete = function(j) {
  2253. var i = j.target,
  2254. l = i.getItem();
  2255. if (this._loadedResults[l.id] = i.getResult(), i instanceof createjs.XHRLoader && (this._loadedRawResults[l.id] = i.getResult(!0)), this._removeLoadItem(i), this.maintainScriptOrder && l.type == createjs.LoadQueue.JAVASCRIPT) {
  2256. if (!(i instanceof createjs.TagLoader)) {
  2257. return this._loadedScripts[createjs.indexOf(this._scriptOrder, l)] = l, this._checkScriptLoadOrder(i), void 0
  2258. }
  2259. this._currentlyLoadingScript = !1
  2260. }
  2261. if (delete l._loadAsJSONP, l.type == createjs.LoadQueue.MANIFEST) {
  2262. var k = i.getResult();
  2263. null != k && void 0 !== k.manifest && this.loadManifest(k, !0)
  2264. }
  2265. this._processFinishedLoad(l, i)
  2266. }, e._processFinishedLoad = function(d, c) {
  2267. this._numItemsLoaded++, this._updateProgress(), this._sendFileComplete(d, c), this._loadNext()
  2268. }, e._checkScriptLoadOrder = function() {
  2269. for (var j = this._loadedScripts.length, i = 0; j > i; i++) {
  2270. var l = this._loadedScripts[i];
  2271. if (null === l) {
  2272. break
  2273. }
  2274. if (l !== !0) {
  2275. var k = this._loadedResults[l.id];
  2276. (document.body || document.getElementsByTagName("body")[0]).appendChild(k), this._processFinishedLoad(l), this._loadedScripts[i] = !0
  2277. }
  2278. }
  2279. }, e._removeLoadItem = function(i) {
  2280. for (var d = this._currentLoads.length, j = 0; d > j; j++) {
  2281. if (this._currentLoads[j] == i) {
  2282. this._currentLoads.splice(j, 1);
  2283. break
  2284. }
  2285. }
  2286. }, e._handleProgress = function(d) {
  2287. var c = d.target;
  2288. this._sendFileProgress(c.getItem(), c.progress), this._updateProgress()
  2289. }, e._updateProgress = function() {
  2290. var j = this._numItemsLoaded / this._numItems,
  2291. i = this._numItems - this._numItemsLoaded;
  2292. if (i > 0) {
  2293. for (var m = 0, l = 0, k = this._currentLoads.length; k > l; l++) {
  2294. m += this._currentLoads[l].progress
  2295. }
  2296. j += m / i * (i / this._numItems)
  2297. }
  2298. this._sendProgress(j)
  2299. }, e._disposeItem = function(b) {
  2300. delete this._loadedResults[b.id], delete this._loadedRawResults[b.id], delete this._loadItemsById[b.id], delete this._loadItemsBySrc[b.src]
  2301. }, e._createTag = function(d) {
  2302. var c = null;
  2303. switch (d.type) {
  2304. case createjs.LoadQueue.IMAGE:
  2305. return c = document.createElement("img"), "" == this._crossOrigin || this._isLocal(d) || (c.crossOrigin = this._crossOrigin), c;
  2306. case createjs.LoadQueue.SOUND:
  2307. return c = document.createElement("audio"), c.autoplay = !1, c;
  2308. case createjs.LoadQueue.JSON:
  2309. case createjs.LoadQueue.JSONP:
  2310. case createjs.LoadQueue.JAVASCRIPT:
  2311. case createjs.LoadQueue.MANIFEST:
  2312. return c = document.createElement("script"), c.type = "text/javascript", c;
  2313. case createjs.LoadQueue.CSS:
  2314. return c = this.useXHR ? document.createElement("style") : document.createElement("link"), c.rel = "stylesheet", c.type = "text/css", c;
  2315. case createjs.LoadQueue.SVG:
  2316. return this.useXHR ? c = document.createElement("svg") : (c = document.createElement("object"), c.type = "image/svg+xml"), c
  2317. }
  2318. return null
  2319. }, e._getTypeByExtension = function(b) {
  2320. if (null == b) {
  2321. return createjs.LoadQueue.TEXT
  2322. }
  2323. switch (b.toLowerCase()) {
  2324. case "jpeg":
  2325. case "jpg":
  2326. case "gif":
  2327. case "png":
  2328. case "webp":
  2329. case "bmp":
  2330. return createjs.LoadQueue.IMAGE;
  2331. case "ogg":
  2332. case "mp3":
  2333. case "wav":
  2334. return createjs.LoadQueue.SOUND;
  2335. case "json":
  2336. return createjs.LoadQueue.JSON;
  2337. case "xml":
  2338. return createjs.LoadQueue.XML;
  2339. case "css":
  2340. return createjs.LoadQueue.CSS;
  2341. case "js":
  2342. return createjs.LoadQueue.JAVASCRIPT;
  2343. case "svg":
  2344. return createjs.LoadQueue.SVG;
  2345. default:
  2346. return createjs.LoadQueue.TEXT
  2347. }
  2348. }, e._sendFileProgress = function(i, d) {
  2349. if (this._isCanceled()) {
  2350. return this._cleanUp(), void 0
  2351. }
  2352. if (this.hasEventListener("fileprogress")) {
  2353. var j = new createjs.Event("fileprogress");
  2354. j.progress = d, j.loaded = d, j.total = 1, j.item = i, this.dispatchEvent(j)
  2355. }
  2356. }, e._sendFileComplete = function(i, d) {
  2357. if (!this._isCanceled()) {
  2358. var j = new createjs.Event("fileload");
  2359. j.loader = d, j.item = i, j.result = this._loadedResults[i.id], j.rawResult = this._loadedRawResults[i.id], i.completeHandler && i.completeHandler(j), this.hasEventListener("fileload") && this.dispatchEvent(j)
  2360. }
  2361. }, e._sendFileStart = function(d) {
  2362. var c = new createjs.Event("filestart");
  2363. c.item = d, this.hasEventListener("filestart") && this.dispatchEvent(c)
  2364. }, e.toString = function() {
  2365. return "[PreloadJS LoadQueue]"
  2366. }, createjs.LoadQueue = f;
  2367. var g = function() {};
  2368. g.init = function() {
  2369. var b = navigator.userAgent;
  2370. g.isFirefox = b.indexOf("Firefox") > -1, g.isOpera = null != window.opera, g.isChrome = b.indexOf("Chrome") > -1, g.isIOS = b.indexOf("iPod") > -1 || b.indexOf("iPhone") > -1 || b.indexOf("iPad") > -1
  2371. }, g.init(), createjs.LoadQueue.BrowserDetect = g
  2372. }(), this.createjs = this.createjs || {},
  2373. function() {
  2374. var d = function(b) {
  2375. this.init(b)
  2376. },
  2377. c = d.prototype = new createjs.AbstractLoader;
  2378. c._loadTimeout = null, c._tagCompleteProxy = null, c._isAudio = !1, c._tag = null, c._jsonResult = null, c.init = function(b) {
  2379. this._item = b, this._tag = b.tag, this._isAudio = window.HTMLAudioElement && b.tag instanceof window.HTMLAudioElement, this._tagCompleteProxy = createjs.proxy(this._handleLoad, this)
  2380. }, c.getResult = function() {
  2381. return this._item.type == createjs.LoadQueue.JSONP || this._item.type == createjs.LoadQueue.MANIFEST ? this._jsonResult : this._tag
  2382. }, c.cancel = function() {
  2383. this.canceled = !0, this._clean()
  2384. }, c.load = function() {
  2385. var f = this._item,
  2386. e = this._tag;
  2387. clearTimeout(this._loadTimeout);
  2388. var h = createjs.LoadQueue.LOAD_TIMEOUT;
  2389. 0 == h && (h = createjs.LoadQueue.loadTimeout), this._loadTimeout = setTimeout(createjs.proxy(this._handleTimeout, this), h), this._isAudio && (e.src = null, e.preload = "auto"), e.onerror = createjs.proxy(this._handleError, this), this._isAudio ? (e.onstalled = createjs.proxy(this._handleStalled, this), e.addEventListener("canplaythrough", this._tagCompleteProxy, !1)) : (e.onload = createjs.proxy(this._handleLoad, this), e.onreadystatechange = createjs.proxy(this._handleReadyStateChange, this));
  2390. var g = this.buildPath(f.src, f.values);
  2391. switch (f.type) {
  2392. case createjs.LoadQueue.CSS:
  2393. e.href = g;
  2394. break;
  2395. case createjs.LoadQueue.SVG:
  2396. e.data = g;
  2397. break;
  2398. default:
  2399. e.src = g
  2400. }
  2401. if (f.type == createjs.LoadQueue.JSONP || f.type == createjs.LoadQueue.JSON || f.type == createjs.LoadQueue.MANIFEST) {
  2402. if (null == f.callback) {
  2403. throw new Error("callback is required for loading JSONP requests.")
  2404. }
  2405. if (null != window[f.callback]) {
  2406. throw new Error('JSONP callback "' + f.callback + '" already exists on window. You need to specify a different callback. Or re-name the current one.')
  2407. }
  2408. window[f.callback] = createjs.proxy(this._handleJSONPLoad, this)
  2409. }(f.type == createjs.LoadQueue.SVG || f.type == createjs.LoadQueue.JSONP || f.type == createjs.LoadQueue.JSON || f.type == createjs.LoadQueue.MANIFEST || f.type == createjs.LoadQueue.JAVASCRIPT || f.type == createjs.LoadQueue.CSS) && (this._startTagVisibility = e.style.visibility, e.style.visibility = "hidden", (document.body || document.getElementsByTagName("body")[0]).appendChild(e)), null != e.load && e.load()
  2410. }, c._handleJSONPLoad = function(b) {
  2411. this._jsonResult = b
  2412. }, c._handleTimeout = function() {
  2413. this._clean();
  2414. var b = new createjs.Event("error");
  2415. b.text = "PRELOAD_TIMEOUT", this._sendError(b)
  2416. }, c._handleStalled = function() {}, c._handleError = function() {
  2417. this._clean();
  2418. var b = new createjs.Event("error");
  2419. this._sendError(b)
  2420. }, c._handleReadyStateChange = function() {
  2421. clearTimeout(this._loadTimeout);
  2422. var b = this.getItem().tag;
  2423. ("loaded" == b.readyState || "complete" == b.readyState) && this._handleLoad()
  2424. }, c._handleLoad = function() {
  2425. if (!this._isCanceled()) {
  2426. var f = this.getItem(),
  2427. e = f.tag;
  2428. if (!(this.loaded || this._isAudio && 4 !== e.readyState)) {
  2429. switch (this.loaded = !0, f.type) {
  2430. case createjs.LoadQueue.SVG:
  2431. case createjs.LoadQueue.JSON:
  2432. case createjs.LoadQueue.JSONP:
  2433. case createjs.LoadQueue.MANIFEST:
  2434. case createjs.LoadQueue.CSS:
  2435. e.style.visibility = this._startTagVisibility, (document.body || document.getElementsByTagName("body")[0]).removeChild(e)
  2436. }
  2437. this._clean(), this._sendComplete()
  2438. }
  2439. }
  2440. }, c._clean = function() {
  2441. clearTimeout(this._loadTimeout);
  2442. var f = this.getItem(),
  2443. e = f.tag;
  2444. null != e && (e.onload = null, e.removeEventListener && e.removeEventListener("canplaythrough", this._tagCompleteProxy, !1), e.onstalled = null, e.onprogress = null, e.onerror = null, null != e.parentNode && f.type == createjs.LoadQueue.SVG && f.type == createjs.LoadQueue.JSON && f.type == createjs.LoadQueue.MANIFEST && f.type == createjs.LoadQueue.CSS && f.type == createjs.LoadQueue.JSONP && e.parentNode.removeChild(e));
  2445. var f = this.getItem();
  2446. (f.type == createjs.LoadQueue.JSONP || f.type == createjs.LoadQueue.MANIFEST) && (window[f.callback] = null)
  2447. }, c.toString = function() {
  2448. return "[PreloadJS TagLoader]"
  2449. }, createjs.TagLoader = d
  2450. }(), this.createjs = this.createjs || {},
  2451. function() {
  2452. var d = function(f, e) {
  2453. this.init(f, e)
  2454. },
  2455. c = d.prototype = new createjs.AbstractLoader;
  2456. c._request = null, c._loadTimeout = null, c._xhrLevel = 1, c._response = null, c._rawResponse = null, c._crossOrigin = "", c.init = function(f, e) {
  2457. this._item = f, this._crossOrigin = e, !this._createXHR(f)
  2458. }, c.getResult = function(b) {
  2459. return b && this._rawResponse ? this._rawResponse : this._response
  2460. }, c.cancel = function() {
  2461. this.canceled = !0, this._clean(), this._request.abort()
  2462. }, c.load = function() {
  2463. if (null == this._request) {
  2464. return this._handleError(), void 0
  2465. }
  2466. if (this._request.onloadstart = createjs.proxy(this._handleLoadStart, this), this._request.onprogress = createjs.proxy(this._handleProgress, this), this._request.onabort = createjs.proxy(this._handleAbort, this), this._request.onerror = createjs.proxy(this._handleError, this), this._request.ontimeout = createjs.proxy(this._handleTimeout, this), 1 == this._xhrLevel) {
  2467. var f = createjs.LoadQueue.LOAD_TIMEOUT;
  2468. if (0 == f) {
  2469. f = createjs.LoadQueue.loadTimeout
  2470. } else {
  2471. try {
  2472. console.warn("LoadQueue.LOAD_TIMEOUT has been deprecated in favor of LoadQueue.loadTimeout")
  2473. } catch (e) {}
  2474. }
  2475. this._loadTimeout = setTimeout(createjs.proxy(this._handleTimeout, this), f)
  2476. }
  2477. this._request.onload = createjs.proxy(this._handleLoad, this), this._request.onreadystatechange = createjs.proxy(this._handleReadyStateChange, this);
  2478. try {
  2479. this._item.values && this._item.method != createjs.LoadQueue.GET ? this._item.method == createjs.LoadQueue.POST && this._request.send(this._formatQueryString(this._item.values)) : this._request.send()
  2480. } catch (h) {
  2481. var g = new createjs.Event("error");
  2482. g.error = h, this._sendError(g)
  2483. }
  2484. }, c.getAllResponseHeaders = function() {
  2485. return this._request.getAllResponseHeaders instanceof Function ? this._request.getAllResponseHeaders() : null
  2486. }, c.getResponseHeader = function(b) {
  2487. return this._request.getResponseHeader instanceof Function ? this._request.getResponseHeader(b) : null
  2488. }, c._handleProgress = function(f) {
  2489. if (f && !(f.loaded > 0 && 0 == f.total)) {
  2490. var e = new createjs.Event("progress");
  2491. e.loaded = f.loaded, e.total = f.total, this._sendProgress(e)
  2492. }
  2493. }, c._handleLoadStart = function() {
  2494. clearTimeout(this._loadTimeout), this._sendLoadStart()
  2495. }, c._handleAbort = function() {
  2496. this._clean();
  2497. var b = new createjs.Event("error");
  2498. b.text = "XHR_ABORTED", this._sendError(b)
  2499. }, c._handleError = function() {
  2500. this._clean();
  2501. var b = new createjs.Event("error");
  2502. this._sendError(b)
  2503. }, c._handleReadyStateChange = function() {
  2504. 4 == this._request.readyState && this._handleLoad()
  2505. }, c._handleLoad = function() {
  2506. if (!this.loaded) {
  2507. if (this.loaded = !0, !this._checkError()) {
  2508. return this._handleError(), void 0
  2509. }
  2510. this._response = this._getResponse(), this._clean();
  2511. var b = this._generateTag();
  2512. b && this._sendComplete()
  2513. }
  2514. }, c._handleTimeout = function(f) {
  2515. this._clean();
  2516. var e = new createjs.Event("error");
  2517. e.text = "PRELOAD_TIMEOUT", this._sendError(f)
  2518. }, c._checkError = function() {
  2519. var b = parseInt(this._request.status);
  2520. switch (b) {
  2521. case 404:
  2522. case 0:
  2523. return !1
  2524. }
  2525. return !0
  2526. }, c._getResponse = function() {
  2527. if (null != this._response) {
  2528. return this._response
  2529. }
  2530. if (null != this._request.response) {
  2531. return this._request.response
  2532. }
  2533. try {
  2534. if (null != this._request.responseText) {
  2535. return this._request.responseText
  2536. }
  2537. } catch (b) {}
  2538. try {
  2539. if (null != this._request.responseXML) {
  2540. return this._request.responseXML
  2541. }
  2542. } catch (b) {}
  2543. return null
  2544. }, c._createXHR = function(g) {
  2545. var f = this._isCrossDomain(g),
  2546. j = null;
  2547. if (f && window.XDomainRequest) {
  2548. j = new XDomainRequest
  2549. } else {
  2550. if (window.XMLHttpRequest) {
  2551. j = new XMLHttpRequest
  2552. } else {
  2553. try {
  2554. j = new ActiveXObject("Msxml2.XMLHTTP.6.0")
  2555. } catch (i) {
  2556. try {
  2557. j = new ActiveXObject("Msxml2.XMLHTTP.3.0")
  2558. } catch (i) {
  2559. try {
  2560. j = new ActiveXObject("Msxml2.XMLHTTP")
  2561. } catch (i) {
  2562. return !1
  2563. }
  2564. }
  2565. }
  2566. }
  2567. }
  2568. createjs.LoadQueue.isText(g.type) && j.overrideMimeType && j.overrideMimeType("text/plain; charset=utf-8"), this._xhrLevel = "string" == typeof j.responseType ? 2 : 1;
  2569. var h = null;
  2570. return h = g.method == createjs.LoadQueue.GET ? this.buildPath(g.src, g.values) : g.src, j.open(g.method || createjs.LoadQueue.GET, h, !0), f && j instanceof XMLHttpRequest && 1 == this._xhrLevel && j.setRequestHeader("Origin", location.origin), g.values && g.method == createjs.LoadQueue.POST && j.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"), createjs.LoadQueue.isBinary(g.type) && (j.responseType = "arraybuffer"), this._request = j, !0
  2571. }, c._clean = function() {
  2572. clearTimeout(this._loadTimeout);
  2573. var b = this._request;
  2574. b.onloadstart = null, b.onprogress = null, b.onabort = null, b.onerror = null, b.onload = null, b.ontimeout = null, b.onloadend = null, b.onreadystatechange = null
  2575. }, c._generateTag = function() {
  2576. var i = this._item.type,
  2577. h = this._item.tag;
  2578. switch (i) {
  2579. case createjs.LoadQueue.IMAGE:
  2580. return h.onload = createjs.proxy(this._handleTagReady, this), "" != this._crossOrigin && (h.crossOrigin = "Anonymous"), h.src = this.buildPath(this._item.src, this._item.values), this._rawResponse = this._response, this._response = h, !1;
  2581. case createjs.LoadQueue.JAVASCRIPT:
  2582. return h = document.createElement("script"), h.text = this._response, this._rawResponse = this._response, this._response = h, !0;
  2583. case createjs.LoadQueue.CSS:
  2584. var n = document.getElementsByTagName("head")[0];
  2585. if (n.appendChild(h), h.styleSheet) {
  2586. h.styleSheet.cssText = this._response
  2587. } else {
  2588. var m = document.createTextNode(this._response);
  2589. h.appendChild(m)
  2590. }
  2591. return this._rawResponse = this._response, this._response = h, !0;
  2592. case createjs.LoadQueue.XML:
  2593. var l = this._parseXML(this._response, "text/xml");
  2594. return this._rawResponse = this._response, this._response = l, !0;
  2595. case createjs.LoadQueue.SVG:
  2596. var l = this._parseXML(this._response, "image/svg+xml");
  2597. return this._rawResponse = this._response, null != l.documentElement ? (h.appendChild(l.documentElement), this._response = h) : this._response = l, !0;
  2598. case createjs.LoadQueue.JSON:
  2599. case createjs.LoadQueue.MANIFEST:
  2600. var k = {};
  2601. try {
  2602. k = JSON.parse(this._response)
  2603. } catch (j) {
  2604. k = j
  2605. }
  2606. return this._rawResponse = this._response, this._response = k, !0
  2607. }
  2608. return !0
  2609. }, c._parseXML = function(g, f) {
  2610. var j = null;
  2611. try {
  2612. if (window.DOMParser) {
  2613. var i = new DOMParser;
  2614. j = i.parseFromString(g, f)
  2615. } else {
  2616. j = new ActiveXObject("Microsoft.XMLDOM"), j.async = !1, j.loadXML(g)
  2617. }
  2618. } catch (h) {}
  2619. return j
  2620. }, c._handleTagReady = function() {
  2621. this._sendComplete()
  2622. }, c.toString = function() {
  2623. return "[PreloadJS XHRLoader]"
  2624. }, createjs.XHRLoader = d
  2625. }(), "object" != typeof JSON && (JSON = {}),
  2626. function() {
  2627. function f(a) {
  2628. return 10 > a ? "0" + a : a
  2629. }
  2630. function quote(a) {
  2631. return escapable.lastIndex = 0, escapable.test(a) ? '"' + a.replace(escapable, function(a) {
  2632. var b = meta[a];
  2633. return "string" == typeof b ? b : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4)
  2634. }) + '"' : '"' + a + '"'
  2635. }
  2636. function str(a, b) {
  2637. var c, d, e, f, g, h = gap,
  2638. i = b[a];
  2639. switch (i && "object" == typeof i && "function" == typeof i.toJSON && (i = i.toJSON(a)), "function" == typeof rep && (i = rep.call(b, a, i)), typeof i) {
  2640. case "string":
  2641. return quote(i);
  2642. case "number":
  2643. return isFinite(i) ? String(i) : "null";
  2644. case "boolean":
  2645. case "null":
  2646. return String(i);
  2647. case "object":
  2648. if (!i) {
  2649. return "null"
  2650. }
  2651. if (gap += indent, g = [], "[object Array]" === Object.prototype.toString.apply(i)) {
  2652. for (f = i.length, c = 0; f > c; c += 1) {
  2653. g[c] = str(c, i) || "null"
  2654. }
  2655. return e = 0 === g.length ? "[]" : gap ? "[\n" + gap + g.join(",\n" + gap) + "\n" + h + "]" : "[" + g.join(",") + "]", gap = h, e
  2656. }
  2657. if (rep && "object" == typeof rep) {
  2658. for (f = rep.length, c = 0; f > c; c += 1) {
  2659. "string" == typeof rep[c] && (d = rep[c], e = str(d, i), e && g.push(quote(d) + (gap ? ": " : ":") + e))
  2660. }
  2661. } else {
  2662. for (d in i) {
  2663. Object.prototype.hasOwnProperty.call(i, d) && (e = str(d, i), e && g.push(quote(d) + (gap ? ": " : ":") + e))
  2664. }
  2665. }
  2666. return e = 0 === g.length ? "{}" : gap ? "{\n" + gap + g.join(",\n" + gap) + "\n" + h + "}" : "{" + g.join(",") + "}", gap = h, e
  2667. }
  2668. }
  2669. "function" != typeof Date.prototype.toJSON && (Date.prototype.toJSON = function() {
  2670. return isFinite(this.valueOf()) ? this.getUTCFullYear() + "-" + f(this.getUTCMonth() + 1) + "-" + f(this.getUTCDate()) + "T" + f(this.getUTCHours()) + ":" + f(this.getUTCMinutes()) + ":" + f(this.getUTCSeconds()) + "Z" : null
  2671. }, String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function() {
  2672. return this.valueOf()
  2673. });
  2674. var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
  2675. escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
  2676. gap, indent, meta = {
  2677. "\b": "\\b",
  2678. " ": "\\t",
  2679. "\n": "\\n",
  2680. "\f": "\\f",
  2681. "\r": "\\r",
  2682. '"': '\\"',
  2683. "\\": "\\\\"
  2684. },
  2685. rep;
  2686. "function" != typeof JSON.stringify && (JSON.stringify = function(a, b, c) {
  2687. var d;
  2688. if (gap = "", indent = "", "number" == typeof c) {
  2689. for (d = 0; c > d; d += 1) {
  2690. indent += " "
  2691. }
  2692. } else {
  2693. "string" == typeof c && (indent = c)
  2694. } if (rep = b, b && "function" != typeof b && ("object" != typeof b || "number" != typeof b.length)) {
  2695. throw new Error("JSON.stringify")
  2696. }
  2697. return str("", {
  2698. "": a
  2699. })
  2700. }), "function" != typeof JSON.parse && (JSON.parse = function(text, reviver) {
  2701. function walk(a, b) {
  2702. var c, d, e = a[b];
  2703. if (e && "object" == typeof e) {
  2704. for (c in e) {
  2705. Object.prototype.hasOwnProperty.call(e, c) && (d = walk(e, c), void 0 !== d ? e[c] = d : delete e[c])
  2706. }
  2707. }
  2708. return reviver.call(a, b, e)
  2709. }
  2710. var j;
  2711. if (text = String(text), cx.lastIndex = 0, cx.test(text) && (text = text.replace(cx, function(a) {
  2712. return "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4)
  2713. })), /^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]").replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) {
  2714. return j = eval("(" + text + ")"), "function" == typeof reviver ? walk({
  2715. "": j
  2716. }, "") : j
  2717. }
  2718. throw new SyntaxError("JSON.parse")
  2719. })
  2720. }();
  2721. function Preloader() {
  2722. this.sceneManager
  2723. }
  2724. Preloader.prototype = new Preloader();
  2725. Preloader.prototype.constructor = Preloader;
  2726. Preloader.staticLoader = null;
  2727. Preloader.prototype.init = function() {
  2728. this.sceneManager = new SceneManager();
  2729. this.sceneManager.init();
  2730. this.progress = 0;
  2731. canvas = document.getElementById("canvas");
  2732. ctx = canvas.getContext("2d");
  2733. ctx.font = "normal normal normal " + 100 + "px chunkfive";
  2734. ctx.fillText("\u6587\u672c", 0, 0);
  2735. ctx.clearRect(0, 0, canvas.width, canvas.height);
  2736. this.logo = new Image();
  2737. this.logo.src = "content/textures/ui/preloaderLogo.png";
  2738. this.edge = new Image();
  2739. this.edge.src = "content/textures/ui/preloaderLogoEdge.png";
  2740. this.device = new Image();
  2741. this.device.src = "content/textures/preloaderDeviceSmall.png";
  2742. this.device.onload = this.onLoaded;
  2743. this.loadingTextOffsetY = 0;
  2744. this.orientationTextSize = 18;
  2745. this.deviceOffsetY = 0;
  2746. this.logoOffsetY = 0;
  2747. Preloader.staticLoader = this;
  2748. resizeGame()
  2749. };
  2750. Preloader.prototype.onLoaded = function() {
  2751. var c = new Drawable();
  2752. c.init(Preloader.staticLoader.logo, 0, 0);
  2753. c.originX = c.sprite.width * 0.5;
  2754. c.originY = c.sprite.height * 0.5;
  2755. c.x = canvas.width * 0.5;
  2756. c.y = canvas.height - 56;
  2757. c.useCamera = false;
  2758. Preloader.staticLoader.sceneManager.addEntity(c);
  2759. var b = new Drawable();
  2760. b.init(Preloader.staticLoader.edge, 0, 0);
  2761. b.originX = 1;
  2762. b.x = c.x - 80;
  2763. b.y = c.y - 6;
  2764. b.scaleX = (canvas.width * 0.5 - 80);
  2765. b.useCamera = false;
  2766. Preloader.staticLoader.sceneManager.addEntity(b);
  2767. b = new Drawable();
  2768. b.init(Preloader.staticLoader.edge, 0, 0);
  2769. b.x = c.x + 80;
  2770. b.y = c.y - 6;
  2771. b.scaleX = canvas.width * 0.5 - 80;
  2772. b.useCamera = false;
  2773. Preloader.staticLoader.sceneManager.addEntity(b);
  2774. var a = new Drawable();
  2775. a.init(Preloader.staticLoader.device, 0, 0);
  2776. a.x = 0;
  2777. a.y = 0;
  2778. a.useCamera = false;
  2779. Preloader.staticLoader.sceneManager.addEntity(a)
  2780. };
  2781. Preloader.prototype.start = function() {
  2782. var a = this;
  2783. this.interval = window.setInterval(function() {
  2784. a.update(0.033)
  2785. }, 0.033)
  2786. };
  2787. Preloader.prototype.end = function(b) {
  2788. this.callback = b;
  2789. this.sceneManager.entities[3].sprite = content.preloadDeviceLarge;
  2790. this.sceneManager.entities[3].scaleX = 0.333;
  2791. this.sceneManager.entities[3].scaleY = 0.333;
  2792. var a = 36;
  2793. if (canvas.width < 620) {
  2794. a *= canvas.width / 620
  2795. }
  2796. TweenLite.to(this, 0.5, {
  2797. loadingTextOffsetY: -(canvas.height * 0.5 - 40) - 80,
  2798. ease: Back.easeIn
  2799. });
  2800. TweenLite.to(this.sceneManager.entities[3], 0.5, {
  2801. scaleX: 1,
  2802. scaleY: 1,
  2803. ease: Expo.easeIn
  2804. });
  2805. TweenLite.to(this, 0.5, {
  2806. deviceOffsetY: -160,
  2807. orientationTextSize: a,
  2808. ease: Expo.easeIn,
  2809. overwrite: 0
  2810. });
  2811. TweenLite.to(this, 0.25, {
  2812. logoOffsetY: 100,
  2813. deviceOffsetY: -canvas.height,
  2814. orientationTextSize: 0,
  2815. ease: Sine.easeIn,
  2816. overwrite: 0,
  2817. delay: 2.5,
  2818. onCompleteParams: [this],
  2819. onComplete: function(c) {
  2820. if (c.interval) {
  2821. window.clearInterval(c.interval)
  2822. }
  2823. if (c.callback) {
  2824. c.callback()
  2825. }
  2826. }
  2827. })
  2828. };
  2829. Preloader.prototype.update = function(a) {
  2830. this.sceneManager.update(a);
  2831. if (this.sceneManager.entityCount != 0) {
  2832. this.sceneManager.entities[0].x = canvas.width * 0.5;
  2833. this.sceneManager.entities[1].x = this.sceneManager.entities[0].x - 80;
  2834. this.sceneManager.entities[2].x = this.sceneManager.entities[0].x + 80;
  2835. this.sceneManager.entities[0].y = canvas.height - 56 + this.logoOffsetY;
  2836. this.sceneManager.entities[1].y = this.sceneManager.entities[0].y - 6;
  2837. this.sceneManager.entities[2].y = this.sceneManager.entities[0].y - 6;
  2838. this.sceneManager.entities[1].scaleX = (canvas.width * 0.5 - 80);
  2839. this.sceneManager.entities[2].scaleX = (canvas.width * 0.5 - 80);
  2840. this.sceneManager.entities[3].x = (canvas.width * 0.5 - (this.sceneManager.entities[3].scaleX * this.sceneManager.entities[3].sprite.width * 0.5));
  2841. this.sceneManager.entities[3].y = (canvas.height * 0.5 + 64) + this.deviceOffsetY
  2842. }
  2843. this.draw()
  2844. };
  2845. Preloader.prototype.draw = function() {
  2846. ctx.fillStyle = "#fcb040";
  2847. ctx.fillRect(0, 0, canvas.width, canvas.height);
  2848. this.sceneManager.masterAlpha = 1;
  2849. this.sceneManager.draw();
  2850. var a = "\u52a0\u8f7d";
  2851. ctx.fillStyle = "#000000";
  2852. ctx.globalAlpha = 0.25;
  2853. ctx.font = "normal normal normal " + 72 + "px chunkfive";
  2854. ctx.textAlign = "center";
  2855. ctx.fillText(a, canvas.width * 0.5, canvas.height * 0.5 - 40 + 5 + this.loadingTextOffsetY);
  2856. ctx.globalAlpha = 1;
  2857. ctx.fillStyle = "#FFFFFF";
  2858. ctx.fillText(a, canvas.width * 0.5, canvas.height * 0.5 - 40 + this.loadingTextOffsetY);
  2859. ctx.globalAlpha = 1;
  2860. a = Math.floor(this.progress * 100).toString() + "%";
  2861. ctx.fillStyle = "#000000";
  2862. ctx.globalAlpha = 0.25;
  2863. ctx.font = "normal normal normal " + 36 + "px chunkfive";
  2864. ctx.textAlign = "center";
  2865. ctx.fillText(a, canvas.width * 0.5, canvas.height * 0.5 + 5 + this.loadingTextOffsetY);
  2866. ctx.globalAlpha = 1;
  2867. ctx.fillStyle = "#FFFFFF";
  2868. ctx.fillText(a, canvas.width * 0.5, canvas.height * 0.5 + this.loadingTextOffsetY);
  2869. ctx.globalAlpha = 1;
  2870. a = "\u6e38\u620f\u5373\u5c06\u5f00\u59cb\u2026";
  2871. ctx.fillStyle = "#000000";
  2872. ctx.globalAlpha = 0.25;
  2873. ctx.font = "normal normal normal " + this.orientationTextSize + "px chunkfive";
  2874. ctx.textAlign = "center";
  2875. ctx.fillText(a, canvas.width * 0.5, canvas.height * 0.5 + 3 + 160);
  2876. ctx.globalAlpha = 1;
  2877. ctx.fillStyle = "#FFFFFF";
  2878. ctx.fillText(a, canvas.width * 0.5, canvas.height * 0.5 + 160);
  2879. ctx.globalAlpha = 1;
  2880. a = "";
  2881. ctx.fillStyle = "#000000";
  2882. ctx.globalAlpha = 0.25;
  2883. ctx.font = "normal normal normal " + this.orientationTextSize + "px chunkfive";
  2884. ctx.textAlign = "center";
  2885. ctx.fillText(a, canvas.width * 0.5, canvas.height * 0.5 + 3 + 160 + 22 * (this.orientationTextSize / 18));
  2886. ctx.globalAlpha = 1;
  2887. ctx.fillStyle = "#FFFFFF";
  2888. ctx.fillText(a, canvas.width * 0.5, canvas.height * 0.5 + 160 + 22 * (this.orientationTextSize / 18));
  2889. ctx.globalAlpha = 1
  2890. };
  2891. var progressCallback;
  2892. var completeCallback;
  2893. var content = new function() {
  2894. var b = false;
  2895. var a = false;
  2896. this.preload = new createjs.LoadQueue(false);
  2897. createjs.Sound.alternateExtensions = ["mp3"];
  2898. this.preload.installPlugin(createjs.Sound);
  2899. this.load = function() {
  2900. this.preloader = new Preloader();
  2901. this.preloader.init();
  2902. var d = this;
  2903. progressCallback = function(f) {
  2904. d.handleProgress(f)
  2905. };
  2906. completeCallback = function(f) {
  2907. d.handleComplete(f)
  2908. };
  2909. this.preload.addEventListener("progress", progressCallback);
  2910. this.preload.addEventListener("complete", completeCallback);
  2911. var c = [{
  2912. id: "crateHit",
  2913. src: "content/sound/crateHit.ogg"
  2914. }, {
  2915. id: "dirtRoadRumble",
  2916. src: "content/sound/dirtRoadRumble.ogg"
  2917. }, {
  2918. id: "explosion",
  2919. src: "content/sound/explosion.ogg"
  2920. }, {
  2921. id: "hitCrash01",
  2922. src: "content/sound/hitCrash01.ogg"
  2923. }, {
  2924. id: "hitCrash02",
  2925. src: "content/sound/hitCrash02.ogg"
  2926. }, {
  2927. id: "hitCrash03",
  2928. src: "content/sound/hitCrash03.ogg"
  2929. }, {
  2930. id: "impactCrash",
  2931. src: "content/sound/impactCrash.ogg"
  2932. }, {
  2933. id: "pothole01",
  2934. src: "content/sound/pothole01.ogg"
  2935. }, {
  2936. id: "pothole02",
  2937. src: "content/sound/pothole02.ogg"
  2938. }, {
  2939. id: "pothole03",
  2940. src: "content/sound/pothole03.ogg"
  2941. }, {
  2942. id: "roadBlockHit",
  2943. src: "content/sound/roadBlockHit.ogg"
  2944. }, {
  2945. id: "siren",
  2946. src: "content/sound/siren.ogg"
  2947. }, {
  2948. id: "skid",
  2949. src: "content/sound/skid.ogg"
  2950. }, {
  2951. id: "wrench",
  2952. src: "content/sound/wrench.ogg"
  2953. }, {
  2954. id: "menuLoop",
  2955. src: "content/sound/menuloop.ogg"
  2956. }, {
  2957. id: "gameLoop",
  2958. src: "content/sound/gameloop.ogg"
  2959. }, {
  2960. id: "pixel",
  2961. src: "content/textures/pixel.png"
  2962. }, {
  2963. id: "black",
  2964. src: "content/textures/black.png"
  2965. }, {
  2966. id: "roadStripe",
  2967. src: "content/textures/world/roadStripe.png"
  2968. }, {
  2969. id: "road",
  2970. src: "content/textures/world/road.png"
  2971. }, {
  2972. id: "preloaderLogo",
  2973. src: "content/textures/ui/preloaderLogo.png"
  2974. }, {
  2975. id: "preloaderLogoEdge",
  2976. src: "content/textures/ui/preloaderLogoEdge.png"
  2977. }, {
  2978. id: "carLayer0",
  2979. src: "content/textures/world/carLayer0.png"
  2980. }, {
  2981. id: "carLayer1",
  2982. src: "content/textures/world/carLayer1.png"
  2983. }, {
  2984. id: "carLayer2",
  2985. src: "content/textures/world/carLayer2.png"
  2986. }, {
  2987. id: "carLayer3",
  2988. src: "content/textures/world/carLayer3.png"
  2989. }, {
  2990. id: "carLayer4",
  2991. src: "content/textures/world/carLayer4.png"
  2992. }, {
  2993. id: "carCrashLayer0",
  2994. src: "content/textures/world/carCrashLayer0.png"
  2995. }, {
  2996. id: "carCrashLayer1",
  2997. src: "content/textures/world/carCrashLayer1.png"
  2998. }, {
  2999. id: "carCrashLayer2",
  3000. src: "content/textures/world/carCrashLayer2.png"
  3001. }, {
  3002. id: "carCrashLayer3",
  3003. src: "content/textures/world/carCrashLayer3.png"
  3004. }, {
  3005. id: "carCrashLayer4",
  3006. src: "content/textures/world/carCrashLayer4.png"
  3007. }, {
  3008. id: "carExplosionLayer",
  3009. src: "content/textures/world/carExplosionLayer.png"
  3010. }, {
  3011. id: "copCar",
  3012. src: "content/textures/world/copCar.png"
  3013. }, {
  3014. id: "truck",
  3015. src: "content/textures/world/truck.png"
  3016. }, {
  3017. id: "copCarCrash",
  3018. src: "content/textures/world/copCarCrash.png"
  3019. }, {
  3020. id: "truckCrash",
  3021. src: "content/textures/world/truckCrash.png"
  3022. }, {
  3023. id: "truckExploded",
  3024. src: "content/textures/world/truckExplosion.png"
  3025. }, {
  3026. id: "blueCopLight",
  3027. src: "content/textures/world/blueCopLight.png"
  3028. }, {
  3029. id: "redCopLight",
  3030. src: "content/textures/world/redCopLight.png"
  3031. }, {
  3032. id: "wall",
  3033. src: "content/textures/world/wall.png"
  3034. }, {
  3035. id: "steeringBack",
  3036. src: "content/textures/ui/steeringBack.png"
  3037. }, {
  3038. id: "steeringCircle",
  3039. src: "content/textures/ui/steeringCircle.png"
  3040. }, {
  3041. id: "roadBacking",
  3042. src: "content/textures/ui/roadBacking.png"
  3043. }, {
  3044. id: "crate",
  3045. src: "content/textures/world/crate.png"
  3046. }, {
  3047. id: "explodingCrate",
  3048. src: "content/textures/world/explodingCrate.png"
  3049. }, {
  3050. id: "dust",
  3051. src: "content/textures/world/dust.png"
  3052. }, {
  3053. id: "smoke",
  3054. src: "content/textures/particles/smoke.png"
  3055. }, {
  3056. id: "skid",
  3057. src: "content/textures/world/skid.png"
  3058. }, {
  3059. id: "white4",
  3060. src: "content/textures/world/white4.png"
  3061. }, {
  3062. id: "black4",
  3063. src: "content/textures/world/black4.png"
  3064. }, {
  3065. id: "star",
  3066. src: "content/textures/ui/star.png"
  3067. }, {
  3068. id: "circleTimerRing",
  3069. src: "content/textures/ui/circleTimerRing.png"
  3070. }, {
  3071. id: "circleTimerBase",
  3072. src: "content/textures/ui/circleTimerBase.png"
  3073. }, {
  3074. id: "restartBtnUp",
  3075. src: "content/textures/ui/restartBtn_up.png"
  3076. }, {
  3077. id: "restartBtnDown",
  3078. src: "content/textures/ui/restartBtn_down.png"
  3079. }, {
  3080. id: "homeBtnUp",
  3081. src: "content/textures/ui/homeBtn_up.png"
  3082. }, {
  3083. id: "homeBtnDown",
  3084. src: "content/textures/ui/homeBtn_down.png"
  3085. }, {
  3086. id: "playBtnUp",
  3087. src: "content/textures/ui/playBtn_up.png"
  3088. }, {
  3089. id: "playBtnDown",
  3090. src: "content/textures/ui/playBtn_down.png"
  3091. }, {
  3092. id: "bannerEdge",
  3093. src: "content/textures/ui/bannerEdge.png"
  3094. }, {
  3095. id: "bannerSpread",
  3096. src: "content/textures/ui/bannerSpread.png"
  3097. }, {
  3098. id: "bannerShine",
  3099. src: "content/textures/ui/bannerShine.png"
  3100. }, {
  3101. id: "endFade",
  3102. src: "content/textures/ui/endFade.png"
  3103. }, {
  3104. id: "bestGlow",
  3105. src: "content/textures/ui/bestGlow.png"
  3106. }, {
  3107. id: "menuBack",
  3108. src: "content/textures/ui/menuBack.png"
  3109. }, {
  3110. id: "menuSign",
  3111. src: "content/textures/ui/menuSign.png"
  3112. }, {
  3113. id: "menuSignShadow",
  3114. src: "content/textures/ui/menuSignShadow.png"
  3115. }, {
  3116. id: "cloudLine",
  3117. src: "content/textures/ui/cloudline.png"
  3118. }, {
  3119. id: "heliBody",
  3120. src: "content/textures/world/heliBody.png"
  3121. }, {
  3122. id: "heliBlades",
  3123. src: "content/textures/world/heliBlades.png"
  3124. }, {
  3125. id: "rock01",
  3126. src: "content/textures/world/rock01.png"
  3127. }, {
  3128. id: "rock02",
  3129. src: "content/textures/world/rock02.png"
  3130. }, {
  3131. id: "rock03",
  3132. src: "content/textures/world/rock03.png"
  3133. }, {
  3134. id: "rock04",
  3135. src: "content/textures/world/rock04.png"
  3136. }, {
  3137. id: "sandEdge",
  3138. src: "content/textures/world/sandEdge.png"
  3139. }, {
  3140. id: "pothole0",
  3141. src: "content/textures/world/pothole0.png"
  3142. }, {
  3143. id: "pothole1",
  3144. src: "content/textures/world/pothole1.png"
  3145. }, {
  3146. id: "pothole2",
  3147. src: "content/textures/world/pothole2.png"
  3148. }, {
  3149. id: "oil",
  3150. src: "content/textures/world/oil.png"
  3151. }, {
  3152. id: "warningStripe",
  3153. src: "content/textures/ui/warningStripe.png"
  3154. }, {
  3155. id: "dirtArrow",
  3156. src: "content/textures/ui/dirtArrow.png"
  3157. }, {
  3158. id: "dirtRoad",
  3159. src: "content/textures/world/dirtRoad.png"
  3160. }, {
  3161. id: "dirtTransition",
  3162. src: "content/textures/world/dirtTransition.png"
  3163. }, {
  3164. id: "dirtSkid",
  3165. src: "content/textures/world/dirtSkid.png"
  3166. }, {
  3167. id: "blockStanding",
  3168. src: "content/textures/world/blockStanding.png"
  3169. }, {
  3170. id: "blockFallen",
  3171. src: "content/textures/world/blockFallen.png"
  3172. }, {
  3173. id: "wrenchParticle",
  3174. src: "content/textures/particles/wrenchParticle.png"
  3175. }, {
  3176. id: "explosion",
  3177. src: "content/textures/particles/explosion.png"
  3178. }, {
  3179. id: "explosionSpark",
  3180. src: "content/textures/particles/explosionSpark.png"
  3181. }, {
  3182. id: "flash",
  3183. src: "content/textures/particles/flash.png"
  3184. }, {
  3185. id: "pauseBtn",
  3186. src: "content/textures/ui/pauseBtn.png"
  3187. }, {
  3188. id: "backBtn",
  3189. src: "content/textures/ui/backBtn.png"
  3190. }, {
  3191. id: "pauseBack",
  3192. src: "content/textures/ui/pauseBack.png"
  3193. }, {
  3194. id: "pauseText",
  3195. src: "content/textures/ui/pauseText.png"
  3196. }, {
  3197. id: "tut01",
  3198. src: "content/textures/ui/tut01.png"
  3199. }, {
  3200. id: "tut02",
  3201. src: "content/textures/ui/tut02.png"
  3202. }, {
  3203. id: "tutArrow",
  3204. src: "content/textures/ui/tutArrow.png"
  3205. }, {
  3206. id: "wrench",
  3207. src: "content/textures/world/wrench.png"
  3208. }, {
  3209. id: "wrenchStar",
  3210. src: "content/textures/world/wrenchStar.png"
  3211. }, {
  3212. id: "hitOn",
  3213. src: "content/textures/ui/hitOn.png"
  3214. }, {
  3215. id: "hitOff",
  3216. src: "content/textures/ui/hitOff.png"
  3217. }, {
  3218. id: "soundOff",
  3219. src: "content/textures/ui/soundOffBtn.png"
  3220. }, {
  3221. id: "soundOn",
  3222. src: "content/textures/ui/soundOnBtn.png"
  3223. }, {
  3224. id: "preloadDeviceLarge",
  3225. src: "content/textures/preloaderDeviceLarge.png"
  3226. }, {
  3227. id: "ffBadge",
  3228. src: "content/textures/branding/ffBadge.png"
  3229. }, {
  3230. id: "moreGames",
  3231. src: "content/textures/ui/moreGames.png"
  3232. }];
  3233. switch (gCurrentBrand) {
  3234. case BRAND.ADDICTING:
  3235. c.push({
  3236. id: "addictingEnd",
  3237. src: "content/textures/branding/AddictingGames/addictingEnd.png"
  3238. });
  3239. c.push({
  3240. id: "addictingMenu",
  3241. src: "content/textures/branding/AddictingGames/addictingMenu.png"
  3242. });
  3243. c.push({
  3244. id: "addictingSplash",
  3245. src: "content/textures/branding/AddictingGames/addictingSplash.png"
  3246. });
  3247. break;
  3248. case BRAND.MRG:
  3249. // c.push({
  3250. // id: "mrgEnd",
  3251. // src: "content/textures/branding/MyRealGames/mrgEnd.png"
  3252. // });
  3253. c.push({
  3254. id: "mrgMenu",
  3255. src: "content/textures/branding/MyRealGames/mrgMenu.png"
  3256. });
  3257. c.push({
  3258. id: "mrgSplash",
  3259. src: "content/textures/branding/MyRealGames/mrgSplash.png"
  3260. });
  3261. break
  3262. }
  3263. this.preload.loadManifest(c);
  3264. this.preloader.start()
  3265. };
  3266. this.handleProgress = function(c) {
  3267. if (this.preloader) {
  3268. this.preloader.progress = c.progress
  3269. }
  3270. };
  3271. this.handleComplete = function(d) {
  3272. this.preload.removeEventListener("progress", progressCallback);
  3273. this.preload.removeEventListener("complete", completeCallback);
  3274. this.pixel = this.preload.getResult("pixel");
  3275. this.black = this.preload.getResult("black");
  3276. this.road = this.preload.getResult("road");
  3277. this.roadStripe = this.preload.getResult("roadStripe");
  3278. this.preloaderLogo = this.preload.getResult("preloaderLogo");
  3279. this.preloaderLogoEdge = this.preload.getResult("preloaderLogoEdge");
  3280. this.carLayer0 = this.preload.getResult("carLayer0");
  3281. this.carLayer1 = this.preload.getResult("carLayer1");
  3282. this.carLayer2 = this.preload.getResult("carLayer2");
  3283. this.carLayer3 = this.preload.getResult("carLayer3");
  3284. this.carLayer4 = this.preload.getResult("carLayer4");
  3285. this.carCrashLayer0 = this.preload.getResult("carCrashLayer0");
  3286. this.carCrashLayer1 = this.preload.getResult("carCrashLayer1");
  3287. this.carCrashLayer2 = this.preload.getResult("carCrashLayer2");
  3288. this.carCrashLayer3 = this.preload.getResult("carCrashLayer3");
  3289. this.carCrashLayer4 = this.preload.getResult("carCrashLayer4");
  3290. this.carExplosionLayer = this.preload.getResult("carExplosionLayer");
  3291. this.copCar = this.preload.getResult("copCar");
  3292. this.truck = this.preload.getResult("truck");
  3293. this.copCarCrash = this.preload.getResult("copCarCrash");
  3294. this.truckCrash = this.preload.getResult("truckCrash");
  3295. this.truckExploded = this.preload.getResult("truckExploded");
  3296. this.blueCopLight = this.preload.getResult("blueCopLight");
  3297. this.redCopLight = this.preload.getResult("redCopLight");
  3298. this.wall = this.preload.getResult("wall");
  3299. this.steeringBack = this.preload.getResult("steeringBack");
  3300. this.steeringCircle = this.preload.getResult("steeringCircle");
  3301. this.roadBacking = this.preload.getResult("roadBacking");
  3302. this.crate = this.preload.getResult("crate");
  3303. this.explodingCrate = this.preload.getResult("explodingCrate");
  3304. this.dust = this.preload.getResult("dust");
  3305. this.smoke = this.preload.getResult("smoke");
  3306. this.skid = this.preload.getResult("skid");
  3307. this.white4 = this.preload.getResult("white4");
  3308. this.black4 = this.preload.getResult("black4");
  3309. this.star = this.preload.getResult("star");
  3310. this.circleTimerRing = this.preload.getResult("circleTimerRing");
  3311. this.circleTimerBase = this.preload.getResult("circleTimerBase");
  3312. this.homeBtnDown = this.preload.getResult("homeBtnDown");
  3313. this.homeBtnUp = this.preload.getResult("homeBtnUp");
  3314. this.restartBtnDown = this.preload.getResult("restartBtnDown");
  3315. this.restartBtnUp = this.preload.getResult("restartBtnUp");
  3316. this.playBtnDown = this.preload.getResult("playBtnDown");
  3317. this.playBtnUp = this.preload.getResult("playBtnUp");
  3318. this.bannerEdge = this.preload.getResult("bannerEdge");
  3319. this.bannerSpread = this.preload.getResult("bannerSpread");
  3320. this.bannerShine = this.preload.getResult("bannerShine");
  3321. this.endFade = this.preload.getResult("endFade");
  3322. this.bestGlow = this.preload.getResult("bestGlow");
  3323. this.menuBack = this.preload.getResult("menuBack");
  3324. this.menuSign = this.preload.getResult("menuSign");
  3325. this.menuSignShadow = this.preload.getResult("menuSignShadow");
  3326. this.cloudLine = this.preload.getResult("cloudLine");
  3327. this.explosion = this.preload.getResult("explosion");
  3328. this.explosionSpark = this.preload.getResult("explosionSpark");
  3329. this.flash = this.preload.getResult("flash");
  3330. this.dust = this.preload.getResult("dust");
  3331. this.heliBody = this.preload.getResult("heliBody");
  3332. this.heliBlades = this.preload.getResult("heliBlades");
  3333. this.rock01 = this.preload.getResult("rock01");
  3334. this.rock02 = this.preload.getResult("rock02");
  3335. this.rock03 = this.preload.getResult("rock03");
  3336. this.rock04 = this.preload.getResult("rock04");
  3337. this.sandEdge = this.preload.getResult("sandEdge");
  3338. this.pothole0 = this.preload.getResult("pothole0");
  3339. this.pothole1 = this.preload.getResult("pothole1");
  3340. this.pothole2 = this.preload.getResult("pothole2");
  3341. this.oil = this.preload.getResult("oil");
  3342. this.warningStripe = this.preload.getResult("warningStripe");
  3343. this.dirtArrow = this.preload.getResult("dirtArrow");
  3344. this.dirtRoad = this.preload.getResult("dirtRoad");
  3345. this.dirtTransition = this.preload.getResult("dirtTransition");
  3346. this.dirtSkid = this.preload.getResult("dirtSkid");
  3347. this.blockStanding = this.preload.getResult("blockStanding");
  3348. this.blockFallen = this.preload.getResult("blockFallen");
  3349. this.wrenchParticle = this.preload.getResult("wrenchParticle");
  3350. this.pauseBtn = this.preload.getResult("pauseBtn");
  3351. this.backBtn = this.preload.getResult("backBtn");
  3352. this.pauseBack = this.preload.getResult("pauseBack");
  3353. this.pauseText = this.preload.getResult("pauseText");
  3354. this.tut01 = this.preload.getResult("tut01");
  3355. this.tut02 = this.preload.getResult("tut02");
  3356. this.tutArrow = this.preload.getResult("tutArrow");
  3357. this.wrench = this.preload.getResult("wrench");
  3358. this.wrenchStar = this.preload.getResult("wrenchStar");
  3359. this.hitOn = this.preload.getResult("hitOn");
  3360. this.hitOff = this.preload.getResult("hitOff");
  3361. this.soundOn = this.preload.getResult("soundOn");
  3362. this.soundOff = this.preload.getResult("soundOff");
  3363. this.preloadDeviceLarge = this.preload.getResult("preloadDeviceLarge");
  3364. this.ffBadge = this.preload.getResult("ffBadge");
  3365. this.moreGames = this.preload.getResult("moreGames");
  3366. this.blueCar = this.createCar("#009bc9");
  3367. this.greenCar = this.createCar("#1e9c30");
  3368. this.redCar = this.createCar("#c90000");
  3369. this.purpleCar = this.createCar("#613c73");
  3370. this.silverCar = this.createCar("#dbdbdb");
  3371. this.orangeCar = this.createCar("#ff9607");
  3372. this.blueCarCrash = this.createCar("#009bc9", "crash");
  3373. this.greenCarCrash = this.createCar("#1e9c30", "crash");
  3374. this.redCarCrash = this.createCar("#c90000", "crash");
  3375. this.purpleCarCrash = this.createCar("#613c73", "crash");
  3376. this.silverCarCrash = this.createCar("#dbdbdb", "crash");
  3377. this.orangeCarCrash = this.createCar("#ff9607", "crash");
  3378. this.blueCarExploded = this.createCar("#009bc9", "exploded");
  3379. this.greenCarExploded = this.createCar("#1e9c30", "exploded");
  3380. this.redCarExploded = this.createCar("#c90000", "exploded");
  3381. this.purpleCarExploded = this.createCar("#613c73", "exploded");
  3382. this.silverCarExploded = this.createCar("#dbdbdb", "exploded");
  3383. this.orangeCarExploded = this.createCar("#ff9607", "exploded");
  3384. this.copCarExploded = document.createElement("canvas");
  3385. this.copCarExploded.width = this.copCar.width;
  3386. this.copCarExploded.height = this.copCar.height;
  3387. var c = this.copCarExploded.getContext("2d");
  3388. c.drawImage(this.copCar, 0, 0);
  3389. c.drawImage(this.carExplosionLayer, 0, 0);
  3390. this.carSprites = [];
  3391. this.carSprites.push(this.blueCar);
  3392. this.carSprites.push(this.greenCar);
  3393. this.carSprites.push(this.redCar);
  3394. this.carSprites.push(this.purpleCar);
  3395. this.carSprites.push(this.silverCar);
  3396. this.carSprites.push(this.orangeCar);
  3397. this.crashSprites = [];
  3398. this.crashSprites.push(this.blueCarCrash);
  3399. this.crashSprites.push(this.greenCarCrash);
  3400. this.crashSprites.push(this.redCarCrash);
  3401. this.crashSprites.push(this.purpleCarCrash);
  3402. this.crashSprites.push(this.silverCarCrash);
  3403. this.crashSprites.push(this.orangeCarCrash);
  3404. this.explodeSprites = [];
  3405. this.explodeSprites.push(this.blueCarExploded);
  3406. this.explodeSprites.push(this.greenCarExploded);
  3407. this.explodeSprites.push(this.redCarExploded);
  3408. this.explodeSprites.push(this.purpleCarExploded);
  3409. this.explodeSprites.push(this.silverCarExploded);
  3410. this.explodeSprites.push(this.orangeCarExploded);
  3411. switch (gCurrentBrand) {
  3412. case BRAND.ADDICTING:
  3413. this.addictingEnd = this.preload.getResult("addictingEnd");
  3414. this.addictingMenu = this.preload.getResult("addictingMenu");
  3415. this.addictingSplash = this.preload.getResult("addictingSplash");
  3416. break;
  3417. case BRAND.MRG:
  3418. this.mrgEnd = this.preload.getResult("mrgEnd");
  3419. this.mrgMenu = this.preload.getResult("mrgMenu");
  3420. this.mrgSplash = this.preload.getResult("mrgSplash");
  3421. break
  3422. }
  3423. if (this.preloader) {
  3424. this.preloader.end(init);
  3425. this.preloader = null
  3426. }
  3427. };
  3428. this.createCar = function(h, j) {
  3429. if (j == null) {
  3430. j = ""
  3431. }
  3432. var d = 97;
  3433. var m = 65;
  3434. switch (j) {
  3435. case "crash":
  3436. d = 101;
  3437. m = 71;
  3438. break
  3439. }
  3440. var i = document.createElement("canvas");
  3441. i.width = d;
  3442. i.height = m;
  3443. var e = i.getContext("2d");
  3444. var l = this.carLayer0;
  3445. switch (j) {
  3446. case "crash":
  3447. l = this.carCrashLayer0;
  3448. break
  3449. }
  3450. e.drawImage(l, 0, 0);
  3451. var k = hexToRGB(h);
  3452. var f = [k.r / 255, 0, 0, 0, 0, 0, k.g / 255, 0, 0, 0, 0, 0, k.b / 255, 0, 0, 0, 0, 0, 1, 0];
  3453. var n = document.createElement("canvas");
  3454. n.width = d;
  3455. n.height = m;
  3456. var c = n.getContext("2d");
  3457. l = this.carLayer1;
  3458. switch (j) {
  3459. case "crash":
  3460. l = this.carCrashLayer1;
  3461. break
  3462. }
  3463. c.drawImage(l, 0, 0);
  3464. var g = colorMatrixFilter(c.getImageData(0, 0, d, m), f);
  3465. c.clearRect(0, 0, d, m);
  3466. c.putImageData(g, 0, 0);
  3467. e.drawImage(n, 0, 0);
  3468. f[0] *= 0.6667;
  3469. f[6] *= 0.6667;
  3470. f[12] *= 0.6667;
  3471. c.clearRect(0, 0, d, m);
  3472. l = this.carLayer2;
  3473. switch (j) {
  3474. case "crash":
  3475. l = this.carCrashLayer2;
  3476. break
  3477. }
  3478. c.drawImage(l, 0, 0);
  3479. g = colorMatrixFilter(c.getImageData(0, 0, d, m), f);
  3480. c.clearRect(0, 0, d, m);
  3481. c.putImageData(g, 0, 0);
  3482. e.drawImage(n, 0, 0);
  3483. f[0] = Math.min(1, k.r / 255 * 2);
  3484. f[6] = Math.min(1, k.g / 255 * 2);
  3485. f[12] = Math.min(1, k.b / 255 * 2);
  3486. c.clearRect(0, 0, d, m);
  3487. l = this.carLayer3;
  3488. switch (j) {
  3489. case "crash":
  3490. l = this.carCrashLayer3;
  3491. break
  3492. }
  3493. c.drawImage(l, 0, 0);
  3494. g = colorMatrixFilter(c.getImageData(0, 0, d, m), f);
  3495. c.clearRect(0, 0, d, m);
  3496. c.putImageData(g, 0, 0);
  3497. e.drawImage(n, 0, 0);
  3498. l = this.carLayer4;
  3499. switch (j) {
  3500. case "crash":
  3501. l = this.carCrashLayer4;
  3502. break
  3503. }
  3504. e.drawImage(l, 0, 0);
  3505. if (j == "exploded") {
  3506. e.drawImage(content.carExplosionLayer, 0, 0)
  3507. }
  3508. return i
  3509. }
  3510. };
  3511. var AUDIO_STATE = {
  3512. NONE: 0,
  3513. MENULOOP: 1,
  3514. GAMELOOP: 2
  3515. };
  3516. var currentAudioState = AUDIO_STATE.NONE;
  3517. var musicInstance = null;
  3518. var soundMuted = false;
  3519. var musicMuted = false;
  3520. function setAudioState(a) {
  3521. currentAudioState = a;
  3522. if (musicInstance) {
  3523. musicInstance.stop()
  3524. }
  3525. switch (currentAudioState) {
  3526. case AUDIO_STATE.NONE:
  3527. break;
  3528. case AUDIO_STATE.MENULOOP:
  3529. musicInstance = createjs.Sound.play("menuLoop", {
  3530. loop: -1
  3531. });
  3532. break;
  3533. case AUDIO_STATE.GAMELOOP:
  3534. musicInstance = createjs.Sound.play("gameLoop", {
  3535. loop: -1
  3536. });
  3537. break
  3538. }
  3539. if (musicInstance && musicMuted) {
  3540. musicInstance.setVolume(0)
  3541. }
  3542. }
  3543. function playSound(a) {
  3544. createjs.Sound.play(a, {
  3545. volume: soundMuted ? 0 : 1
  3546. })
  3547. }
  3548. function setSoundMute(a) {
  3549. soundMuted = a;
  3550. if (gStorageAvailable) {
  3551. setLocalVar("soundMuted", soundMuted)
  3552. }
  3553. }
  3554. function setMusicMute(a) {
  3555. musicMuted = a;
  3556. if (gStorageAvailable) {
  3557. setLocalVar("musicMuted", musicMuted)
  3558. }
  3559. if (musicInstance) {
  3560. if (musicMuted) {
  3561. musicInstance.setVolume(0)
  3562. } else {
  3563. musicInstance.setVolume(1)
  3564. }
  3565. }
  3566. }
  3567. var ColliderType = {
  3568. NULL: 0,
  3569. CIRCLE: 1,
  3570. LINE: 2
  3571. };
  3572. function Collider() {
  3573. this.active;
  3574. this.colliding;
  3575. this.sensor;
  3576. this.lastCollisionObject;
  3577. this.initialized = false;
  3578. this.type = ColliderType.NULL
  3579. }
  3580. Collider.prototype.init = function() {
  3581. this.active = true;
  3582. this.sensor = false;
  3583. this.initialized = true;
  3584. this.colliding = false;
  3585. this.lastCollisionObject = null
  3586. };
  3587. Collider.prototype.draw = function(a) {};
  3588. var Collision = new function() {
  3589. this.getCollision = function(d, c) {
  3590. if (!d.active || !c.active) {
  3591. return null
  3592. }
  3593. if (d.type === ColliderType.CIRCLE) {
  3594. if (c.type === ColliderType.CIRCLE) {
  3595. return this.intersectCircleCircle(d, c)
  3596. } else {
  3597. if (c.type === ColliderType.LINE) {
  3598. return this.intersectCircleLine(d, c)
  3599. }
  3600. }
  3601. } else {
  3602. if (d.type === ColliderType.LINE) {
  3603. if (c.type === ColliderType.CIRCLE) {
  3604. return this.intersectCircleLine(c, d)
  3605. } else {
  3606. return this.intersectLineLine(d, c)
  3607. }
  3608. }
  3609. }
  3610. return null
  3611. };
  3612. this.intersectCircleLine = function(b, a) {
  3613. this.dirX = a.x1 - a.x0;
  3614. this.dirY = a.y1 - a.y0;
  3615. this.diffX = b.x - a.x0;
  3616. this.diffY = b.y - a.y0;
  3617. this.t = (this.diffX * this.dirX + this.diffY * this.dirY) / (this.dirX * this.dirX + this.dirY * this.dirY);
  3618. if (this.t < 0) {
  3619. this.t = 0
  3620. }
  3621. if (this.t > 1) {
  3622. this.t = 1
  3623. }
  3624. this.closestX = a.x0 + this.dirX * this.t;
  3625. this.closestY = a.y0 + this.dirY * this.t;
  3626. this.closestX -= b.x;
  3627. this.closestY -= b.y;
  3628. this.r = b.radius;
  3629. this.dot = (this.closestX * this.closestX) + (this.closestY * this.closestY);
  3630. if (this.dot <= this.r * this.r) {
  3631. b.colliding = true;
  3632. a.colliding = true;
  3633. if (b.sensor || a.sensor) {
  3634. return null
  3635. }
  3636. this.dirX = -this.closestX;
  3637. this.dirY = -this.closestY;
  3638. this.len = Math.sqrt((this.dirX * this.dirX) + (this.dirY * this.dirY));
  3639. if (this.len != 0) {
  3640. this.dirX /= this.len;
  3641. this.dirY /= this.len
  3642. } else {
  3643. this.dirX = 1;
  3644. this.dirY = 0
  3645. }
  3646. this.mag = this.r - this.len;
  3647. if (!this.result) {
  3648. this.result = new CollisionResult()
  3649. }
  3650. this.result.set(this.mag, this.dirX, this.dirY, this.closestX + b.x, this.closestY + b.y);
  3651. return this.result
  3652. }
  3653. return null
  3654. };
  3655. this.intersectCircleCircle = function(b, a) {
  3656. this.a = b.x - a.x;
  3657. this.b = b.y - a.y;
  3658. this.r = b.radius + a.radius;
  3659. if (Math.abs(b.x - a.x) > this.r || Math.abs(b.y - a.y) > this.r) {
  3660. return null
  3661. }
  3662. this.dirX = b.x - a.x;
  3663. this.dirY = b.y - a.y;
  3664. this.d = (this.a * this.a + this.b * this.b);
  3665. if (this.d < this.r * this.r && this.d != 0) {
  3666. b.colliding = true;
  3667. a.colliding = true;
  3668. if (b.sensor || a.sensor) {
  3669. return null
  3670. }
  3671. this.d = Math.sqrt(this.d);
  3672. this.dirX /= this.d;
  3673. this.dirY /= this.d;
  3674. this.mag = this.r - this.d;
  3675. if (!this.result) {
  3676. this.result = new CollisionResult()
  3677. }
  3678. this.result.set(this.mag, this.dirX, this.dirY, b.x + this.dirX * b.radius, b.y + this.dirY * b.radius);
  3679. return this.result
  3680. }
  3681. return null
  3682. };
  3683. this.intersectLineLine = function(b, a) {
  3684. if (!b.active || !a.active) {
  3685. return null
  3686. }
  3687. if ((b.x0 == a.x0 && b.y0 == a.y0) || (b.x1 == a.x1 && b.y1 == a.y1)) {
  3688. return null
  3689. }
  3690. this.min1 = Number.MAX_VALUE;
  3691. this.min2 = Number.MAX_VALUE;
  3692. this.max1 = -Number.MAX_VALUE;
  3693. this.max2 = -Number.MAX_VALUE;
  3694. this.minOverlap = Number.MAX_VALUE;
  3695. this.overlapAxisX = 0;
  3696. this.overlapAxisY = 0;
  3697. this.axisX = 0;
  3698. this.axisY = 0;
  3699. this.vertX = 0;
  3700. this.vertY = 0;
  3701. for (var c = 0; c < 2; c++) {
  3702. this.axisX = 0;
  3703. this.axisY = 0;
  3704. this.min1 = Number.MAX_VALUE;
  3705. this.min2 = Number.MAX_VALUE;
  3706. this.max1 = -Number.MAX_VALUE;
  3707. this.max2 = -Number.MAX_VALUE;
  3708. if (c == 0) {
  3709. this.axisX = -(b.y1 - b.y0);
  3710. this.axisY = b.x1 - b.x0
  3711. } else {
  3712. this.axisX = -(a.y1 - a.y0);
  3713. this.axisY = a.x1 - a.x0
  3714. }
  3715. this.len = Math.sqrt(this.axisX * this.axisX + this.axisY * this.axisY);
  3716. this.axisX /= this.len;
  3717. this.axisY /= this.len;
  3718. for (var d = 0; d < (c == 0 ? 1 : 2); d++) {
  3719. this.vertX = 0;
  3720. this.vertY = 0;
  3721. switch (d) {
  3722. case 0:
  3723. this.vertX = b.x0;
  3724. this.vertY = b.y0;
  3725. break;
  3726. case 1:
  3727. this.vertX = b.x1;
  3728. this.vertY = b.y1;
  3729. break
  3730. }
  3731. this.max1 = Math.max((this.vertX * this.axisX + this.vertY * this.axisY), this.max1);
  3732. this.min1 = Math.min((this.vertX * this.axisX + this.vertY * this.axisY), this.min1)
  3733. }
  3734. for (var d = 0; d < (c == 1 ? 1 : 2); d++) {
  3735. this.vertX = 0;
  3736. this.vertY = 0;
  3737. switch (d) {
  3738. case 0:
  3739. this.vertX = a.x0;
  3740. this.vertY = a.y0;
  3741. break;
  3742. case 1:
  3743. this.vertX = a.x1;
  3744. this.vertY = a.y1;
  3745. break
  3746. }
  3747. this.max2 = Math.max((this.vertX * this.axisX + this.vertY * this.axisY), this.max2);
  3748. this.min2 = Math.min((this.vertX * this.axisX + this.vertY * this.axisY), this.min2)
  3749. }
  3750. if (this.min1 < this.min2) {
  3751. if (c == 0) {
  3752. this.minOverlap = this.min2 - this.max1;
  3753. this.overlapAxisX = this.axisX;
  3754. this.overlapAxisY = this.axisY
  3755. }
  3756. if (this.min2 - this.max1 > 0) {
  3757. return null
  3758. } else {
  3759. if (this.min2 - this.max1 > this.minOverlap) {
  3760. this.minOverlap = this.min2 - this.max1;
  3761. this.overlapAxisX = this.axisX;
  3762. this.overlapAxisY = this.axisY
  3763. }
  3764. }
  3765. } else {
  3766. if (c == 0) {
  3767. this.minOverlap = this.min1 - this.max2;
  3768. this.overlapAxisX = -this.axisX;
  3769. this.overlapAxisY = -this.axisY
  3770. }
  3771. if (this.min1 - this.max2 > 0) {
  3772. return null
  3773. } else {
  3774. if (this.min1 - this.max2 > this.minOverlap) {
  3775. this.minOverlap = this.min1 - this.max2;
  3776. this.overlapAxisX = -this.axisX;
  3777. this.overlapAxisY = -this.axisY
  3778. }
  3779. }
  3780. }
  3781. }
  3782. if (!this.result) {
  3783. this.result = new CollisionResult()
  3784. }
  3785. this.result.set(-this.minOverlap, this.overlapAxisX, this.overlapAxisY, 0, 0);
  3786. return this.result
  3787. }
  3788. };
  3789. function CollisionResult() {
  3790. this.magnitude = 0;
  3791. this.directionX = 1;
  3792. this.directionY = 0;
  3793. this.x = 0;
  3794. this.y = 0
  3795. }
  3796. CollisionResult.prototype.set = function(d, c, b, a, e) {
  3797. this.magnitude = d;
  3798. this.directionX = c;
  3799. this.directionY = b;
  3800. this.x = a;
  3801. this.y = e
  3802. };
  3803. function CircleCollider() {
  3804. this.radius;
  3805. this.x;
  3806. this.y
  3807. }
  3808. CircleCollider.prototype = new Collider();
  3809. CircleCollider.prototype.constructor = CircleCollider;
  3810. CircleCollider.prototype.init = function(b, c, a) {
  3811. this.type = ColliderType.CIRCLE;
  3812. this.active = true;
  3813. this.initialized = true;
  3814. this.sensor = false;
  3815. this.colliding = false;
  3816. this.radius = a;
  3817. this.x = b;
  3818. this.y = c
  3819. };
  3820. CircleCollider.prototype.draw = function(c) {
  3821. if (!this.initialized) {
  3822. return
  3823. }
  3824. var b = document.createElement("canvas");
  3825. b.width = this.radius * 2;
  3826. b.height = this.radius * 2;
  3827. var a = b.getContext("2d");
  3828. a.strokeStyle = "#00FF00";
  3829. a.lineWidth = 2;
  3830. a.lineWidth = 0;
  3831. a.beginPath();
  3832. a.arc(this.radius, this.radius, this.radius, 0, Math.PI * 2);
  3833. a.stroke();
  3834. var e = new Drawable();
  3835. e.init(b, this.x, this.y);
  3836. e.originX = this.radius;
  3837. e.originY = this.radius;
  3838. e.sceneManager = c;
  3839. e.draw()
  3840. };
  3841. function LineCollider() {
  3842. this.x0;
  3843. this.y0;
  3844. this.x1;
  3845. this.y1
  3846. }
  3847. LineCollider.prototype = new Collider();
  3848. LineCollider.prototype.constructor = LineCollider;
  3849. LineCollider.prototype.init = function(b, d, a, c) {
  3850. this.type = ColliderType.LINE;
  3851. this.active = true;
  3852. this.initialized = true;
  3853. this.sensor = false;
  3854. this.colliding = false;
  3855. this.x0 = b;
  3856. this.y0 = d;
  3857. this.x1 = a;
  3858. this.y1 = c;
  3859. this.basex0 = b;
  3860. this.basey0 = d;
  3861. this.basex1 = a;
  3862. this.basey1 = c;
  3863. this.offsetX = 0;
  3864. this.offsetY = 0
  3865. };
  3866. LineCollider.prototype.update = function() {
  3867. this.x0 = this.basex0 + this.offsetX;
  3868. this.y0 = this.basey0 + this.offsetY;
  3869. this.x1 = this.basex1 + this.offsetX;
  3870. this.y1 = this.basey1 + this.offsetY
  3871. };
  3872. LineCollider.prototype.draw = function(a) {
  3873. if (!this.initialized) {
  3874. return
  3875. }
  3876. var b = Math.sqrt(((this.x1 - this.x0) * (this.x1 - this.x0)) + ((this.y1 - this.y0) * (this.y1 - this.y0)));
  3877. var e = Math.atan2(this.y1 - this.y0, this.x1 - this.x0);
  3878. var c = new Drawable();
  3879. c.init(content.pixel, this.x0, this.y0);
  3880. c.originY = 0.5;
  3881. c.scaleX = b;
  3882. c.scaleY = 4;
  3883. c.angle = e;
  3884. c.sceneManager = a;
  3885. c.update(0);
  3886. c.draw()
  3887. };
  3888. var OnFinishAnimation = {
  3889. STOP: 0,
  3890. LOOP: 1,
  3891. REWIND: 2,
  3892. REWINDLOOP: 3,
  3893. RESET: 4
  3894. };
  3895. var AnimationState = {
  3896. STOPPED: 0,
  3897. PLAYING: 1,
  3898. REWINDING: 2
  3899. };
  3900. function Animation() {
  3901. this.name = "";
  3902. this.framesPerSecond = 1;
  3903. this.currentFrame = 0;
  3904. this.frames = [];
  3905. this.finishAction = OnFinishAnimation.STOP;
  3906. this.currentState = AnimationState.STOPPED;
  3907. this.timer = 0;
  3908. this.frameSwitched = false
  3909. }
  3910. Animation.prototype.init = function(a, b, d, c) {
  3911. this.name = a;
  3912. this.frames = b;
  3913. this.framesPerSecond = d;
  3914. this.finishAction = c;
  3915. this.currentState = AnimationState.STOPPED;
  3916. this.currentFrame = 0;
  3917. this.frameSwitched = false;
  3918. this.timer = 0
  3919. };
  3920. Animation.prototype.update = function(a) {
  3921. this.frameSwitched = false;
  3922. switch (this.currentState) {
  3923. case AnimationState.PLAYING:
  3924. this.timer += a;
  3925. while (this.timer >= 1 / this.framesPerSecond) {
  3926. this.timer -= 1 / this.framesPerSecond;
  3927. this.currentFrame++;
  3928. this.frameSwitched = true;
  3929. if (this.currentFrame >= this.frames.length) {
  3930. this.AnimationFinished()
  3931. }
  3932. }
  3933. break;
  3934. case AnimationState.STOPPED:
  3935. break;
  3936. case AnimationState.REWINDING:
  3937. this.timer += a;
  3938. while (this.timer >= 1 / this.framesPerSecond) {
  3939. this.timer -= 1 / this.framesPerSecond;
  3940. this.currentFrame--;
  3941. this.frameSwitched = true;
  3942. if (this.currentFrame < 0) {
  3943. this.AnimationFinished()
  3944. }
  3945. }
  3946. break;
  3947. default:
  3948. break
  3949. }
  3950. };
  3951. Animation.prototype.ResetTimer = function() {
  3952. this.timer = 0
  3953. };
  3954. Animation.prototype.SetState = function(a) {
  3955. this.currentState = a
  3956. };
  3957. Animation.prototype.SetFrame = function(a) {
  3958. this.currentFrame = a
  3959. };
  3960. Animation.prototype.AnimationFinished = function() {
  3961. switch (this.finishAction) {
  3962. case OnFinishAnimation.LOOP:
  3963. this.currentFrame = 0;
  3964. this.timer = 0;
  3965. this.currentState = AnimationState.PLAYING;
  3966. break;
  3967. case OnFinishAnimation.REWIND:
  3968. if (this.currentState != AnimationState.REWINDING) {
  3969. this.timer = 0;
  3970. this.currentFrame -= 2;
  3971. this.currentState = AnimationState.REWINDING
  3972. } else {
  3973. this.currentFrame = 0;
  3974. this.currentState = AnimationState.STOPPED
  3975. }
  3976. break;
  3977. case OnFinishAnimation.REWINDLOOP:
  3978. if (this.currentState != AnimationState.REWINDING) {
  3979. this.timer = 0;
  3980. this.currentFrame -= 2;
  3981. this.currentState = AnimationState.REWINDING
  3982. } else {
  3983. this.timer = 0;
  3984. this.currentFrame += 2;
  3985. this.currentState = AnimationState.PLAYING
  3986. }
  3987. break;
  3988. case OnFinishAnimation.STOP:
  3989. this.currentFrame = this.frames.length - 1;
  3990. this.currentState = AnimationState.STOPPED;
  3991. break;
  3992. case OnFinishAnimation.RESET:
  3993. this.currentFrame = 0;
  3994. this.currentState = AnimationState.STOPPED;
  3995. break;
  3996. default:
  3997. break
  3998. }
  3999. };
  4000. function Camera() {
  4001. this.active;
  4002. this.originX;
  4003. this.originY;
  4004. this.lockX;
  4005. this.lockY;
  4006. this.pixelSnap;
  4007. this.internalMatrix;
  4008. this.useTarget;
  4009. this.useAcceleration;
  4010. this.positionX;
  4011. this.positionY;
  4012. this.velocityX;
  4013. this.velocityY;
  4014. this.accelerationX;
  4015. this.accelerationY;
  4016. this.dragX;
  4017. this.dragY;
  4018. this.targetPositionX;
  4019. this.targetPositionY;
  4020. this.directionX;
  4021. this.directionY;
  4022. this.movementSpeed;
  4023. this.lockStartX;
  4024. this.lockStartY;
  4025. this.angle;
  4026. this.rotationSpeed;
  4027. this.rotationVelocity;
  4028. this.targetAngle;
  4029. this.zoom;
  4030. this.zoomTarget;
  4031. this.zoomSpeed;
  4032. this.shakeTimer;
  4033. this.shakeTime;
  4034. this.shakeFrequency;
  4035. this.shakeStartTime;
  4036. this.shakeSamplesX = [];
  4037. this.shakeSamplesY = [];
  4038. this.isShaking = false;
  4039. this.shakeMagnitude;
  4040. this.init = function(a, d, c, b) {
  4041. this.originX = 400;
  4042. this.originY = 240;
  4043. this.setPosition(a, d);
  4044. this.setAngle(c);
  4045. this.setZoom(b);
  4046. this.active = true;
  4047. this.lockX = false;
  4048. this.lockY = false;
  4049. this.pixelSnap = false;
  4050. this.useTarget = true;
  4051. this.useAcceleration = true;
  4052. this.velocityX = 0;
  4053. this.velocityY = 0;
  4054. this.oldVelocityX = 0;
  4055. this.oldVelocityY = 0;
  4056. this.accelerationX = 0;
  4057. this.accelerationY = 0;
  4058. this.movementSpeed = 40;
  4059. this.dragX = 0.001;
  4060. this.dragY = 0.001;
  4061. this.directionX = 0;
  4062. this.directionY = 0;
  4063. this.directionLength;
  4064. this.displacement;
  4065. this.force;
  4066. this.rotationSpeed = 0.5;
  4067. this.rotationVelocity = 0;
  4068. this.zoomSpeed = 0.75;
  4069. this.shakeTimer = 0;
  4070. this.shakeTime = 0;
  4071. this.shakeMagnitude = 0;
  4072. this.shakeOffsetX = 0;
  4073. this.shakeOffsetY = 0;
  4074. this.internalMatrix = mat2d.create();
  4075. mat2d.identity(this.internalMatrix)
  4076. };
  4077. this.update = function(a) {
  4078. this.originX = canvas.width * 0.5;
  4079. this.originY = canvas.height * 0.5;
  4080. if (this.active) {
  4081. if (this.useTarget) {
  4082. this.displacement = distanceBetweenPoints(this.positionX, this.positionY, this.targetPositionX, this.targetPositionY);
  4083. if (this.useAcceleration) {
  4084. if (this.displacement !== 0) {
  4085. this.force = -this.displacement * this.movementSpeed;
  4086. this.directionX = this.positionX - this.targetPositionX;
  4087. this.directionY = this.positionY - this.targetPositionY;
  4088. this.directionLength = distanceBetweenPoints(0, 0, this.directionX, this.directionY);
  4089. this.directionX /= this.directionLength;
  4090. this.directionY /= this.directionLength;
  4091. this.accelerationX += this.directionX * this.force;
  4092. this.accelerationY += this.directionY * this.force
  4093. }
  4094. this.oldVelocityX = this.velocityX;
  4095. this.oldVelocityY = this.velocityY;
  4096. this.velocityX += this.accelerationX * a;
  4097. this.velocityY += this.accelerationY * a;
  4098. this.positionX += ((this.oldVelocityX + this.velocityX) * (0.5 * a) * (this.lockX ? 0 : 1));
  4099. this.positionY += ((this.oldVelocityY + this.velocityY) * (0.5 * a) * (this.lockY ? 0 : 1));
  4100. this.accelerationX = 0;
  4101. this.accelerationY = 0;
  4102. if (this.dragX != 1) {
  4103. this.velocityX *= Math.pow(this.dragX, a)
  4104. }
  4105. if (this.dragY != 1) {
  4106. this.velocityY *= Math.pow(this.dragY, a)
  4107. }
  4108. } else {
  4109. this.positionX = this.targetPositionX;
  4110. this.positionY = this.targetPositionY
  4111. }
  4112. }
  4113. if (this.angle < this.targetAngle) {
  4114. this.angle = Math.min(this.targetAngle, this.angle + this.rotationSpeed * a)
  4115. } else {
  4116. if (this.angle > this.targetAngle) {
  4117. this.angle = Math.max(this.targetAngle, this.angle - this.rotationSpeed * a)
  4118. }
  4119. }
  4120. this.angle = normalizeAngle(this.angle);
  4121. if (this.pixelSnap) {
  4122. this.positionX = Math.floor(this.positionX);
  4123. this.positionY = Math.floor(this.positionY)
  4124. }
  4125. }
  4126. };
  4127. this.setPosition = function(a, b) {
  4128. this.setTargetPosition(a, b);
  4129. this.positionX = this.targetPositionX;
  4130. this.positionY = this.targetPositionY;
  4131. this.velocityX = 0;
  4132. this.velocityY = 0
  4133. };
  4134. this.setTargetPosition = function(a, b) {
  4135. this.targetPositionX = -a;
  4136. this.targetPositionY = -b
  4137. };
  4138. this.moveTargetPosition = function(b, a) {
  4139. this.targetPositionX += b;
  4140. this.targetPositionY += a
  4141. };
  4142. this.setZoom = function(a) {
  4143. this.setZoomTarget(a);
  4144. this.zoom = a
  4145. };
  4146. this.setZoomTarget = function(a) {
  4147. this.zoomTarget = a
  4148. };
  4149. this.setAngle = function(b) {
  4150. this.setTargetAngle(b);
  4151. this.angle = b
  4152. };
  4153. this.setTargetAngle = function(b) {
  4154. this.targetAngle = b
  4155. };
  4156. this.shake = function(e, d, c) {
  4157. this.shakeTime = e;
  4158. this.shakeTimer = e;
  4159. this.shakeFrequency = d;
  4160. this.shakeMagnitude = c;
  4161. var a = (this.shakeTime) * d;
  4162. this.shakeSamplesX = [];
  4163. this.shakeSamplesY = [];
  4164. for (var b = 0; b < a; b++) {
  4165. this.shakeSamplesX.push(Math.random() * 2 - 1);
  4166. this.shakeSamplesY.push(Math.random() * 2 - 1)
  4167. }
  4168. };
  4169. this.getShakeX = function() {
  4170. var d = (1 - (this.shakeTimer / this.shakeTime)) * (this.shakeSamplesX.length - 2);
  4171. var c = Math.floor(d);
  4172. var b = c + 1;
  4173. var a = this.shakeDecay(this.shakeTimer);
  4174. return (this.shakeSamplesX[c] + (d - c) * (this.shakeSamplesX[b] - this.shakeSamplesX[c])) * a * this.shakeMagnitude
  4175. };
  4176. this.getShakeY = function() {
  4177. var d = (1 - (this.shakeTimer / this.shakeTime)) * (this.shakeSamplesY.length - 2);
  4178. var c = Math.floor(d);
  4179. var b = c + 1;
  4180. var a = this.shakeDecay(this.shakeTimer);
  4181. var e = (this.shakeSamplesY[c] + (d - c) * (this.shakeSamplesY[b] - this.shakeSamplesY[c])) * a * this.shakeMagnitude;
  4182. return e
  4183. };
  4184. this.shakeDecay = function(a) {
  4185. if (this.shakeTimer <= 0) {
  4186. return 0
  4187. }
  4188. return this.shakeTimer / this.shakeTime
  4189. }
  4190. }
  4191. function Entity() {
  4192. this.x = 0;
  4193. this.y = 0;
  4194. this.canvasWidth = 0;
  4195. this.canvasHeight = 0;
  4196. this.useCamera = true;
  4197. this.toBeRemoved = false;
  4198. this.depth = 0;
  4199. this.visible = true;
  4200. this.useDepthSort = true;
  4201. this.sceneManager = null;
  4202. this.hasUpdated = true
  4203. }
  4204. Entity.prototype.init = function() {
  4205. this.x = 0;
  4206. this.y = 0;
  4207. this.toBeRemoved = false;
  4208. this.useCamera = true
  4209. };
  4210. Entity.prototype.update = function(a) {};
  4211. Entity.prototype.draw = function() {};
  4212. Entity.prototype.onAddedToSceneManager = function() {};
  4213. Entity.prototype.flagForRemoval = function() {
  4214. this.toBeRemoved = true
  4215. };
  4216. function Drawable() {
  4217. Entity.call(this);
  4218. this.sprite = null;
  4219. this.angle = 0;
  4220. this.originX = 0;
  4221. this.originY = 0;
  4222. this.scaleX = 1;
  4223. this.scaleY = 1;
  4224. this.alpha = 1;
  4225. this.sourceRectX = 0;
  4226. this.sourceRectY = 0;
  4227. this.sourceRectW = 0;
  4228. this.sourceRectH = 0;
  4229. this.useSourceRect = false;
  4230. this.useParallax = false;
  4231. this.parent = null;
  4232. this.visible = true;
  4233. this.active = true;
  4234. this.worldX = 0;
  4235. this.worldY = 0;
  4236. this.hasUpdated = true;
  4237. this.useMask = false;
  4238. this.mask = null;
  4239. this.maskX = 0;
  4240. this.maskY = 0;
  4241. this.maskOriginX = 0;
  4242. this.maskOriginY = 0;
  4243. this.maskAngle = 0;
  4244. this.maskCanvas;
  4245. this.drawingSM;
  4246. this.sceneAlpha;
  4247. this.internalMatrix;
  4248. this._originTransformVec2;
  4249. this._scaleTransformVec2;
  4250. this._translateTransformVec2
  4251. }
  4252. Drawable.prototype = new Entity();
  4253. Drawable.prototype.constructor = Drawable;
  4254. Drawable.prototype.init = function(b, a, c) {
  4255. this.sprite = b;
  4256. this.x = a;
  4257. this.y = c;
  4258. this.toBeRemoved = false;
  4259. this.useCamera = true;
  4260. this._originTransformVec2 = vec2.create();
  4261. this._scaleTransformVec2 = vec2.create();
  4262. this._translateTransformVec2 = vec2.create()
  4263. };
  4264. Drawable.prototype.update = function(a) {
  4265. if (!this.active) {
  4266. return
  4267. }
  4268. this.hasUpdated = true
  4269. };
  4270. Drawable.prototype.draw = function(c) {
  4271. if (!this.visible || this.alpha <= 0 || !this.sprite) {
  4272. return
  4273. }
  4274. if (this.sprite.width <= 0 || this.sprite.height <= 0) {
  4275. return
  4276. }
  4277. c = (c ? c : ctx);
  4278. c.save();
  4279. this.worldX = 0;
  4280. this.worldY = 0;
  4281. this.drawingSM = this.sceneManager;
  4282. var b = false;
  4283. if (this.parent && this.parent.sceneManager) {
  4284. this.drawingSM = this.parent.sceneManager
  4285. }
  4286. this.sceneAlpha = 1;
  4287. if (this.drawingSM) {
  4288. this.sceneAlpha = this.drawingSM.masterAlpha
  4289. }
  4290. c.globalAlpha = this.alpha * this.sceneAlpha;
  4291. var a = this.x;
  4292. var e = this.y;
  4293. if (this.parent) {
  4294. a += this.parent.x;
  4295. e += this.parent.y
  4296. }
  4297. this.worldX += a;
  4298. this.worldY += e;
  4299. if (!this.internalMatrix) {
  4300. this.internalMatrix = mat2d.create()
  4301. }
  4302. mat2d.identity(this.internalMatrix);
  4303. if (this.originX != 0 || this.originY != 0) {
  4304. if (!this._originTransformVec2) {
  4305. this._originTransformVec2 = vec2.create()
  4306. }
  4307. this._originTransformVec2[0] = -this.originX;
  4308. this._originTransformVec2[1] = -this.originY;
  4309. mat2d.translate(this.internalMatrix, this.internalMatrix, this._originTransformVec2)
  4310. }
  4311. if (this.scaleX != 1 || this.scaleY != 1) {
  4312. if (!this._scaleTransformVec2) {
  4313. this._scaleTransformVec2 = vec2.create()
  4314. }
  4315. this._scaleTransformVec2[0] = this.scaleX;
  4316. this._scaleTransformVec2[1] = this.scaleY;
  4317. mat2d.scale(this.internalMatrix, this.internalMatrix, this._scaleTransformVec2)
  4318. }
  4319. if (this.angle != 0) {
  4320. mat2d.rotate(this.internalMatrix, this.internalMatrix, -this.angle)
  4321. }
  4322. if (a != 0 || e != 0) {
  4323. if (!this._translateTransformVec2) {
  4324. this._translateTransformVec2 = vec2.create()
  4325. }
  4326. this._translateTransformVec2[0] = a;
  4327. this._translateTransformVec2[1] = e;
  4328. mat2d.translate(this.internalMatrix, this.internalMatrix, this._translateTransformVec2)
  4329. }
  4330. if (this.drawingSM) {
  4331. if ((!this.parent && this.useCamera) || (this.parent && this.parent.useCamera)) {
  4332. mat2d.multiply(this.internalMatrix, this.internalMatrix, this.drawingSM.camera.internalMatrix)
  4333. }
  4334. }
  4335. c.setTransform(this.internalMatrix[0], this.internalMatrix[1], this.internalMatrix[2], this.internalMatrix[3], this.internalMatrix[4], this.internalMatrix[5]);
  4336. if (this.useMask && this.mask) {
  4337. if (!this.maskCanvas) {
  4338. this.maskCanvas = document.createElement("canvas");
  4339. this.maskCanvas.width = Math.max(this.sprite.width * this.scaleX + this.scaleX * this.originX, this.mask.width);
  4340. this.maskCanvas.height = Math.max(this.sprite.height * this.scaleY + this.scaleY * this.originY, this.mask.height)
  4341. }
  4342. var d = this.maskCanvas.getContext("2d");
  4343. d.clearRect(0, 0, this.maskCanvas.width, this.maskCanvas.height);
  4344. d.save();
  4345. d.translate(this.maskX, this.maskY);
  4346. d.rotate(this.maskAngle);
  4347. d.translate(-this.maskOriginX, -this.maskOriginY);
  4348. d.drawImage(this.mask, 0, 0);
  4349. d.restore();
  4350. d.save();
  4351. d.globalCompositeOperation = "source-in";
  4352. if (this.useSourceRect) {
  4353. d.drawImage(this.sprite, this.sourceRectX, this.sourceRectY, this.sourceRectW, this.sourceRectH, 0, 0, this.sourceRectW, this.sourceRectH)
  4354. } else {
  4355. d.drawImage(this.sprite, 0, 0)
  4356. }
  4357. d.restore();
  4358. if (this.useSourceRect) {
  4359. c.drawImage(this.maskCanvas, this.sourceRectX, this.sourceRectY, this.sourceRectW, this.sourceRectH, 0, 0, this.sourceRectW, this.sourceRectH)
  4360. } else {
  4361. c.drawImage(this.maskCanvas, 0, 0)
  4362. }
  4363. c.globalCompositeOperation = "source-over"
  4364. } else {
  4365. if (this.useSourceRect) {
  4366. c.drawImage(this.sprite, this.sourceRectX, this.sourceRectY, this.sourceRectW, this.sourceRectH, 0, 0, this.sourceRectW, this.sourceRectH)
  4367. } else {
  4368. c.drawImage(this.sprite, 0, 0)
  4369. }
  4370. }
  4371. c.restore()
  4372. };
  4373. Drawable.prototype.mouseOver = function() {
  4374. var e = mouseX;
  4375. var d = mouseY;
  4376. if ((this.useCamera && !this.parent) || (this.parent && this.parent.useCamera)) {
  4377. var g = this.sceneManager;
  4378. if (!g) {
  4379. if (this.parent) {
  4380. g = this.parent.sceneManager
  4381. } else {
  4382. return false
  4383. }
  4384. }
  4385. if (!g) {
  4386. return false
  4387. }
  4388. e = g.worldMouseX;
  4389. d = g.worldMouseY
  4390. }
  4391. var a = this.x - this.originX * this.scaleX;
  4392. var f = this.y - this.originY * this.scaleY;
  4393. if (this.parent) {
  4394. a += this.parent.x;
  4395. f += this.parent.y
  4396. }
  4397. var b = this.sprite.width * this.scaleX;
  4398. var c = this.sprite.height * this.scaleY;
  4399. if (e < a || d < f || e > a + b || d > f + c) {
  4400. return false
  4401. }
  4402. return true
  4403. };
  4404. Drawable.prototype.touchOver = function() {
  4405. var b = null;
  4406. if ((this.useCamera && !this.parent) || (this.parent && this.parent.useCamera)) {
  4407. b = this.sceneManager;
  4408. if (!b) {
  4409. if (this.parent) {
  4410. b = this.parent.sceneManager
  4411. } else {
  4412. return {
  4413. touched: false,
  4414. id: -1
  4415. }
  4416. }
  4417. }
  4418. if (!b) {
  4419. return {
  4420. touched: false,
  4421. id: -1
  4422. }
  4423. }
  4424. }
  4425. for (var d = 0; d < currentTouches.length; d++) {
  4426. var c = currentTouches[d].x;
  4427. var a = currentTouches[d].y;
  4428. if (b) {
  4429. var k = b.viewToWorld(currentTouches[d].x, currentTouches[d].y);
  4430. c = k.x;
  4431. a = k.y
  4432. }
  4433. var g = this.x - this.originX * this.scaleX;
  4434. var f = this.y - this.originY * this.scaleY;
  4435. if (this.parent) {
  4436. g += this.parent.x;
  4437. f += this.parent.y
  4438. }
  4439. var j = this.sprite.width * this.scaleX;
  4440. var e = this.sprite.height * this.scaleY;
  4441. if (c < g || a < f || c > g + j || a > f + e) {
  4442. continue
  4443. }
  4444. currentTouches[d].moved = true;
  4445. return {
  4446. touched: true,
  4447. id: currentTouches[d].id
  4448. }
  4449. }
  4450. return {
  4451. touched: false,
  4452. id: -1
  4453. }
  4454. };
  4455. (function(b) {
  4456. var a = {};
  4457. typeof exports == "undefined" ? typeof define == "function" && typeof define.amd == "object" && define.amd ? (a.exports = {}, define(function() {
  4458. return a.exports
  4459. })) : a.exports = typeof window != "undefined" ? window : b : a.exports = exports,
  4460. function(x) {
  4461. if (!B) {
  4462. var B = 0.000001
  4463. }
  4464. if (!k) {
  4465. var k = typeof Float32Array != "undefined" ? Float32Array : Array
  4466. }
  4467. if (!d) {
  4468. var d = Math.random
  4469. }
  4470. var q = {};
  4471. q.setMatrixArrayType = function(c) {
  4472. k = c
  4473. }, typeof x != "undefined" && (x.glMatrix = q);
  4474. var C = Math.PI / 180;
  4475. q.toRadian = function(c) {
  4476. return c * C
  4477. };
  4478. var j = {};
  4479. j.create = function() {
  4480. var c = new k(2);
  4481. return c[0] = 0, c[1] = 0, c
  4482. }, j.clone = function(f) {
  4483. var c = new k(2);
  4484. return c[0] = f[0], c[1] = f[1], c
  4485. }, j.fromValues = function(h, c) {
  4486. var f = new k(2);
  4487. return f[0] = h, f[1] = c, f
  4488. }, j.copy = function(f, c) {
  4489. return f[0] = c[0], f[1] = c[1], f
  4490. }, j.set = function(f, c, h) {
  4491. return f[0] = c, f[1] = h, f
  4492. }, j.add = function(f, c, h) {
  4493. return f[0] = c[0] + h[0], f[1] = c[1] + h[1], f
  4494. }, j.subtract = function(f, c, h) {
  4495. return f[0] = c[0] - h[0], f[1] = c[1] - h[1], f
  4496. }, j.sub = j.subtract, j.multiply = function(f, c, h) {
  4497. return f[0] = c[0] * h[0], f[1] = c[1] * h[1], f
  4498. }, j.mul = j.multiply, j.divide = function(f, c, h) {
  4499. return f[0] = c[0] / h[0], f[1] = c[1] / h[1], f
  4500. }, j.div = j.divide, j.min = function(f, c, h) {
  4501. return f[0] = Math.min(c[0], h[0]), f[1] = Math.min(c[1], h[1]), f
  4502. }, j.max = function(f, c, h) {
  4503. return f[0] = Math.max(c[0], h[0]), f[1] = Math.max(c[1], h[1]), f
  4504. }, j.scale = function(f, c, h) {
  4505. return f[0] = c[0] * h, f[1] = c[1] * h, f
  4506. }, j.scaleAndAdd = function(h, c, i, f) {
  4507. return h[0] = c[0] + i[0] * f, h[1] = c[1] + i[1] * f, h
  4508. }, j.distance = function(h, c) {
  4509. var i = c[0] - h[0],
  4510. f = c[1] - h[1];
  4511. return Math.sqrt(i * i + f * f)
  4512. }, j.dist = j.distance, j.squaredDistance = function(h, c) {
  4513. var i = c[0] - h[0],
  4514. f = c[1] - h[1];
  4515. return i * i + f * f
  4516. }, j.sqrDist = j.squaredDistance, j.length = function(f) {
  4517. var c = f[0],
  4518. h = f[1];
  4519. return Math.sqrt(c * c + h * h)
  4520. }, j.len = j.length, j.squaredLength = function(f) {
  4521. var c = f[0],
  4522. h = f[1];
  4523. return c * c + h * h
  4524. }, j.sqrLen = j.squaredLength, j.negate = function(f, c) {
  4525. return f[0] = -c[0], f[1] = -c[1], f
  4526. }, j.normalize = function(l, f) {
  4527. var o = f[0],
  4528. h = f[1],
  4529. c = o * o + h * h;
  4530. return c > 0 && (c = 1 / Math.sqrt(c), l[0] = f[0] * c, l[1] = f[1] * c), l
  4531. }, j.dot = function(f, c) {
  4532. return f[0] * c[0] + f[1] * c[1]
  4533. }, j.cross = function(h, c, i) {
  4534. var f = c[0] * i[1] - c[1] * i[0];
  4535. return h[0] = h[1] = 0, h[2] = f, h
  4536. }, j.lerp = function(o, f, p, l) {
  4537. var c = f[0],
  4538. h = f[1];
  4539. return o[0] = c + l * (p[0] - c), o[1] = h + l * (p[1] - h), o
  4540. }, j.random = function(f, c) {
  4541. c = c || 1;
  4542. var h = d() * 2 * Math.PI;
  4543. return f[0] = Math.cos(h) * c, f[1] = Math.sin(h) * c, f
  4544. }, j.transformMat2 = function(l, f, o) {
  4545. var h = f[0],
  4546. c = f[1];
  4547. return l[0] = o[0] * h + o[2] * c, l[1] = o[1] * h + o[3] * c, l
  4548. }, j.transformMat2d = function(l, f, o) {
  4549. var h = f[0],
  4550. c = f[1];
  4551. return l[0] = o[0] * h + o[2] * c + o[4], l[1] = o[1] * h + o[3] * c + o[5], l
  4552. }, j.transformMat3 = function(l, f, o) {
  4553. var h = f[0],
  4554. c = f[1];
  4555. return l[0] = o[0] * h + o[3] * c + o[6], l[1] = o[1] * h + o[4] * c + o[7], l
  4556. }, j.transformMat4 = function(l, f, o) {
  4557. var h = f[0],
  4558. c = f[1];
  4559. return l[0] = o[0] * h + o[4] * c + o[12], l[1] = o[1] * h + o[5] * c + o[13], l
  4560. }, j.forEach = function() {
  4561. var c = j.create();
  4562. return function(l, F, D, h, p, E) {
  4563. var f, e;
  4564. F || (F = 2), D || (D = 0), h ? e = Math.min(h * F + D, l.length) : e = l.length;
  4565. for (f = D; f < e; f += F) {
  4566. c[0] = l[f], c[1] = l[f + 1], p(c, c, E), l[f] = c[0], l[f + 1] = c[1]
  4567. }
  4568. return l
  4569. }
  4570. }(), j.str = function(c) {
  4571. return "vec2(" + c[0] + ", " + c[1] + ")"
  4572. }, typeof x != "undefined" && (x.vec2 = j);
  4573. var A = {};
  4574. A.create = function() {
  4575. var c = new k(3);
  4576. return c[0] = 0, c[1] = 0, c[2] = 0, c
  4577. }, A.clone = function(f) {
  4578. var c = new k(3);
  4579. return c[0] = f[0], c[1] = f[1], c[2] = f[2], c
  4580. }, A.fromValues = function(l, f, h) {
  4581. var c = new k(3);
  4582. return c[0] = l, c[1] = f, c[2] = h, c
  4583. }, A.copy = function(f, c) {
  4584. return f[0] = c[0], f[1] = c[1], f[2] = c[2], f
  4585. }, A.set = function(h, c, i, f) {
  4586. return h[0] = c, h[1] = i, h[2] = f, h
  4587. }, A.add = function(f, c, h) {
  4588. return f[0] = c[0] + h[0], f[1] = c[1] + h[1], f[2] = c[2] + h[2], f
  4589. }, A.subtract = function(f, c, h) {
  4590. return f[0] = c[0] - h[0], f[1] = c[1] - h[1], f[2] = c[2] - h[2], f
  4591. }, A.sub = A.subtract, A.multiply = function(f, c, h) {
  4592. return f[0] = c[0] * h[0], f[1] = c[1] * h[1], f[2] = c[2] * h[2], f
  4593. }, A.mul = A.multiply, A.divide = function(f, c, h) {
  4594. return f[0] = c[0] / h[0], f[1] = c[1] / h[1], f[2] = c[2] / h[2], f
  4595. }, A.div = A.divide, A.min = function(f, c, h) {
  4596. return f[0] = Math.min(c[0], h[0]), f[1] = Math.min(c[1], h[1]), f[2] = Math.min(c[2], h[2]), f
  4597. }, A.max = function(f, c, h) {
  4598. return f[0] = Math.max(c[0], h[0]), f[1] = Math.max(c[1], h[1]), f[2] = Math.max(c[2], h[2]), f
  4599. }, A.scale = function(f, c, h) {
  4600. return f[0] = c[0] * h, f[1] = c[1] * h, f[2] = c[2] * h, f
  4601. }, A.scaleAndAdd = function(h, c, i, f) {
  4602. return h[0] = c[0] + i[0] * f, h[1] = c[1] + i[1] * f, h[2] = c[2] + i[2] * f, h
  4603. }, A.distance = function(l, f) {
  4604. var o = f[0] - l[0],
  4605. h = f[1] - l[1],
  4606. c = f[2] - l[2];
  4607. return Math.sqrt(o * o + h * h + c * c)
  4608. }, A.dist = A.distance, A.squaredDistance = function(l, f) {
  4609. var o = f[0] - l[0],
  4610. h = f[1] - l[1],
  4611. c = f[2] - l[2];
  4612. return o * o + h * h + c * c
  4613. }, A.sqrDist = A.squaredDistance, A.length = function(h) {
  4614. var c = h[0],
  4615. i = h[1],
  4616. f = h[2];
  4617. return Math.sqrt(c * c + i * i + f * f)
  4618. }, A.len = A.length, A.squaredLength = function(h) {
  4619. var c = h[0],
  4620. i = h[1],
  4621. f = h[2];
  4622. return c * c + i * i + f * f
  4623. }, A.sqrLen = A.squaredLength, A.negate = function(f, c) {
  4624. return f[0] = -c[0], f[1] = -c[1], f[2] = -c[2], f
  4625. }, A.normalize = function(o, f) {
  4626. var p = f[0],
  4627. l = f[1],
  4628. c = f[2],
  4629. h = p * p + l * l + c * c;
  4630. return h > 0 && (h = 1 / Math.sqrt(h), o[0] = f[0] * h, o[1] = f[1] * h, o[2] = f[2] * h), o
  4631. }, A.dot = function(f, c) {
  4632. return f[0] * c[0] + f[1] * c[1] + f[2] * c[2]
  4633. }, A.cross = function(p, F, h) {
  4634. var c = F[0],
  4635. l = F[1],
  4636. G = F[2],
  4637. f = h[0],
  4638. E = h[1],
  4639. D = h[2];
  4640. return p[0] = l * D - G * E, p[1] = G * f - c * D, p[2] = c * E - l * f, p
  4641. }, A.lerp = function(p, f, D, l) {
  4642. var c = f[0],
  4643. h = f[1],
  4644. u = f[2];
  4645. return p[0] = c + l * (D[0] - c), p[1] = h + l * (D[1] - h), p[2] = u + l * (D[2] - u), p
  4646. }, A.random = function(l, f) {
  4647. f = f || 1;
  4648. var o = d() * 2 * Math.PI,
  4649. c = d() * 2 - 1,
  4650. h = Math.sqrt(1 - c * c) * f;
  4651. return l[0] = Math.cos(o) * h, l[1] = Math.sin(o) * h, l[2] = c * f, l
  4652. }, A.transformMat4 = function(o, f, p) {
  4653. var l = f[0],
  4654. c = f[1],
  4655. h = f[2];
  4656. return o[0] = p[0] * l + p[4] * c + p[8] * h + p[12], o[1] = p[1] * l + p[5] * c + p[9] * h + p[13], o[2] = p[2] * l + p[6] * c + p[10] * h + p[14], o
  4657. }, A.transformMat3 = function(o, f, p) {
  4658. var l = f[0],
  4659. c = f[1],
  4660. h = f[2];
  4661. return o[0] = l * p[0] + c * p[3] + h * p[6], o[1] = l * p[1] + c * p[4] + h * p[7], o[2] = l * p[2] + c * p[5] + h * p[8], o
  4662. }, A.transformQuat = function(L, P, G) {
  4663. var D = P[0],
  4664. I = P[1],
  4665. Q = P[2],
  4666. F = G[0],
  4667. O = G[1],
  4668. N = G[2],
  4669. K = G[3],
  4670. H = K * D + O * Q - N * I,
  4671. M = K * I + N * D - F * Q,
  4672. J = K * Q + F * I - O * D,
  4673. E = -F * D - O * I - N * Q;
  4674. return L[0] = H * K + E * -F + M * -N - J * -O, L[1] = M * K + E * -O + J * -F - H * -N, L[2] = J * K + E * -N + H * -O - M * -F, L
  4675. }, A.forEach = function() {
  4676. var c = A.create();
  4677. return function(l, F, D, h, p, E) {
  4678. var f, e;
  4679. F || (F = 3), D || (D = 0), h ? e = Math.min(h * F + D, l.length) : e = l.length;
  4680. for (f = D; f < e; f += F) {
  4681. c[0] = l[f], c[1] = l[f + 1], c[2] = l[f + 2], p(c, c, E), l[f] = c[0], l[f + 1] = c[1], l[f + 2] = c[2]
  4682. }
  4683. return l
  4684. }
  4685. }(), A.str = function(c) {
  4686. return "vec3(" + c[0] + ", " + c[1] + ", " + c[2] + ")"
  4687. }, typeof x != "undefined" && (x.vec3 = A);
  4688. var z = {};
  4689. z.create = function() {
  4690. var c = new k(4);
  4691. return c[0] = 0, c[1] = 0, c[2] = 0, c[3] = 0, c
  4692. }, z.clone = function(f) {
  4693. var c = new k(4);
  4694. return c[0] = f[0], c[1] = f[1], c[2] = f[2], c[3] = f[3], c
  4695. }, z.fromValues = function(n, f, l, c) {
  4696. var h = new k(4);
  4697. return h[0] = n, h[1] = f, h[2] = l, h[3] = c, h
  4698. }, z.copy = function(f, c) {
  4699. return f[0] = c[0], f[1] = c[1], f[2] = c[2], f[3] = c[3], f
  4700. }, z.set = function(l, f, o, h, c) {
  4701. return l[0] = f, l[1] = o, l[2] = h, l[3] = c, l
  4702. }, z.add = function(f, c, h) {
  4703. return f[0] = c[0] + h[0], f[1] = c[1] + h[1], f[2] = c[2] + h[2], f[3] = c[3] + h[3], f
  4704. }, z.subtract = function(f, c, h) {
  4705. return f[0] = c[0] - h[0], f[1] = c[1] - h[1], f[2] = c[2] - h[2], f[3] = c[3] - h[3], f
  4706. }, z.sub = z.subtract, z.multiply = function(f, c, h) {
  4707. return f[0] = c[0] * h[0], f[1] = c[1] * h[1], f[2] = c[2] * h[2], f[3] = c[3] * h[3], f
  4708. }, z.mul = z.multiply, z.divide = function(f, c, h) {
  4709. return f[0] = c[0] / h[0], f[1] = c[1] / h[1], f[2] = c[2] / h[2], f[3] = c[3] / h[3], f
  4710. }, z.div = z.divide, z.min = function(f, c, h) {
  4711. return f[0] = Math.min(c[0], h[0]), f[1] = Math.min(c[1], h[1]), f[2] = Math.min(c[2], h[2]), f[3] = Math.min(c[3], h[3]), f
  4712. }, z.max = function(f, c, h) {
  4713. return f[0] = Math.max(c[0], h[0]), f[1] = Math.max(c[1], h[1]), f[2] = Math.max(c[2], h[2]), f[3] = Math.max(c[3], h[3]), f
  4714. }, z.scale = function(f, c, h) {
  4715. return f[0] = c[0] * h, f[1] = c[1] * h, f[2] = c[2] * h, f[3] = c[3] * h, f
  4716. }, z.scaleAndAdd = function(h, c, i, f) {
  4717. return h[0] = c[0] + i[0] * f, h[1] = c[1] + i[1] * f, h[2] = c[2] + i[2] * f, h[3] = c[3] + i[3] * f, h
  4718. }, z.distance = function(o, f) {
  4719. var p = f[0] - o[0],
  4720. l = f[1] - o[1],
  4721. c = f[2] - o[2],
  4722. h = f[3] - o[3];
  4723. return Math.sqrt(p * p + l * l + c * c + h * h)
  4724. }, z.dist = z.distance, z.squaredDistance = function(o, f) {
  4725. var p = f[0] - o[0],
  4726. l = f[1] - o[1],
  4727. c = f[2] - o[2],
  4728. h = f[3] - o[3];
  4729. return p * p + l * l + c * c + h * h
  4730. }, z.sqrDist = z.squaredDistance, z.length = function(l) {
  4731. var f = l[0],
  4732. o = l[1],
  4733. h = l[2],
  4734. c = l[3];
  4735. return Math.sqrt(f * f + o * o + h * h + c * c)
  4736. }, z.len = z.length, z.squaredLength = function(l) {
  4737. var f = l[0],
  4738. o = l[1],
  4739. h = l[2],
  4740. c = l[3];
  4741. return f * f + o * o + h * h + c * c
  4742. }, z.sqrLen = z.squaredLength, z.negate = function(f, c) {
  4743. return f[0] = -c[0], f[1] = -c[1], f[2] = -c[2], f[3] = -c[3], f
  4744. }, z.normalize = function(p, f) {
  4745. var D = f[0],
  4746. l = f[1],
  4747. c = f[2],
  4748. h = f[3],
  4749. u = D * D + l * l + c * c + h * h;
  4750. return u > 0 && (u = 1 / Math.sqrt(u), p[0] = f[0] * u, p[1] = f[1] * u, p[2] = f[2] * u, p[3] = f[3] * u), p
  4751. }, z.dot = function(f, c) {
  4752. return f[0] * c[0] + f[1] * c[1] + f[2] * c[2] + f[3] * c[3]
  4753. }, z.lerp = function(D, h, F, p) {
  4754. var f = h[0],
  4755. l = h[1],
  4756. E = h[2],
  4757. c = h[3];
  4758. return D[0] = f + p * (F[0] - f), D[1] = l + p * (F[1] - l), D[2] = E + p * (F[2] - E), D[3] = c + p * (F[3] - c), D
  4759. }, z.random = function(f, c) {
  4760. return c = c || 1, f[0] = d(), f[1] = d(), f[2] = d(), f[3] = d(), z.normalize(f, f), z.scale(f, f, c), f
  4761. }, z.transformMat4 = function(p, f, D) {
  4762. var l = f[0],
  4763. c = f[1],
  4764. h = f[2],
  4765. u = f[3];
  4766. return p[0] = D[0] * l + D[4] * c + D[8] * h + D[12] * u, p[1] = D[1] * l + D[5] * c + D[9] * h + D[13] * u, p[2] = D[2] * l + D[6] * c + D[10] * h + D[14] * u, p[3] = D[3] * l + D[7] * c + D[11] * h + D[15] * u, p
  4767. }, z.transformQuat = function(L, P, G) {
  4768. var D = P[0],
  4769. I = P[1],
  4770. Q = P[2],
  4771. F = G[0],
  4772. O = G[1],
  4773. N = G[2],
  4774. K = G[3],
  4775. H = K * D + O * Q - N * I,
  4776. M = K * I + N * D - F * Q,
  4777. J = K * Q + F * I - O * D,
  4778. E = -F * D - O * I - N * Q;
  4779. return L[0] = H * K + E * -F + M * -N - J * -O, L[1] = M * K + E * -O + J * -F - H * -N, L[2] = J * K + E * -N + H * -O - M * -F, L
  4780. }, z.forEach = function() {
  4781. var c = z.create();
  4782. return function(l, F, D, h, p, E) {
  4783. var f, e;
  4784. F || (F = 4), D || (D = 0), h ? e = Math.min(h * F + D, l.length) : e = l.length;
  4785. for (f = D; f < e; f += F) {
  4786. c[0] = l[f], c[1] = l[f + 1], c[2] = l[f + 2], c[3] = l[f + 3], p(c, c, E), l[f] = c[0], l[f + 1] = c[1], l[f + 2] = c[2], l[f + 3] = c[3]
  4787. }
  4788. return l
  4789. }
  4790. }(), z.str = function(c) {
  4791. return "vec4(" + c[0] + ", " + c[1] + ", " + c[2] + ", " + c[3] + ")"
  4792. }, typeof x != "undefined" && (x.vec4 = z);
  4793. var w = {};
  4794. w.create = function() {
  4795. var c = new k(4);
  4796. return c[0] = 1, c[1] = 0, c[2] = 0, c[3] = 1, c
  4797. }, w.clone = function(f) {
  4798. var c = new k(4);
  4799. return c[0] = f[0], c[1] = f[1], c[2] = f[2], c[3] = f[3], c
  4800. }, w.copy = function(f, c) {
  4801. return f[0] = c[0], f[1] = c[1], f[2] = c[2], f[3] = c[3], f
  4802. }, w.identity = function(c) {
  4803. return c[0] = 1, c[1] = 0, c[2] = 0, c[3] = 1, c
  4804. }, w.transpose = function(f, c) {
  4805. if (f === c) {
  4806. var h = c[1];
  4807. f[1] = c[2], f[2] = h
  4808. } else {
  4809. f[0] = c[0], f[1] = c[2], f[2] = c[1], f[3] = c[3]
  4810. }
  4811. return f
  4812. }, w.invert = function(p, f) {
  4813. var D = f[0],
  4814. l = f[1],
  4815. c = f[2],
  4816. h = f[3],
  4817. u = D * h - c * l;
  4818. return u ? (u = 1 / u, p[0] = h * u, p[1] = -l * u, p[2] = -c * u, p[3] = D * u, p) : null
  4819. }, w.adjoint = function(f, c) {
  4820. var h = c[0];
  4821. return f[0] = c[3], f[1] = -c[1], f[2] = -c[2], f[3] = h, f
  4822. }, w.determinant = function(c) {
  4823. return c[0] * c[3] - c[2] * c[1]
  4824. }, w.multiply = function(G, J, p) {
  4825. var c = J[0],
  4826. E = J[1],
  4827. K = J[2],
  4828. h = J[3],
  4829. I = p[0],
  4830. H = p[1],
  4831. F = p[2],
  4832. D = p[3];
  4833. return G[0] = c * I + E * F, G[1] = c * H + E * D, G[2] = K * I + h * F, G[3] = K * H + h * D, G
  4834. }, w.mul = w.multiply, w.rotate = function(p, F, h) {
  4835. var c = F[0],
  4836. l = F[1],
  4837. G = F[2],
  4838. f = F[3],
  4839. E = Math.sin(h),
  4840. D = Math.cos(h);
  4841. return p[0] = c * D + l * E, p[1] = c * -E + l * D, p[2] = G * D + f * E, p[3] = G * -E + f * D, p
  4842. }, w.scale = function(p, F, h) {
  4843. var c = F[0],
  4844. l = F[1],
  4845. G = F[2],
  4846. f = F[3],
  4847. E = h[0],
  4848. D = h[1];
  4849. return p[0] = c * E, p[1] = l * D, p[2] = G * E, p[3] = f * D, p
  4850. }, w.str = function(c) {
  4851. return "mat2(" + c[0] + ", " + c[1] + ", " + c[2] + ", " + c[3] + ")"
  4852. }, typeof x != "undefined" && (x.mat2 = w);
  4853. var m = {};
  4854. m.create = function() {
  4855. var c = new k(6);
  4856. return c[0] = 1, c[1] = 0, c[2] = 0, c[3] = 1, c[4] = 0, c[5] = 0, c
  4857. }, m.clone = function(f) {
  4858. var c = new k(6);
  4859. return c[0] = f[0], c[1] = f[1], c[2] = f[2], c[3] = f[3], c[4] = f[4], c[5] = f[5], c
  4860. }, m.copy = function(f, c) {
  4861. return f[0] = c[0], f[1] = c[1], f[2] = c[2], f[3] = c[3], f[4] = c[4], f[5] = c[5], f
  4862. }, m.identity = function(c) {
  4863. return c[0] = 1, c[1] = 0, c[2] = 0, c[3] = 1, c[4] = 0, c[5] = 0, c
  4864. }, m.invert = function(p, F) {
  4865. var h = F[0],
  4866. c = F[1],
  4867. l = F[2],
  4868. G = F[3],
  4869. f = F[4],
  4870. E = F[5],
  4871. D = h * G - c * l;
  4872. return D ? (D = 1 / D, p[0] = G * D, p[1] = -c * D, p[2] = -l * D, p[3] = h * D, p[4] = (l * E - G * f) * D, p[5] = (c * f - h * E) * D, p) : null
  4873. }, m.determinant = function(c) {
  4874. return c[0] * c[3] - c[1] * c[2]
  4875. }, m.multiply = function(L, Q, G) {
  4876. var D = Q[0],
  4877. I = Q[1],
  4878. R = Q[2],
  4879. F = Q[3],
  4880. P = Q[4],
  4881. O = Q[5],
  4882. K = G[0],
  4883. H = G[1],
  4884. N = G[2],
  4885. J = G[3],
  4886. E = G[4],
  4887. M = G[5];
  4888. return L[0] = D * K + I * N, L[1] = D * H + I * J, L[2] = R * K + F * N, L[3] = R * H + F * J, L[4] = K * P + N * O + E, L[5] = H * P + J * O + M, L
  4889. }, m.mul = m.multiply, m.rotate = function(G, J, p) {
  4890. var c = J[0],
  4891. E = J[1],
  4892. K = J[2],
  4893. h = J[3],
  4894. I = J[4],
  4895. H = J[5],
  4896. F = Math.sin(p),
  4897. D = Math.cos(p);
  4898. return G[0] = c * D + E * F, G[1] = -c * F + E * D, G[2] = K * D + h * F, G[3] = -K * F + D * h, G[4] = D * I + F * H, G[5] = D * H - F * I, G
  4899. }, m.scale = function(l, f, o) {
  4900. var h = o[0],
  4901. c = o[1];
  4902. return l[0] = f[0] * h, l[1] = f[1] * c, l[2] = f[2] * h, l[3] = f[3] * c, l[4] = f[4] * h, l[5] = f[5] * c, l
  4903. }, m.translate = function(f, c, h) {
  4904. return f[0] = c[0], f[1] = c[1], f[2] = c[2], f[3] = c[3], f[4] = c[4] + h[0], f[5] = c[5] + h[1], f
  4905. }, m.str = function(c) {
  4906. return "mat2d(" + c[0] + ", " + c[1] + ", " + c[2] + ", " + c[3] + ", " + c[4] + ", " + c[5] + ")"
  4907. }, typeof x != "undefined" && (x.mat2d = m);
  4908. var y = {};
  4909. y.create = function() {
  4910. var c = new k(9);
  4911. return c[0] = 1, c[1] = 0, c[2] = 0, c[3] = 0, c[4] = 1, c[5] = 0, c[6] = 0, c[7] = 0, c[8] = 1, c
  4912. }, y.fromMat4 = function(f, c) {
  4913. return f[0] = c[0], f[1] = c[1], f[2] = c[2], f[3] = c[4], f[4] = c[5], f[5] = c[6], f[6] = c[8], f[7] = c[9], f[8] = c[10], f
  4914. }, y.clone = function(f) {
  4915. var c = new k(9);
  4916. return c[0] = f[0], c[1] = f[1], c[2] = f[2], c[3] = f[3], c[4] = f[4], c[5] = f[5], c[6] = f[6], c[7] = f[7], c[8] = f[8], c
  4917. }, y.copy = function(f, c) {
  4918. return f[0] = c[0], f[1] = c[1], f[2] = c[2], f[3] = c[3], f[4] = c[4], f[5] = c[5], f[6] = c[6], f[7] = c[7], f[8] = c[8], f
  4919. }, y.identity = function(c) {
  4920. return c[0] = 1, c[1] = 0, c[2] = 0, c[3] = 0, c[4] = 1, c[5] = 0, c[6] = 0, c[7] = 0, c[8] = 1, c
  4921. }, y.transpose = function(l, f) {
  4922. if (l === f) {
  4923. var o = f[1],
  4924. h = f[2],
  4925. c = f[5];
  4926. l[1] = f[3], l[2] = f[6], l[3] = o, l[5] = f[7], l[6] = h, l[7] = c
  4927. } else {
  4928. l[0] = f[0], l[1] = f[3], l[2] = f[6], l[3] = f[1], l[4] = f[4], l[5] = f[7], l[6] = f[2], l[7] = f[5], l[8] = f[8]
  4929. }
  4930. return l
  4931. }, y.invert = function(L, Q) {
  4932. var G = Q[0],
  4933. D = Q[1],
  4934. I = Q[2],
  4935. R = Q[3],
  4936. F = Q[4],
  4937. P = Q[5],
  4938. O = Q[6],
  4939. K = Q[7],
  4940. H = Q[8],
  4941. N = H * F - P * K,
  4942. J = -H * R + P * O,
  4943. E = K * R - F * O,
  4944. M = G * N + D * J + I * E;
  4945. return M ? (M = 1 / M, L[0] = N * M, L[1] = (-H * D + I * K) * M, L[2] = (P * D - I * F) * M, L[3] = J * M, L[4] = (H * G - I * O) * M, L[5] = (-P * G + I * R) * M, L[6] = E * M, L[7] = (-K * G + D * O) * M, L[8] = (F * G - D * R) * M, L) : null
  4946. }, y.adjoint = function(G, J) {
  4947. var p = J[0],
  4948. c = J[1],
  4949. E = J[2],
  4950. K = J[3],
  4951. h = J[4],
  4952. I = J[5],
  4953. H = J[6],
  4954. F = J[7],
  4955. D = J[8];
  4956. return G[0] = h * D - I * F, G[1] = E * F - c * D, G[2] = c * I - E * h, G[3] = I * H - K * D, G[4] = p * D - E * H, G[5] = E * K - p * I, G[6] = K * F - h * H, G[7] = c * H - p * F, G[8] = p * h - c * K, G
  4957. }, y.determinant = function(E) {
  4958. var H = E[0],
  4959. l = E[1],
  4960. c = E[2],
  4961. p = E[3],
  4962. I = E[4],
  4963. h = E[5],
  4964. G = E[6],
  4965. F = E[7],
  4966. D = E[8];
  4967. return H * (D * I - h * F) + l * (-D * p + h * G) + c * (F * p - I * G)
  4968. }, y.multiply = function(T, H, M) {
  4969. var J = H[0],
  4970. P = H[1],
  4971. I = H[2],
  4972. L = H[3],
  4973. G = H[4],
  4974. X = H[5],
  4975. S = H[6],
  4976. O = H[7],
  4977. V = H[8],
  4978. Q = M[0],
  4979. K = M[1],
  4980. U = M[2],
  4981. F = M[3],
  4982. N = M[4],
  4983. R = M[5],
  4984. D = M[6],
  4985. W = M[7],
  4986. E = M[8];
  4987. return T[0] = Q * J + K * L + U * S, T[1] = Q * P + K * G + U * O, T[2] = Q * I + K * X + U * V, T[3] = F * J + N * L + R * S, T[4] = F * P + N * G + R * O, T[5] = F * I + N * X + R * V, T[6] = D * J + W * L + E * S, T[7] = D * P + W * G + E * O, T[8] = D * I + W * X + E * V, T
  4988. }, y.mul = y.multiply, y.translate = function(L, P, G) {
  4989. var D = P[0],
  4990. I = P[1],
  4991. Q = P[2],
  4992. F = P[3],
  4993. O = P[4],
  4994. N = P[5],
  4995. K = P[6],
  4996. H = P[7],
  4997. M = P[8],
  4998. J = G[0],
  4999. E = G[1];
  5000. return L[0] = D, L[1] = I, L[2] = Q, L[3] = F, L[4] = O, L[5] = N, L[6] = J * D + E * F + K, L[7] = J * I + E * O + H, L[8] = J * Q + E * N + M, L
  5001. }, y.rotate = function(L, P, G) {
  5002. var D = P[0],
  5003. I = P[1],
  5004. Q = P[2],
  5005. F = P[3],
  5006. O = P[4],
  5007. N = P[5],
  5008. K = P[6],
  5009. H = P[7],
  5010. M = P[8],
  5011. J = Math.sin(G),
  5012. E = Math.cos(G);
  5013. return L[0] = E * D + J * F, L[1] = E * I + J * O, L[2] = E * Q + J * N, L[3] = E * F - J * D, L[4] = E * O - J * I, L[5] = E * N - J * Q, L[6] = K, L[7] = H, L[8] = M, L
  5014. }, y.scale = function(l, f, o) {
  5015. var h = o[0],
  5016. c = o[1];
  5017. return l[0] = h * f[0], l[1] = h * f[1], l[2] = h * f[2], l[3] = c * f[3], l[4] = c * f[4], l[5] = c * f[5], l[6] = f[6], l[7] = f[7], l[8] = f[8], l
  5018. }, y.fromMat2d = function(f, c) {
  5019. return f[0] = c[0], f[1] = c[1], f[2] = 0, f[3] = c[2], f[4] = c[3], f[5] = 0, f[6] = c[4], f[7] = c[5], f[8] = 1, f
  5020. }, y.fromQuat = function(R, F) {
  5021. var K = F[0],
  5022. H = F[1],
  5023. N = F[2],
  5024. G = F[3],
  5025. J = K + K,
  5026. E = H + H,
  5027. U = N + N,
  5028. Q = K * J,
  5029. M = H * J,
  5030. T = H * E,
  5031. O = N * J,
  5032. I = N * E,
  5033. S = N * U,
  5034. D = G * J,
  5035. L = G * E,
  5036. P = G * U;
  5037. return R[0] = 1 - T - S, R[3] = M - P, R[6] = O + L, R[1] = M + P, R[4] = 1 - Q - S, R[7] = I - D, R[2] = O - L, R[5] = I + D, R[8] = 1 - Q - T, R
  5038. }, y.normalFromMat4 = function(aj, U) {
  5039. var ab = U[0],
  5040. X = U[1],
  5041. af = U[2],
  5042. V = U[3],
  5043. aa = U[4],
  5044. Q = U[5],
  5045. an = U[6],
  5046. ai = U[7],
  5047. ad = U[8],
  5048. al = U[9],
  5049. ag = U[10],
  5050. Z = U[11],
  5051. ak = U[12],
  5052. P = U[13],
  5053. ac = U[14],
  5054. ah = U[15],
  5055. J = ab * Q - X * aa,
  5056. am = ab * an - af * aa,
  5057. M = ab * ai - V * aa,
  5058. R = X * an - af * Q,
  5059. F = X * ai - V * Q,
  5060. K = af * ai - V * an,
  5061. D = ad * P - al * ak,
  5062. H = ad * ac - ag * ak,
  5063. W = ad * ah - Z * ak,
  5064. ae = al * ac - ag * P,
  5065. I = al * ah - Z * P,
  5066. Y = ag * ah - Z * ac,
  5067. G = J * Y - am * I + M * ae + R * W - F * H + K * D;
  5068. return G ? (G = 1 / G, aj[0] = (Q * Y - an * I + ai * ae) * G, aj[1] = (an * W - aa * Y - ai * H) * G, aj[2] = (aa * I - Q * W + ai * D) * G, aj[3] = (af * I - X * Y - V * ae) * G, aj[4] = (ab * Y - af * W + V * H) * G, aj[5] = (X * W - ab * I - V * D) * G, aj[6] = (P * K - ac * F + ah * R) * G, aj[7] = (ac * M - ak * K - ah * am) * G, aj[8] = (ak * F - P * M + ah * J) * G, aj) : null
  5069. }, y.str = function(c) {
  5070. return "mat3(" + c[0] + ", " + c[1] + ", " + c[2] + ", " + c[3] + ", " + c[4] + ", " + c[5] + ", " + c[6] + ", " + c[7] + ", " + c[8] + ")"
  5071. }, typeof x != "undefined" && (x.mat3 = y);
  5072. var v = {};
  5073. v.create = function() {
  5074. var c = new k(16);
  5075. return c[0] = 1, c[1] = 0, c[2] = 0, c[3] = 0, c[4] = 0, c[5] = 1, c[6] = 0, c[7] = 0, c[8] = 0, c[9] = 0, c[10] = 1, c[11] = 0, c[12] = 0, c[13] = 0, c[14] = 0, c[15] = 1, c
  5076. }, v.clone = function(f) {
  5077. var c = new k(16);
  5078. return c[0] = f[0], c[1] = f[1], c[2] = f[2], c[3] = f[3], c[4] = f[4], c[5] = f[5], c[6] = f[6], c[7] = f[7], c[8] = f[8], c[9] = f[9], c[10] = f[10], c[11] = f[11], c[12] = f[12], c[13] = f[13], c[14] = f[14], c[15] = f[15], c
  5079. }, v.copy = function(f, c) {
  5080. return f[0] = c[0], f[1] = c[1], f[2] = c[2], f[3] = c[3], f[4] = c[4], f[5] = c[5], f[6] = c[6], f[7] = c[7], f[8] = c[8], f[9] = c[9], f[10] = c[10], f[11] = c[11], f[12] = c[12], f[13] = c[13], f[14] = c[14], f[15] = c[15], f
  5081. }, v.identity = function(c) {
  5082. return c[0] = 1, c[1] = 0, c[2] = 0, c[3] = 0, c[4] = 0, c[5] = 1, c[6] = 0, c[7] = 0, c[8] = 0, c[9] = 0, c[10] = 1, c[11] = 0, c[12] = 0, c[13] = 0, c[14] = 0, c[15] = 1, c
  5083. }, v.transpose = function(D, h) {
  5084. if (D === h) {
  5085. var F = h[1],
  5086. p = h[2],
  5087. f = h[3],
  5088. l = h[6],
  5089. E = h[7],
  5090. c = h[11];
  5091. D[1] = h[4], D[2] = h[8], D[3] = h[12], D[4] = F, D[6] = h[9], D[7] = h[13], D[8] = p, D[9] = l, D[11] = h[14], D[12] = f, D[13] = E, D[14] = c
  5092. } else {
  5093. D[0] = h[0], D[1] = h[4], D[2] = h[8], D[3] = h[12], D[4] = h[1], D[5] = h[5], D[6] = h[9], D[7] = h[13], D[8] = h[2], D[9] = h[6], D[10] = h[10], D[11] = h[14], D[12] = h[3], D[13] = h[7], D[14] = h[11], D[15] = h[15]
  5094. }
  5095. return D
  5096. }, v.invert = function(aj, U) {
  5097. var ab = U[0],
  5098. X = U[1],
  5099. af = U[2],
  5100. V = U[3],
  5101. aa = U[4],
  5102. Q = U[5],
  5103. an = U[6],
  5104. ai = U[7],
  5105. ad = U[8],
  5106. al = U[9],
  5107. ag = U[10],
  5108. Z = U[11],
  5109. ak = U[12],
  5110. P = U[13],
  5111. ac = U[14],
  5112. ah = U[15],
  5113. J = ab * Q - X * aa,
  5114. am = ab * an - af * aa,
  5115. M = ab * ai - V * aa,
  5116. R = X * an - af * Q,
  5117. F = X * ai - V * Q,
  5118. K = af * ai - V * an,
  5119. D = ad * P - al * ak,
  5120. H = ad * ac - ag * ak,
  5121. W = ad * ah - Z * ak,
  5122. ae = al * ac - ag * P,
  5123. I = al * ah - Z * P,
  5124. Y = ag * ah - Z * ac,
  5125. G = J * Y - am * I + M * ae + R * W - F * H + K * D;
  5126. return G ? (G = 1 / G, aj[0] = (Q * Y - an * I + ai * ae) * G, aj[1] = (af * I - X * Y - V * ae) * G, aj[2] = (P * K - ac * F + ah * R) * G, aj[3] = (ag * F - al * K - Z * R) * G, aj[4] = (an * W - aa * Y - ai * H) * G, aj[5] = (ab * Y - af * W + V * H) * G, aj[6] = (ac * M - ak * K - ah * am) * G, aj[7] = (ad * K - ag * M + Z * am) * G, aj[8] = (aa * I - Q * W + ai * D) * G, aj[9] = (X * W - ab * I - V * D) * G, aj[10] = (ak * F - P * M + ah * J) * G, aj[11] = (al * M - ad * F - Z * J) * G, aj[12] = (Q * H - aa * ae - an * D) * G, aj[13] = (ab * ae - X * H + af * D) * G, aj[14] = (P * am - ak * R - ac * J) * G, aj[15] = (ad * R - al * am + ag * J) * G, aj) : null
  5127. }, v.adjoint = function(R, F) {
  5128. var K = F[0],
  5129. H = F[1],
  5130. N = F[2],
  5131. G = F[3],
  5132. J = F[4],
  5133. E = F[5],
  5134. U = F[6],
  5135. Q = F[7],
  5136. M = F[8],
  5137. T = F[9],
  5138. O = F[10],
  5139. I = F[11],
  5140. S = F[12],
  5141. D = F[13],
  5142. L = F[14],
  5143. P = F[15];
  5144. return R[0] = E * (O * P - I * L) - T * (U * P - Q * L) + D * (U * I - Q * O), R[1] = -(H * (O * P - I * L) - T * (N * P - G * L) + D * (N * I - G * O)), R[2] = H * (U * P - Q * L) - E * (N * P - G * L) + D * (N * Q - G * U), R[3] = -(H * (U * I - Q * O) - E * (N * I - G * O) + T * (N * Q - G * U)), R[4] = -(J * (O * P - I * L) - M * (U * P - Q * L) + S * (U * I - Q * O)), R[5] = K * (O * P - I * L) - M * (N * P - G * L) + S * (N * I - G * O), R[6] = -(K * (U * P - Q * L) - J * (N * P - G * L) + S * (N * Q - G * U)), R[7] = K * (U * I - Q * O) - J * (N * I - G * O) + M * (N * Q - G * U), R[8] = J * (T * P - I * D) - M * (E * P - Q * D) + S * (E * I - Q * T), R[9] = -(K * (T * P - I * D) - M * (H * P - G * D) + S * (H * I - G * T)), R[10] = K * (E * P - Q * D) - J * (H * P - G * D) + S * (H * Q - G * E), R[11] = -(K * (E * I - Q * T) - J * (H * I - G * T) + M * (H * Q - G * E)), R[12] = -(J * (T * L - O * D) - M * (E * L - U * D) + S * (E * O - U * T)), R[13] = K * (T * L - O * D) - M * (H * L - N * D) + S * (H * O - N * T), R[14] = -(K * (E * L - U * D) - J * (H * L - N * D) + S * (H * U - N * E)), R[15] = K * (E * O - U * T) - J * (H * O - N * T) + M * (H * U - N * E), R
  5145. }, v.determinant = function(ag) {
  5146. var Q = ag[0],
  5147. Y = ag[1],
  5148. V = ag[2],
  5149. ac = ag[3],
  5150. R = ag[4],
  5151. X = ag[5],
  5152. O = ag[6],
  5153. ak = ag[7],
  5154. af = ag[8],
  5155. aa = ag[9],
  5156. ai = ag[10],
  5157. ad = ag[11],
  5158. W = ag[12],
  5159. ah = ag[13],
  5160. M = ag[14],
  5161. Z = ag[15],
  5162. ae = Q * X - Y * R,
  5163. I = Q * O - V * R,
  5164. aj = Q * ak - ac * R,
  5165. K = Y * O - V * X,
  5166. P = Y * ak - ac * X,
  5167. F = V * ak - ac * O,
  5168. J = af * ah - aa * W,
  5169. D = af * M - ai * W,
  5170. G = af * Z - ad * W,
  5171. U = aa * M - ai * ah,
  5172. ab = aa * Z - ad * ah,
  5173. H = ai * Z - ad * M;
  5174. return ae * H - I * ab + aj * U + K * G - P * D + F * J
  5175. }, v.multiply = function(X, K, P) {
  5176. var M = K[0],
  5177. T = K[1],
  5178. L = K[2],
  5179. O = K[3],
  5180. I = K[4],
  5181. ab = K[5],
  5182. W = K[6],
  5183. R = K[7],
  5184. Z = K[8],
  5185. U = K[9],
  5186. N = K[10],
  5187. Y = K[11],
  5188. H = K[12],
  5189. Q = K[13],
  5190. V = K[14],
  5191. F = K[15],
  5192. aa = P[0],
  5193. G = P[1],
  5194. J = P[2],
  5195. D = P[3];
  5196. return X[0] = aa * M + G * I + J * Z + D * H, X[1] = aa * T + G * ab + J * U + D * Q, X[2] = aa * L + G * W + J * N + D * V, X[3] = aa * O + G * R + J * Y + D * F, aa = P[4], G = P[5], J = P[6], D = P[7], X[4] = aa * M + G * I + J * Z + D * H, X[5] = aa * T + G * ab + J * U + D * Q, X[6] = aa * L + G * W + J * N + D * V, X[7] = aa * O + G * R + J * Y + D * F, aa = P[8], G = P[9], J = P[10], D = P[11], X[8] = aa * M + G * I + J * Z + D * H, X[9] = aa * T + G * ab + J * U + D * Q, X[10] = aa * L + G * W + J * N + D * V, X[11] = aa * O + G * R + J * Y + D * F, aa = P[12], G = P[13], J = P[14], D = P[15], X[12] = aa * M + G * I + J * Z + D * H, X[13] = aa * T + G * ab + J * U + D * Q, X[14] = aa * L + G * W + J * N + D * V, X[15] = aa * O + G * R + J * Y + D * F, X
  5197. }, v.mul = v.multiply, v.translate = function(V, J, O) {
  5198. var L = O[0],
  5199. R = O[1],
  5200. K = O[2],
  5201. N, H, Z, U, Q, X, S, M, W, G, P, T, D, Y, F, I;
  5202. return N = J[0], H = J[1], Z = J[2], U = J[3], Q = J[4], X = J[5], S = J[6], M = J[7], W = J[8], G = J[9], P = J[10], T = J[11], D = J[12], Y = J[13], F = J[14], I = J[15], V[0] = N + U * L, V[1] = H + U * R, V[2] = Z + U * K, V[3] = U, V[4] = Q + M * L, V[5] = X + M * R, V[6] = S + M * K, V[7] = M, V[8] = W + T * L, V[9] = G + T * R, V[10] = P + T * K, V[11] = T, V[12] = D + I * L, V[13] = Y + I * R, V[14] = F + I * K, V[15] = I, V
  5203. }, v.scale = function(o, f, p) {
  5204. var l = p[0],
  5205. c = p[1],
  5206. h = p[2];
  5207. return o[0] = f[0] * l, o[1] = f[1] * l, o[2] = f[2] * l, o[3] = f[3] * l, o[4] = f[4] * c, o[5] = f[5] * c, o[6] = f[6] * c, o[7] = f[7] * c, o[8] = f[8] * h, o[9] = f[9] * h, o[10] = f[10] * h, o[11] = f[11] * h, o[12] = f[12], o[13] = f[13], o[14] = f[14], o[15] = f[15], o
  5208. }, v.rotate = function(aj, ab, X, af) {
  5209. var V = af[0],
  5210. aa = af[1],
  5211. R = af[2],
  5212. an = Math.sqrt(V * V + aa * aa + R * R),
  5213. ai, ad, al, ag, Z, ak, Q, ac, ah, J, am, P, U, D, K, t, G, W, ae, I, Y, F, H, ao;
  5214. return Math.abs(an) < B ? null : (an = 1 / an, V *= an, aa *= an, R *= an, ai = Math.sin(X), ad = Math.cos(X), al = 1 - ad, ag = ab[0], Z = ab[1], ak = ab[2], Q = ab[3], ac = ab[4], ah = ab[5], J = ab[6], am = ab[7], P = ab[8], U = ab[9], D = ab[10], K = ab[11], t = V * V * al + ad, G = aa * V * al + R * ai, W = R * V * al - aa * ai, ae = V * aa * al - R * ai, I = aa * aa * al + ad, Y = R * aa * al + V * ai, F = V * R * al + aa * ai, H = aa * R * al - V * ai, ao = R * R * al + ad, aj[0] = ag * t + ac * G + P * W, aj[1] = Z * t + ah * G + U * W, aj[2] = ak * t + J * G + D * W, aj[3] = Q * t + am * G + K * W, aj[4] = ag * ae + ac * I + P * Y, aj[5] = Z * ae + ah * I + U * Y, aj[6] = ak * ae + J * I + D * Y, aj[7] = Q * ae + am * I + K * Y, aj[8] = ag * F + ac * H + P * ao, aj[9] = Z * F + ah * H + U * ao, aj[10] = ak * F + J * H + D * ao, aj[11] = Q * F + am * H + K * ao, ab !== aj && (aj[12] = ab[12], aj[13] = ab[13], aj[14] = ab[14], aj[15] = ab[15]), aj)
  5215. }, v.rotateX = function(J, N, E) {
  5216. var p = Math.sin(E),
  5217. G = Math.cos(E),
  5218. O = N[4],
  5219. D = N[5],
  5220. M = N[6],
  5221. L = N[7],
  5222. I = N[8],
  5223. F = N[9],
  5224. K = N[10],
  5225. H = N[11];
  5226. return N !== J && (J[0] = N[0], J[1] = N[1], J[2] = N[2], J[3] = N[3], J[12] = N[12], J[13] = N[13], J[14] = N[14], J[15] = N[15]), J[4] = O * G + I * p, J[5] = D * G + F * p, J[6] = M * G + K * p, J[7] = L * G + H * p, J[8] = I * G - O * p, J[9] = F * G - D * p, J[10] = K * G - M * p, J[11] = H * G - L * p, J
  5227. }, v.rotateY = function(J, N, E) {
  5228. var p = Math.sin(E),
  5229. G = Math.cos(E),
  5230. O = N[0],
  5231. D = N[1],
  5232. M = N[2],
  5233. L = N[3],
  5234. I = N[8],
  5235. F = N[9],
  5236. K = N[10],
  5237. H = N[11];
  5238. return N !== J && (J[4] = N[4], J[5] = N[5], J[6] = N[6], J[7] = N[7], J[12] = N[12], J[13] = N[13], J[14] = N[14], J[15] = N[15]), J[0] = O * G - I * p, J[1] = D * G - F * p, J[2] = M * G - K * p, J[3] = L * G - H * p, J[8] = O * p + I * G, J[9] = D * p + F * G, J[10] = M * p + K * G, J[11] = L * p + H * G, J
  5239. }, v.rotateZ = function(J, N, E) {
  5240. var p = Math.sin(E),
  5241. G = Math.cos(E),
  5242. O = N[0],
  5243. D = N[1],
  5244. M = N[2],
  5245. L = N[3],
  5246. I = N[4],
  5247. F = N[5],
  5248. K = N[6],
  5249. H = N[7];
  5250. return N !== J && (J[8] = N[8], J[9] = N[9], J[10] = N[10], J[11] = N[11], J[12] = N[12], J[13] = N[13], J[14] = N[14], J[15] = N[15]), J[0] = O * G + I * p, J[1] = D * G + F * p, J[2] = M * G + K * p, J[3] = L * G + H * p, J[4] = I * G - O * p, J[5] = F * G - D * p, J[6] = K * G - M * p, J[7] = H * G - L * p, J
  5251. }, v.fromRotationTranslation = function(S, G, L) {
  5252. var I = G[0],
  5253. O = G[1],
  5254. H = G[2],
  5255. K = G[3],
  5256. F = I + I,
  5257. V = O + O,
  5258. R = H + H,
  5259. N = I * F,
  5260. U = I * V,
  5261. P = I * R,
  5262. J = O * V,
  5263. T = O * R,
  5264. E = H * R,
  5265. M = K * F,
  5266. Q = K * V,
  5267. D = K * R;
  5268. return S[0] = 1 - (J + E), S[1] = U + D, S[2] = P - Q, S[3] = 0, S[4] = U - D, S[5] = 1 - (N + E), S[6] = T + M, S[7] = 0, S[8] = P + Q, S[9] = T - M, S[10] = 1 - (N + J), S[11] = 0, S[12] = L[0], S[13] = L[1], S[14] = L[2], S[15] = 1, S
  5269. }, v.fromQuat = function(R, F) {
  5270. var K = F[0],
  5271. H = F[1],
  5272. N = F[2],
  5273. G = F[3],
  5274. J = K + K,
  5275. E = H + H,
  5276. U = N + N,
  5277. Q = K * J,
  5278. M = H * J,
  5279. T = H * E,
  5280. O = N * J,
  5281. I = N * E,
  5282. S = N * U,
  5283. D = G * J,
  5284. L = G * E,
  5285. P = G * U;
  5286. return R[0] = 1 - T - S, R[1] = M + P, R[2] = O - L, R[3] = 0, R[4] = M - P, R[5] = 1 - Q - S, R[6] = I + D, R[7] = 0, R[8] = O + L, R[9] = I - D, R[10] = 1 - Q - T, R[11] = 0, R[12] = 0, R[13] = 0, R[14] = 0, R[15] = 1, R
  5287. }, v.frustum = function(E, H, l, c, p, I, h) {
  5288. var G = 1 / (l - H),
  5289. F = 1 / (p - c),
  5290. D = 1 / (I - h);
  5291. return E[0] = I * 2 * G, E[1] = 0, E[2] = 0, E[3] = 0, E[4] = 0, E[5] = I * 2 * F, E[6] = 0, E[7] = 0, E[8] = (l + H) * G, E[9] = (p + c) * F, E[10] = (h + I) * D, E[11] = -1, E[12] = 0, E[13] = 0, E[14] = h * I * 2 * D, E[15] = 0, E
  5292. }, v.perspective = function(p, f, D, l, c) {
  5293. var h = 1 / Math.tan(f / 2),
  5294. u = 1 / (l - c);
  5295. return p[0] = h / D, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = h, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = (c + l) * u, p[11] = -1, p[12] = 0, p[13] = 0, p[14] = 2 * c * l * u, p[15] = 0, p
  5296. }, v.ortho = function(E, H, l, c, p, I, h) {
  5297. var G = 1 / (H - l),
  5298. F = 1 / (c - p),
  5299. D = 1 / (I - h);
  5300. return E[0] = -2 * G, E[1] = 0, E[2] = 0, E[3] = 0, E[4] = 0, E[5] = -2 * F, E[6] = 0, E[7] = 0, E[8] = 0, E[9] = 0, E[10] = 2 * D, E[11] = 0, E[12] = (H + l) * G, E[13] = (p + c) * F, E[14] = (h + I) * D, E[15] = 1, E
  5301. }, v.lookAt = function(W, O, L, R) {
  5302. var K, N, I, aa, V, Q, Y, M, X, H, P = O[0],
  5303. U = O[1],
  5304. D = O[2],
  5305. Z = R[0],
  5306. G = R[1],
  5307. J = R[2],
  5308. t = L[0],
  5309. F = L[1],
  5310. h = L[2];
  5311. return Math.abs(P - t) < B && Math.abs(U - F) < B && Math.abs(D - h) < B ? v.identity(W) : (Y = P - t, M = U - F, X = D - h, H = 1 / Math.sqrt(Y * Y + M * M + X * X), Y *= H, M *= H, X *= H, K = G * X - J * M, N = J * Y - Z * X, I = Z * M - G * Y, H = Math.sqrt(K * K + N * N + I * I), H ? (H = 1 / H, K *= H, N *= H, I *= H) : (K = 0, N = 0, I = 0), aa = M * I - X * N, V = X * K - Y * I, Q = Y * N - M * K, H = Math.sqrt(aa * aa + V * V + Q * Q), H ? (H = 1 / H, aa *= H, V *= H, Q *= H) : (aa = 0, V = 0, Q = 0), W[0] = K, W[1] = aa, W[2] = Y, W[3] = 0, W[4] = N, W[5] = V, W[6] = M, W[7] = 0, W[8] = I, W[9] = Q, W[10] = X, W[11] = 0, W[12] = -(K * P + N * U + I * D), W[13] = -(aa * P + V * U + Q * D), W[14] = -(Y * P + M * U + X * D), W[15] = 1, W)
  5312. }, v.str = function(c) {
  5313. return "mat4(" + c[0] + ", " + c[1] + ", " + c[2] + ", " + c[3] + ", " + c[4] + ", " + c[5] + ", " + c[6] + ", " + c[7] + ", " + c[8] + ", " + c[9] + ", " + c[10] + ", " + c[11] + ", " + c[12] + ", " + c[13] + ", " + c[14] + ", " + c[15] + ")"
  5314. }, typeof x != "undefined" && (x.mat4 = v);
  5315. var g = {};
  5316. g.create = function() {
  5317. var c = new k(4);
  5318. return c[0] = 0, c[1] = 0, c[2] = 0, c[3] = 1, c
  5319. }, g.rotationTo = function() {
  5320. var f = A.create(),
  5321. c = A.fromValues(1, 0, 0),
  5322. h = A.fromValues(0, 1, 0);
  5323. return function(n, e, l) {
  5324. var p = A.dot(e, l);
  5325. return p < -0.999999 ? (A.cross(f, c, e), A.length(f) < 0.000001 && A.cross(f, h, e), A.normalize(f, f), g.setAxisAngle(n, f, Math.PI), n) : p > 0.999999 ? (n[0] = 0, n[1] = 0, n[2] = 0, n[3] = 1, n) : (A.cross(f, e, l), n[0] = f[0], n[1] = f[1], n[2] = f[2], n[3] = 1 + p, g.normalize(n, n))
  5326. }
  5327. }(), g.setAxes = function() {
  5328. var c = y.create();
  5329. return function(f, l, h, e) {
  5330. return c[0] = h[0], c[3] = h[1], c[6] = h[2], c[1] = e[0], c[4] = e[1], c[7] = e[2], c[2] = -l[0], c[5] = -l[1], c[8] = -l[2], g.normalize(f, g.fromMat3(f, c))
  5331. }
  5332. }(), g.clone = z.clone, g.fromValues = z.fromValues, g.copy = z.copy, g.set = z.set, g.identity = function(c) {
  5333. return c[0] = 0, c[1] = 0, c[2] = 0, c[3] = 1, c
  5334. }, g.setAxisAngle = function(h, c, i) {
  5335. i *= 0.5;
  5336. var f = Math.sin(i);
  5337. return h[0] = f * c[0], h[1] = f * c[1], h[2] = f * c[2], h[3] = Math.cos(i), h
  5338. }, g.add = z.add, g.multiply = function(G, J, p) {
  5339. var c = J[0],
  5340. E = J[1],
  5341. K = J[2],
  5342. h = J[3],
  5343. I = p[0],
  5344. H = p[1],
  5345. F = p[2],
  5346. D = p[3];
  5347. return G[0] = c * D + h * I + E * F - K * H, G[1] = E * D + h * H + K * I - c * F, G[2] = K * D + h * F + c * H - E * I, G[3] = h * D - c * I - E * H - K * F, G
  5348. }, g.mul = g.multiply, g.scale = z.scale, g.rotateX = function(p, F, h) {
  5349. h *= 0.5;
  5350. var c = F[0],
  5351. l = F[1],
  5352. G = F[2],
  5353. f = F[3],
  5354. E = Math.sin(h),
  5355. D = Math.cos(h);
  5356. return p[0] = c * D + f * E, p[1] = l * D + G * E, p[2] = G * D - l * E, p[3] = f * D - c * E, p
  5357. }, g.rotateY = function(p, F, h) {
  5358. h *= 0.5;
  5359. var c = F[0],
  5360. l = F[1],
  5361. G = F[2],
  5362. f = F[3],
  5363. E = Math.sin(h),
  5364. D = Math.cos(h);
  5365. return p[0] = c * D - G * E, p[1] = l * D + f * E, p[2] = G * D + c * E, p[3] = f * D - l * E, p
  5366. }, g.rotateZ = function(p, F, h) {
  5367. h *= 0.5;
  5368. var c = F[0],
  5369. l = F[1],
  5370. G = F[2],
  5371. f = F[3],
  5372. E = Math.sin(h),
  5373. D = Math.cos(h);
  5374. return p[0] = c * D + l * E, p[1] = l * D - c * E, p[2] = G * D + f * E, p[3] = f * D - G * E, p
  5375. }, g.calculateW = function(l, f) {
  5376. var o = f[0],
  5377. h = f[1],
  5378. c = f[2];
  5379. return l[0] = o, l[1] = h, l[2] = c, l[3] = -Math.sqrt(Math.abs(1 - o * o - h * h - c * c)), l
  5380. }, g.dot = z.dot, g.lerp = z.lerp, g.slerp = function(M, S, G, D) {
  5381. var J = S[0],
  5382. T = S[1],
  5383. F = S[2],
  5384. R = S[3],
  5385. P = G[0],
  5386. L = G[1],
  5387. I = G[2],
  5388. O = G[3],
  5389. K, E, N, Q, H;
  5390. return E = J * P + T * L + F * I + R * O, E < 0 && (E = -E, P = -P, L = -L, I = -I, O = -O), 1 - E > 0.000001 ? (K = Math.acos(E), N = Math.sin(K), Q = Math.sin((1 - D) * K) / N, H = Math.sin(D * K) / N) : (Q = 1 - D, H = D), M[0] = Q * J + H * P, M[1] = Q * T + H * L, M[2] = Q * F + H * I, M[3] = Q * R + H * O, M
  5391. }, g.invert = function(D, h) {
  5392. var F = h[0],
  5393. p = h[1],
  5394. f = h[2],
  5395. l = h[3],
  5396. E = F * F + p * p + f * f + l * l,
  5397. c = E ? 1 / E : 0;
  5398. return D[0] = -F * c, D[1] = -p * c, D[2] = -f * c, D[3] = l * c, D
  5399. }, g.conjugate = function(f, c) {
  5400. return f[0] = -c[0], f[1] = -c[1], f[2] = -c[2], f[3] = c[3], f
  5401. }, g.length = z.length, g.len = g.length, g.squaredLength = z.squaredLength, g.sqrLen = g.squaredLength, g.normalize = z.normalize, g.fromMat3 = function(p, f) {
  5402. var D = f[0] + f[4] + f[8],
  5403. l;
  5404. if (D > 0) {
  5405. l = Math.sqrt(D + 1), p[3] = 0.5 * l, l = 0.5 / l, p[0] = (f[7] - f[5]) * l, p[1] = (f[2] - f[6]) * l, p[2] = (f[3] - f[1]) * l
  5406. } else {
  5407. var c = 0;
  5408. f[4] > f[0] && (c = 1), f[8] > f[c * 3 + c] && (c = 2);
  5409. var h = (c + 1) % 3,
  5410. u = (c + 2) % 3;
  5411. l = Math.sqrt(f[c * 3 + c] - f[h * 3 + h] - f[u * 3 + u] + 1), p[c] = 0.5 * l, l = 0.5 / l, p[3] = (f[u * 3 + h] - f[h * 3 + u]) * l, p[h] = (f[h * 3 + c] + f[c * 3 + h]) * l, p[u] = (f[u * 3 + c] + f[c * 3 + u]) * l
  5412. }
  5413. return p
  5414. }, g.str = function(c) {
  5415. return "quat(" + c[0] + ", " + c[1] + ", " + c[2] + ", " + c[3] + ")"
  5416. }, typeof x != "undefined" && (x.quat = g)
  5417. }(a.exports)
  5418. })(this);
  5419. var mouseX = 0;
  5420. var mouseY = 0;
  5421. var mouseDown = false;
  5422. var mouseDownLast = false;
  5423. var mouseWheelDelta = 0;
  5424. var touchDown = false;
  5425. var touchDownLast = false;
  5426. var currentTouches = [];
  5427. var Input = new function() {
  5428. this.update = function() {
  5429. mouseWheelDelta = 0;
  5430. mouseDownLast = mouseDown;
  5431. touchDownLast = touchDown;
  5432. for (var a = 0; a < 255; a++) {
  5433. Key._prevPressed[a] = Key._pressed[a]
  5434. }
  5435. for (var a = 0; a < currentTouches.length; a++) {
  5436. currentTouches[a].moved = false
  5437. }
  5438. };
  5439. this.mouseClick = function() {
  5440. return (mouseDown && !mouseDownLast) || (touchDown && !touchDownLast)
  5441. };
  5442. this.mouseUp = function() {
  5443. return (!mouseDown && mouseDownLast) || (!touchDown && touchDownLast)
  5444. }
  5445. };
  5446. function handle_mousemove(b) {
  5447. rawMouseX = b.layerX;
  5448. rawMouseY = b.layerY;
  5449. var a = Math.min(parseFloat(canvas.style.width) / 480, parseFloat(canvas.style.height) / 720);
  5450. mouseX = b.layerX / a;
  5451. mouseY = b.layerY / a
  5452. }
  5453. function handle_mousedown(a) {
  5454. mouseDown = true
  5455. }
  5456. function handle_mouseup(a) {
  5457. mouseDown = false
  5458. }
  5459. function handle_touchstart(d) {
  5460. d.preventDefault();
  5461. var b = Math.min(parseFloat(canvas.style.width) / canvas.width, parseFloat(canvas.style.height) / canvas.height);
  5462. for (var c = 0; c < d.changedTouches.length; c++) {
  5463. var a = d.changedTouches[c].pageX;
  5464. var e = d.changedTouches[c].pageY;
  5465. a -= canvas.offsetLeft;
  5466. e -= canvas.offsetTop;
  5467. a /= b;
  5468. e /= b;
  5469. currentTouches.push({
  5470. x: a,
  5471. y: e,
  5472. id: d.changedTouches[c].identifier,
  5473. moved: false
  5474. })
  5475. }
  5476. touchDown = true
  5477. }
  5478. function handle_touchend(c) {
  5479. c.preventDefault();
  5480. for (var b = 0; b < c.changedTouches.length; b++) {
  5481. for (var a = 0; a < currentTouches.length; a++) {
  5482. if (currentTouches[a].id == c.changedTouches[b].identifier) {
  5483. currentTouches.splice(a, 1);
  5484. break
  5485. }
  5486. }
  5487. }
  5488. if (currentTouches.length == 0 || c.targetTouches.length == 0) {
  5489. touchDown = false
  5490. }
  5491. }
  5492. function handle_touchmove(e) {
  5493. e.preventDefault();
  5494. var b = Math.min(parseFloat(canvas.style.width) / canvas.width, parseFloat(canvas.style.height) / canvas.height);
  5495. for (var d = 0; d < e.changedTouches.length; d++) {
  5496. for (var c = 0; c < currentTouches.length; c++) {
  5497. if (currentTouches[c].id == e.changedTouches[d].identifier) {
  5498. var a = e.changedTouches[d].pageX;
  5499. var f = e.changedTouches[d].pageY;
  5500. a -= canvas.offsetLeft;
  5501. f -= canvas.offsetTop;
  5502. a /= b;
  5503. f /= b;
  5504. currentTouches[c].x = a;
  5505. currentTouches[c].y = f;
  5506. currentTouches[c].moved = true;
  5507. break
  5508. }
  5509. }
  5510. }
  5511. }
  5512. function handle_mousewheel(a) {
  5513. var b = window.event || b;
  5514. mouseWheelDelta = Math.max(-1, Math.min(1, (b.wheelDelta || -b.detail)))
  5515. }
  5516. var Key = {
  5517. _pressed: {},
  5518. _prevPressed: {},
  5519. LEFT: 37,
  5520. UP: 38,
  5521. RIGHT: 39,
  5522. DOWN: 40,
  5523. SPACE: 32,
  5524. Q: 81,
  5525. E: 69,
  5526. W: 87,
  5527. A: 65,
  5528. S: 83,
  5529. D: 68,
  5530. isDown: function(a) {
  5531. return this._pressed[a]
  5532. },
  5533. isPressed: function(a) {
  5534. return (this._pressed[a] && !this._prevPressed[a])
  5535. },
  5536. onKeydown: function(a) {
  5537. this._pressed[a.keyCode] = true
  5538. },
  5539. onKeyup: function(a) {
  5540. delete this._pressed[a.keyCode]
  5541. }
  5542. };
  5543. var debugText = "";
  5544. var context = null;
  5545. var focused = true;
  5546. var viewScale = 1;
  5547. var firstRun = true;
  5548. var gRedrawActive = true;
  5549. var gFirstDraw = true;
  5550. var gWrongOrientation = false;
  5551. var gMobile = false;
  5552. function Game() {
  5553. var a;
  5554. this.init = function() {
  5555. canvas = document.getElementById("canvas");
  5556. vectorResizeEvent = document.createEvent("Event");
  5557. vectorResizeEvent.initEvent("vectorResize", true, true);
  5558. if (canvas.getContext) {
  5559. gMobile = queryIsTouchDevice();
  5560. gStorageAvailable = supports_html5_storage();
  5561. if (gStorageAvailable) {
  5562. soundMuted = (queryLocalVar("soundMuted") == "true");
  5563. musicMuted = (queryLocalVar("musicMuted") == "true")
  5564. }
  5565. document.addEventListener("mousemove", handle_mousemove);
  5566. document.addEventListener("mousedown", handle_mousedown);
  5567. document.addEventListener("mouseup", handle_mouseup);
  5568. document.addEventListener("touchstart", handle_touchstart, false);
  5569. document.addEventListener("touchend", handle_touchend, false);
  5570. document.addEventListener("touchmove", handle_touchmove, true);
  5571. document.addEventListener("keyup", function(d) {
  5572. Key.onKeyup(d)
  5573. }, false);
  5574. document.addEventListener("keydown", function(d) {
  5575. Key.onKeydown(d)
  5576. }, false);
  5577. document.addEventListener("mousewheel", handle_mousewheel, false);
  5578. document.addEventListener("DOMMouseScroll", handle_mousewheel, false);
  5579. window.addEventListener("resize", resizeGame, false);
  5580. ctx = canvas.getContext("2d");
  5581. this.stateManager = new StateManager();
  5582. this.stateManager.init();
  5583. switch (gCurrentBrand) {
  5584. case BRAND.ADDICTING:
  5585. case BRAND.MRG:
  5586. var c = new SplashState();
  5587. c.init();
  5588. this.stateManager.setState(c);
  5589. break;
  5590. default:
  5591. var b = new MainMenuState();
  5592. b.init();
  5593. this.stateManager.setState(b);
  5594. break
  5595. }
  5596. return true
  5597. } else {
  5598. return false
  5599. }
  5600. };
  5601. this.start = function() {
  5602. canvas.style.width = "480px";
  5603. canvas.style.height = "720px";
  5604. resizeGame();
  5605. tick()
  5606. }
  5607. }
  5608. var lastFrame = Date.now();
  5609. function tick() {
  5610. requestAnimFrame(tick);
  5611. if (!gFirstDraw) {
  5612. gRedrawActive = false
  5613. }
  5614. gFirstDraw = false;
  5615. var a = 1 / 60;
  5616. var d = Date.now();
  5617. var c = (d - lastFrame) / 1000;
  5618. lastFrame = d;
  5619. var b = c;
  5620. if (c < 0.5) {
  5621. while (b > 0) {
  5622. if (b < a) {
  5623. game.stateManager.update(a);
  5624. b = 0
  5625. } else {
  5626. game.stateManager.update(a);
  5627. b -= a
  5628. }
  5629. Input.update()
  5630. }
  5631. ctx.fillStyle = "#fcb040";
  5632. ctx.fillRect(0, 0, canvas.width, canvas.height);
  5633. ctx.globalAlpha = 1;
  5634. game.stateManager.draw()
  5635. }
  5636. ctx.fillStyle = "#000000";
  5637. Input.update()
  5638. }
  5639. function setCursor(a) {
  5640. document.body.style.cursor = a
  5641. }
  5642. window.onfocus = function() {
  5643. createjs.Sound.setMute(false)
  5644. };
  5645. window.onblur = function() {
  5646. createjs.Sound.setMute(true)
  5647. };
  5648. function resizeGame() {
  5649. gRedrawActive = true;
  5650. gFirstDraw = true;
  5651. var c = 0.6666666666667;
  5652. var d = window.innerWidth;
  5653. var a = window.innerHeight;
  5654. canvas.style.height = a + "px";
  5655. canvas.style.width = d + "px";
  5656. canvas.height = a;
  5657. canvas.width = d;
  5658. viewH = a;
  5659. viewW = d;
  5660. var b = viewW / 480;
  5661. var e = viewH / 720;
  5662. if (b < e) {
  5663. canvas.height = a / b;
  5664. canvas.width = d / b;
  5665. canvas.style.width = (canvas.width * b) + "px";
  5666. canvas.style.height = (canvas.height * b) + "px";
  5667. viewW = 480;
  5668. viewH = 720
  5669. } else {
  5670. canvas.height = a / e;
  5671. canvas.width = d / e;
  5672. canvas.style.width = (canvas.width * e) + "px";
  5673. canvas.style.height = (canvas.height * e) + "px";
  5674. viewW = 480;
  5675. viewH = 720
  5676. }
  5677. styleW = d;
  5678. styleH = a;
  5679. docToCanv = Math.min(styleW / 480, styleH / 720);
  5680. window.scrollTo(0, 1)
  5681. }
  5682. function orientationChanged(a) {
  5683. console.log(window.orientation);
  5684. gWrongOrientation = false;
  5685. if (window.orientation != 0) {
  5686. gWrongOrientation = true
  5687. }
  5688. }
  5689. window.requestAnimFrame = (function() {
  5690. return (window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(a) {
  5691. window.setTimeout(a, 1000 / 60)
  5692. })
  5693. })();
  5694. var game = new Game();
  5695. this.loadContent = function() {
  5696. resizeGame();
  5697. content.load()
  5698. };
  5699. function queryIsTouchDevice() {
  5700. return "ontouchstart" in window || "onmsgesturechange" in window
  5701. }
  5702. function init() {
  5703. if (game.init()) {
  5704. game.start()
  5705. }
  5706. }
  5707. function checkSL() {
  5708. var b = [];
  5709. var d = gCurrentBrand;
  5710. switch (d) {
  5711. default:
  5712. case BRAND.NONE:
  5713. break;
  5714. case BRAND.ADDICTING:
  5715. b.push("addictinggames.com");
  5716. break;
  5717. case BRAND.MRG:
  5718. b.push("myrealgames.com");
  5719. break
  5720. }
  5721. if (b.length != 0) {
  5722. for (var c = 0; c < b.length; c++) {
  5723. if (window.top.location.hostname.indexOf(b[c]) != -1) {
  5724. break
  5725. }
  5726. }
  5727. if (c >= b.length) {
  5728. throw "This game cannot be played from this domain";
  5729. invalid = true
  5730. }
  5731. }
  5732. }
  5733. function Particle() {
  5734. Drawable.call(this);
  5735. this.started = false;
  5736. this.velocityX = 0;
  5737. this.velocityY = 0;
  5738. this.dragX = 1;
  5739. this.dragY = 1;
  5740. this.timer = 0;
  5741. this.lifetime = 0;
  5742. this.gravityX = 0;
  5743. this.gravityY = 0;
  5744. this.angularVelocity = 0;
  5745. this.accelerationX = 0;
  5746. this.accelerationY = 0;
  5747. this.startScaleX = 1;
  5748. this.startScaleY = 1;
  5749. this.endScaleX = 1;
  5750. this.endScaleY = 1;
  5751. this.startAlpha = 1;
  5752. this.endAlpha = 1;
  5753. this.angle = 0;
  5754. this.followVelocity = false
  5755. }
  5756. Particle.prototype = new Drawable();
  5757. Particle.prototype.constructor = Particle;
  5758. Particle.prototype.init = function(b, a) {
  5759. this.sprite = b;
  5760. this.lifetime = a;
  5761. this.started = false;
  5762. this.useCamera = true
  5763. };
  5764. Particle.prototype.update = function(b) {
  5765. if (this.started && !this.toBeRemoved) {
  5766. this.timer += b;
  5767. if (this.timer >= this.lifetime) {
  5768. this.flagForRemoval();
  5769. return
  5770. }
  5771. var a = this.timer / this.lifetime;
  5772. this.alpha = this.startAlpha + (this.endAlpha - this.startAlpha) * a;
  5773. this.scaleX = this.startScaleX + (this.endScaleX - this.startScaleX) * a;
  5774. this.scaleY = this.startScaleY + (this.endScaleY - this.startScaleY) * a;
  5775. this.angle += this.angularVelocity;
  5776. this.accelerationX += this.gravityX;
  5777. this.accelerationY += this.gravityY;
  5778. var d = this.velocityX;
  5779. var c = this.velocityY;
  5780. this.velocityX += this.accelerationX * b;
  5781. this.velocityY += this.accelerationY * b;
  5782. this.x += d + this.velocityX * 0.5 * b;
  5783. this.y += c + this.velocityY * 0.5 * b;
  5784. this.accelerationX = 0;
  5785. this.accelerationY = 0;
  5786. if (this.dragX != 1) {
  5787. this.velocityX *= Math.pow(this.dragX, b)
  5788. }
  5789. if (this.dragY != 1) {
  5790. this.velocityY *= Math.pow(this.dragY, b)
  5791. }
  5792. if (this.followVelocity) {
  5793. this.angle = Math.atan2(this.velocityY, this.velocityX)
  5794. }
  5795. }
  5796. this.hasUpdated = true
  5797. };
  5798. Particle.prototype.start = function(a) {
  5799. if (!a) {
  5800. a = this
  5801. }
  5802. a.started = true;
  5803. a.timer = 0;
  5804. a.scaleX = a.startScaleX;
  5805. a.scaleY = a.startScaleY
  5806. };
  5807. function SceneObject() {
  5808. Entity.call(this);
  5809. this.children = [];
  5810. this.childCount = 0
  5811. }
  5812. SceneObject.prototype = new Entity();
  5813. SceneObject.prototype.constructor = SceneObject;
  5814. SceneObject.prototype.init = function(a, b) {
  5815. this.x = a;
  5816. this.y = b;
  5817. this.children = [];
  5818. this.childCount = 0;
  5819. this.toBeRemoved = false;
  5820. this.useCamera = true
  5821. };
  5822. SceneObject.prototype.update = function(b) {
  5823. this.removeChildren();
  5824. for (var a = 0; a < this.childCount; a++) {
  5825. this.children[a].update(b)
  5826. }
  5827. };
  5828. SceneObject.prototype.draw = function(b) {
  5829. if (!this.visible) {
  5830. return
  5831. }
  5832. for (var a = 0; a < this.childCount; a++) {
  5833. this.children[a].draw(b)
  5834. }
  5835. };
  5836. SceneObject.prototype.addChild = function(a) {
  5837. a.parent = this;
  5838. a.sceneManager = this.sceneManager;
  5839. this.children.push(a);
  5840. this.childCount++
  5841. };
  5842. SceneObject.prototype.removeChildren = function() {
  5843. for (var a = 0; a < this.childCount; a++) {
  5844. if (this.children[a].toBeRemoved) {
  5845. this.children.splice(a, 1);
  5846. this.childCount--;
  5847. return
  5848. }
  5849. }
  5850. };
  5851. function SceneManager() {
  5852. this.entities = [];
  5853. this.entityCount = 0;
  5854. this.camera;
  5855. this.masterAlpha;
  5856. this.timeMultiplier;
  5857. this.inverseMatrix;
  5858. this.mousePoint;
  5859. this.init = function() {
  5860. this.camera = new Camera();
  5861. this.camera.init(0, 0, 0, 1);
  5862. this.masterAlpha = 1;
  5863. this.timeMultiplier = 1;
  5864. this.parallaxMagnitudeX = 1;
  5865. this.parallaxMagnitudeY = 1;
  5866. this.worldMouseX = 0;
  5867. this.worldMouseY = 0
  5868. };
  5869. this.update = function(b) {
  5870. b *= this.timeMultiplier;
  5871. this.camera.update(b);
  5872. for (var a = 0; a < this.entityCount; a++) {
  5873. if (this.entities[a].toBeRemoved) {
  5874. this.entities.splice(a, 1);
  5875. this.entityCount--;
  5876. a--;
  5877. continue
  5878. }
  5879. this.entities[a].update(b)
  5880. }
  5881. this.sort();
  5882. this.updateWorldMouse()
  5883. };
  5884. this.updateWorldMouse = function() {
  5885. if (!this.inverseMatrix) {
  5886. this.inverseMatrix = mat2d.create()
  5887. }
  5888. mat2d.copy(this.inverseMatrix, this.camera.internalMatrix);
  5889. mat2d.invert(this.inverseMatrix, this.inverseMatrix);
  5890. if (!this.mousePoint) {
  5891. this.mousePoint = vec2.create()
  5892. }
  5893. if (gMobile && currentTouches.length != 0) {
  5894. this.mousePoint[0] = currentTouches[0].x;
  5895. this.mousePoint[1] = currentTouches[0].y
  5896. } else {
  5897. if (gMobile) {
  5898. return
  5899. } else {
  5900. this.mousePoint[0] = mouseX;
  5901. this.mousePoint[1] = mouseY
  5902. }
  5903. }
  5904. vec2.transformMat2d(this.mousePoint, this.mousePoint, this.inverseMatrix);
  5905. this.worldMouseX = this.mousePoint[0];
  5906. this.worldMouseY = this.mousePoint[1]
  5907. };
  5908. this.draw = function() {
  5909. mat2d.identity(this.camera.internalMatrix);
  5910. if (this.camera.originX != 0 || this.camera.originY != 0) {
  5911. mat2d.translate(this.camera.internalMatrix, this.camera.internalMatrix, [this.camera.originX, this.camera.originY])
  5912. }
  5913. if (this.camera.zoom != 1) {
  5914. mat2d.scale(this.camera.internalMatrix, this.camera.internalMatrix, [this.camera.zoom, this.camera.zoom])
  5915. }
  5916. if (this.camera.angle != 0) {
  5917. mat2d.rotateZ(this.camera.internalMatrix, this.camera.internalMatrix, this.camera.angle)
  5918. }
  5919. if (this.camera.positionX != 0 || this.camera.positionY != 0) {
  5920. mat2d.translate(this.camera.internalMatrix, this.camera.internalMatrix, [this.camera.positionX, this.camera.positionY])
  5921. }
  5922. if (this.camera.shakeOffsetX != 0 || this.camera.shakeOffsetY != 0) {
  5923. mat2d.translate(this.camera.internalMatrix, this.camera.internalMatrix, [this.camera.shakeOffsetX, this.camera.shakeOffsetY])
  5924. }
  5925. ctx.save();
  5926. for (var a = 0; a < this.entityCount; a++) {
  5927. this.entities[a].draw()
  5928. }
  5929. ctx.restore()
  5930. };
  5931. this.addEntity = function(a) {
  5932. a.sceneManager = this;
  5933. this.entities.push(a);
  5934. a.onAddedToSceneManager();
  5935. this.entityCount++
  5936. };
  5937. this.sort = function() {
  5938. this.entities.sort(this.depthSort)
  5939. };
  5940. this.removeEntity = function(a) {
  5941. for (var b = 0; b < this.entityCount; b++) {
  5942. if (this.entities[b].toBeRemoved) {
  5943. var a = this.entities[b];
  5944. this.entities.splice(b, 1);
  5945. this.entityCount--;
  5946. delete a;
  5947. return
  5948. }
  5949. }
  5950. };
  5951. this.depthSort = function(d, c) {
  5952. if (d.depth > c.depth) {
  5953. return -1
  5954. } else {
  5955. if (d.depth < c.depth) {
  5956. return 1
  5957. }
  5958. }
  5959. return 0
  5960. };
  5961. this.clear = function() {
  5962. while (this.entities.length) {
  5963. this.entities[0].flagForRemoval();
  5964. this.entities.splice(0, 1)
  5965. }
  5966. this.entityCount = 0
  5967. };
  5968. this.viewToWorld = function(d, c) {
  5969. var b = mat2.create(this.camera.internalMatrix);
  5970. mat2.invert(b, b);
  5971. var a = vec2.create();
  5972. a[0] = d;
  5973. a[1] = c;
  5974. vec2.transformMat2d(a, a, b);
  5975. return {
  5976. x: a[0],
  5977. y: a[1]
  5978. }
  5979. }
  5980. }
  5981. function SpriteSheet() {
  5982. Drawable.call(this);
  5983. this.animations = [];
  5984. this.animationCount = 0;
  5985. this.currentAnimation = -1;
  5986. this.frameWidth = 0;
  5987. this.frameHeight = 0;
  5988. this.textureWidth = 0;
  5989. this.textureHeight = 0;
  5990. this.speedModifier = 1;
  5991. this.removeWhenStopped = false
  5992. }
  5993. SpriteSheet.prototype = new Drawable();
  5994. SpriteSheet.prototype.constructor = SpriteSheet;
  5995. SpriteSheet.prototype.init = function(c, a, b) {
  5996. this.sprite = c;
  5997. this.frameWidth = a;
  5998. this.frameHeight = b;
  5999. this.sourceRectX = 0;
  6000. this.sourceRectY = 0;
  6001. this.sourceRectW = a;
  6002. this.sourceRectH = b;
  6003. this.useSourceRect = true;
  6004. this.useCamera = true
  6005. };
  6006. SpriteSheet.prototype.update = function(e) {
  6007. if (!this.active || !this.visible) {
  6008. return
  6009. }
  6010. if (this.currentAnimation > -1 && this.currentAnimation < this.animationCount) {
  6011. var g = this.animations[this.currentAnimation].currentFrame;
  6012. var c = this.animations[this.currentAnimation].frames[g];
  6013. this.animations[this.currentAnimation].update(e * this.speedModifier);
  6014. var a = this.sprite.width;
  6015. var b = this.sprite.height;
  6016. var f = this.frameWidth * this.animations[this.currentAnimation].frames[g];
  6017. var d = 0;
  6018. while (f >= a) {
  6019. d += this.frameHeight * Math.floor((f / a));
  6020. f = (f) % a
  6021. }
  6022. this.sourceRectX = f;
  6023. this.sourceRectY = d;
  6024. this.sourceRectW = this.frameWidth;
  6025. this.sourceRectH = this.frameHeight;
  6026. if (this.removeWhenStopped && this.animations[this.currentAnimation].currentState == AnimationState.STOPPED) {
  6027. this.flagForRemoval();
  6028. return
  6029. }
  6030. }
  6031. };
  6032. SpriteSheet.prototype.currentAnimationState = function() {
  6033. if (this.currentAnimation > -1 && this.currentAnimation < this.animationCount) {
  6034. return this.animations[this.currentAnimation].currentState
  6035. }
  6036. return null
  6037. };
  6038. SpriteSheet.prototype.addAnimation = function(b, e, g, f, a) {
  6039. var d = new Animation();
  6040. d.init(b, e, g, f);
  6041. for (var c = 0; c < this.animationCount; c++) {
  6042. if (this.animations[c].name == b) {
  6043. if (a) {
  6044. this.animations.splice(c, 1);
  6045. this.animationCount--;
  6046. break
  6047. } else {
  6048. return
  6049. }
  6050. }
  6051. }
  6052. this.animations.push(d);
  6053. this.animationCount++
  6054. };
  6055. SpriteSheet.prototype.playAnimation = function(b, a) {
  6056. for (var c = 0; c < this.animationCount; c++) {
  6057. if (this.animations[c].name == b) {
  6058. if (a) {
  6059. this.animations[c].ResetTimer();
  6060. this.animations[c].SetFrame(0)
  6061. }
  6062. this.animations[c].SetState(AnimationState.PLAYING);
  6063. this.currentAnimation = c;
  6064. break
  6065. }
  6066. }
  6067. this.update(0)
  6068. };
  6069. SpriteSheet.prototype.stopAnimation = function(a) {
  6070. for (var b = 0; b < this.animationCount; b++) {
  6071. if (this.animations[b].name == a) {
  6072. this.animations[b].SetState(AnimationState.STOPPED);
  6073. this.currentAnimation = -1;
  6074. break
  6075. }
  6076. }
  6077. };
  6078. SpriteSheet.prototype.rewindAnimation = function(a) {
  6079. for (var b = 0; b < this.animationCount; b++) {
  6080. if (this.animations[b].name == a) {
  6081. this.animations[b].SetState(AnimationState.REWINDING);
  6082. this.currentAnimation = b;
  6083. break
  6084. }
  6085. }
  6086. };
  6087. var TO_DEGREES = 180 / Math.PI;
  6088. var TO_RADIANS = Math.PI / 180;
  6089. function randIntRange(b, a) {
  6090. return Math.floor(randFloatRange(b, a))
  6091. }
  6092. function randFloatRange(b, a) {
  6093. return (Math.random() * (a - b)) + b
  6094. }
  6095. function distanceBetweenPoints(b, d, a, c) {
  6096. return Math.sqrt(((a - b) * (a - b)) + ((c - d) * (c - d)))
  6097. }
  6098. function normalizeAngle(b) {
  6099. while (b > Math.PI * 2) {
  6100. b -= Math.PI * 2
  6101. }
  6102. while (b < 0) {
  6103. b += Math.PI * 2
  6104. }
  6105. return b
  6106. }
  6107. function supports_html5_storage() {
  6108. try {
  6109. return "localStorage" in window && window.localStorage !== null
  6110. } catch (a) {
  6111. return false
  6112. }
  6113. }
  6114. function queryLocalVar(a) {
  6115. if (!gStorageAvailable) {
  6116. return null
  6117. }
  6118. a = "MATTER." + a;
  6119. var b = localStorage.getItem(a);
  6120. return b
  6121. }
  6122. function setLocalVar(a, b) {
  6123. if (!gStorageAvailable) {
  6124. return
  6125. }
  6126. a = "MATTER." + a;
  6127. localStorage.setItem(a, b)
  6128. }
  6129. function submitScore(b, c, d) {
  6130. leaderboard = new Clay.Leaderboard({
  6131. id: 1866
  6132. });
  6133. var a = {
  6134. score: c,
  6135. name: b,
  6136. hideUI: true
  6137. };
  6138. leaderboard.post(a, d)
  6139. }
  6140. function getFormattedTime(c) {
  6141. var a = "";
  6142. if (c < 0) {
  6143. c *= -1;
  6144. a += "-"
  6145. }
  6146. if (c >= 60) {
  6147. if (c / 60 < 10) {
  6148. a += "0"
  6149. }
  6150. a += Math.floor(c / 60).toString()
  6151. } else {
  6152. a += "00"
  6153. }
  6154. a += ":";
  6155. if (c >= 1) {
  6156. if (c % 60 < 10) {
  6157. a += "0"
  6158. }
  6159. a += Math.floor(c % 60).toString()
  6160. } else {
  6161. a += "00"
  6162. }
  6163. a += ":";
  6164. var b = (c % 1).toString();
  6165. a += b.substring(2, 4);
  6166. return a
  6167. }
  6168. function hexToRGB(b) {
  6169. var a = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(b);
  6170. return a ? {
  6171. r: parseInt(a[1], 16),
  6172. g: parseInt(a[2], 16),
  6173. b: parseInt(a[3], 16)
  6174. } : null
  6175. }
  6176. function colorMatrixFilter(n, e) {
  6177. var l = n.data;
  6178. for (var h = 0; h < l.length; h += 4) {
  6179. var k = l[h];
  6180. var j = l[h + 1];
  6181. var c = l[h + 2];
  6182. var f = l[h + 3];
  6183. l[h] = k * e[0] + j * e[1] + c * e[2] + f * e[3] + e[4];
  6184. l[h + 1] = k * e[5] + j * e[6] + c * e[7] + f * e[8] + e[9];
  6185. l[h + 2] = k * e[10] + j * e[11] + c * e[12] + f * e[13] + e[14];
  6186. l[h + 3] = k * e[15] + j * e[16] + c * e[17] + f * e[18] + e[19]
  6187. }
  6188. return n
  6189. }
  6190. var Trigger = {
  6191. IN: 0,
  6192. OUT: 1
  6193. };
  6194. function Transition() {
  6195. this.time = 1;
  6196. this.delay = 0;
  6197. this.ease = null;
  6198. this.reverse = false;
  6199. this.last = 0;
  6200. this.state = null;
  6201. this.nextState = null;
  6202. this.previousState = null;
  6203. this.drawable = false;
  6204. this.done = false;
  6205. this.started = false
  6206. }
  6207. Transition.prototype.init = function(d, e, f, b, g, c, a) {
  6208. this.time = e;
  6209. this.delay = a;
  6210. this.reverse = b;
  6211. this.ease = f;
  6212. this.state = d;
  6213. if (this.state) {
  6214. this.state.progress = g
  6215. }
  6216. this.nextState = c
  6217. };
  6218. Transition.prototype.trigger = function(b, a) {
  6219. if (!this.state) {
  6220. return false
  6221. }
  6222. this.done = false;
  6223. this.started = true;
  6224. if (b == Trigger.IN && this.state.progress == 1) {
  6225. return false
  6226. } else {
  6227. if (b == Trigger.OUT && this.state.progress === 0) {
  6228. return false
  6229. }
  6230. } if (b == Trigger.OUT) {
  6231. this.nextState = a
  6232. } else {
  6233. this.previousState = a
  6234. }
  6235. this.last = b;
  6236. if (this.time === 0) {
  6237. this.state.progress = (b == Trigger.IN ? 1 : 0);
  6238. this.onTransitionDone(this);
  6239. return false
  6240. }
  6241. if (b == Trigger.IN) {
  6242. this.state.transitionState = TransitionState.ENTERING
  6243. } else {
  6244. this.state.transitionState = TransitionState.EXITING
  6245. }
  6246. this.last = b;
  6247. TweenLite.to(this.state, this.time, {
  6248. progress: (b == Trigger.IN ? 1 : 0),
  6249. onComplete: this.onTransitionDone,
  6250. ease: this.ease,
  6251. overwrite: false,
  6252. delay: this.delay,
  6253. data: this
  6254. });
  6255. return true
  6256. };
  6257. Transition.prototype.onTransitionDone = function(a) {
  6258. if (this.data) {
  6259. a = this.data
  6260. }
  6261. if (a.last === Trigger.IN) {
  6262. a.state.onEnter()
  6263. } else {
  6264. if (a.last === Trigger.OUT) {
  6265. a.state.onExit()
  6266. }
  6267. } if (a.nextState) {
  6268. a.nextState.onPrevStateFinished()
  6269. }
  6270. a.done = true
  6271. };
  6272. Transition.prototype.draw = function() {
  6273. if (this.done) {
  6274. return false
  6275. }
  6276. if (!this.drawable) {
  6277. return false
  6278. }
  6279. return true
  6280. };
  6281. Transition.prototype.kill = function() {
  6282. this.done = true;
  6283. this.OnTransitionDone();
  6284. TweenLite.killTweensOf(this.state);
  6285. this.state.progress = (this.direction == TRIGGER.IN ? 1 : 0)
  6286. };
  6287. function FadeToBlackTransition() {
  6288. Transition.call(this);
  6289. this.time = 1;
  6290. this.delay = 0;
  6291. this.ease = null;
  6292. this.reverse = false;
  6293. this.last = 0;
  6294. this.state = null;
  6295. this.nextState = null;
  6296. this.previousState = null;
  6297. this.drawable = true;
  6298. this.done = false;
  6299. this.started = false
  6300. }
  6301. FadeToBlackTransition.prototype = new Transition();
  6302. FadeToBlackTransition.prototype.constructor = FadeToBlackTransition;
  6303. FadeToBlackTransition.prototype.init = function(d, e, f, b, g, c, a) {
  6304. this.time = e;
  6305. this.delay = a;
  6306. this.reverse = b;
  6307. this.ease = f;
  6308. this.state = d;
  6309. if (this.state) {
  6310. this.state.progress = g
  6311. }
  6312. this.nextState = c;
  6313. this.black = content.black4
  6314. };
  6315. FadeToBlackTransition.prototype.draw = function() {
  6316. if (this.done) {
  6317. return false
  6318. }
  6319. ctx.save();
  6320. ctx.globalAlpha = 1 - this.state.progress;
  6321. ctx.scale(canvas.width, canvas.height);
  6322. ctx.drawImage(this.black, 0, 0);
  6323. ctx.restore();
  6324. return true
  6325. };
  6326. var ButtonHover = {
  6327. MOVERIGHT16: 0,
  6328. MOVELEFT16: 1,
  6329. MOVERIGHT32: 2,
  6330. MOVELEFT32: 3,
  6331. GROW: 4,
  6332. TURNLEFT: 5,
  6333. TURNRIGHT: 6,
  6334. SKEWRIGHT: 7
  6335. };
  6336. var ButtonHit = {
  6337. PULSE: 0,
  6338. SHIFTRIGHT: 1,
  6339. SHIFTLEFT: 2
  6340. };
  6341. function reactIn(a, b) {
  6342. switch (b) {
  6343. case ButtonHover.MOVERIGHT16:
  6344. TweenLite.to(a, 0.15, {
  6345. reactOffsetX: 16,
  6346. ease: Sine.easeOut
  6347. });
  6348. break;
  6349. case ButtonHover.MOVELEFT16:
  6350. TweenLite.to(a, 0.15, {
  6351. reactOffsetX: -16,
  6352. ease: Sine.easeOut
  6353. });
  6354. break;
  6355. case ButtonHover.MOVERIGHT32:
  6356. TweenLite.to(a, 0.15, {
  6357. reactOffsetX: 32,
  6358. ease: Sine.easeOut
  6359. });
  6360. break;
  6361. case ButtonHover.MOVELEFT32:
  6362. TweenLite.to(a, 0.15, {
  6363. reactOffsetX: -32,
  6364. ease: Sine.easeOut
  6365. });
  6366. break;
  6367. case ButtonHover.GROW:
  6368. TweenLite.to(a, 0.15, {
  6369. reactScaleX: 1.15,
  6370. reactScaleY: 1.15,
  6371. ease: Sine.easeOut
  6372. });
  6373. break;
  6374. case ButtonHover.TURNLEFT:
  6375. TweenLite.to(a, 0.15, {
  6376. reactAngle: -0.2,
  6377. ease: Sine.easeOut
  6378. });
  6379. break;
  6380. case ButtonHover.TURNRIGHT:
  6381. TweenLite.to(a, 0.15, {
  6382. reactAngle: 0.2,
  6383. ease: Sine.easeOut
  6384. });
  6385. break;
  6386. case ButtonHover.SKEWRIGHT:
  6387. TweenLite.to(a, 0.15, {
  6388. reactSkewX: 0.2,
  6389. ease: Sine.easeOut
  6390. });
  6391. TweenLite.to(a.reactOffset, 0.15, {
  6392. x: 16,
  6393. ease: Sine.easeOut
  6394. });
  6395. break
  6396. }
  6397. }
  6398. function reactOut(a, b) {
  6399. switch (b) {
  6400. case ButtonHover.MOVERIGHT16:
  6401. case ButtonHover.MOVELEFT16:
  6402. case ButtonHover.MOVERIGHT32:
  6403. case ButtonHover.MOVELEFT32:
  6404. TweenLite.to(a, 0.25, {
  6405. reactOffsetX: 0,
  6406. ease: Sine.easeOut
  6407. });
  6408. break;
  6409. case ButtonHover.GROW:
  6410. TweenLite.to(a, 0.25, {
  6411. reactScaleX: 1,
  6412. reactScaleY: 1,
  6413. ease: Sine.easeOut
  6414. });
  6415. break;
  6416. case ButtonHover.TURNLEFT:
  6417. case ButtonHover.TURNRIGHT:
  6418. TweenLite.to(a, 0.25, {
  6419. reactAngle: 0,
  6420. ease: Sine.easeOut
  6421. });
  6422. break;
  6423. case ButtonHover.SKEWRIGHT:
  6424. TweenLite.to(a, 0.15, {
  6425. reactSkewX: 0,
  6426. ease: Sine.easeOut
  6427. });
  6428. TweenLite.to(a, 0.15, {
  6429. reactOffsetX: 0,
  6430. ease: Sine.easeOut
  6431. });
  6432. break
  6433. }
  6434. }
  6435. function hitReact(b, c) {
  6436. switch (c) {
  6437. case ButtonHit.PULSE:
  6438. b.reactScaleX = 1.4;
  6439. b.reactScaleY = 1.4;
  6440. TweenLite.to(b, 0.45, {
  6441. reactScaleX: 1,
  6442. reactScaleY: 1,
  6443. ease: Elastic.easeOut
  6444. });
  6445. break;
  6446. case ButtonHit.SHIFTRIGHT:
  6447. var a = b.reactOffsetX;
  6448. b.reactOffsetX = b.reactOffsetX - 8;
  6449. TweenLite.to(b, 0.45, {
  6450. reactOffsetX: a,
  6451. ease: Sine.easeOut
  6452. });
  6453. break;
  6454. case ButtonHit.SHIFTLEFT:
  6455. var a = b.reactOffsetX;
  6456. b.reactOffsetX = b.reactOffsetX + 8;
  6457. TweenLite.to(b, 0.45, {
  6458. reactOffsetX: a,
  6459. ease: Sine.easeOut
  6460. });
  6461. break
  6462. }
  6463. }
  6464. var ButtonState = {
  6465. DEFAULT: 0,
  6466. HOVER: 1,
  6467. HIT: 2,
  6468. UP: 3,
  6469. INACTIVE: 4
  6470. };
  6471. function Button() {
  6472. Drawable.call(this);
  6473. this.currentBitmap = null;
  6474. this.defaultGraphic = null;
  6475. this.hoverGraphic = null;
  6476. this.hitGraphic = null;
  6477. this.inactiveGraphic = null;
  6478. this.buttonText = "";
  6479. this.textColor = "#000000";
  6480. this.textFont = "sans-serif";
  6481. this.textSize = "18px";
  6482. this.active = true;
  6483. this.buttonState = ButtonState.DEFAULT;
  6484. this.prevButtonState = ButtonState.INACTIVE;
  6485. this.visible = true;
  6486. this.dirty = true;
  6487. this.forceUpdate = false;
  6488. this.mouseOver = false;
  6489. this.prevMouseOver = false;
  6490. this.parentState = null;
  6491. this.callback = null;
  6492. this.hoverCallback = null;
  6493. this.leaveCallback = null;
  6494. this.hitAreaX = 0;
  6495. this.hitAreaY = 0;
  6496. this.hitAreaW = 128;
  6497. this.hitAreaH = 64;
  6498. this.hitReact = -1;
  6499. this.hoverReact = -1;
  6500. this.screenSizeOffsetX = 0;
  6501. this.screenSizeOffsetY = 0;
  6502. this.reactOffsetX = 0;
  6503. this.reactOffsetY = 0;
  6504. this.reactAngle = 0;
  6505. this.reactScaleX = 1;
  6506. this.reactScaleY = 1;
  6507. this.reactSkewX = 0;
  6508. this.reactSkewY = 0
  6509. }
  6510. Button.prototype = new Drawable();
  6511. Button.prototype.constructor = Button;
  6512. Button.prototype.init = function() {
  6513. this.useCamera = false;
  6514. if (this.buttonText === undefined || this.buttonText == "") {
  6515. this.hitAreaX = -this.defaultGraphic.width * 0.5;
  6516. this.hitAreaY = -this.defaultGraphic.height * 0.5;
  6517. this.hitAreaW = this.defaultGraphic.width;
  6518. this.hitAreaH = this.defaultGraphic.height;
  6519. this.originX = this.defaultGraphic.width * 0.5;
  6520. this.originY = this.defaultGraphic.height * 0.5
  6521. } else {
  6522. var a = this.MeasureText(this.buttonText, false, this.textFont, this.textSize);
  6523. this.hitAreaX = 0;
  6524. this.hitAreaY = 0;
  6525. this.hitAreaW = a[0] * 0.75;
  6526. this.hitAreaH = a[1] * 0.75
  6527. }
  6528. };
  6529. Button.prototype.checkMouseCoords = function() {
  6530. if (gMobile) {
  6531. for (var a = 0; a < currentTouches.length; a++) {
  6532. if (currentTouches[a].x >= (this.x + this.screenSizeOffsetX) + this.hitAreaX && currentTouches[a].x <= (this.x + this.screenSizeOffsetX) + this.hitAreaX + this.hitAreaW && currentTouches[a].y >= (this.y + this.screenSizeOffsetY) + this.hitAreaY && currentTouches[a].y <= (this.y + this.screenSizeOffsetY) + this.hitAreaY + this.hitAreaH) {
  6533. return true
  6534. }
  6535. }
  6536. } else {
  6537. if (mouseX >= (this.x + this.screenSizeOffsetX) + this.hitAreaX && mouseX <= (this.x + this.screenSizeOffsetX) + this.hitAreaX + this.hitAreaW && mouseY >= (this.y + this.screenSizeOffsetY) + this.hitAreaY && mouseY <= (this.y + this.screenSizeOffsetY) + this.hitAreaY + this.hitAreaH) {
  6538. return true
  6539. }
  6540. }
  6541. return false
  6542. };
  6543. Button.prototype.onMouseOver = function() {
  6544. if (!this.active) {
  6545. return
  6546. }
  6547. this.buttonState = ButtonState.HOVER;
  6548. setCursor("pointer");
  6549. if (this.hoverReact != -1) {
  6550. reactIn(this, this.hoverReact)
  6551. }
  6552. if (this.hoverCallback) {
  6553. this.hoverCallback(this.parentState)
  6554. }
  6555. };
  6556. Button.prototype.onMouseDown = function() {
  6557. if (!this.active) {
  6558. return
  6559. }
  6560. this.buttonState = ButtonState.HIT;
  6561. setCursor("default");
  6562. if (this.hitReact != -1) {
  6563. hitReact(this, this.hitReact)
  6564. }
  6565. if (this.callback) {
  6566. this.callback(this.parentState)
  6567. }
  6568. };
  6569. Button.prototype.onMouseUp = function() {
  6570. if (!this.active) {
  6571. return
  6572. }
  6573. this.buttonState = ButtonState.HOVER
  6574. };
  6575. Button.prototype.onMouseOff = function() {
  6576. if (!this.active) {
  6577. return
  6578. }
  6579. this.buttonState = ButtonState.DEFAULT;
  6580. setCursor("default");
  6581. if (this.hoverReact != -1) {
  6582. reactOut(this, this.hoverReact)
  6583. }
  6584. if (this.leaveCallback) {
  6585. this.leaveCallback(this.parentState)
  6586. }
  6587. };
  6588. Button.prototype.update = function(a) {
  6589. if (this.active) {
  6590. this.mouseOver = this.checkMouseCoords();
  6591. if (this.mouseOver && !this.prevMouseOver) {
  6592. this.onMouseOver()
  6593. } else {
  6594. if (!this.mouseOver && this.prevMouseOver) {
  6595. this.onMouseOff()
  6596. }
  6597. } if (this.mouseOver) {
  6598. if (gMobile) {
  6599. if (touchDown && !touchDownLast) {
  6600. this.onMouseDown()
  6601. } else {
  6602. if (!touchDown && touchDownLast) {
  6603. this.onMouseUp()
  6604. }
  6605. }
  6606. } else {
  6607. if (mouseDown && !mouseDownLast) {
  6608. this.onMouseDown()
  6609. } else {
  6610. if (!mouseDown && mouseDownLast) {
  6611. this.onMouseUp()
  6612. }
  6613. }
  6614. }
  6615. }
  6616. }
  6617. this.prevMouseOver = this.mouseOver;
  6618. if (this.prevButtonState != this.buttonState || this.forceUpdate) {
  6619. this.forceUpdate = false;
  6620. if (this.buttonText === undefined || this.buttonText === "") {
  6621. switch (this.buttonState) {
  6622. case ButtonState.DEFAULT:
  6623. this.currentBitmap = this.defaultGraphic;
  6624. break;
  6625. case ButtonState.HOVER:
  6626. this.currentBitmap = this.hoverGraphic;
  6627. break;
  6628. case ButtonState.HIT:
  6629. this.currentBitmap = this.hitGraphic;
  6630. break;
  6631. case ButtonState.INACTIVE:
  6632. this.currentBitmap = this.inactiveGraphic;
  6633. break
  6634. }
  6635. if (this.currentBitmap === null) {
  6636. this.currentBitmap = this.defaultGraphic
  6637. }
  6638. } else {}
  6639. }
  6640. this.prevButtonState = this.buttonState
  6641. };
  6642. Button.prototype.draw = function() {
  6643. if (!this.visible) {
  6644. return
  6645. }
  6646. ctx.save();
  6647. ctx.translate(this.x + this.reactOffsetX + this.screenSizeOffsetX, this.y + this.reactOffsetY + this.screenSizeOffsetY);
  6648. if (this.parent) {
  6649. ctx.translate(this.parent.x, this.parent.y)
  6650. }
  6651. ctx.rotate(this.angle + this.reactAngle);
  6652. ctx.scale(this.scaleX * this.reactScaleX, this.scaleY * this.reactScaleY);
  6653. ctx.translate(-this.originX, -this.originY);
  6654. ctx.globalAlpha = this.alpha;
  6655. if (this.currentBitmap) {
  6656. if (this.useSourceRect) {
  6657. ctx.drawImage(this.currentBitmap, this.sourceRectX, this.sourceRectY, this.sourceRectW, this.sourceRectH, 0, 0, this.sourceRectW, this.sourceRectH)
  6658. } else {
  6659. ctx.drawImage(this.currentBitmap, 0, 0)
  6660. }
  6661. } else {
  6662. if (this.buttonText != "") {
  6663. ctx.textBaseline = "top";
  6664. ctx.fillStyle = this.textColor;
  6665. ctx.font = this.textSize + "px regular " + this.textFont;
  6666. ctx.fillText(this.buttonText, 0, 0)
  6667. }
  6668. }
  6669. ctx.restore()
  6670. };
  6671. Button.prototype.MeasureText = function(e, c, a, b) {
  6672. var d = e + ":" + c + ":" + a + ":" + b;
  6673. if (typeof(__measuretext_cache__) == "object" && __measuretext_cache__[d]) {
  6674. return __measuretext_cache__[d]
  6675. }
  6676. var f = document.createElement("DIV");
  6677. f.innerHTML = e;
  6678. f.style.position = "absolute";
  6679. f.style.top = "-100px";
  6680. f.style.left = "-100px";
  6681. f.style.fontFamily = a;
  6682. f.style.fontWeight = c ? "bold" : "normal";
  6683. f.style.fontSize = b + "pt";
  6684. document.body.appendChild(f);
  6685. var b = [f.offsetWidth, f.offsetHeight];
  6686. document.body.removeChild(f);
  6687. if (typeof(__measuretext_cache__) != "object") {
  6688. __measuretext_cache__ = []
  6689. }
  6690. __measuretext_cache__[d] = b;
  6691. return b
  6692. };
  6693. var TransitionState = {
  6694. NULL: 0,
  6695. ENTERING: 1,
  6696. EXITING: 2,
  6697. ENTERED: 3,
  6698. EXITED: 4
  6699. };
  6700. function State() {
  6701. this.stateManager = null;
  6702. this.initialized = false;
  6703. this.destroyed = false;
  6704. this.isOverlay = false;
  6705. this.buttons = [];
  6706. this.inTransition = null;
  6707. this.outTransition = null;
  6708. this.transitionState = TransitionState.NULL;
  6709. this.progress = 0
  6710. }
  6711. State.prototype.init = function() {
  6712. this.initialized = true;
  6713. this.destroyed = false;
  6714. this.inTransition = new Transition();
  6715. this.inTransition.init(this, 1, Sine.easeOut, false, 0, null, 0);
  6716. this.outTransition = new Transition();
  6717. this.outTransition.init(this, 1, Sine.easeOut, false, 0, null, 0)
  6718. };
  6719. State.prototype.onEnter = function() {
  6720. if (!this.initialized) {
  6721. return
  6722. }
  6723. this.transitionState = TransitionState.ENTERED
  6724. };
  6725. State.prototype.onExit = function() {
  6726. if (!this.initialized) {
  6727. return
  6728. }
  6729. this.transitionState = TransitionState.EXITED
  6730. };
  6731. State.prototype.triggerEnter = function() {
  6732. if (!this.initialized) {
  6733. return
  6734. }
  6735. this.inTransition.trigger(Trigger.IN)
  6736. };
  6737. State.prototype.triggerExit = function(a) {
  6738. if (!this.initialized) {
  6739. return
  6740. }
  6741. this.outTransition.trigger(Trigger.OUT, a)
  6742. };
  6743. State.prototype.onPrevStateFinished = function() {};
  6744. State.prototype.update = function(b) {
  6745. if (this.transitionState != TransitionState.ENTERED) {
  6746. gRedrawActive = true
  6747. }
  6748. for (var a = 0; a < this.buttons.length; a++) {
  6749. this.buttons[a].update(b)
  6750. }
  6751. };
  6752. State.prototype.draw = function() {};
  6753. State.prototype.destroy = function() {
  6754. this.destroyed = true
  6755. };
  6756. State.prototype.onRestored = function() {};
  6757. function StateManager() {
  6758. this.currentState = null;
  6759. this.previousStates = null;
  6760. this.desiredState = null;
  6761. this.destroyed = false;
  6762. this.initialized = false
  6763. }
  6764. StateManager.prototype.init = function() {
  6765. this.destroyed = false;
  6766. this.initialized = true;
  6767. this.popping = false;
  6768. this.currentState = null;
  6769. this.previousStates = [];
  6770. this.desiredState = null
  6771. };
  6772. StateManager.prototype.update = function(a) {
  6773. if (!this.initialized) {
  6774. return
  6775. }
  6776. if (this.desiredState && this.desiredState !== this.currentState) {
  6777. if (this.currentState) {
  6778. if (this.currentState.transitionState !== TransitionState.EXITING) {
  6779. if (this.currentState.transitionState === TransitionState.EXITED) {
  6780. if (this.previousStates.length != 0 && !this.desiredState.isOverlay) {
  6781. this.previousStates.length = 0
  6782. }
  6783. if (!this.popping) {
  6784. this.previousStates.push(this.currentState);
  6785. if (this.previousStates.length != 0) {
  6786. this.removeChild(this.previousStates[this.previousStates.length - 1])
  6787. }
  6788. } else {
  6789. this.previousStates.pop()
  6790. }
  6791. this.popping = false;
  6792. this.currentState = this.desiredState;
  6793. this.addChild(this.currentState);
  6794. this.currentState.triggerEnter()
  6795. } else {
  6796. this.currentState.triggerExit()
  6797. }
  6798. }
  6799. } else {
  6800. this.currentState = this.desiredState;
  6801. this.addChild(this.currentState);
  6802. this.currentState.triggerEnter()
  6803. }
  6804. }
  6805. if (this.desiredState && this.desiredState !== this.currentState && this.currentState.outTransition.done) {
  6806. this.desiredState.update(a)
  6807. }
  6808. if (this.currentState) {
  6809. this.currentState.update(a)
  6810. }
  6811. };
  6812. StateManager.prototype.addChild = function(a) {};
  6813. StateManager.prototype.removeChild = function(a) {};
  6814. StateManager.prototype.draw = function() {
  6815. if (this.desiredState !== this.currentState && this.desiredState !== null && this.desiredState.parent !== null) {
  6816. this.desiredState.draw()
  6817. }
  6818. if (this.currentState !== null) {
  6819. this.currentState.draw()
  6820. }
  6821. if (this.currentState && !this.currentState.outTransition.done && this.currentState.outTransition.started) {
  6822. this.currentState.outTransition.draw()
  6823. }
  6824. if (this.desiredState && !this.desiredState.inTransition.done && this.desiredState.inTransition.started) {
  6825. this.desiredState.inTransition.draw()
  6826. }
  6827. };
  6828. StateManager.prototype.destroy = function() {
  6829. if (!this.initialized) {
  6830. return
  6831. }
  6832. for (var a = 0; a < this.previousStates.length; a++) {
  6833. this.previousStates[a].destroy()
  6834. }
  6835. if (this.currentState) {
  6836. this.currentState.destroy()
  6837. }
  6838. if (this.desiredState) {
  6839. this.desiredState.destroy()
  6840. }
  6841. this.destroyed = true
  6842. };
  6843. StateManager.prototype.setState = function(a) {
  6844. if (!this.initialized) {
  6845. return
  6846. }
  6847. if (this.desiredState != this.currentState) {
  6848. return
  6849. }
  6850. if (!a.initialized) {
  6851. a.init()
  6852. }
  6853. this.desiredState = a;
  6854. this.desiredState.stateManager = this;
  6855. if (this.desiredState.inTransition) {
  6856. this.desiredState.inTransition.previousState = this.currentState
  6857. }
  6858. };
  6859. StateManager.prototype.restoreLastState = function() {
  6860. if (this.previousStates.length != 0) {
  6861. this.popping = true;
  6862. this.previousStates[this.previousStates.length - 1].onRestored();
  6863. this.setState(this.previousStates[this.previousStates.length - 1])
  6864. }
  6865. };
  6866. function MainMenuState() {
  6867. State.call(this);
  6868. this.stateManager = null;
  6869. this.initialized = false;
  6870. this.destroyed = false;
  6871. this.buttons = [];
  6872. this.inTransition = null;
  6873. this.outTransition = null;
  6874. this.transitionState = TransitionState.NULL;
  6875. this.progress = 0
  6876. }
  6877. MainMenuState.prototype = new State();
  6878. MainMenuState.prototype.constructor = MainMenuState;
  6879. MainMenuState.prototype.init = function() {
  6880. this.initialized = true;
  6881. this.destroyed = false;
  6882. this.sceneManager = new SceneManager();
  6883. this.sceneManager.init();
  6884. this.background = new Drawable();
  6885. this.background.init(content.menuBack, 0, 0);
  6886. this.background.useCamera = true;
  6887. this.background.originX = this.background.sprite.width * 0.5;
  6888. this.background.originY = this.background.sprite.height * 0.5;
  6889. this.sceneManager.addEntity(this.background);
  6890. this.cloudLine = new Drawable();
  6891. this.cloudLine.init(null, 0, 0);
  6892. this.cloudLine.useCamera = true;
  6893. this.sceneManager.addEntity(this.cloudLine);
  6894. this.cloudLine.sprite = document.createElement("canvas");
  6895. this.cloudLine.sprite.width = canvas.width;
  6896. this.cloudLine.sprite.height = 150;
  6897. var a = this.cloudLine.sprite.getContext("2d");
  6898. this.cloudPattern = a.createPattern(content.cloudLine, "repeat");
  6899. this.cloudScroll = 0;
  6900. this.canvasChanged = false;
  6901. this.sign = new Drawable();
  6902. this.sign.init(content.menuSign, 0, 0);
  6903. this.sign.originX = this.sign.sprite.width * 0.5;
  6904. this.sign.originY = this.sign.sprite.height;
  6905. this.sceneManager.addEntity(this.sign);
  6906. this.shadow = new Drawable();
  6907. this.shadow.init(content.menuSignShadow, 0, 0);
  6908. this.shadow.useCamera = true;
  6909. this.shadow.originX = this.shadow.sprite.width * 0.5;
  6910. this.shadow.originY = 0;
  6911. this.sceneManager.addEntity(this.shadow);
  6912. this.playBtn = new Button();
  6913. this.playBtn.defaultGraphic = content.playBtnUp;
  6914. this.playBtn.hitGraphic = content.playBtnDown;
  6915. this.playBtn.callback = this.onPlayHit;
  6916. this.playBtn.parentState = this;
  6917. this.playBtn.init();
  6918. this.playBtn.originX = this.playBtn.defaultGraphic.width * 0.5;
  6919. this.playBtn.originY = this.playBtn.defaultGraphic.height * 0.5;
  6920. this.buttons.push(this.playBtn);
  6921. this.soundButton = new Button();
  6922. this.soundButton.defaultGraphic = content.soundOff;
  6923. this.soundButton.callback = this.onSoundHit;
  6924. this.soundButton.parentState = this;
  6925. this.soundButton.init();
  6926. this.soundButton.originX = this.soundButton.defaultGraphic.width * 0.5;
  6927. this.soundButton.originY = this.soundButton.defaultGraphic.height * 0.5;
  6928. this.soundButton.scaleX = 0.95;
  6929. this.soundButton.scaleY = 0.95;
  6930. this.buttons.push(this.soundButton);
  6931. if (!soundMuted) {
  6932. this.soundButton.defaultGraphic = content.soundOn
  6933. }
  6934. switch (gCurrentBrand) {
  6935. case BRAND.ADDICTING:
  6936. this.addictingLogo = new Drawable();
  6937. this.addictingLogo.init(content.addictingMenu, canvas.width - 4, canvas.height - 8);
  6938. this.addictingLogo.originX = this.addictingLogo.sprite.width;
  6939. this.addictingLogo.originY = this.addictingLogo.sprite.height;
  6940. this.addictingLogo.useCamera = false;
  6941. this.sceneManager.addEntity(this.addictingLogo);
  6942. this.badge = new Drawable();
  6943. this.badge.init(content.ffBadge, 4, canvas.height - 8);
  6944. this.badge.originX = 0;
  6945. this.badge.originY = this.badge.sprite.height;
  6946. this.badge.useCamera = false;
  6947. this.sceneManager.addEntity(this.badge);
  6948. break;
  6949. case BRAND.MRG:
  6950. this.mrgLogo = new Drawable();
  6951. this.mrgLogo.init(content.mrgMenu, canvas.width - 4, canvas.height - 8);
  6952. this.mrgLogo.originX = this.mrgLogo.sprite.width;
  6953. this.mrgLogo.originY = this.mrgLogo.sprite.height;
  6954. this.mrgLogo.useCamera = false;
  6955. this.sceneManager.addEntity(this.mrgLogo);
  6956. this.moreBtn = new Button();
  6957. this.moreBtn.defaultGraphic = content.moreGames;
  6958. this.moreBtn.parentState = this;
  6959. this.moreBtn.init();
  6960. this.moreBtn.originX = this.moreBtn.defaultGraphic.width * 0.5;
  6961. this.moreBtn.originY = this.moreBtn.defaultGraphic.height * 0.5;
  6962. this.buttons.push(this.moreBtn);
  6963. window.addEventListener("click", this.onMoreHit);
  6964. window.addEventListener("touchend", this.onMoreHit);
  6965. this.badge = new Drawable();
  6966. this.badge.init(content.ffBadge, 4, canvas.height - 8);
  6967. this.badge.originX = 0;
  6968. this.badge.originY = this.badge.sprite.height;
  6969. this.badge.useCamera = false;
  6970. this.sceneManager.addEntity(this.badge);
  6971. break
  6972. }
  6973. this.inTransition = new FadeToBlackTransition();
  6974. this.inTransition.init(this, 1, Sine.easeOut, false, 0, null, 0);
  6975. this.outTransition = new FadeToBlackTransition();
  6976. this.outTransition.init(this, 1, Sine.easeOut, false, 0, null, 0);
  6977. setAudioState(AUDIO_STATE.MENULOOP)
  6978. };
  6979. MainMenuState.prototype.onPlayHit = function(b) {
  6980. var a = new GameplayState();
  6981. a.init();
  6982. b.stateManager.setState(a)
  6983. };
  6984. MainMenuState.prototype.onMoreHit = function(b) {
  6985. var a = this.game.stateManager.currentState || this.game.stateManager.desiredState;
  6986. if (!a || !a.moreBtn) {
  6987. return
  6988. }
  6989. if (a.moreBtn.buttonState == ButtonState.HIT) {
  6990. // Play68.goHome();
  6991. gotomore();
  6992. try {
  6993. parent.moregame();
  6994. } catch (e) {}
  6995. }
  6996. };
  6997. MainMenuState.prototype.onSoundHit = function(a) {
  6998. setSoundMute(!soundMuted);
  6999. setMusicMute(soundMuted);
  7000. if (soundMuted) {
  7001. a.soundButton.defaultGraphic = content.soundOff
  7002. } else {
  7003. a.soundButton.defaultGraphic = content.soundOn
  7004. }
  7005. };
  7006. MainMenuState.prototype.update = function(b) {
  7007. if (!focused) {
  7008. this.tweensPaused = true;
  7009. return
  7010. } else {
  7011. if (this.tweensPaused) {
  7012. this.tweensPaused = false
  7013. }
  7014. }
  7015. for (var a = 0; a < this.buttons.length; a++) {
  7016. this.buttons[a].update(b)
  7017. }
  7018. this.cloudScroll += b * 10;
  7019. while (this.cloudScroll > 669) {
  7020. this.cloudScroll -= 669
  7021. }
  7022. this.cloudLine.x = -canvas.width * 0.5;
  7023. this.playBtn.screenSizeOffsetX = canvas.width * 0.5;
  7024. this.playBtn.screenSizeOffsetY = canvas.height - 92;
  7025. this.soundButton.screenSizeOffsetX = canvas.width - this.soundButton.defaultGraphic.width * 0.5;
  7026. this.soundButton.screenSizeOffsetY = 36;
  7027. this.background.scaleX = canvas.width / 4;
  7028. this.background.scaleY = canvas.height / 720;
  7029. this.sign.y = canvas.height * 0.5 - (125 * this.background.scaleY);
  7030. this.shadow.x = -2;
  7031. this.shadow.y = this.sign.y;
  7032. this.shadow.scaleY = 200;
  7033. switch (gCurrentBrand) {
  7034. case BRAND.ADDICTING:
  7035. this.addictingLogo.x = canvas.width - 4;
  7036. this.addictingLogo.y = canvas.height - 8;
  7037. this.badge.x = 6;
  7038. this.badge.y = canvas.height - 6;
  7039. break;
  7040. case BRAND.MRG:
  7041. this.mrgLogo.x = canvas.width - 4;
  7042. this.mrgLogo.y = canvas.height - 8;
  7043. this.moreBtn.x = canvas.width * 0.5;
  7044. this.moreBtn.y = canvas.height * 0.5 + this.sign.y - 256;
  7045. this.badge.x = 6;
  7046. this.badge.y = canvas.height - 6
  7047. }
  7048. this.sceneManager.update(b);
  7049. if (this.lastCanvasWidth != canvas.width) {
  7050. this.cloudLine.sprite.width = canvas.width
  7051. }
  7052. this.lastCanvasWidth = canvas.width
  7053. };
  7054. MainMenuState.prototype.draw = function() {
  7055. this.sceneManager.masterAlpha = 1;
  7056. if (this.inTransition.previousState) {
  7057. if (!this.inTransition.previousState.done) {
  7058. this.sceneManager.masterAlpha = 0
  7059. }
  7060. }
  7061. var b = this.cloudLine.sprite.getContext("2d");
  7062. b.clearRect(0, 0, canvas.width, 150);
  7063. b.save();
  7064. b.globalAlpha = this.sceneManager.masterAlpha;
  7065. b.fillStyle = this.cloudPattern;
  7066. b.translate(-this.cloudScroll, 0);
  7067. b.fillRect(this.cloudScroll, 0, canvas.width, 150);
  7068. b.restore();
  7069. this.sceneManager.draw();
  7070. for (var a = 0; a < this.buttons.length; a++) {
  7071. this.buttons[a].alpha = this.sceneManager.masterAlpha;
  7072. this.buttons[a].draw()
  7073. }
  7074. if (this.paused) {}
  7075. };
  7076. var PlayState = {
  7077. TUTORIAL: 0,
  7078. INTRO: 1,
  7079. GAME: 2,
  7080. DYING: 3,
  7081. END: 4
  7082. };
  7083. function GameplayState() {
  7084. State.call(this);
  7085. this.sceneManager;
  7086. this.stateManager = null;
  7087. this.initialized = false;
  7088. this.destroyed = false;
  7089. this.playState = PlayState.GAME;
  7090. this.buttons = [];
  7091. this.inTransition = null;
  7092. this.outTransition = null;
  7093. this.transitionState = TransitionState.NULL;
  7094. this.progress = 0;
  7095. this.road;
  7096. this.player;
  7097. this.cars = [];
  7098. this.walls = [];
  7099. this.crates = [];
  7100. this.detritus = [];
  7101. this.potholes = [];
  7102. this.oilSlicks = [];
  7103. this.roadBlocks = [];
  7104. this.wrenches = [];
  7105. this.steeringUI;
  7106. this.homeBtn;
  7107. this.restartBtn;
  7108. this.hud;
  7109. this.paused = false;
  7110. this.pauseOverlay;
  7111. this.tweensPaused
  7112. }
  7113. GameplayState.prototype = new State();
  7114. GameplayState.prototype.constructor = GameplayState;
  7115. GameplayState.prototype.init = function() {
  7116. this.initialized = true;
  7117. this.destroyed = false;
  7118. this.sceneManager = new SceneManager();
  7119. this.sceneManager.init();
  7120. this.pauseOverlay = new SceneObject();
  7121. this.pauseOverlay.init(0, 0);
  7122. this.pauseOverlay.depth = -1;
  7123. this.pauseOverlay.useCamera = false;
  7124. var a = new Drawable();
  7125. a.init(content.pauseBack, 0, 0);
  7126. a.originX = a.sprite.width * 0.5;
  7127. a.originY = a.sprite.height * 0.5;
  7128. this.pauseOverlay.addChild(a);
  7129. a = new Drawable();
  7130. a.init(content.pauseText, 0, 0);
  7131. a.originX = a.sprite.width * 0.5;
  7132. a.originY = a.sprite.height * 0.5;
  7133. this.pauseOverlay.addChild(a);
  7134. this.pauseOverlay.visible = false;
  7135. this.sceneManager.addEntity(this.pauseOverlay);
  7136. this.leftEdge = new Drawable();
  7137. this.leftEdge.init(content.sandEdge, 0, 0);
  7138. this.leftEdge.useCamera = false;
  7139. this.leftEdge.depth = 0.1;
  7140. this.sceneManager.addEntity(this.leftEdge);
  7141. this.rightEdge = new Drawable();
  7142. this.rightEdge.init(content.sandEdge, canvas.width, 0);
  7143. this.rightEdge.useCamera = false;
  7144. this.rightEdge.depth = 0.1;
  7145. this.rightEdge.scaleX = -1;
  7146. this.sceneManager.addEntity(this.rightEdge);
  7147. this.road = new Road();
  7148. this.road.init(this);
  7149. this.road.x = 512;
  7150. this.sceneManager.addEntity(this.road);
  7151. this.player = new PlayerCar();
  7152. this.player.init(-80, 0, this);
  7153. this.sceneManager.addEntity(this.player);
  7154. this.cars.push(this.player);
  7155. this.sceneManager.camera.setPosition(0, this.cars[0].y - 128);
  7156. this.steeringUI = new SteerController();
  7157. this.steeringUI.init(this);
  7158. this.sceneManager.addEntity(this.steeringUI);
  7159. this.hud = new Hud();
  7160. this.hud.init(this);
  7161. this.sceneManager.addEntity(this.hud);
  7162. this.homeBtn = new Button();
  7163. this.homeBtn.defaultGraphic = content.homeBtnUp;
  7164. this.homeBtn.hitGraphic = content.homeBtnDown;
  7165. this.homeBtn.callback = this.onHomeHit;
  7166. this.homeBtn.parentState = this;
  7167. this.homeBtn.init();
  7168. this.homeBtn.originX = this.homeBtn.defaultGraphic.width * 0.5;
  7169. this.homeBtn.originY = this.homeBtn.defaultGraphic.height * 0.5;
  7170. this.homeBtn.visible = false;
  7171. this.homeBtn.active = false;
  7172. this.buttons.push(this.homeBtn);
  7173. this.replayBtn = new Button();
  7174. this.replayBtn.defaultGraphic = content.restartBtnUp;
  7175. this.replayBtn.hitGraphic = content.restartBtnDown;
  7176. this.replayBtn.callback = this.onReplayHit;
  7177. this.replayBtn.parentState = this;
  7178. this.replayBtn.init();
  7179. this.replayBtn.originX = this.replayBtn.defaultGraphic.width * 0.5;
  7180. this.replayBtn.originY = this.replayBtn.defaultGraphic.height * 0.5;
  7181. this.replayBtn.visible = false;
  7182. this.replayBtn.active = false;
  7183. this.buttons.push(this.replayBtn);
  7184. this.inTransition = new FadeToBlackTransition();
  7185. this.inTransition.init(this, 0.5, Sine.easeOut, false, 0, null, 0);
  7186. this.outTransition = new FadeToBlackTransition();
  7187. this.outTransition.init(this, 0.5, Sine.easeOut, false, 0, null, 0);
  7188. this.generator = new GameGenerator();
  7189. this.generator.init(this);
  7190. this.lastCameraY = 0;
  7191. this.bestGlowTime = 0.15;
  7192. this.bestGlowTimer = this.bestGlowTime;
  7193. this.tutorialStage = 0;
  7194. this.tut01 = new Drawable();
  7195. this.tut01.init(content.tut01, 0, 0);
  7196. this.tut01.useCamera = false;
  7197. this.tut01.originX = this.tut01.sprite.width * 0.5;
  7198. this.tut01.originY = this.tut01.sprite.height;
  7199. this.tutSteerDot = new Drawable();
  7200. this.tutSteerDot.init(content.steeringCircle, 0, 0);
  7201. this.tutSteerDot.useCamera = false;
  7202. this.tutSteerDot.originX = this.tutSteerDot.sprite.width * 0.5;
  7203. this.tutSteerDot.originY = this.tutSteerDot.sprite.height * 0.5;
  7204. this.tutSteerDot.alpha = 0.5;
  7205. this.steerTutSine = 0;
  7206. this.tutTimer = 0;
  7207. this.tutEndPosition = 0;
  7208. if (firstRun) {
  7209. this.playState = PlayState.TUTORIAL;
  7210. this.sceneManager.addEntity(this.tut01);
  7211. this.sceneManager.addEntity(this.tutSteerDot);
  7212. firstRun = false
  7213. }
  7214. setAudioState(AUDIO_STATE.GAMELOOP)
  7215. };
  7216. GameplayState.prototype.reset = function() {};
  7217. GameplayState.prototype.onHomeHit = function(a) {
  7218. var b = new MainMenuState();
  7219. b.init();
  7220. a.stateManager.setState(b)
  7221. };
  7222. GameplayState.prototype.onReplayHit = function(b) {
  7223. var a = new GameplayState();
  7224. a.init();
  7225. b.stateManager.setState(a)
  7226. };
  7227. GameplayState.prototype.update = function(c) {
  7228. if (this.paused) {
  7229. if ((touchDown && !touchDownLast) || (mouseDown && !mouseDownLast)) {
  7230. this.paused = false
  7231. }
  7232. this.pauseOverlay.visible = true;
  7233. this.pauseOverlay.x = canvas.width * 0.5;
  7234. this.pauseOverlay.y = canvas.height * 0.5;
  7235. this.pauseOverlay.children[0].scaleX = (canvas.width / this.pauseOverlay.children[0].sprite.width) * 1.1;
  7236. this.pauseOverlay.children[0].scaleY = (canvas.height / this.pauseOverlay.children[0].sprite.height) * 1.1
  7237. } else {
  7238. this.pauseOverlay.visible = false
  7239. } if (this.paused) {
  7240. this.tweensPaused = true;
  7241. return
  7242. } else {
  7243. if (this.tweensPaused) {
  7244. this.tweensPaused = false
  7245. }
  7246. }
  7247. for (var d = 0; d < this.buttons.length; d++) {
  7248. this.buttons[d].update(c)
  7249. }
  7250. this.road.x = canvas.width * 0.5;
  7251. var f = 0;
  7252. var e = this.cars[0].y - 160;
  7253. switch (this.playState) {
  7254. case PlayState.TUTORIAL:
  7255. this.tutEndPosition = this.player.y;
  7256. this.hud.distance = 1;
  7257. this.steeringUI.x = canvas.width * 0.5;
  7258. this.steeringUI.y = canvas.height - 64;
  7259. this.tut01.x = canvas.width * 0.5;
  7260. this.tut01.y = this.steeringUI.y - 64;
  7261. this.steerTutSine += c;
  7262. while (this.steerTutSine > Math.PI * 2) {
  7263. this.steerTutSine -= Math.PI * 2
  7264. }
  7265. switch (this.tutorialStage) {
  7266. case 0:
  7267. this.tutSteerDot.x = this.steeringUI.x + Math.sin(this.steerTutSine) * 96;
  7268. this.tutSteerDot.y = this.steeringUI.y;
  7269. if (this.steeringUI.inUse) {
  7270. this.tutorialStage++;
  7271. TweenLite.to(this.tut01, 0.25, {
  7272. alpha: 0,
  7273. ease: Sine.easeOut,
  7274. onCompleteParams: [this.tut01],
  7275. onComplete: function(i) {
  7276. i.flagForRemoval()
  7277. }
  7278. });
  7279. TweenLite.to(this.tutSteerDot, 0.25, {
  7280. alpha: 0,
  7281. ease: Sine.easeOut,
  7282. onCompleteParams: [this.tutSteerDot],
  7283. onComplete: function(i) {
  7284. i.flagForRemoval()
  7285. }
  7286. });
  7287. this.tut02 = new Drawable();
  7288. this.tut02.init(content.tut02, canvas.width * 0.5 + 66, 56);
  7289. this.tut02.useCamera = false;
  7290. this.tut02.originX = 0;
  7291. this.tut02.originY = 0;
  7292. this.sceneManager.addEntity(this.tut02);
  7293. this.tutArrow = new Drawable();
  7294. this.tutArrow.init(content.tutArrow, canvas.width * 0.5 + 42, 70 + Math.sin(this.steerTutSine) * 8);
  7295. this.tutArrow.useCamera = false;
  7296. this.tutArrow.originX = this.tutArrow.sprite.width * 0.5;
  7297. this.tutArrow.originY = this.tutArrow.sprite.height * 0.5;
  7298. this.sceneManager.addEntity(this.tutArrow);
  7299. this.tutTimer = 6;
  7300. for (var d = 0; d < this.hud.hits.length; d++) {
  7301. this.hud.hits[d].sprite = content.hitOff;
  7302. var a = new Particle();
  7303. a.init(content.hitOn, 1.5);
  7304. a.x = this.hud.x + this.hud.hits[d].x;
  7305. a.y = this.hud.y + this.hud.hits[d].y;
  7306. a.originX = a.sprite.width * 0.5;
  7307. a.originY = a.sprite.height * 0.5;
  7308. a.startScaleX = 2;
  7309. a.startScaleY = 2;
  7310. a.endScaleX = 0;
  7311. a.endScaleY = 0;
  7312. a.startAlpha = 1;
  7313. a.endAlpha = 0;
  7314. a.depth = this.hud.depth - 0.01;
  7315. a.useCamera = false;
  7316. a.alpha = 0;
  7317. TweenLite.to(a, 1, {
  7318. alpha: 1,
  7319. ease: Sine.easeOut
  7320. });
  7321. TweenLite.delayedCall(1 + d * 0.5, a.start, [a]);
  7322. this.sceneManager.addEntity(a)
  7323. }
  7324. }
  7325. break;
  7326. case 1:
  7327. this.steerTutSine += c * 4;
  7328. this.tutArrow.x = canvas.width * 0.5 + 42;
  7329. this.tutArrow.y = 70 + Math.sin(this.steerTutSine) * 8;
  7330. this.tut02.x = canvas.width * 0.5 + 66;
  7331. this.tut02.y = 56;
  7332. this.tutTimer -= c;
  7333. if (this.tutTimer <= 0) {
  7334. this.playState = PlayState.GAME;
  7335. TweenLite.to(this.tut02, 0.25, {
  7336. alpha: 0,
  7337. ease: Sine.easeOut,
  7338. onCompleteParams: [this.tut02],
  7339. onComplete: function(i) {
  7340. i.flagForRemoval()
  7341. }
  7342. });
  7343. TweenLite.to(this.tutArrow, 0.25, {
  7344. alpha: 0,
  7345. ease: Sine.easeOut,
  7346. onCompleteParams: [this.tutArrow],
  7347. onComplete: function(i) {
  7348. i.flagForRemoval()
  7349. }
  7350. })
  7351. }
  7352. break
  7353. }
  7354. break;
  7355. case PlayState.INTRO:
  7356. break;
  7357. case PlayState.GAME:
  7358. this.hud.distance = -(this.player.y - this.tutEndPosition) / 30;
  7359. this.steeringUI.x = canvas.width * 0.5;
  7360. this.steeringUI.y = canvas.height - 64;
  7361. this.generator.update(c);
  7362. this.updateCars(c);
  7363. break;
  7364. case PlayState.DYING:
  7365. if (this.best) {
  7366. this.bestGlowTimer -= c;
  7367. while (this.bestGlowTimer <= 0) {
  7368. this.bestGlowTimer += this.bestGlowTime;
  7369. var g = new Particle();
  7370. g.init(content.bestGlow, randFloatRange(0.25, 0.75) * 8);
  7371. g.useCamera = false;
  7372. g.x = this.best.x + randFloatRange(-115, 115);
  7373. g.y = this.best.y + randFloatRange(-12, 12);
  7374. g.originX = g.sprite.width * 0.5;
  7375. g.originY = g.sprite.height * 0.5;
  7376. var j = randFloatRange(0.75, 1) * 2;
  7377. g.startScaleX = 4;
  7378. g.startScaleY = 4;
  7379. g.endScaleX = 0;
  7380. g.endScaleY = 0;
  7381. g.startAlpha = 0;
  7382. g.endAlpha = 1;
  7383. g.depth = this.best.depth + 0.01;
  7384. g.dragX = 0.1;
  7385. g.dragY = g.dragX;
  7386. g.angularVelocity = randFloatRange(-1, 1) * 0.01;
  7387. var b = randFloatRange(0, Math.PI * 2);
  7388. var h = 0;
  7389. g.velocityX = h * Math.cos(b);
  7390. g.velocityY = h * Math.sin(b);
  7391. g.start();
  7392. this.sceneManager.addEntity(g)
  7393. }
  7394. }
  7395. this.homeBtn.screenSizeOffsetX = canvas.width * 0.5 - 128;
  7396. this.homeBtn.screenSizeOffsetY = canvas.height - 92;
  7397. this.replayBtn.screenSizeOffsetX = canvas.width * 0.5 + 128;
  7398. this.replayBtn.screenSizeOffsetY = canvas.height - 92;
  7399. this.endFadeTop.scaleX = canvas.width / 4;
  7400. this.endFadeBottom.scaleX = canvas.width / 4;
  7401. this.endBanner.x = canvas.width * 0.5;
  7402. this.endBanner.y = 90;
  7403. this.distanceTitle.x = canvas.width * 0.5;
  7404. this.distanceTitle.y = this.endBanner.y + 140;
  7405. if (this.best) {
  7406. this.best.x = canvas.width * 0.5;
  7407. this.best.y = this.endBanner.y + 190
  7408. }
  7409. e = this.cars[0].y - 40;
  7410. this.endFadeBottom.y = canvas.height;
  7411. switch (gCurrentBrand) {
  7412. case BRAND.ADDICTING:
  7413. if (this.addictingGamesLogo) {
  7414. this.addictingGamesLogo.x = canvas.width * 0.5
  7415. }
  7416. break;
  7417. case BRAND.MRG:
  7418. if (this.mrgLogo) {
  7419. this.mrgLogo.x = canvas.width * 0.5
  7420. }
  7421. break
  7422. }
  7423. break;
  7424. case PlayState.END:
  7425. break
  7426. }
  7427. this.leftEdge.x = 0;
  7428. this.rightEdge.x = canvas.width;
  7429. this.updatePhysics(c);
  7430. this.sceneManager.camera.shakeOffsetX = 0;
  7431. this.sceneManager.camera.shakeOffsetY = 0;
  7432. if (this.player.offroad && (this.player.currentState != CarState.BROKENDOWN && this.player.currentState != CarState.SPINNING)) {
  7433. this.hud.offroad.open();
  7434. this.sceneManager.camera.shakeOffsetX = randFloatRange(-2, 2);
  7435. this.sceneManager.camera.shakeOffsetY = randFloatRange(-2, 2)
  7436. } else {
  7437. this.hud.offroad.close()
  7438. } if (this.player.dirtRoad && (this.player.currentState != CarState.BROKENDOWN && this.player.currentState != CarState.SPINNING)) {
  7439. this.sceneManager.camera.shakeOffsetX = randFloatRange(-2, 2);
  7440. this.sceneManager.camera.shakeOffsetY = randFloatRange(-2, 2);
  7441. if (!this.player.dirtLoopInstance && !soundMuted) {
  7442. this.player.dirtLoopInstance = createjs.Sound.play("dirtRoadRumble")
  7443. }
  7444. }
  7445. this.sceneManager.camera.setTargetPosition(f, e);
  7446. this.sceneManager.update(c);
  7447. this.cullObjects()
  7448. };
  7449. GameplayState.prototype.updatePhysics = function(e) {
  7450. for (var b = 0; b < this.cars.length; b++) {
  7451. for (var f = b + 1; f < this.cars.length; f++) {
  7452. this.cars[b].checkCollision(this.cars[f])
  7453. }
  7454. for (var a = 0; a < this.walls.length; a++) {
  7455. this.cars[b].checkCollision(this.walls[a])
  7456. }
  7457. for (var d = 0; d < this.roadBlocks.length; d++) {
  7458. this.cars[b].checkCollision(this.roadBlocks[d])
  7459. }
  7460. for (var j = 0; j < this.crates.length; j++) {
  7461. if (this.crates[j].spawner === this.cars[b]) {
  7462. continue
  7463. }
  7464. this.cars[b].checkCollision(this.crates[j])
  7465. }
  7466. for (var g = 0; g < this.potholes.length; g++) {
  7467. this.cars[b].checkCollision(this.potholes[g])
  7468. }
  7469. for (var h = 0; h < this.oilSlicks.length; h++) {
  7470. this.cars[b].checkCollision(this.oilSlicks[h])
  7471. }
  7472. }
  7473. for (var a = 0; a < this.wrenches.length; a++) {
  7474. this.player.checkCollision(this.wrenches[a])
  7475. }
  7476. for (var b = 0; b < this.crates.length; b++) {
  7477. for (var j = b + 1; j < this.crates.length; j++) {
  7478. this.crates[b].checkCollision(this.crates[j])
  7479. }
  7480. for (var a = 0; a < this.walls.length; a++) {
  7481. this.crates[b].checkCollision(this.walls[a])
  7482. }
  7483. }
  7484. };
  7485. GameplayState.prototype.updateCars = function(b) {
  7486. for (var a = 0; a < this.cars.length; a++) {
  7487. if (Math.abs(this.cars[a].y - -this.sceneManager.camera.positionY) > 1024) {
  7488. this.cars[a].flagForRemoval()
  7489. }
  7490. }
  7491. };
  7492. GameplayState.prototype.cullObjects = function() {
  7493. var b = -this.sceneManager.camera.positionY;
  7494. for (var a = 0; a < this.cars.length; a++) {
  7495. if (this.cars[a].toBeRemoved) {
  7496. this.cars.splice(a, 1);
  7497. a--;
  7498. continue
  7499. }
  7500. }
  7501. for (var a = 0; a < this.walls.length; a++) {
  7502. if (this.walls[a].y > b && Math.abs(this.walls[a].y - b) > 1024) {
  7503. this.walls[a].flagForRemoval()
  7504. }
  7505. if (this.walls[a].toBeRemoved) {
  7506. this.walls.splice(a, 1);
  7507. a--;
  7508. continue
  7509. }
  7510. }
  7511. for (var a = 0; a < this.roadBlocks.length; a++) {
  7512. if (this.roadBlocks[a].y > b && Math.abs(this.roadBlocks[a].y - b) > 1024) {
  7513. this.roadBlocks[a].flagForRemoval()
  7514. }
  7515. if (this.roadBlocks[a].toBeRemoved) {
  7516. this.roadBlocks.splice(a, 1);
  7517. a--;
  7518. continue
  7519. }
  7520. }
  7521. for (var a = 0; a < this.crates.length; a++) {
  7522. if (this.crates[a].y > b && Math.abs(this.crates[a].y - b) > 1024) {
  7523. this.crates[a].flagForRemoval()
  7524. }
  7525. if (this.crates[a].toBeRemoved) {
  7526. this.crates.splice(a, 1);
  7527. a--;
  7528. continue
  7529. }
  7530. }
  7531. for (var a = 0; a < this.detritus.length; a++) {
  7532. if (this.detritus[a].y > b && Math.abs(this.detritus[a].y - b) > 1024) {
  7533. this.detritus[a].flagForRemoval()
  7534. }
  7535. if (this.detritus[a].toBeRemoved) {
  7536. this.detritus.splice(a, 1);
  7537. a--;
  7538. continue
  7539. }
  7540. }
  7541. for (var a = 0; a < this.potholes.length; a++) {
  7542. if (this.potholes[a].y > b && Math.abs(this.potholes[a].y - b) > 1024) {
  7543. this.potholes[a].flagForRemoval()
  7544. }
  7545. if (this.potholes[a].toBeRemoved) {
  7546. this.potholes.splice(a, 1);
  7547. a--;
  7548. continue
  7549. }
  7550. }
  7551. for (var a = 0; a < this.oilSlicks.length; a++) {
  7552. if (this.oilSlicks[a].y > b && Math.abs(this.oilSlicks[a].y - b) > 1024) {
  7553. this.oilSlicks[a].flagForRemoval()
  7554. }
  7555. if (this.oilSlicks[a].toBeRemoved) {
  7556. this.oilSlicks.splice(a, 1);
  7557. a--;
  7558. continue
  7559. }
  7560. }
  7561. for (var a = 0; a < this.wrenches.length; a++) {
  7562. if (this.wrenches[a].y > b && Math.abs(this.wrenches[a].y - b) > 1024) {
  7563. this.wrenches[a].flagForRemoval()
  7564. }
  7565. if (this.wrenches[a].toBeRemoved) {
  7566. this.wrenches.splice(a, 1);
  7567. a--;
  7568. continue
  7569. }
  7570. }
  7571. };
  7572. GameplayState.prototype.draw = function() {
  7573. this.sceneManager.masterAlpha = 1;
  7574. if (this.inTransition.previousState) {
  7575. if (!this.inTransition.previousState.done) {
  7576. this.sceneManager.masterAlpha = 0
  7577. }
  7578. }
  7579. this.sceneManager.draw();
  7580. for (var a = 0; a < this.buttons.length; a++) {
  7581. this.buttons[a].alpha = this.sceneManager.masterAlpha;
  7582. this.buttons[a].draw()
  7583. }
  7584. };
  7585. GameplayState.prototype.onExit = function() {
  7586. if (!this.initialized) {
  7587. return
  7588. }
  7589. this.transitionState = TransitionState.EXITED;
  7590. this.sceneManager.clear()
  7591. };
  7592. GameplayState.prototype.crashFlash = function() {
  7593. this.flash = new Drawable();
  7594. this.flash.init(content.white4, canvas.width * 0.5, canvas.height * 0.5);
  7595. this.flash.scaleX = canvas.width / 4;
  7596. this.flash.scaleY = canvas.height / 4;
  7597. this.flash.originX = 2;
  7598. this.flash.originY = 2;
  7599. this.flash.depth = -0.95;
  7600. this.flash.useCamera = false;
  7601. this.sceneManager.addEntity(this.flash);
  7602. TweenLite.to(this.flash, 0.5, {
  7603. alpha: 0,
  7604. ease: Sine.easeOut,
  7605. onCompleteParams: [this.flash],
  7606. onComplete: function(a) {
  7607. a.flagForRemoval()
  7608. }
  7609. })
  7610. };
  7611. GameplayState.prototype.endGame = function(b) {
  7612. if (this.playState == PlayState.DYING || this.playState == PlayState.END) {
  7613. return
  7614. }
  7615. var c = queryLocalVar("BEST_DISTANCE");
  7616. var e = false;
  7617. if (c == null || this.hud.distance > c) {
  7618. e = true;
  7619. setLocalVar("BEST_DISTANCE", this.hud.distance)
  7620. }
  7621. this.playState = PlayState.DYING;
  7622. this.steeringUI.hide();
  7623. this.hud.endGame(b);
  7624. this.endFadeBottom = new Drawable();
  7625. this.endFadeBottom.init(content.endFade, 0, 0);
  7626. this.endFadeBottom.useCamera = false;
  7627. this.endFadeBottom.scaleX = canvas.width / 4;
  7628. this.endFadeBottom.originY = this.endFadeBottom.sprite.height;
  7629. this.endFadeBottom.y = canvas.height;
  7630. this.endFadeBottom.depth = -0.98;
  7631. this.endFadeBottom.alpha = 0;
  7632. this.sceneManager.addEntity(this.endFadeBottom);
  7633. TweenLite.to(this.endFadeBottom, 1, {
  7634. alpha: 1,
  7635. ease: Sine.easeOut,
  7636. overwrite: 1
  7637. });
  7638. this.endFadeTop = new Drawable();
  7639. this.endFadeTop.init(content.endFade, 0, 0);
  7640. this.endFadeTop.useCamera = false;
  7641. this.endFadeTop.scaleX = canvas.width / 4;
  7642. this.endFadeTop.scaleY = -1;
  7643. this.endFadeTop.originY = this.endFadeTop.sprite.height;
  7644. this.endFadeTop.depth = -0.98;
  7645. this.endFadeTop.alpha = 0;
  7646. this.sceneManager.addEntity(this.endFadeTop);
  7647. TweenLite.to(this.endFadeTop, 1, {
  7648. alpha: 1,
  7649. ease: Sine.easeOut,
  7650. overwrite: 1
  7651. });
  7652. this.replayBtn.visible = true;
  7653. this.replayBtn.active = true;
  7654. this.homeBtn.visible = true;
  7655. this.homeBtn.active = true;
  7656. this.replayBtn.y = 256;
  7657. TweenLite.to(this.replayBtn, 0.5, {
  7658. y: 0,
  7659. ease: Sine.easeOut,
  7660. overwrite: 1
  7661. });
  7662. this.homeBtn.y = 256;
  7663. TweenLite.to(this.homeBtn, 0.5, {
  7664. y: 0,
  7665. ease: Sine.easeOut,
  7666. overwrite: 1
  7667. });
  7668. this.endBanner = new EndBanner();
  7669. this.endBanner.init(b);
  7670. this.endBanner.x = canvas.width * 0.5;
  7671. this.endBanner.y = 90;
  7672. this.sceneManager.addEntity(this.endBanner);
  7673. this.endBanner.open();
  7674. this.distanceTitle = new Drawable();
  7675. this.distanceTitle.init(null, 0, 0);
  7676. this.distanceTitle.sprite = document.createElement("canvas");
  7677. this.distanceTitle.sprite.width = 348;
  7678. this.distanceTitle.sprite.height = 50;
  7679. this.distanceTitle.useCamera = false;
  7680. this.distanceTitle.originX = this.distanceTitle.sprite.width * 0.5;
  7681. this.distanceTitle.originY = this.distanceTitle.sprite.height * 0.5;
  7682. this.distanceTitle.depth = -0.985;
  7683. this.sceneManager.addEntity(this.distanceTitle);
  7684. var a = this.distanceTitle.sprite.getContext("2d");
  7685. a.font = "normal normal normal " + 48 + "px chunkfive";
  7686. a.textAlign = "center";
  7687. a.textBaseline = "middle";
  7688. a.fillStyle = "#000000";
  7689. a.fillText(this.hud.lastDistanceText, this.distanceTitle.sprite.width * 0.5 + 5, this.distanceTitle.sprite.height * 0.5 + 5);
  7690. a.fillStyle = "#dfdfdf";
  7691. a.fillText(this.hud.lastDistanceText, this.distanceTitle.sprite.width * 0.5, this.distanceTitle.sprite.height * 0.5);
  7692. if (e) {
  7693. this.best = new Drawable();
  7694. this.best.init(null, 0, 0);
  7695. this.best.sprite = document.createElement("canvas");
  7696. this.best.sprite.width = 275;
  7697. this.best.sprite.height = 60;
  7698. this.best.useCamera = false;
  7699. this.best.originX = this.best.sprite.width * 0.5;
  7700. this.best.originY = this.best.sprite.height * 0.5;
  7701. this.best.depth = -0.985;
  7702. this.sceneManager.addEntity(this.best);
  7703. var d = this.best.sprite.getContext("2d");
  7704. d.font = "normal normal normal " + 36 + "px chunkfive";
  7705. d.textAlign = "center";
  7706. d.textBaseline = "middle";
  7707. d.fillStyle = "#000000";
  7708. d.globalAlpha = 0.75;
  7709. d.fillText("\u6700\u597d\u6210\u7ee9 !", this.best.sprite.width * 0.5 + 5, this.best.sprite.height * 0.5 + 5);
  7710. d.fillStyle = "#a5ff5d";
  7711. d.globalAlpha = 1;
  7712. d.fillText("\u6700\u597d\u6210\u7ee9 !", this.best.sprite.width * 0.5, this.best.sprite.height * 0.5)
  7713. }
  7714. switch (gCurrentBrand) {
  7715. case BRAND.ADDICTING:
  7716. this.addictingGamesLogo = new Drawable();
  7717. this.addictingGamesLogo.init(content.addictingEnd, 0, 0);
  7718. this.addictingGamesLogo.originX = this.addictingGamesLogo.sprite.width * 0.5;
  7719. this.addictingGamesLogo.originY = 0;
  7720. this.addictingGamesLogo.scaleX = 1;
  7721. this.addictingGamesLogo.scaleY = 1;
  7722. this.addictingGamesLogo.useCamera = false;
  7723. this.addictingGamesLogo.depth = -1;
  7724. this.sceneManager.addEntity(this.addictingGamesLogo);
  7725. this.addictingGamesLogo.x = canvas.width * 0.5;
  7726. this.addictingGamesLogo.y = -this.addictingGamesLogo.sprite.height;
  7727. TweenLite.to(this.addictingGamesLogo, 0.5, {
  7728. y: 16,
  7729. ease: Sine.easeIn
  7730. });
  7731. break;
  7732. case BRAND.MRG:
  7733. this.mrgLogo = new Drawable();
  7734. this.mrgLogo.init(content.mrgEnd, 0, 0);
  7735. this.mrgLogo.originX = this.mrgLogo.sprite.width * 0.5;
  7736. this.mrgLogo.originY = 0;
  7737. this.mrgLogo.scaleX = 1;
  7738. this.mrgLogo.scaleY = 1;
  7739. this.mrgLogo.useCamera = false;
  7740. this.mrgLogo.depth = -1;
  7741. this.sceneManager.addEntity(this.mrgLogo);
  7742. this.mrgLogo.x = canvas.width * 0.5;
  7743. this.mrgLogo.y = -this.mrgLogo.sprite.height;
  7744. TweenLite.to(this.mrgLogo, 0.5, {
  7745. y: 7,
  7746. ease: Sine.easeIn
  7747. });
  7748. break
  7749. }
  7750. };
  7751. function SplashState() {
  7752. State.call(this);
  7753. this.stateManager = null;
  7754. this.initialized = false;
  7755. this.destroyed = false;
  7756. this.buttons = [];
  7757. this.inTransition = null;
  7758. this.outTransition = null;
  7759. this.transitionState = TransitionState.NULL;
  7760. this.progress = 0;
  7761. this.timer = 0;
  7762. this.addictingGamesLogo;
  7763. this.mrgLogo
  7764. }
  7765. SplashState.prototype = new State();
  7766. SplashState.prototype.constructor = SplashState;
  7767. SplashState.prototype.init = function() {
  7768. this.initialized = true;
  7769. this.destroyed = false;
  7770. this.sceneManager = new SceneManager();
  7771. this.sceneManager.init();
  7772. this.sceneManager.camera.useTarget = false;
  7773. switch (gCurrentBrand) {
  7774. case BRAND.ADDICTING:
  7775. this.setupAddictingGames();
  7776. break;
  7777. case BRAND.MRG:
  7778. this.setupMRG();
  7779. break
  7780. }
  7781. this.inTransition = new FadeToBlackTransition();
  7782. this.inTransition.init(this, 1, Sine.easeOut, false, 0, null, 0);
  7783. this.outTransition = new FadeToBlackTransition();
  7784. this.outTransition.init(this, 1, Sine.easeOut, false, 0, null, 0);
  7785. setAudioState(AUDIO_STATE.NONE)
  7786. };
  7787. SplashState.prototype.setupAddictingGames = function(a) {
  7788. this.addictingGamesLogo = new Drawable();
  7789. this.addictingGamesLogo.init(content.addictingSplash, 0, 0);
  7790. this.addictingGamesLogo.originX = this.addictingGamesLogo.sprite.width * 0.5 - 8;
  7791. this.addictingGamesLogo.originY = this.addictingGamesLogo.sprite.height * 0.5;
  7792. this.addictingGamesLogo.scaleX = 1;
  7793. this.addictingGamesLogo.scaleY = 1;
  7794. this.sceneManager.addEntity(this.addictingGamesLogo);
  7795. this.timer = 4
  7796. };
  7797. SplashState.prototype.setupMRG = function(a) {
  7798. this.mrgLogo = new Drawable();
  7799. this.mrgLogo.init(content.mrgSplash, 0, 0);
  7800. this.mrgLogo.originX = this.mrgLogo.sprite.width * 0.5 - 8;
  7801. this.mrgLogo.originY = this.mrgLogo.sprite.height * 0.5;
  7802. this.mrgLogo.scaleX = 1;
  7803. this.mrgLogo.scaleY = 1;
  7804. this.sceneManager.addEntity(this.mrgLogo);
  7805. this.timer = 4
  7806. };
  7807. SplashState.prototype.update = function(b) {
  7808. for (var a = 0; a < this.buttons.length; a++) {
  7809. this.buttons[a].update(b)
  7810. }
  7811. switch (gCurrentBrand) {
  7812. case BRAND.ADDICTING:
  7813. case BRAND.MRG:
  7814. this.timer -= b;
  7815. if (this.timer <= 0) {
  7816. if (this.transitionState != TransitionState.ENTERED) {
  7817. return
  7818. }
  7819. var c = new MainMenuState();
  7820. c.init();
  7821. this.stateManager.setState(c);
  7822. return
  7823. }
  7824. break
  7825. }
  7826. this.sceneManager.update(b);
  7827. gRedrawActive = true
  7828. };
  7829. SplashState.prototype.draw = function() {
  7830. ctx.fillStyle = "#FFFFFF";
  7831. ctx.fillRect(0, 0, canvas.width, canvas.height);
  7832. this.sceneManager.masterAlpha = this.progress;
  7833. this.sceneManager.draw();
  7834. for (var a = 0; a < this.buttons.length; a++) {
  7835. this.buttons[a].alpha = this.sceneManager.masterAlpha;
  7836. this.buttons[a].draw()
  7837. }
  7838. };
  7839. SplashState.prototype.onPrevStateFinished = function() {};
  7840. function Explosion() {
  7841. SceneObject.call(this)
  7842. }
  7843. Explosion.prototype = new SceneObject();
  7844. Explosion.prototype.constructor = Explosion;
  7845. Explosion.prototype.init = function(a, d, b, c) {
  7846. this.x = a;
  7847. this.y = d;
  7848. this.children = [];
  7849. this.childCount = 0;
  7850. this.toBeRemoved = false;
  7851. this.useCamera = true;
  7852. this.magnitude = b;
  7853. this.scale = c;
  7854. this.triggered = false
  7855. };
  7856. Explosion.prototype.update = function(b) {
  7857. for (var a = 0; a < this.childCount; a++) {
  7858. this.children[a].update(b)
  7859. }
  7860. if (this.triggered) {
  7861. this.flagForRemoval()
  7862. } else {
  7863. if (this.timer > 0) {
  7864. this.timer -= b;
  7865. if (this.timer <= 0) {
  7866. this.trigger()
  7867. }
  7868. }
  7869. }
  7870. };
  7871. Explosion.prototype.trigger = function(b, g, e) {
  7872. if (this.triggered) {
  7873. return
  7874. }
  7875. if (b > 0) {
  7876. this.timer = b;
  7877. return
  7878. }
  7879. this.triggered = true;
  7880. for (var c = 0; c < 5; c++) {
  7881. var f = new Particle();
  7882. if (f) {
  7883. f.init(content.smoke, 4);
  7884. f.depth = this.depth + randFloatRange(-1, 1) * 0.01;
  7885. f.angle = randFloatRange(0, Math.PI * 2);
  7886. f.originX = f.sprite.width * 0.5;
  7887. f.originY = f.sprite.height * 0.5;
  7888. f.x = this.x;
  7889. f.y = this.y;
  7890. f.startScaleX = 0.33 * this.scale;
  7891. f.startScaleY = 0.33 * this.scale;
  7892. f.endScaleX = 4 * this.scale;
  7893. f.endScaleY = 4 * this.scale;
  7894. f.startAlpha = 1;
  7895. f.endAlpha = 0;
  7896. f.angularVelocity = randFloatRange(-1, 1) * 0.01;
  7897. var a = randFloatRange(0, Math.PI * 2);
  7898. var d = 2 * this.scale;
  7899. f.velocityX = Math.cos(a) * d;
  7900. f.velocityY = Math.sin(a) * d;
  7901. f.dragX = 0.001;
  7902. f.dragY = 0.001;
  7903. f.start();
  7904. this.sceneManager.addEntity(f)
  7905. }
  7906. }
  7907. for (var c = 0; c < 4; c++) {
  7908. var f = new Particle();
  7909. if (f) {
  7910. f.init(content.flash, randFloatRange(0.2, 0.3));
  7911. f.depth = this.depth + randFloatRange(-1, 1) * 0.01;
  7912. f.originX = f.sprite.width * 0.5;
  7913. f.originY = f.sprite.height * 0.5;
  7914. f.x = this.x;
  7915. f.y = this.y;
  7916. f.startScaleX = 3 * this.scale;
  7917. f.startScaleY = 3 * this.scale;
  7918. f.endScaleX = 0;
  7919. f.endScaleY = 0;
  7920. f.startAlpha = 1;
  7921. f.endAlpha = 1;
  7922. f.angle = randFloatRange(0, Math.PI * 2);
  7923. f.start();
  7924. this.sceneManager.addEntity(f)
  7925. }
  7926. }
  7927. for (var c = 0; c < 5; c++) {
  7928. var f = new Particle();
  7929. if (f) {
  7930. f.init(content.explosion, randFloatRange(1, 1.25) * 0.25);
  7931. f.depth = this.depth + randFloatRange(-1, 1) * 0.01;
  7932. f.angle = randFloatRange(0, Math.PI * 2);
  7933. f.originX = f.sprite.width * 0.5;
  7934. f.originY = f.sprite.height * 0.5;
  7935. f.x = this.x;
  7936. f.y = this.y;
  7937. f.startScaleX = 0.33 * this.scale;
  7938. f.startScaleY = 0.33 * this.scale;
  7939. f.endScaleX = 2 * this.scale;
  7940. f.endScaleY = 2 * this.scale;
  7941. f.startAlpha = randFloatRange(0.5, 1);
  7942. f.endAlpha = 0;
  7943. f.angularVelocity = randFloatRange(-1, 1) * 0.05;
  7944. var a = randFloatRange(0, Math.PI * 2);
  7945. var d = 10 * this.scale;
  7946. f.velocityX = Math.cos(a) * d;
  7947. f.velocityY = Math.sin(a) * d;
  7948. f.dragX = 0.0001;
  7949. f.dragY = 0.0001;
  7950. f.start();
  7951. this.sceneManager.addEntity(f)
  7952. }
  7953. }
  7954. for (var c = 0; c < 10; c++) {
  7955. var f = new Particle();
  7956. if (f) {
  7957. f.init(content.explosionSpark, randFloatRange(0.5, 1.5) * 0.25);
  7958. f.depth = this.depth + randFloatRange(-1, 1) * 0.01;
  7959. f.originX = 116;
  7960. f.originY = 8;
  7961. f.x = this.x;
  7962. f.y = this.y;
  7963. f.startScaleX = 0;
  7964. f.startScaleY = 0;
  7965. var h = randFloatRange(0.45 * this.scale, 0.85 * this.scale);
  7966. f.endScaleX = this.scale;
  7967. f.endScaleY = this.scale;
  7968. f.startAlpha = 1;
  7969. f.endAlpha = 0;
  7970. var a = randFloatRange(0, Math.PI * 2);
  7971. var d = 10 * this.scale;
  7972. f.velocityX = Math.sin(a) * d;
  7973. f.velocityY = Math.cos(a) * d;
  7974. f.followVelocity = true;
  7975. f.dragX = 0.001;
  7976. f.dragY = 0.001;
  7977. f.start();
  7978. this.sceneManager.addEntity(f)
  7979. }
  7980. }
  7981. };
  7982. var explosionSoundCount = 0;
  7983. onExplosionSoundComplete = function() {
  7984. explosionSoundCount--
  7985. };
  7986. function Road() {
  7987. Drawable.call(this);
  7988. this.pattern;
  7989. this.dirtPattern;
  7990. this.roadCtx
  7991. }
  7992. Road.prototype = new Drawable();
  7993. Road.prototype.constructor = Road;
  7994. Road.prototype.init = function(a) {
  7995. this.scroll = 0;
  7996. this.useCamera = false;
  7997. this.gameState = a;
  7998. this.sprite = document.createElement("canvas");
  7999. this.sprite.width = 349;
  8000. this.sprite.height = 720;
  8001. this.originX = this.sprite.width * 0.5;
  8002. this.roadCtx = this.sprite.getContext("2d");
  8003. this.pattern = this.roadCtx.createPattern(content.roadStripe, "repeat");
  8004. this.dirtPattern = this.roadCtx.createPattern(content.dirtRoad, "repeat");
  8005. this.roadCtx.save();
  8006. this.roadCtx.scale(1, 720);
  8007. this.roadCtx.drawImage(content.road, 0, 0);
  8008. this.roadCtx.restore();
  8009. this.depth = 0.1;
  8010. this.dirtRoad = false;
  8011. this.dirtRoadStart = 0;
  8012. this.dirtRoadEnd = 0
  8013. };
  8014. Road.prototype.update = function(a) {
  8015. this.hasUpdated = true
  8016. };
  8017. Road.prototype.draw = function(d) {
  8018. d = (d ? d : ctx);
  8019. if (canvas.height != this.sprite.height) {
  8020. this.sprite.height = canvas.height;
  8021. this.roadCtx.save();
  8022. this.roadCtx.scale(1, this.sprite.height);
  8023. this.roadCtx.drawImage(content.road, 0, 0);
  8024. this.roadCtx.restore()
  8025. }
  8026. this.roadCtx.save();
  8027. this.roadCtx.fillStyle = "#1e1207";
  8028. this.roadCtx.fillRect(168.5, 0, 12, this.sprite.height);
  8029. this.roadCtx.fillStyle = this.pattern;
  8030. this.roadCtx.translate(this.sceneManager.camera.positionX, this.sceneManager.camera.positionY);
  8031. this.roadCtx.fillRect(-this.sceneManager.camera.positionX + 174.5 - 3, -this.sceneManager.camera.positionY, 6, this.sprite.height);
  8032. this.roadCtx.restore();
  8033. this.gameState.player.dirtRoad = false;
  8034. if (this.dirtRoad) {
  8035. this.roadCtx.save();
  8036. var g = 0;
  8037. var e = this.sceneManager.camera.positionY - this.dirtRoadStart;
  8038. var c = canvas.height / 720;
  8039. if (e < 0) {
  8040. g = e;
  8041. if (e > -640 * c) {
  8042. this.gameState.hud.dirtroad.close()
  8043. }
  8044. }
  8045. if (e > -300 * c && e < Math.abs(this.dirtRoadStart - this.dirtRoadEnd) - 240 * c) {
  8046. this.gameState.player.dirtRoad = true
  8047. }
  8048. if (e > (this.dirtRoadEnd - this.dirtRoadStart)) {
  8049. this.roadCtx.save();
  8050. this.dirtRoad = false;
  8051. this.roadCtx.scale(1, canvas.height);
  8052. this.roadCtx.drawImage(content.road, 0, 0);
  8053. this.roadCtx.restore()
  8054. } else {
  8055. this.roadCtx.save();
  8056. this.roadCtx.translate(this.sceneManager.camera.positionX, this.sceneManager.camera.positionY);
  8057. this.roadCtx.clearRect(-this.sceneManager.camera.positionX, -this.sceneManager.camera.positionY + g, this.sprite.width, this.sprite.height);
  8058. this.roadCtx.fillStyle = this.dirtPattern;
  8059. this.roadCtx.fillRect(-this.sceneManager.camera.positionX, -this.sceneManager.camera.positionY + g, this.sprite.width, this.sprite.height);
  8060. this.roadCtx.drawImage(content.dirtTransition, 0, -this.sceneManager.camera.positionY + g + this.sprite.height);
  8061. this.roadCtx.restore()
  8062. } if (this.dirtRoad && e > (this.dirtRoadEnd - this.dirtRoadStart) - canvas.height) {
  8063. this.roadCtx.save();
  8064. this.roadCtx.translate(0, e - ((this.dirtRoadEnd - this.dirtRoadStart) - canvas.height) - canvas.height);
  8065. this.roadCtx.scale(1, canvas.height);
  8066. this.roadCtx.drawImage(content.road, 0, 0);
  8067. this.roadCtx.restore();
  8068. this.roadCtx.save();
  8069. this.roadCtx.translate(0, e - ((this.dirtRoadEnd - this.dirtRoadStart) - canvas.height));
  8070. this.roadCtx.scale(1, -1);
  8071. this.roadCtx.drawImage(content.dirtTransition, 0, 0);
  8072. this.roadCtx.restore();
  8073. this.roadCtx.fillStyle = this.pattern;
  8074. this.roadCtx.translate(this.sceneManager.camera.positionX, this.sceneManager.camera.positionY);
  8075. this.roadCtx.fillRect(-this.sceneManager.camera.positionX + 174.5 - 3, -this.sceneManager.camera.positionY, 6, this.sprite.height + (this.sceneManager.camera.positionY - this.dirtRoadEnd))
  8076. }
  8077. this.roadCtx.restore()
  8078. }
  8079. d.save();
  8080. this.worldX = 0;
  8081. this.worldY = 0;
  8082. this.drawingSM = this.sceneManager;
  8083. var b = false;
  8084. if (this.parent && this.parent.sceneManager) {
  8085. this.drawingSM = this.parent.sceneManager
  8086. }
  8087. this.sceneAlpha = 1;
  8088. if (this.drawingSM) {
  8089. this.sceneAlpha = this.drawingSM.masterAlpha
  8090. }
  8091. d.globalAlpha = this.alpha * this.sceneAlpha;
  8092. var a = this.x;
  8093. var f = this.y;
  8094. if (this.parent) {
  8095. a += this.parent.x;
  8096. f += this.parent.y
  8097. }
  8098. this.worldX += a;
  8099. this.worldY += f;
  8100. if (!this.internalMatrix) {
  8101. this.internalMatrix = mat2d.create()
  8102. }
  8103. mat2d.identity(this.internalMatrix);
  8104. if (this.originX != 0 || this.originY != 0) {
  8105. if (!this._originTransformVec2) {
  8106. this._originTransformVec2 = vec2.create()
  8107. }
  8108. this._originTransformVec2[0] = -this.originX;
  8109. this._originTransformVec2[1] = -this.originY;
  8110. mat2d.translate(this.internalMatrix, this.internalMatrix, this._originTransformVec2)
  8111. }
  8112. if (this.scaleX != 1 || this.scaleY != 1) {
  8113. if (!this._scaleTransformVec2) {
  8114. this._scaleTransformVec2 = vec2.create()
  8115. }
  8116. this._scaleTransformVec2[0] = this.scaleX;
  8117. this._scaleTransformVec2[1] = this.scaleY;
  8118. mat2d.scale(this.internalMatrix, this.internalMatrix, this._scaleTransformVec2)
  8119. }
  8120. if (this.angle != 0) {
  8121. mat2d.rotate(this.internalMatrix, this.internalMatrix, -this.angle)
  8122. }
  8123. if (a != 0 || f != 0) {
  8124. if (!this._translateTransformVec2) {
  8125. this._translateTransformVec2 = vec2.create()
  8126. }
  8127. this._translateTransformVec2[0] = a;
  8128. this._translateTransformVec2[1] = f;
  8129. mat2d.translate(this.internalMatrix, this.internalMatrix, this._translateTransformVec2)
  8130. }
  8131. if (this.drawingSM) {
  8132. mat2d.translate(this.internalMatrix, this.internalMatrix, [this.drawingSM.camera.shakeOffsetX, this.drawingSM.camera.shakeOffsetY])
  8133. }
  8134. d.setTransform(this.internalMatrix[0], this.internalMatrix[1], this.internalMatrix[2], this.internalMatrix[3], this.internalMatrix[4], this.internalMatrix[5]);
  8135. d.drawImage(this.sprite, 0, 0);
  8136. d.restore()
  8137. };
  8138. Road.prototype.startDirtRoad = function(a, b) {
  8139. this.dirtRoad = true;
  8140. this.dirtRoadStart = a;
  8141. this.dirtRoadEnd = this.dirtRoadStart + b;
  8142. this.gameState.hud.dirtroad.open()
  8143. };
  8144. CarState = {
  8145. NULL: -1,
  8146. IDLE: 0,
  8147. PULLINGOVER: 1,
  8148. PARKED: 2,
  8149. CRUSING: 3,
  8150. BROKENDOWN: 4,
  8151. CHASING: 5,
  8152. EVADING: 6,
  8153. SPINNING: 7
  8154. };
  8155. FailType = {
  8156. SPIN: 0,
  8157. CRASH: 1,
  8158. EXPLODED: 2,
  8159. BROKEDOWN: 3
  8160. };
  8161. Car.rightLaneX = 80;
  8162. Car.leftLaneX = -80;
  8163. function Car() {
  8164. SceneObject.call(this);
  8165. this.carColorIndex;
  8166. this.body;
  8167. this.gameState;
  8168. this.currentState = CarState.NULL;
  8169. this.desiredState = CarState.IDLE;
  8170. this.previousState = CarState.IDLE;
  8171. this.colliders;
  8172. this.collisionVelocityAccumulatorX = 0;
  8173. this.collisionVelocityAccumulatorY = 0
  8174. }
  8175. Car.prototype = new SceneObject();
  8176. Car.prototype.constructor = Car;
  8177. Car.prototype.init = function(a, d, c) {
  8178. this.x = a;
  8179. this.y = d;
  8180. this.gameState = c;
  8181. this.children = [];
  8182. this.childCount = 0;
  8183. this.leftDustTimer = randFloatRange(0, 0.25);
  8184. this.rightDustTimer = randFloatRange(0, 0.25);
  8185. this.offroadTimer = 0;
  8186. this.toBeRemoved = false;
  8187. this.useCamera = true;
  8188. this.collider = null;
  8189. this.collisionEnabled = true;
  8190. this.mass = 1;
  8191. this.restitution = 1;
  8192. this.immovable = false;
  8193. this.contactLessCollision = false;
  8194. this.chaseTarget = null;
  8195. this.colliders = [];
  8196. var b = new CircleCollider();
  8197. b.init(this.x, this.y, 28);
  8198. this.colliders.push(b);
  8199. b = new CircleCollider();
  8200. b.init(this.x, this.y, 28);
  8201. this.colliders.push(b);
  8202. this.updateColliders();
  8203. this.cruiseSpeed = 200 + randIntRange(-50, 50);
  8204. this.topSpeed = 300;
  8205. this.trafficSpeed = this.cruiseSpeed;
  8206. this.defaultDrag = 0.25;
  8207. this.turnSpeed = 0.975;
  8208. this.carAngle = Math.PI * 1.5;
  8209. this.wheelAngle = Math.PI * 1.5;
  8210. this.stuckBehindCar = false;
  8211. this.changingLanes = false;
  8212. this.laneChangeCorrectionTimer = 1;
  8213. this.desiredLaneX = 0;
  8214. this.randomLaneChangeChance = 0.001;
  8215. this.offroad = false;
  8216. this.parkTargetX = 0;
  8217. this.parkTargetY = 0;
  8218. this.parkAngle = 0;
  8219. this.oldVelocityX = 0;
  8220. this.oldVelocityY = 0;
  8221. this.velocityX = 0;
  8222. this.velocityY = -1;
  8223. this.accelerationX = 0;
  8224. this.accelerationY = 0;
  8225. this.dragX = this.defaultDrag;
  8226. this.dragY = this.defaultDrag;
  8227. this.angularAcceleration = 0;
  8228. this.angularVelocity = 0;
  8229. this.angularDrag = 1;
  8230. this.oldAngularVelocity = 0;
  8231. this.skidmarkBuffer;
  8232. this.skidStartX;
  8233. this.skidStartY;
  8234. this.smokeTime = 0.25;
  8235. this.smokeTimer = this.smokeTime;
  8236. this.body = new Drawable();
  8237. this.carColorIndex = randIntRange(0, content.carSprites.length);
  8238. this.body.init(content.carSprites[this.carColorIndex], 0, 0);
  8239. this.body.originX = this.body.sprite.width * 0.5;
  8240. this.body.originY = this.body.sprite.height * 0.5;
  8241. this.addChild(this.body);
  8242. this.depth = -0.2 + randFloatRange(-0.01, 0.01);
  8243. this.wasOffroad = false;
  8244. this.dirtRoad = false
  8245. };
  8246. Car.prototype.update = function(b) {
  8247. if (!this.immovable) {
  8248. if (isNaN(this.collisionVelocityAccumulatorX) || isNaN(this.collisionVelocityAccumulatorY)) {
  8249. this.collisionVelocityAccumulatorX = 0;
  8250. this.collisionVelocityAccumulatorY = 0
  8251. }
  8252. this.velocityX += this.collisionVelocityAccumulatorX;
  8253. this.velocityY += this.collisionVelocityAccumulatorY;
  8254. if (this.currentState != CarState.BROKENDOWN) {
  8255. if (this.collisionVelocityAccumulatorX != 0 || this.collisionVelocityAccumulatorY != 0) {
  8256. var c = Math.atan2(this.collisionVelocityAccumulatorY, this.collisionVelocityAccumulatorX) + Math.PI;
  8257. while (Math.abs(c - this.wheelAngle) > Math.PI) {
  8258. if (c > this.wheelAngle) {
  8259. c -= Math.PI * 2
  8260. } else {
  8261. c += Math.PI * 2
  8262. }
  8263. }
  8264. if (this.colliders[0].colliding) {
  8265. this.wheelAngle -= (c - this.wheelAngle) * 0.5
  8266. } else {
  8267. this.wheelAngle += (c - this.wheelAngle) * 0.5
  8268. }
  8269. }
  8270. }
  8271. this.collisionVelocityAccumulatorX = 0;
  8272. this.collisionVelocityAccumulatorY = 0;
  8273. this.oldVelocityX = this.velocityX;
  8274. this.oldVelocityY = this.velocityY;
  8275. this.velocityX += this.accelerationX * b;
  8276. this.velocityY += this.accelerationY * b;
  8277. this.x += (this.oldVelocityX + this.velocityX) * 0.5 * b;
  8278. this.y += (this.oldVelocityY + this.velocityY) * 0.5 * b;
  8279. if (this.dragX != 1) {
  8280. this.velocityX *= Math.pow(this.dragX, b)
  8281. }
  8282. if (this.dragY != 1) {
  8283. this.velocityY *= Math.pow(this.dragY, b)
  8284. }
  8285. if (this.angularDrag != 1) {
  8286. this.angularVelocity *= Math.pow(this.angularDrag, b)
  8287. }
  8288. }
  8289. this.accelerationX = 0;
  8290. this.accelerationY = 0;
  8291. this.angularAcceleration = 0;
  8292. this.updateColliders();
  8293. this.updateSteering(b);
  8294. for (var a = 0; a < this.childCount; a++) {
  8295. this.children[a].angle = this.carAngle;
  8296. this.children[a].update(b)
  8297. }
  8298. if (this.desiredState != this.currentState) {
  8299. this.onExitState(this.currentState);
  8300. this.currentState = this.desiredState;
  8301. this.onEnterState(this.currentState)
  8302. }
  8303. this.tickState(this.currentState, b);
  8304. this.updateDust(b);
  8305. if (this.offroad) {
  8306. if (!this.wasOffroad) {
  8307. this.offroadTimer = 0
  8308. }
  8309. this.offroadTimer += b;
  8310. if (this.offroadTimer >= 3) {
  8311. this.spinOut()
  8312. }
  8313. }
  8314. this.wasOffroad = this.offroad
  8315. };
  8316. Car.prototype.draw = function(b) {
  8317. if (!this.visible) {
  8318. return
  8319. }
  8320. for (var a = 0; a < this.childCount; a++) {
  8321. this.children[a].draw(b)
  8322. }
  8323. };
  8324. Car.prototype.setDesiredState = function(a) {
  8325. if (this.desiredState == a) {
  8326. return
  8327. }
  8328. this.desiredState = a
  8329. };
  8330. Car.prototype.onEnterState = function(a) {
  8331. switch (a) {
  8332. case CarState.NULL:
  8333. break;
  8334. case CarState.IDLE:
  8335. break;
  8336. case CarState.PARKED:
  8337. this.dragX = 0.1;
  8338. this.dragY = 0.1;
  8339. break;
  8340. case CarState.PULLINGOVER:
  8341. break;
  8342. case CarState.CRUSING:
  8343. break;
  8344. case CarState.CHASING:
  8345. break;
  8346. case CarState.EVADING:
  8347. break;
  8348. case CarState.BROKENDOWN:
  8349. while (this.carAngle > Math.PI * 2) {
  8350. this.carAngle -= Math.PI * 2
  8351. }
  8352. while (this.carAngle < 0) {
  8353. this.carAngle += Math.PI * 2
  8354. }
  8355. while (this.wheelAngle > Math.PI * 2) {
  8356. this.wheelAngle -= Math.PI * 2
  8357. }
  8358. while (this.wheelAngle < 0) {
  8359. this.wheelAngle += Math.PI * 2
  8360. }
  8361. break;
  8362. case CarState.SPINNING:
  8363. this.dragX = 0.5;
  8364. this.dragY = 0.5;
  8365. this.skidStartX = this.x;
  8366. this.skidStartY = this.y;
  8367. this.skidmarkBuffer = new Drawable();
  8368. this.skidmarkBuffer.init(null, 0, 0);
  8369. this.skidmarkBuffer.sprite = document.createElement("canvas");
  8370. this.skidmarkBuffer.sprite.width = canvas.width;
  8371. this.skidmarkBuffer.sprite.height = 720;
  8372. this.skidmarkBuffer.originX = this.skidmarkBuffer.sprite.width * 0.5;
  8373. this.skidmarkBuffer.originY = 720;
  8374. this.skidmarkBuffer.depth = 0.099;
  8375. this.skidmarkBuffer.parent = this;
  8376. this.sceneManager.addEntity(this.skidmarkBuffer);
  8377. break
  8378. }
  8379. };
  8380. Car.prototype.onExitState = function(a) {
  8381. switch (a) {
  8382. case CarState.NULL:
  8383. break;
  8384. case CarState.IDLE:
  8385. break;
  8386. case CarState.PARKED:
  8387. this.dragX = this.defaultDrag;
  8388. this.dragY = this.defaultDrag;
  8389. break;
  8390. case CarState.PULLINGOVER:
  8391. break;
  8392. case CarState.CRUSING:
  8393. break;
  8394. case CarState.CHASING:
  8395. break;
  8396. case CarState.EVADING:
  8397. break;
  8398. case CarState.BROKENDOWN:
  8399. break;
  8400. case CarState.SPINNING:
  8401. break
  8402. }
  8403. };
  8404. Car.prototype.tickState = function(e, n) {
  8405. switch (e) {
  8406. case CarState.NULL:
  8407. break;
  8408. case CarState.IDLE:
  8409. break;
  8410. case CarState.PARKED:
  8411. break;
  8412. case CarState.PULLINGOVER:
  8413. var d = (this.parkTargetX - this.x);
  8414. var c = (this.parkTargetY - this.y);
  8415. var y = Math.sqrt(d * d + c * c);
  8416. var f = Math.abs(this.carAngle - this.parkAngle);
  8417. if (f > Math.PI) {
  8418. if (this.carAngle < this.parkAngle) {
  8419. this.carAngle += Math.PI * 2
  8420. } else {
  8421. this.carAngle -= Math.PI * 2
  8422. }
  8423. f = Math.abs(this.carAngle - this.parkAngle)
  8424. }
  8425. if (y < 80 && f < Math.PI * 0.25) {
  8426. this.setDesiredState(CarState.PARKED)
  8427. } else {
  8428. var m = this.parkTargetX - Math.cos(this.parkAngle) * 128;
  8429. var l = this.parkTargetY - Math.sin(this.parkAngle) * 128;
  8430. d = (m - this.x);
  8431. c = (l - this.y);
  8432. y = Math.sqrt(d * d + c * c);
  8433. if (y < 80) {
  8434. this.wheelAngle = this.parkAngle;
  8435. this.accelerationX += Math.cos(this.wheelAngle) * this.cruiseSpeed * 0.1;
  8436. this.accelerationY += Math.sin(this.wheelAngle) * this.cruiseSpeed * 0.1
  8437. } else {
  8438. this.wheelAngle = Math.atan2(c, d);
  8439. this.accelerationX += Math.cos(this.wheelAngle) * this.cruiseSpeed;
  8440. this.accelerationY += Math.sin(this.wheelAngle) * this.cruiseSpeed
  8441. }
  8442. }
  8443. break;
  8444. case CarState.CRUSING:
  8445. var q = this.cruiseSpeed;
  8446. if (this.stuckBehindCar) {
  8447. q = this.trafficSpeed
  8448. }
  8449. this.wheelAngle = (Math.PI * 1.5) + (this.wheelAngle - (Math.PI * 1.5)) * 0.95;
  8450. this.accelerationX += Math.cos(this.wheelAngle) * q;
  8451. this.accelerationY += Math.sin(this.wheelAngle) * q;
  8452. if (this.changingLanes) {
  8453. var t = Math.abs(this.x - this.desiredLaneX);
  8454. if (t < 16) {
  8455. this.wheelAngle = Math.PI * 1.5;
  8456. this.laneChangeCorrectionTimer -= n;
  8457. if (this.laneChangeCorrectionTimer <= 0) {
  8458. this.changingLanes = false;
  8459. this.laneChangeCorrectionTimer = 1
  8460. }
  8461. } else {
  8462. if (this.desiredLaneX > this.x) {
  8463. this.wheelAngle = Math.PI * 1.65
  8464. } else {
  8465. this.wheelAngle = Math.PI * 1.35
  8466. }
  8467. }
  8468. } else {
  8469. if (this.obstructionAhead() || (randFloatRange(0, 1) < this.randomLaneChangeChance && this.isAdjacentLaneOpen())) {
  8470. this.changingLanes = true;
  8471. if (this.x > 0) {
  8472. this.desiredLaneX = Car.leftLaneX
  8473. } else {
  8474. this.desiredLaneX = Car.rightLaneX
  8475. }
  8476. }
  8477. }
  8478. this.stuckBehindCar = false;
  8479. if (!this.changingLanes) {
  8480. for (var p = 0; p < this.gameState.cars.length; p++) {
  8481. if (this.gameState.cars[p] === this) {
  8482. continue
  8483. }
  8484. var g = Math.abs(this.gameState.cars[p].y - this.y);
  8485. if (g >= 160 || this.gameState.cars[p].y >= this.y) {
  8486. continue
  8487. }
  8488. if (Math.abs(this.gameState.cars[p].x - this.x) < 80 && Math.abs(this.gameState.cars[p].velocityY) < Math.abs(this.velocityY)) {
  8489. var z = this.isAdjacentLaneOpen();
  8490. if (z) {
  8491. this.stuckBehindCar = false;
  8492. this.changingLanes = true;
  8493. if (this.x > 0) {
  8494. this.desiredLaneX = Car.leftLaneX
  8495. } else {
  8496. this.desiredLaneX = Car.rightLaneX
  8497. }
  8498. } else {
  8499. this.stuckBehindCar = true;
  8500. this.trafficSpeed = this.gameState.cars[p].trafficSpeed
  8501. }
  8502. }
  8503. }
  8504. }
  8505. break;
  8506. case CarState.CHASING:
  8507. break;
  8508. case CarState.EVADING:
  8509. this.accelerationX += Math.cos(this.wheelAngle) * this.topSpeed;
  8510. this.accelerationY += Math.sin(this.wheelAngle) * this.topSpeed;
  8511. break;
  8512. case CarState.BROKENDOWN:
  8513. this.smokeTimer -= n;
  8514. if (this.smokeTimer <= 0) {
  8515. this.smokeTimer = this.smokeTime;
  8516. var x = new Particle();
  8517. x.init(content.smoke, randFloatRange(0.25, 0.75) * 6);
  8518. x.x = this.x + Math.cos(this.carAngle) * 30;
  8519. x.y = this.y + Math.sin(this.carAngle) * 30;
  8520. x.originX = x.sprite.width * 0.5;
  8521. x.originY = x.sprite.height * 0.5;
  8522. var k = randFloatRange(0.75, 1) * 2;
  8523. x.startScaleX = 0;
  8524. x.startScaleY = 0;
  8525. x.endScaleX = k;
  8526. x.endScaleY = k;
  8527. x.startAlpha = 0.65;
  8528. x.endAlpha = 0;
  8529. x.depth = this.depth - 0.01;
  8530. x.dragX = 1;
  8531. x.dragY = 1;
  8532. var h = randFloatRange(0, 0.25);
  8533. var o = randFloatRange(0, Math.PI * 2);
  8534. x.velocityX = Math.cos(o) * h;
  8535. x.velocityY = Math.sin(o) * h;
  8536. x.start();
  8537. this.sceneManager.addEntity(x)
  8538. }
  8539. break;
  8540. case CarState.SPINNING:
  8541. this.skidmarkBuffer.x = -this.x;
  8542. this.skidmarkBuffer.originX = this.skidmarkBuffer.sprite.width * 0.5;
  8543. this.skidmarkBuffer.originY = 720 + (this.y - this.skidStartY);
  8544. var j = Math.sqrt(this.velocityX * this.velocityX + this.velocityY * this.velocityY);
  8545. if (j < 1) {
  8546. this.setDesiredState(CarState.BROKENDOWN);
  8547. break
  8548. }
  8549. var b = this.skidmarkBuffer.sprite.getContext("2d");
  8550. var w = this.skidmarkBuffer.sprite.width * 0.5;
  8551. var u = 720;
  8552. w += this.x;
  8553. u += (this.y - this.skidStartY);
  8554. var a = content.skid;
  8555. if (this.dirtRoad) {
  8556. a = content.dirtSkid
  8557. }
  8558. for (var p = 0; p < 4; p++) {
  8559. b.drawImage(a, w + Math.cos(this.carAngle + Math.PI * 0.25 + p * Math.PI * 0.5) * 28, u + Math.sin(this.carAngle + Math.PI * 0.25 + p * Math.PI * 0.5) * 28)
  8560. }
  8561. break
  8562. }
  8563. };
  8564. Car.prototype.updateDust = function(d) {
  8565. this.offroad = false;
  8566. if (this.currentState == CarState.SPINNING || this.currentState == CarState.BROKENDOWN) {
  8567. return
  8568. }
  8569. if (this.x < -160 || this.x > (160 + 32) || this.dirtRoad) {
  8570. if (this.x < -160 || this.x > (160 + 32)) {
  8571. this.offroad = true
  8572. }
  8573. this.leftDustTimer -= d;
  8574. if (this.leftDustTimer <= 0) {
  8575. this.leftDustTimer = 0.25 + randFloatRange(-0.05, 0.05);
  8576. var c = new Particle();
  8577. c.init(content.dust, randFloatRange(0.25, 0.75) * 2);
  8578. c.x = this.x + Math.cos(this.carAngle + (-Math.PI + 0.4)) * 48;
  8579. c.y = this.y + Math.sin(this.carAngle + (-Math.PI + 0.4)) * 48;
  8580. c.originX = c.sprite.width * 0.5;
  8581. c.originY = c.sprite.height * 0.5;
  8582. var b = randFloatRange(0.75, 1) * 2;
  8583. c.startScaleX = 0.5;
  8584. c.startScaleY = 0.5;
  8585. c.endScaleX = b;
  8586. c.endScaleY = b;
  8587. c.startAlpha = 1;
  8588. c.endAlpha = 0;
  8589. c.depth = this.depth + 0.01;
  8590. c.dragX = 0.5 + randFloatRange(-0.25, 0.25);
  8591. c.dragY = c.dragX;
  8592. var a = 0;
  8593. c.velocityX = Math.cos(this.carAngle) * a;
  8594. c.velocityY = Math.sin(this.carAngle) * a;
  8595. c.start();
  8596. this.sceneManager.addEntity(c)
  8597. }
  8598. }
  8599. if (this.x < -(160 + 32) || this.x > (160) || this.dirtRoad) {
  8600. if (this.x < -(160 + 32) || this.x > (160)) {
  8601. this.offroad = true
  8602. }
  8603. this.rightDustTimer -= d;
  8604. if (this.rightDustTimer <= 0) {
  8605. this.rightDustTimer = 0.25 + randFloatRange(-0.05, 0.05);
  8606. var c = new Particle();
  8607. c.init(content.dust, randFloatRange(0.25, 0.75) * 2);
  8608. c.x = this.x + Math.cos(this.carAngle + (Math.PI - 0.4)) * 48;
  8609. c.y = this.y + Math.sin(this.carAngle + (Math.PI - 0.4)) * 48;
  8610. c.originX = c.sprite.width * 0.5;
  8611. c.originY = c.sprite.height * 0.5;
  8612. var b = randFloatRange(0.75, 1) * 2;
  8613. c.startScaleX = 0.5;
  8614. c.startScaleY = 0.5;
  8615. c.endScaleX = b;
  8616. c.endScaleY = b;
  8617. c.startAlpha = 1;
  8618. c.endAlpha = 0;
  8619. c.depth = this.depth + 0.01;
  8620. c.dragX = 0.5 + randFloatRange(-0.25, 0.25);
  8621. c.dragY = c.dragX;
  8622. var a = 0;
  8623. c.velocityX = Math.cos(this.carAngle) * a;
  8624. c.velocityY = Math.sin(this.carAngle) * a;
  8625. c.start();
  8626. this.sceneManager.addEntity(c)
  8627. }
  8628. }
  8629. };
  8630. Car.prototype.updateSteering = function(b) {
  8631. if (this.currentState == CarState.BROKENDOWN) {
  8632. return
  8633. }
  8634. this.carAngle = this.wheelAngle + (this.carAngle - this.wheelAngle) * (this.turnSpeed);
  8635. if (this.currentState == CarState.SPINNING) {
  8636. this.wheelAngle += 0.01 * Math.sqrt(this.velocityX * this.velocityX + this.velocityY * this.velocityY) * b;
  8637. return
  8638. }
  8639. while (this.wheelAngle > Math.PI * 2) {
  8640. this.wheelAngle -= Math.PI * 2
  8641. }
  8642. while (this.wheelAngle < 0) {
  8643. this.wheelAngle += Math.PI * 2
  8644. }
  8645. if (this.dirtRoad) {
  8646. var a = randFloatRange(-2, 2);
  8647. this.wheelAngle += a;
  8648. this.accelerationY += Math.sin(this.wheelAngle) * this.speed
  8649. }
  8650. };
  8651. Car.prototype.updateColliders = function() {
  8652. if (!this.colliders) {
  8653. return
  8654. }
  8655. var b = Math.cos(this.carAngle);
  8656. var c = Math.sin(this.carAngle);
  8657. this.colliders[0].x = this.x + b * 14;
  8658. this.colliders[0].y = this.y + c * 14;
  8659. this.colliders[1].x = this.x - b * 14;
  8660. this.colliders[1].y = this.y - c * 14;
  8661. for (var a = 0; a < this.colliders.length; a++) {
  8662. this.colliders[a].colliding = false
  8663. }
  8664. };
  8665. Car.prototype.checkCollision = function(f) {
  8666. if (!this.colliders || !f.colliders) {
  8667. return
  8668. }
  8669. for (var e = 0; e < this.colliders.length; e++) {
  8670. for (var d = 0; d < f.colliders.length; d++) {
  8671. var c = Collision.getCollision(this.colliders[e], f.colliders[d]);
  8672. if (this.colliders[e].colliding && !this.colliders[e].lastCollisionObject) {
  8673. this.colliders[e].lastCollisionObject = f
  8674. }
  8675. if (f.colliders[d].colliding && !f.colliders[d].lastCollisionObject) {
  8676. f.colliders[d].lastCollisionObject = this
  8677. }
  8678. if (c) {
  8679. this.onCollision(c, f);
  8680. c.directionX *= -1;
  8681. c.directionY *= -1;
  8682. f.onCollision(c, this)
  8683. }
  8684. }
  8685. }
  8686. };
  8687. Car.prototype.onCollision = function(p, h) {
  8688. if (!this.collisionEnabled || this.immovable) {
  8689. return
  8690. }
  8691. if (!this.colliders) {
  8692. this.collisionEnabled = false;
  8693. return
  8694. }
  8695. if (Wall.prototype.isPrototypeOf(h)) {
  8696. this.crash()
  8697. } else {
  8698. if (!CopCar.prototype.isPrototypeOf(this) && PlayerCar.prototype.isPrototypeOf(h)) {
  8699. for (var l = 0; l < this.gameState.cars.length; l++) {
  8700. var o = this.gameState.cars[l];
  8701. if (o === this || !CopCar.prototype.isPrototypeOf(o) || o.lightActive) {
  8702. continue
  8703. }
  8704. var a = Math.sqrt((o.x - this.x) * (o.x - this.x) + (o.y - this.y) * (o.y - this.y));
  8705. if (a < 256) {
  8706. o.chaseTarget = this;
  8707. o.setDesiredState(CarState.CHASING)
  8708. }
  8709. }
  8710. }
  8711. }
  8712. this.x += p.directionX * p.magnitude;
  8713. this.y += p.directionY * p.magnitude;
  8714. if (this.mass == 0) {
  8715. return
  8716. }
  8717. var f = this.velocityX - h.velocityX;
  8718. var d = this.velocityY - h.velocityY;
  8719. var n = (f * p.directionX) + (d * p.directionY);
  8720. var b = Math.min(this.restitution, h.restitution);
  8721. var k = -(1 + b) * n;
  8722. if (h.mass == 0) {
  8723. k /= (1 / this.mass)
  8724. } else {
  8725. k /= (1 / this.mass) + (1 / h.mass)
  8726. }
  8727. var e = k * p.directionX;
  8728. var c = k * p.directionY;
  8729. var g = 1 / this.mass;
  8730. this.collisionVelocityAccumulatorX += g * e;
  8731. this.collisionVelocityAccumulatorY += g * c;
  8732. this.updateColliders();
  8733. if (PlayerCar.prototype.isPrototypeOf(this)) {
  8734. if (this.gameState.playState == PlayState.GAME) {
  8735. this.incrementHit()
  8736. }
  8737. if (!soundMuted) {
  8738. var m = "hitCrash01";
  8739. switch (randIntRange(0, 3)) {
  8740. case 0:
  8741. m = "hitCrash01";
  8742. break;
  8743. case 1:
  8744. m = "hitCrash02";
  8745. break;
  8746. case 2:
  8747. m = "hitCrash03";
  8748. break
  8749. }
  8750. playSound(m)
  8751. }
  8752. }
  8753. };
  8754. Car.prototype.isAdjacentLaneOpen = function() {
  8755. for (var f = 0; f < this.gameState.cars.length; f++) {
  8756. if (this.gameState.cars[f] === this) {
  8757. continue
  8758. }
  8759. var d = this.gameState.cars[f];
  8760. var e = Math.abs(d.y - this.y);
  8761. if (e >= 128) {
  8762. continue
  8763. }
  8764. if ((this.x < 0 && d.x > 0 && d.x < 160) || (this.x > 0 && d.x < 0 && d.x > -160)) {
  8765. return false;
  8766. break
  8767. }
  8768. }
  8769. for (var b = 0; b < this.gameState.walls.length; b++) {
  8770. if (this.gameState.walls[b] === this) {
  8771. continue
  8772. }
  8773. var a = this.gameState.walls[b];
  8774. var e = Math.abs(a.y - this.y);
  8775. if (e >= 128) {
  8776. continue
  8777. }
  8778. if ((this.x < 0 && a.x > 0 && a.x < 160) || (this.x > 0 && a.x < 0 && a.x > -160)) {
  8779. return false;
  8780. break
  8781. }
  8782. }
  8783. return true
  8784. };
  8785. Car.prototype.obstructionAhead = function() {
  8786. for (var b = 0; b < this.gameState.walls.length; b++) {
  8787. var a = this.gameState.walls[b];
  8788. var c = (a.y - this.y);
  8789. if (c >= 1024) {
  8790. continue
  8791. }
  8792. if ((this.x < 0 && a.x < 0) || (this.x > 0 && a.x > 0)) {
  8793. return true
  8794. }
  8795. }
  8796. for (var d = 0; d < this.gameState.roadBlocks.length; d++) {
  8797. var e = this.gameState.roadBlocks[d];
  8798. var c = (e.y - this.y);
  8799. if (c >= 512) {
  8800. continue
  8801. }
  8802. if ((this.x < 0 && e.x < 0) || (this.x > 0 && e.x > 0)) {
  8803. return true
  8804. }
  8805. }
  8806. return false
  8807. };
  8808. Car.prototype.spinOut = function() {
  8809. if ((this.currentState == CarState.SPINNING || this.desiredState == CarState.SPINNING) || (this.currentState == CarState.BROKENDOWN || this.desiredState == CarState.BROKENDOWN)) {
  8810. return
  8811. }
  8812. this.setDesiredState(CarState.SPINNING);
  8813. this.depth = -0.19 + randFloatRange(-0.01, 0.01);
  8814. if (!soundMuted && PlayerCar.prototype.isPrototypeOf(this)) {
  8815. var a = "skid";
  8816. playSound(a)
  8817. }
  8818. };
  8819. Car.prototype.crash = function() {
  8820. if (this.currentState == CarState.BROKENDOWN || this.desiredState == CarState.BROKENDOWN) {
  8821. return
  8822. }
  8823. this.body.sprite = content.crashSprites[this.carColorIndex];
  8824. this.restitution = 0.1;
  8825. this.dragX = 0.01;
  8826. this.dragY = 0.01;
  8827. this.angularDrag = 0.01;
  8828. this.setDesiredState(CarState.BROKENDOWN);
  8829. if (!soundMuted) {
  8830. var a = "impactCrash";
  8831. playSound(a)
  8832. }
  8833. };
  8834. Car.prototype.explode = function() {
  8835. if (this.currentState == CarState.BROKENDOWN || this.desiredState == CarState.BROKENDOWN) {
  8836. return
  8837. }
  8838. this.body.sprite = content.explodeSprites[this.carColorIndex];
  8839. this.restitution = 0.1;
  8840. this.dragX = 0.01;
  8841. this.dragY = 0.01;
  8842. this.angularDrag = 0.001;
  8843. this.setDesiredState(CarState.BROKENDOWN)
  8844. };
  8845. Car.prototype.flagForRemoval = function() {
  8846. this.toBeRemoved = true;
  8847. if (this.skidmarkBuffer) {
  8848. this.skidmarkBuffer.flagForRemoval()
  8849. }
  8850. if (this.dirtLoopInstance) {
  8851. this.dirtLoopInstance.stop();
  8852. this.dirtLoopInstance = null
  8853. }
  8854. };
  8855. function Truck() {
  8856. Car.call(this)
  8857. }
  8858. Truck.prototype = new Car();
  8859. Truck.prototype.constructor = Truck;
  8860. Truck.prototype.init = function(a, d, c) {
  8861. this.x = a;
  8862. this.y = d;
  8863. this.gameState = c;
  8864. this.children = [];
  8865. this.childCount = 0;
  8866. this.toBeRemoved = false;
  8867. this.useCamera = true;
  8868. this.lightActive = true;
  8869. this.lightSine = randFloatRange(0, Math.PI * 2);
  8870. this.rammingTimer = 0;
  8871. this.rammingDirection = 0;
  8872. this.collider = null;
  8873. this.collisionEnabled = true;
  8874. this.mass = 4;
  8875. this.restitution = 1;
  8876. this.immovable = false;
  8877. this.contactLessCollision = false;
  8878. this.colliders = [];
  8879. var b = new CircleCollider();
  8880. b.init(this.x, this.y, 34);
  8881. this.colliders.push(b);
  8882. b = new CircleCollider();
  8883. b.init(this.x, this.y, 34);
  8884. this.colliders.push(b);
  8885. b = new CircleCollider();
  8886. b.init(this.x, this.y, 34);
  8887. this.colliders.push(b);
  8888. this.updateColliders();
  8889. this.cruiseSpeed = 200;
  8890. this.topSpeed = 275;
  8891. this.trafficSpeed = this.cruiseSpeed;
  8892. this.defaultDrag = 0.25;
  8893. this.turnSpeed = 0.995;
  8894. this.carAngle = Math.PI * 1.5;
  8895. this.wheelAngle = Math.PI * 1.5;
  8896. this.stuckBehindCar = false;
  8897. this.changingLanes = false;
  8898. this.laneChangeCorrectionTimer = 1;
  8899. this.desiredLaneX = 0;
  8900. this.randomLaneChangeChance = 0.001;
  8901. this.parkTargetX = 0;
  8902. this.parkTargetY = 0;
  8903. this.parkAngle = 0;
  8904. this.oldVelocityX = 0;
  8905. this.oldVelocityY = 0;
  8906. this.velocityX = 0;
  8907. this.velocityY = -1;
  8908. this.accelerationX = 0;
  8909. this.accelerationY = 0;
  8910. this.dragX = this.defaultDrag;
  8911. this.dragY = this.defaultDrag;
  8912. this.angularAcceleration = 0;
  8913. this.angularVelocity = 0;
  8914. this.angularDrag = 1;
  8915. this.oldAngularVelocity = 0;
  8916. this.speed = 250;
  8917. this.body = new Drawable();
  8918. this.body.init(content.truck, 0, 0);
  8919. this.body.originX = 128;
  8920. this.body.originY = this.body.sprite.height * 0.5;
  8921. this.addChild(this.body);
  8922. this.depth = -0.2 + randFloatRange(-0.01, 0.01);
  8923. this.crateDroppingActive = false;
  8924. this.explodingCrates = false;
  8925. this.crateTimer = 0;
  8926. this.crateRate = 2.5;
  8927. this.crateChance = 0.5
  8928. };
  8929. Truck.prototype.updateColliders = function() {
  8930. if (!this.colliders) {
  8931. return
  8932. }
  8933. var a = Math.cos(this.carAngle);
  8934. var b = Math.sin(this.carAngle);
  8935. this.colliders[0].x = this.x + a * (44 - 42);
  8936. this.colliders[0].y = this.y + b * (44 - 42);
  8937. this.colliders[1].x = this.x + a * (-44 - 42);
  8938. this.colliders[1].y = this.y + b * (-44 - 42);
  8939. this.colliders[2].x = this.x + a * (0 - 42);
  8940. this.colliders[2].y = this.y + b * (0 - 42)
  8941. };
  8942. Truck.prototype.tickState = function(f, p) {
  8943. switch (f) {
  8944. case CarState.NULL:
  8945. break;
  8946. case CarState.IDLE:
  8947. break;
  8948. case CarState.PARKED:
  8949. break;
  8950. case CarState.PULLINGOVER:
  8951. var e = (this.parkTargetX - this.x);
  8952. var d = (this.parkTargetY - this.y);
  8953. var z = Math.sqrt(e * e + d * d);
  8954. var g = Math.abs(this.carAngle - this.parkAngle);
  8955. if (g > Math.PI) {
  8956. if (this.carAngle < this.parkAngle) {
  8957. this.carAngle += Math.PI * 2
  8958. } else {
  8959. this.carAngle -= Math.PI * 2
  8960. }
  8961. g = Math.abs(this.carAngle - this.parkAngle)
  8962. }
  8963. if (z < 80 && g < Math.PI * 0.25) {
  8964. this.setDesiredState(CarState.PARKED)
  8965. } else {
  8966. var o = this.parkTargetX - Math.cos(this.parkAngle) * 128;
  8967. var m = this.parkTargetY - Math.sin(this.parkAngle) * 128;
  8968. e = (o - this.x);
  8969. d = (m - this.y);
  8970. z = Math.sqrt(e * e + d * d);
  8971. if (z < 80) {
  8972. this.wheelAngle = this.parkAngle;
  8973. this.accelerationX += Math.cos(this.wheelAngle) * this.cruiseSpeed * 0.1;
  8974. this.accelerationY += Math.sin(this.wheelAngle) * this.cruiseSpeed * 0.1
  8975. } else {
  8976. this.wheelAngle = Math.atan2(d, e);
  8977. this.accelerationX += Math.cos(this.wheelAngle) * this.cruiseSpeed;
  8978. this.accelerationY += Math.sin(this.wheelAngle) * this.cruiseSpeed
  8979. }
  8980. }
  8981. break;
  8982. case CarState.CRUSING:
  8983. if (this.crateDroppingActive) {
  8984. this.crateTimer -= p;
  8985. while (this.crateTimer <= 0) {
  8986. this.crateTimer = this.crateRate;
  8987. if (randFloatRange(0, 1) < this.crateChance) {
  8988. var b = new Crate();
  8989. b.init(this.x - Math.cos(this.carAngle) * 64, this.y - Math.sin(this.carAngle) * 64, randFloatRange(0, Math.PI * 2), this.gameState);
  8990. b.spawner = this;
  8991. b.doSpawnAnimation();
  8992. if (this.explodingCrates && randFloatRange(0, 1) < 0.5) {
  8993. b.setExplosive(true)
  8994. }
  8995. this.sceneManager.addEntity(b);
  8996. this.gameState.crates.push(b);
  8997. b.accelerationX = this.velocityX * 70;
  8998. b.accelerationY = this.velocityY * 70;
  8999. b.angularAcceleration += randFloatRange(-1, 1) * 200
  9000. }
  9001. }
  9002. }
  9003. var t = this.cruiseSpeed;
  9004. if (this.stuckBehindCar) {
  9005. t = this.trafficSpeed
  9006. }
  9007. this.wheelAngle = (Math.PI * 1.5) + (this.wheelAngle - (Math.PI * 1.5)) * 0.95;
  9008. this.accelerationX += Math.cos(this.wheelAngle) * t;
  9009. this.accelerationY += Math.sin(this.wheelAngle) * t;
  9010. if (this.changingLanes) {
  9011. var u = Math.abs(this.x - this.desiredLaneX);
  9012. if (u < 16) {
  9013. this.wheelAngle = Math.PI * 1.5;
  9014. this.laneChangeCorrectionTimer -= p;
  9015. if (this.laneChangeCorrectionTimer <= 0) {
  9016. this.changingLanes = false;
  9017. this.laneChangeCorrectionTimer = 1
  9018. }
  9019. } else {
  9020. if (this.desiredLaneX > this.x) {
  9021. this.wheelAngle = Math.PI * 1.65
  9022. } else {
  9023. this.wheelAngle = Math.PI * 1.35
  9024. }
  9025. }
  9026. } else {
  9027. if (this.obstructionAhead() || (randFloatRange(0, 1) < this.randomLaneChangeChance && this.isAdjacentLaneOpen())) {
  9028. this.changingLanes = true;
  9029. if (this.x > 0) {
  9030. this.desiredLaneX = Car.leftLaneX
  9031. } else {
  9032. this.desiredLaneX = Car.rightLaneX
  9033. }
  9034. }
  9035. }
  9036. this.stuckBehindCar = false;
  9037. if (!this.changingLanes) {
  9038. for (var q = 0; q < this.gameState.cars.length; q++) {
  9039. if (this.gameState.cars[q] === this) {
  9040. continue
  9041. }
  9042. var h = Math.abs(this.gameState.cars[q].y - this.y);
  9043. if (h >= 160 || this.gameState.cars[q].y >= this.y) {
  9044. continue
  9045. }
  9046. if (Math.abs(this.gameState.cars[q].x - this.x) < 80 && Math.abs(this.gameState.cars[q].velocityY) < Math.abs(this.velocityY)) {
  9047. var A = this.isAdjacentLaneOpen();
  9048. if (A) {
  9049. this.stuckBehindCar = false;
  9050. this.changingLanes = true;
  9051. if (this.x > 0) {
  9052. this.desiredLaneX = Car.leftLaneX
  9053. } else {
  9054. this.desiredLaneX = Car.rightLaneX
  9055. }
  9056. } else {
  9057. this.stuckBehindCar = true;
  9058. this.trafficSpeed = this.gameState.cars[q].trafficSpeed
  9059. }
  9060. }
  9061. }
  9062. }
  9063. break;
  9064. case CarState.CHASING:
  9065. break;
  9066. case CarState.EVADING:
  9067. this.accelerationX += Math.cos(this.wheelAngle) * this.topSpeed;
  9068. this.accelerationY += Math.sin(this.wheelAngle) * this.topSpeed;
  9069. break;
  9070. case CarState.BROKENDOWN:
  9071. this.smokeTimer -= p;
  9072. if (this.smokeTimer <= 0) {
  9073. this.smokeTimer = this.smokeTime;
  9074. var y = new Particle();
  9075. y.init(content.smoke, randFloatRange(0.25, 0.75) * 6);
  9076. y.x = this.x + Math.cos(this.carAngle) * 30;
  9077. y.y = this.y + Math.sin(this.carAngle) * 30;
  9078. y.originX = y.sprite.width * 0.5;
  9079. y.originY = y.sprite.height * 0.5;
  9080. var l = randFloatRange(0.75, 1) * 2;
  9081. y.startScaleX = 0;
  9082. y.startScaleY = 0;
  9083. y.endScaleX = l;
  9084. y.endScaleY = l;
  9085. y.startAlpha = 0.65;
  9086. y.endAlpha = 0;
  9087. y.depth = this.depth - 0.01;
  9088. y.dragX = 1;
  9089. y.dragY = 1;
  9090. var j = randFloatRange(0, 0.25);
  9091. var n = randFloatRange(0, Math.PI * 2);
  9092. y.velocityX = Math.cos(n) * j;
  9093. y.velocityY = Math.sin(n) * j;
  9094. y.start();
  9095. this.sceneManager.addEntity(y)
  9096. }
  9097. break;
  9098. case CarState.SPINNING:
  9099. this.skidmarkBuffer.x = -this.x;
  9100. this.skidmarkBuffer.originX = this.skidmarkBuffer.sprite.width * 0.5;
  9101. this.skidmarkBuffer.originY = 360 + (this.y - this.skidStartY);
  9102. var k = Math.sqrt(this.velocityX * this.velocityX + this.velocityY * this.velocityY);
  9103. if (k < 1) {
  9104. this.setDesiredState(CarState.BROKENDOWN);
  9105. break
  9106. }
  9107. var c = this.skidmarkBuffer.sprite.getContext("2d");
  9108. var x = this.skidmarkBuffer.sprite.width * 0.5;
  9109. var w = 360;
  9110. x += this.x;
  9111. w += (this.y - this.skidStartY);
  9112. x += Math.cos(this.carAngle) * -42;
  9113. w += Math.sin(this.carAngle) * -42;
  9114. var a = content.skid;
  9115. if (this.dirtRoad) {
  9116. a = content.dirtSkid
  9117. }
  9118. for (var q = 0; q < 4; q++) {
  9119. c.drawImage(a, x + Math.cos(this.carAngle + Math.PI * 0.25 + q * Math.PI * 0.5) * 56, w + Math.sin(this.carAngle + Math.PI * 0.25 + q * Math.PI * 0.5) * 56)
  9120. }
  9121. break
  9122. }
  9123. };
  9124. Truck.prototype.updateDust = function(d) {
  9125. this.offroad = false;
  9126. if (this.currentState === CarState.SPINNING || this.currentState === CarState.BROKENDOWN) {
  9127. return
  9128. }
  9129. if (this.x < -160 || this.x > (160 + 32)) {
  9130. this.offroad = true;
  9131. this.leftDustTimer -= d;
  9132. if (this.leftDustTimer <= 0) {
  9133. this.leftDustTimer = 0.25;
  9134. var c = new Particle();
  9135. c.init(content.dust, randFloatRange(0.25, 0.75) * 2);
  9136. c.x = this.x + Math.cos(this.carAngle + (-Math.PI + 0.4)) * 48;
  9137. c.y = this.y + Math.sin(this.carAngle + (-Math.PI + 0.4)) * 48;
  9138. c.originX = c.sprite.width * 0.5;
  9139. c.originY = c.sprite.height * 0.5;
  9140. var b = randFloatRange(0.75, 1) * 2;
  9141. c.startScaleX = 0.5;
  9142. c.startScaleY = 0.5;
  9143. c.endScaleX = b;
  9144. c.endScaleY = b;
  9145. c.startAlpha = 1;
  9146. c.endAlpha = 0;
  9147. c.depth = this.depth + 0.01;
  9148. c.dragX = 0.5 + randFloatRange(-0.25, 0.25);
  9149. c.dragY = c.dragX;
  9150. var a = 0;
  9151. c.velocityX = Math.cos(this.carAngle) * a;
  9152. c.velocityY = Math.sin(this.carAngle) * a;
  9153. c.start();
  9154. this.sceneManager.addEntity(c)
  9155. }
  9156. }
  9157. if (this.x < -(160 + 32) || this.x > (160)) {
  9158. this.offroad = true;
  9159. this.rightDustTimer -= d;
  9160. if (this.rightDustTimer <= 0) {
  9161. this.rightDustTimer = 0.25;
  9162. var c = new Particle();
  9163. c.init(content.dust, randFloatRange(0.25, 0.75) * 2);
  9164. c.x = this.x + Math.cos(this.carAngle + (Math.PI - 0.4)) * 48;
  9165. c.y = this.y + Math.sin(this.carAngle + (Math.PI - 0.4)) * 48;
  9166. c.originX = c.sprite.width * 0.5;
  9167. c.originY = c.sprite.height * 0.5;
  9168. var b = randFloatRange(0.75, 1) * 2;
  9169. c.startScaleX = 0.5;
  9170. c.startScaleY = 0.5;
  9171. c.endScaleX = b;
  9172. c.endScaleY = b;
  9173. c.startAlpha = 1;
  9174. c.endAlpha = 0;
  9175. c.depth = this.depth + 0.01;
  9176. c.dragX = 0.5 + randFloatRange(-0.25, 0.25);
  9177. c.dragY = c.dragX;
  9178. var a = 0;
  9179. c.velocityX = Math.cos(this.carAngle) * a;
  9180. c.velocityY = Math.sin(this.carAngle) * a;
  9181. c.start();
  9182. this.sceneManager.addEntity(c)
  9183. }
  9184. }
  9185. };
  9186. Truck.prototype.crash = function() {
  9187. if (this.currentState == CarState.BROKENDOWN || this.desiredState == CarState.BROKENDOWN) {
  9188. return
  9189. }
  9190. this.body.sprite = content.truckCrash;
  9191. this.restitution = 0.1;
  9192. this.dragX = 0.01;
  9193. this.dragY = 0.01;
  9194. this.angularDrag = 0.001;
  9195. this.setDesiredState(CarState.BROKENDOWN)
  9196. };
  9197. Truck.prototype.explode = function() {
  9198. if (this.currentState == CarState.BROKENDOWN || this.desiredState == CarState.BROKENDOWN) {
  9199. return
  9200. }
  9201. this.body.sprite = content.truckExploded;
  9202. this.restitution = 0.1;
  9203. this.dragX = 0.01;
  9204. this.dragY = 0.01;
  9205. this.angularDrag = 0.001;
  9206. this.setDesiredState(CarState.BROKENDOWN)
  9207. };
  9208. function PlayerCar() {
  9209. Car.call(this)
  9210. }
  9211. PlayerCar.prototype = new Car();
  9212. PlayerCar.prototype.constructor = PlayerCar;
  9213. PlayerCar.prototype.init = function(a, d, c) {
  9214. this.x = a;
  9215. this.y = d;
  9216. this.gameState = c;
  9217. this.children = [];
  9218. this.childCount = 0;
  9219. this.leftDustTimer = 0;
  9220. this.rightDustTimer = 0;
  9221. this.offroadTimer = 0;
  9222. this.toBeRemoved = false;
  9223. this.useCamera = true;
  9224. this.collider = null;
  9225. this.collisionEnabled = true;
  9226. this.mass = 1;
  9227. this.restitution = 1;
  9228. this.immovable = false;
  9229. this.contactLessCollision = false;
  9230. this.colliders = [];
  9231. var b = new CircleCollider();
  9232. b.init(this.x, this.y, 28);
  9233. this.colliders.push(b);
  9234. b = new CircleCollider();
  9235. b.init(this.x, this.y, 28);
  9236. this.colliders.push(b);
  9237. this.updateColliders();
  9238. this.oldVelocityX = 0;
  9239. this.oldVelocityY = 0;
  9240. this.velocityX = 0;
  9241. this.velocityY = 0;
  9242. this.accelerationX = 0;
  9243. this.accelerationY = 0;
  9244. this.dragX = 0.25;
  9245. this.dragY = 0.25;
  9246. this.angularAcceleration = 0;
  9247. this.angularVelocity = 0;
  9248. this.angularDrag = 1;
  9249. this.oldAngularVelocity = 0;
  9250. this.carAngle = Math.PI * 1.5;
  9251. this.wheelAngle = Math.PI * 1.5;
  9252. this.speed = 450;
  9253. this.turnSpeed = 0.01;
  9254. this.trafficSpeed = this.speed;
  9255. this.smokeTime = 0.25;
  9256. this.smokeTimer = this.smokeTime;
  9257. this.reversing = false;
  9258. this.body = new Drawable();
  9259. this.carColorIndex = randIntRange(0, content.carSprites.length);
  9260. this.body.init(content.carSprites[this.carColorIndex], 0, 0);
  9261. this.body.originX = this.body.sprite.width * 0.5;
  9262. this.body.originY = this.body.sprite.height * 0.5;
  9263. this.addChild(this.body);
  9264. this.wasOffroad = false;
  9265. this.dirtRoad = false;
  9266. this.depth = -0.2 + randFloatRange(-0.01, 0.01);
  9267. this.hitCount = 0;
  9268. this.dirtLoopInstance
  9269. };
  9270. PlayerCar.prototype.update = function(b) {
  9271. if (!this.immovable) {
  9272. if (isNaN(this.collisionVelocityAccumulatorX) || isNaN(this.collisionVelocityAccumulatorY)) {
  9273. this.collisionVelocityAccumulatorX = 0;
  9274. this.collisionVelocityAccumulatorY = 0
  9275. }
  9276. this.velocityX += this.collisionVelocityAccumulatorX;
  9277. this.velocityY += this.collisionVelocityAccumulatorY;
  9278. if (this.collisionVelocityAccumulatorX != 0 || this.collisionVelocityAccumulatorY != 0) {
  9279. var c = Math.atan2(this.collisionVelocityAccumulatorY, this.collisionVelocityAccumulatorX) + Math.PI;
  9280. while (Math.abs(c - this.wheelAngle) > Math.PI) {
  9281. if (c > this.wheelAngle) {
  9282. c -= Math.PI * 2
  9283. } else {
  9284. c += Math.PI * 2
  9285. }
  9286. }
  9287. if (this.colliders[0].colliding) {
  9288. this.wheelAngle -= (c - this.wheelAngle) * 0.5
  9289. } else {
  9290. this.wheelAngle += (c - this.wheelAngle) * 0.5
  9291. }
  9292. }
  9293. this.collisionVelocityAccumulatorX = 0;
  9294. this.collisionVelocityAccumulatorY = 0;
  9295. this.oldVelocityX = this.velocityX;
  9296. this.oldVelocityY = this.velocityY;
  9297. this.velocityX += this.accelerationX * b;
  9298. this.velocityY += this.accelerationY * b;
  9299. this.x += (this.oldVelocityX + this.velocityX) * 0.5 * b;
  9300. this.y += (this.oldVelocityY + this.velocityY) * 0.5 * b;
  9301. if (this.dragX != 1) {
  9302. this.velocityX *= Math.pow(this.dragX, b)
  9303. }
  9304. if (this.dragY != 1) {
  9305. this.velocityY *= Math.pow(this.dragY, b)
  9306. }
  9307. }
  9308. this.accelerationX = 0;
  9309. this.accelerationY = 0;
  9310. this.angularAcceleration = 0;
  9311. for (var a = 0; a < this.colliders.length; a++) {
  9312. if (this.colliders[a].colliding) {
  9313. if (Wrench.prototype.isPrototypeOf(this.colliders[a].lastCollisionObject)) {
  9314. if (this.colliders[a].lastCollisionObject.wrenchActive) {
  9315. this.decrementHit();
  9316. this.colliders[a].lastCollisionObject.onPickup();
  9317. this.colliders[a].colliding = false;
  9318. this.colliders[a].lastCollisionObject = null
  9319. }
  9320. } else {
  9321. this.colliders[a].lastCollisionObject = null
  9322. }
  9323. }
  9324. }
  9325. this.updateColliders();
  9326. this.updateSteering(b);
  9327. for (var a = 0; a < this.childCount; a++) {
  9328. this.children[a].angle = this.carAngle;
  9329. this.children[a].update(b)
  9330. }
  9331. if (this.desiredState != this.currentState) {
  9332. this.onExitState(this.currentState);
  9333. this.currentState = this.desiredState;
  9334. this.onEnterState(this.currentState)
  9335. }
  9336. this.tickState(this.currentState, b);
  9337. this.updateDust(b);
  9338. if (this.offroad) {
  9339. if (!this.wasOffroad) {
  9340. this.gameState.hud.offroad.timer = 0;
  9341. if (this.dirtLoopInstance) {
  9342. this.dirtLoopInstance.stop();
  9343. this.dirtLoopInstance = null
  9344. }
  9345. if (!soundMuted) {
  9346. this.dirtLoopInstance = createjs.Sound.play("dirtRoadRumble")
  9347. }
  9348. }
  9349. this.gameState.hud.offroad.baseTime = 3;
  9350. this.gameState.hud.offroad.timer += b;
  9351. if (this.gameState.hud.offroad.timerProgress >= 1) {
  9352. this.spinOut();
  9353. this.gameState.endGame(FailType.SPIN)
  9354. }
  9355. } else {
  9356. if (!this.dirtRoad) {
  9357. if (this.dirtLoopInstance) {
  9358. this.dirtLoopInstance.stop();
  9359. this.dirtLoopInstance = null
  9360. }
  9361. }
  9362. }
  9363. this.wasOffroad = this.offroad
  9364. };
  9365. PlayerCar.prototype.handleDirtLoop = function(a) {};
  9366. PlayerCar.prototype.updateSteering = function(c) {
  9367. if (!this.gameState) {
  9368. return
  9369. }
  9370. if (this.currentState === CarState.BROKENDOWN) {
  9371. return
  9372. }
  9373. this.carAngle = this.wheelAngle + (this.carAngle - this.wheelAngle) * 0.915;
  9374. if (this.currentState === CarState.SPINNING) {
  9375. this.wheelAngle += 0.01 * Math.sqrt(this.velocityX * this.velocityX + this.velocityY * this.velocityY) * c;
  9376. return
  9377. }
  9378. var a = this.gameState.steeringUI.value;
  9379. this.wheelAngle = (a * Math.PI * 0.45) + Math.PI * 1.5;
  9380. while (this.wheelAngle > Math.PI * 2) {
  9381. this.wheelAngle -= Math.PI * 2
  9382. }
  9383. while (this.wheelAngle < 0) {
  9384. this.wheelAngle += Math.PI * 2
  9385. }
  9386. if (this.dirtRoad) {
  9387. var b = randFloatRange(-2, 2);
  9388. this.wheelAngle += b;
  9389. this.accelerationY += Math.sin(this.wheelAngle) * this.speed
  9390. }
  9391. this.accelerationX += Math.cos(this.wheelAngle) * this.speed;
  9392. this.accelerationY += Math.sin(this.wheelAngle) * this.speed
  9393. };
  9394. PlayerCar.prototype.crash = function() {
  9395. if (this.currentState === CarState.BROKENDOWN || this.desiredState === CarState.BROKENDOWN) {
  9396. return
  9397. }
  9398. this.body.sprite = content.crashSprites[this.carColorIndex];
  9399. this.restitution = 0.1;
  9400. this.dragX = 0.01;
  9401. this.dragY = 0.01;
  9402. this.setDesiredState(CarState.BROKENDOWN);
  9403. this.gameState.crashFlash();
  9404. this.gameState.endGame(FailType.CRASH)
  9405. };
  9406. PlayerCar.prototype.incrementHit = function() {
  9407. if (this.hitCount >= 3) {
  9408. return
  9409. }
  9410. this.hitCount++;
  9411. this.gameState.hud.setHitCount(this.hitCount);
  9412. if (this.hitCount >= 3) {
  9413. this.breakDown();
  9414. if (!soundMuted) {
  9415. var a = "impactCrash";
  9416. playSound(a)
  9417. }
  9418. }
  9419. };
  9420. PlayerCar.prototype.breakDown = function() {
  9421. if ((this.currentState == CarState.SPINNING || this.desiredState == CarState.SPINNING) || (this.currentState == CarState.BROKENDOWN || this.desiredState == CarState.BROKENDOWN)) {
  9422. return
  9423. }
  9424. this.body.sprite = content.crashSprites[this.carColorIndex];
  9425. this.restitution = 0.1;
  9426. this.dragX = 0.01;
  9427. this.dragY = 0.01;
  9428. this.angularDrag = 0.001;
  9429. this.setDesiredState(CarState.BROKENDOWN);
  9430. this.gameState.crashFlash();
  9431. this.gameState.endGame(FailType.BROKEDOWN)
  9432. };
  9433. PlayerCar.prototype.decrementHit = function() {
  9434. if (this.hitCount <= 0 || this.currentState == CarState.SPINNING || this.currentState == CarState.BROKENDOWN) {
  9435. return
  9436. }
  9437. this.hitCount--;
  9438. this.gameState.hud.setHitCount(this.hitCount)
  9439. };
  9440. function CopCar() {
  9441. Car.call(this);
  9442. this.leftLight;
  9443. this.rightLight;
  9444. this.lightActive
  9445. }
  9446. CopCar.prototype = new Car();
  9447. CopCar.prototype.constructor = CopCar;
  9448. CopCar.prototype.init = function(a, d, c) {
  9449. this.x = a;
  9450. this.y = d;
  9451. this.gameState = c;
  9452. this.children = [];
  9453. this.childCount = 0;
  9454. this.toBeRemoved = false;
  9455. this.useCamera = true;
  9456. this.lightActive = false;
  9457. this.lightSine = randFloatRange(0, Math.PI * 2);
  9458. this.rammingTimer = 0;
  9459. this.rammingDirection = 0;
  9460. this.collider = null;
  9461. this.collisionEnabled = true;
  9462. this.mass = 1;
  9463. this.restitution = 1;
  9464. this.immovable = false;
  9465. this.contactLessCollision = false;
  9466. this.colliders = [];
  9467. var b = new CircleCollider();
  9468. b.init(this.x, this.y, 23);
  9469. this.colliders.push(b);
  9470. b = new CircleCollider();
  9471. b.init(this.x, this.y, 23);
  9472. this.colliders.push(b);
  9473. this.updateColliders();
  9474. this.cruiseSpeed = 300;
  9475. this.topSpeed = 375;
  9476. this.trafficSpeed = this.cruiseSpeed;
  9477. this.defaultDrag = 0.25;
  9478. this.turnSpeed = 0.975;
  9479. this.carAngle = Math.PI * 1.5;
  9480. this.wheelAngle = Math.PI * 1.5;
  9481. this.stuckBehindCar = false;
  9482. this.changingLanes = false;
  9483. this.laneChangeCorrectionTimer = 1;
  9484. this.desiredLaneX = 0;
  9485. this.randomLaneChangeChance = 0.001;
  9486. this.parkTargetX = 0;
  9487. this.parkTargetY = 0;
  9488. this.parkAngle = 0;
  9489. this.oldVelocityX = 0;
  9490. this.oldVelocityY = 0;
  9491. this.velocityX = 0;
  9492. this.velocityY = -1;
  9493. this.accelerationX = 0;
  9494. this.accelerationY = 0;
  9495. this.dragX = this.defaultDrag;
  9496. this.dragY = this.defaultDrag;
  9497. this.angularAcceleration = 0;
  9498. this.angularVelocity = 0;
  9499. this.angularDrag = 1;
  9500. this.oldAngularVelocity = 0;
  9501. this.speed = 350;
  9502. this.body = new Drawable();
  9503. this.body.init(content.copCar, 0, 0);
  9504. this.body.originX = this.body.sprite.width * 0.5;
  9505. this.body.originY = this.body.sprite.height * 0.5;
  9506. this.addChild(this.body);
  9507. this.leftLight = new Drawable();
  9508. this.leftLight.init(content.redCopLight, 0, 0);
  9509. this.leftLight.originX = this.leftLight.sprite.width * 0.5;
  9510. this.leftLight.originY = this.leftLight.sprite.height * 0.65;
  9511. this.leftLight.visible = false;
  9512. this.leftLight.alpha = 0;
  9513. this.addChild(this.leftLight);
  9514. this.rightLight = new Drawable();
  9515. this.rightLight.init(content.blueCopLight, 0, 0);
  9516. this.rightLight.originX = this.rightLight.sprite.width * 0.5;
  9517. this.rightLight.originY = this.rightLight.sprite.height * 0.35;
  9518. this.rightLight.visible = false;
  9519. this.rightLight.alpha = 0;
  9520. this.addChild(this.rightLight);
  9521. this.depth = -0.2 + randFloatRange(-0.01, 0.01);
  9522. this.sirenLoopInstance
  9523. };
  9524. CopCar.prototype.update = function(b) {
  9525. if (!this.immovable) {
  9526. this.velocityX += this.collisionVelocityAccumulatorX;
  9527. this.velocityY += this.collisionVelocityAccumulatorY;
  9528. if (this.currentState != CarState.BROKENDOWN) {
  9529. if (this.collisionVelocityAccumulatorX != 0 || this.collisionVelocityAccumulatorY != 0) {
  9530. var c = Math.atan2(this.collisionVelocityAccumulatorY, this.collisionVelocityAccumulatorX) + Math.PI;
  9531. while (Math.abs(c - this.wheelAngle) > Math.PI) {
  9532. if (c > this.wheelAngle) {
  9533. c -= Math.PI * 2
  9534. } else {
  9535. c += Math.PI * 2
  9536. }
  9537. }
  9538. if (this.colliders[0].colliding) {
  9539. this.wheelAngle -= (c - this.wheelAngle) * 0.5
  9540. } else {
  9541. this.wheelAngle += (c - this.wheelAngle) * 0.5
  9542. }
  9543. }
  9544. }
  9545. this.collisionVelocityAccumulatorX = 0;
  9546. this.collisionVelocityAccumulatorY = 0;
  9547. this.oldVelocityX = this.velocityX;
  9548. this.oldVelocityY = this.velocityY;
  9549. this.velocityX += this.accelerationX * b;
  9550. this.velocityY += this.accelerationY * b;
  9551. this.x += (this.oldVelocityX + this.velocityX) * 0.5 * b;
  9552. this.y += (this.oldVelocityY + this.velocityY) * 0.5 * b;
  9553. if (this.dragX != 1) {
  9554. this.velocityX *= Math.pow(this.dragX, b)
  9555. }
  9556. if (this.dragY != 1) {
  9557. this.velocityY *= Math.pow(this.dragY, b)
  9558. }
  9559. if (this.angularDrag != 1) {
  9560. this.angularVelocity *= Math.pow(this.angularDrag, b)
  9561. }
  9562. }
  9563. this.accelerationX = 0;
  9564. this.accelerationY = 0;
  9565. this.angularAcceleration = 0;
  9566. this.updateColliders();
  9567. this.updateSteering(b);
  9568. if (this.lightActive) {
  9569. this.leftLight.visible = true;
  9570. this.rightLight.visible = true;
  9571. this.leftLight.alpha = 0.35;
  9572. this.rightLight.alpha = 0.35;
  9573. this.lightSine += b * 2;
  9574. while (this.lightSine > Math.PI * 2) {
  9575. this.lightSine -= Math.PI * 2
  9576. }
  9577. this.leftLight.scaleX = Math.abs(Math.sin(this.lightSine));
  9578. this.leftLight.scaleY = this.leftLight.scaleX;
  9579. this.rightLight.scaleX = Math.abs(Math.cos(this.lightSine));
  9580. this.rightLight.scaleY = this.rightLight.scaleX;
  9581. if (!soundMuted) {
  9582. if (!this.sirenLoopInstance) {
  9583. this.sirenLoopInstance = createjs.Sound.play("siren", {
  9584. loop: -1
  9585. })
  9586. } else {
  9587. this.sirenLoopInstance.setVolume(Math.min(1, Math.max(0, 1 - (Math.abs(this.y - -this.sceneManager.camera.positionY) / 640))))
  9588. }
  9589. }
  9590. } else {
  9591. this.leftLight.visible = false;
  9592. this.rightLight.visible = false;
  9593. this.leftLight.alpha = 0;
  9594. this.rightLight.alpha = 0;
  9595. if (this.sirenLoopInstance) {
  9596. this.sirenLoopInstance.stop();
  9597. this.sirenLoopInstance = null
  9598. }
  9599. }
  9600. for (var a = 0; a < this.childCount; a++) {
  9601. this.children[a].angle = this.carAngle;
  9602. this.children[a].update(b)
  9603. }
  9604. if (this.desiredState != this.currentState) {
  9605. this.onExitState(this.currentState);
  9606. this.currentState = this.desiredState;
  9607. this.onEnterState(this.currentState)
  9608. }
  9609. this.lightActive = false;
  9610. this.tickState(this.currentState, b);
  9611. this.updateDust(b)
  9612. };
  9613. CopCar.prototype.handleSirenLoop = function(a) {};
  9614. CopCar.prototype.tickState = function(d, m) {
  9615. switch (d) {
  9616. case CarState.NULL:
  9617. break;
  9618. case CarState.IDLE:
  9619. break;
  9620. case CarState.PARKED:
  9621. break;
  9622. case CarState.PULLINGOVER:
  9623. var c = (this.parkTargetX - this.x);
  9624. var b = (this.parkTargetY - this.y);
  9625. var x = Math.sqrt(c * c + b * b);
  9626. var e = Math.abs(this.carAngle - this.parkAngle);
  9627. if (e > Math.PI) {
  9628. if (this.carAngle < this.parkAngle) {
  9629. this.carAngle += Math.PI * 2
  9630. } else {
  9631. this.carAngle -= Math.PI * 2
  9632. }
  9633. e = Math.abs(this.carAngle - this.parkAngle)
  9634. }
  9635. if (x < 80 && e < Math.PI * 0.25) {
  9636. this.setDesiredState(CarState.PARKED)
  9637. } else {
  9638. var l = this.parkTargetX - Math.cos(this.parkAngle) * 128;
  9639. var k = this.parkTargetY - Math.sin(this.parkAngle) * 128;
  9640. c = (l - this.x);
  9641. b = (k - this.y);
  9642. x = Math.sqrt(c * c + b * b);
  9643. if (x < 80) {
  9644. this.wheelAngle = this.parkAngle;
  9645. this.accelerationX += Math.cos(this.wheelAngle) * this.cruiseSpeed * 0.1;
  9646. this.accelerationY += Math.sin(this.wheelAngle) * this.cruiseSpeed * 0.1
  9647. } else {
  9648. this.wheelAngle = Math.atan2(b, c);
  9649. this.accelerationX += Math.cos(this.wheelAngle) * this.cruiseSpeed;
  9650. this.accelerationY += Math.sin(this.wheelAngle) * this.cruiseSpeed
  9651. }
  9652. }
  9653. break;
  9654. case CarState.CRUSING:
  9655. var p = this.cruiseSpeed;
  9656. if (this.lightActive) {
  9657. p = this.topSpeed
  9658. }
  9659. if (this.stuckBehindCar) {
  9660. p = this.trafficSpeed
  9661. }
  9662. this.wheelAngle = (Math.PI * 1.5) + (this.wheelAngle - (Math.PI * 1.5)) * 0.95;
  9663. this.accelerationX += Math.cos(this.wheelAngle) * p;
  9664. this.accelerationY += Math.sin(this.wheelAngle) * p;
  9665. if (this.changingLanes) {
  9666. var q = Math.abs(this.x - this.desiredLaneX);
  9667. if (q < 16) {
  9668. this.wheelAngle = Math.PI * 1.5;
  9669. this.laneChangeCorrectionTimer -= m;
  9670. if (this.laneChangeCorrectionTimer <= 0) {
  9671. this.changingLanes = false;
  9672. this.laneChangeCorrectionTimer = 1
  9673. }
  9674. } else {
  9675. if (this.desiredLaneX > this.x) {
  9676. this.wheelAngle = Math.PI * 1.65
  9677. } else {
  9678. this.wheelAngle = Math.PI * 1.35
  9679. }
  9680. }
  9681. } else {
  9682. if (this.obstructionAhead() || (randFloatRange(0, 1) < this.randomLaneChangeChance && this.isAdjacentLaneOpen())) {
  9683. this.changingLanes = true;
  9684. if (this.x > 0) {
  9685. this.desiredLaneX = Car.leftLaneX
  9686. } else {
  9687. this.desiredLaneX = Car.rightLaneX
  9688. }
  9689. }
  9690. }
  9691. this.stuckBehindCar = false;
  9692. if (!this.changingLanes) {
  9693. for (var o = 0; o < this.gameState.cars.length; o++) {
  9694. if (this.gameState.cars[o] === this) {
  9695. continue
  9696. }
  9697. var f = Math.abs(this.gameState.cars[o].y - this.y);
  9698. if (f >= 256 || this.gameState.cars[o].y >= this.y) {
  9699. continue
  9700. }
  9701. if (Math.abs(this.gameState.cars[o].x - this.x) < 80 && Math.abs(this.gameState.cars[o].velocityY) < Math.abs(this.velocityY)) {
  9702. var y = this.isAdjacentLaneOpen();
  9703. if (y) {
  9704. this.stuckBehindCar = false;
  9705. this.changingLanes = true;
  9706. if (this.x > 0) {
  9707. this.desiredLaneX = Car.leftLaneX
  9708. } else {
  9709. this.desiredLaneX = Car.rightLaneX
  9710. }
  9711. } else {
  9712. this.stuckBehindCar = true;
  9713. this.trafficSpeed = this.gameState.cars[o].trafficSpeed
  9714. }
  9715. }
  9716. }
  9717. }
  9718. break;
  9719. case CarState.CHASING:
  9720. this.lightActive = true;
  9721. if (!this.chaseTarget) {
  9722. this.setDesiredState(CarState.CRUSING)
  9723. }
  9724. var p = this.topSpeed;
  9725. this.wheelAngle = (Math.PI * 1.5) + (this.wheelAngle - (Math.PI * 1.5)) * 0.95;
  9726. this.accelerationX += Math.cos(this.wheelAngle) * p;
  9727. this.accelerationY += Math.sin(this.wheelAngle) * p;
  9728. if (this.changingLanes) {
  9729. var q = Math.abs(this.x - this.desiredLaneX);
  9730. if (q < 16) {
  9731. this.wheelAngle = Math.PI * 1.5;
  9732. this.laneChangeCorrectionTimer -= m;
  9733. if (this.laneChangeCorrectionTimer <= 0) {
  9734. this.changingLanes = false;
  9735. this.laneChangeCorrectionTimer = 1
  9736. }
  9737. } else {
  9738. if (this.desiredLaneX > this.x) {
  9739. this.wheelAngle = Math.PI * 1.65
  9740. } else {
  9741. this.wheelAngle = Math.PI * 1.35
  9742. }
  9743. }
  9744. }
  9745. if (this.rammingTimer <= 0 && (this.chaseTarget.y >= this.y || (Math.abs(this.carAngle - (Math.PI * 1.5)) > 0.25 && this.chaseTarget.y - 64 >= this.y))) {
  9746. this.rammingTimer = 1;
  9747. if (this.chaseTarget.x > this.x) {
  9748. this.rammingDirection = 1
  9749. } else {
  9750. this.rammingDirection = -1
  9751. }
  9752. }
  9753. if (this.rammingTimer > 0) {
  9754. this.rammingTimer -= m;
  9755. if (this.rammingDirection > 0) {
  9756. this.wheelAngle = Math.PI * 1.85
  9757. } else {
  9758. this.wheelAngle = Math.PI * 1.15
  9759. }
  9760. }
  9761. this.stuckBehindCar = false;
  9762. if (!this.changingLanes) {
  9763. for (var o = 0; o < this.gameState.cars.length; o++) {
  9764. if (this.gameState.cars[o] === this) {
  9765. continue
  9766. }
  9767. var f = Math.abs(this.gameState.cars[o].y - this.y);
  9768. if (f >= 256 || this.gameState.cars[o].y >= this.y) {
  9769. continue
  9770. }
  9771. if (Math.abs(this.gameState.cars[o].x - this.x) < 80 && Math.abs(this.gameState.cars[o].velocityY) < Math.abs(this.velocityY)) {
  9772. var y = this.isAdjacentLaneOpen();
  9773. if (y) {
  9774. this.stuckBehindCar = false;
  9775. this.changingLanes = true;
  9776. if (this.x > 0) {
  9777. this.desiredLaneX = Car.leftLaneX
  9778. } else {
  9779. this.desiredLaneX = Car.rightLaneX
  9780. }
  9781. } else {
  9782. this.stuckBehindCar = true;
  9783. this.trafficSpeed = this.gameState.cars[o].trafficSpeed
  9784. }
  9785. }
  9786. }
  9787. }
  9788. break;
  9789. case CarState.EVADING:
  9790. this.accelerationX += Math.cos(this.wheelAngle) * this.topSpeed;
  9791. this.accelerationY += Math.sin(this.wheelAngle) * this.topSpeed;
  9792. break;
  9793. case CarState.BROKENDOWN:
  9794. this.smokeTimer -= m;
  9795. if (this.smokeTimer <= 0) {
  9796. this.smokeTimer = this.smokeTime;
  9797. var w = new Particle();
  9798. w.init(content.smoke, randFloatRange(0.25, 0.75) * 6);
  9799. w.x = this.x + Math.cos(this.carAngle) * 30;
  9800. w.y = this.y + Math.sin(this.carAngle) * 30;
  9801. w.originX = w.sprite.width * 0.5;
  9802. w.originY = w.sprite.height * 0.5;
  9803. var j = randFloatRange(0.75, 1) * 2;
  9804. w.startScaleX = 0;
  9805. w.startScaleY = 0;
  9806. w.endScaleX = j;
  9807. w.endScaleY = j;
  9808. w.startAlpha = 0.65;
  9809. w.endAlpha = 0;
  9810. w.depth = this.depth - 0.01;
  9811. w.dragX = 1;
  9812. w.dragY = 1;
  9813. var g = randFloatRange(0, 0.25);
  9814. var n = randFloatRange(0, Math.PI * 2);
  9815. w.velocityX = Math.cos(n) * g;
  9816. w.velocityY = Math.sin(n) * g;
  9817. w.start();
  9818. this.sceneManager.addEntity(w)
  9819. }
  9820. break;
  9821. case CarState.SPINNING:
  9822. this.skidmarkBuffer.x = -this.x;
  9823. this.skidmarkBuffer.originX = this.skidmarkBuffer.sprite.width * 0.5;
  9824. this.skidmarkBuffer.originY = 360 + (this.y - this.skidStartY);
  9825. var h = Math.sqrt(this.velocityX * this.velocityX + this.velocityY * this.velocityY);
  9826. if (h < 1) {
  9827. this.setDesiredState(CarState.BROKENDOWN);
  9828. break
  9829. }
  9830. var a = this.skidmarkBuffer.sprite.getContext("2d");
  9831. var u = this.skidmarkBuffer.sprite.width * 0.5;
  9832. var t = 360;
  9833. u += this.x;
  9834. t += (this.y - this.skidStartY);
  9835. for (var o = 0; o < 4; o++) {
  9836. a.drawImage(content.skid, u + Math.cos(this.carAngle + Math.PI * 0.25 + o * Math.PI * 0.5) * 28, t + Math.sin(this.carAngle + Math.PI * 0.25 + o * Math.PI * 0.5) * 28)
  9837. }
  9838. break
  9839. }
  9840. };
  9841. CopCar.prototype.crash = function() {
  9842. if (this.currentState == CarState.BROKENDOWN || this.desiredState == CarState.BROKENDOWN) {
  9843. return
  9844. }
  9845. this.body.sprite = content.copCarCrash;
  9846. this.restitution = 0.1;
  9847. this.dragX = 0.01;
  9848. this.dragY = 0.01;
  9849. this.angularDrag = 0.001;
  9850. this.setDesiredState(CarState.BROKENDOWN)
  9851. };
  9852. CopCar.prototype.explode = function() {
  9853. if (this.currentState == CarState.BROKENDOWN || this.desiredState == CarState.BROKENDOWN) {
  9854. return
  9855. }
  9856. this.body.sprite = content.copCarExploded;
  9857. this.restitution = 0.1;
  9858. this.dragX = 0.01;
  9859. this.dragY = 0.01;
  9860. this.angularDrag = 0.001;
  9861. this.setDesiredState(CarState.BROKENDOWN)
  9862. };
  9863. CopCar.prototype.flagForRemoval = function() {
  9864. this.toBeRemoved = true;
  9865. if (this.skidmarkBuffer) {
  9866. this.skidmarkBuffer.flagForRemoval()
  9867. }
  9868. if (this.dirtLoopInstance) {
  9869. this.dirtLoopInstance.stop();
  9870. this.dirtLoopInstance = null
  9871. }
  9872. if (this.sirenLoopInstance) {
  9873. this.sirenLoopInstance.stop();
  9874. this.sirenLoopInstance = null
  9875. }
  9876. };
  9877. function SteerController() {
  9878. SceneObject.call(this);
  9879. this.backing;
  9880. this.circle;
  9881. this.value;
  9882. this.inUse;
  9883. this.touchID;
  9884. this.usingCar
  9885. }
  9886. SteerController.prototype = new SceneObject();
  9887. SteerController.prototype.constructor = SteerController;
  9888. SteerController.prototype.init = function(a) {
  9889. this.x = canvas.width * 0.5;
  9890. this.y = 0;
  9891. this.gameState = a;
  9892. this.children = [];
  9893. this.childCount = 0;
  9894. this.toBeRemoved = false;
  9895. this.useCamera = false;
  9896. this.backing = new Drawable();
  9897. this.backing.init(content.steeringBack, 0, 0);
  9898. this.backing.originX = 217;
  9899. this.backing.originY = 49;
  9900. this.addChild(this.backing);
  9901. this.circle = new Drawable();
  9902. this.circle.init(content.steeringCircle, 0, 0);
  9903. this.circle.originX = this.circle.sprite.width * 0.5;
  9904. this.circle.originY = this.circle.sprite.height * 0.5;
  9905. this.addChild(this.circle);
  9906. this.value = 0;
  9907. this.touchID = -1;
  9908. this.inUse = false;
  9909. this.desiredValue = 0;
  9910. this.desiredCircleScale = 1;
  9911. this.depth = -1;
  9912. this.masterAlpha = 1;
  9913. this.usingCar = false
  9914. };
  9915. SteerController.prototype.update = function(b) {
  9916. this.updateTouch(b);
  9917. this.value = this.value + ((this.desiredValue) - this.value) * 0.25;
  9918. this.circle.x = this.value * 165;
  9919. this.desiredCircleScale = 1;
  9920. if (this.inUse) {
  9921. this.desiredCircleScale = 1.15
  9922. }
  9923. this.circle.scaleX = this.circle.scaleX + ((this.desiredCircleScale) - this.circle.scaleX) * 0.25;
  9924. this.circle.scaleX *= this.masterAlpha;
  9925. if (this.circle.scaleX < 0.1) {
  9926. this.circle.scaleX = 0
  9927. }
  9928. this.circle.scaleY = this.circle.scaleX;
  9929. if (this.usingCar) {
  9930. this.masterAlpha = this.masterAlpha + (0.1 - this.masterAlpha) * 0.1
  9931. } else {
  9932. this.masterAlpha = this.masterAlpha + (1 - this.masterAlpha) * 0.1
  9933. }
  9934. for (var a = 0; a < this.childCount; a++) {
  9935. this.children[a].alpha = this.masterAlpha;
  9936. this.children[a].update(b)
  9937. }
  9938. };
  9939. SteerController.prototype.updateTouch = function(c) {
  9940. if (!this.inUse) {
  9941. this.desiredValue = 0;
  9942. if ((touchDown && !touchDownLast) || (mouseDown && !mouseDownLast)) {
  9943. if (gMobile) {
  9944. var a = this.backing.touchOver();
  9945. if (a.touched) {
  9946. this.inUse = true;
  9947. this.touchID = a.id;
  9948. this.usingCar = false
  9949. } else {
  9950. a = this.gameState.player.body.touchOver();
  9951. if (a.touched) {
  9952. this.inUse = true;
  9953. this.touchID = a.id;
  9954. this.usingCar = true
  9955. }
  9956. }
  9957. } else {
  9958. var a = this.backing.mouseOver();
  9959. if (a) {
  9960. this.inUse = true;
  9961. this.usingCar = false
  9962. } else {
  9963. if (this.gameState.player.body.mouseOver()) {
  9964. this.inUse = true;
  9965. this.usingCar = true
  9966. }
  9967. }
  9968. }
  9969. }
  9970. }
  9971. if (this.inUse) {
  9972. if (gMobile) {
  9973. if (!touchDown) {
  9974. this.inUse = false
  9975. } else {
  9976. var d;
  9977. for (var b = 0; b < currentTouches.length; b++) {
  9978. if (currentTouches[b].id == this.touchID) {
  9979. d = currentTouches[b];
  9980. break
  9981. }
  9982. }
  9983. if (d) {
  9984. if (this.usingCar) {
  9985. this.desiredValue = (this.gameState.sceneManager.worldMouseX - this.gameState.player.x) / 165;
  9986. this.desiredValue = Math.max(-1, Math.min(1, this.desiredValue))
  9987. } else {
  9988. this.desiredValue = Math.max(-1, Math.min(1, (d.x - this.x) / 165))
  9989. }
  9990. } else {
  9991. this.inUse = false
  9992. }
  9993. }
  9994. } else {
  9995. if (!mouseDown) {
  9996. this.inUse = false
  9997. } else {
  9998. if (this.usingCar) {
  9999. this.desiredValue = (this.gameState.sceneManager.worldMouseX - this.gameState.player.x) / 165;
  10000. this.desiredValue = Math.max(-1, Math.min(1, this.desiredValue))
  10001. } else {
  10002. this.desiredValue = Math.max(-1, Math.min(1, (mouseX - this.x) / 165))
  10003. }
  10004. }
  10005. }
  10006. }
  10007. };
  10008. SteerController.prototype.hide = function() {
  10009. TweenLite.to(this, 1, {
  10010. y: canvas.height + 180,
  10011. ease: Sine.easeOut,
  10012. onCompleteParams: [this],
  10013. onComplete: function(a) {
  10014. a.visible = false
  10015. }
  10016. })
  10017. };
  10018. var OffroadNotificationState = {
  10019. OPEN: 0,
  10020. CLOSED: 1,
  10021. OPENING: 2,
  10022. CLOSING: 3
  10023. };
  10024. function OffroadNotification() {
  10025. SceneObject.call(this)
  10026. }
  10027. OffroadNotification.prototype = new SceneObject();
  10028. OffroadNotification.prototype.constructor = OffroadNotification;
  10029. OffroadNotification.prototype.init = function() {
  10030. this.state = OffroadNotificationState.CLOSED;
  10031. this.useCamera = false;
  10032. this.x = 0;
  10033. this.y = 0;
  10034. this.stars = [];
  10035. this.starTime = 0.05;
  10036. this.starTimer = this.starTime;
  10037. this.starBuffer = new Drawable();
  10038. this.starBuffer.init(null, 0, 0);
  10039. this.addChild(this.starBuffer);
  10040. this.starBuffer.sprite = document.createElement("canvas");
  10041. this.starBuffer.sprite.width = 320;
  10042. this.starBuffer.sprite.height = 140;
  10043. this.starBuffer.originX = this.starBuffer.sprite.width * 0.5;
  10044. this.starBuffer.originY = this.starBuffer.sprite.height * 0.5;
  10045. var b = this.starBuffer.sprite.getContext("2d");
  10046. b.fillStyle = "#FF0000";
  10047. b.fillRect(0, 0, 260, 140);
  10048. this.offroadText = new Drawable();
  10049. this.offroadText.init(null, 0, 0);
  10050. this.addChild(this.offroadText);
  10051. this.offroadText.sprite = document.createElement("canvas");
  10052. this.offroadText.sprite.width = 232;
  10053. this.offroadText.sprite.height = 50;
  10054. this.offroadText.originX = this.offroadText.sprite.width * 0.5;
  10055. this.offroadText.originY = this.offroadText.sprite.height * 0.5;
  10056. var a = this.offroadText.sprite.getContext("2d");
  10057. a.font = "normal normal normal " + 41 + "px chunkfive";
  10058. a.textAlign = "center";
  10059. a.textBaseline = "middle";
  10060. a.fillStyle = "#000000";
  10061. a.fillText("\u504f\u79bb\u9053\u8def !", this.offroadText.sprite.width * 0.5 + 3, this.offroadText.sprite.height * 0.5 + 3);
  10062. a.fillStyle = "#FFFFFF";
  10063. a.fillText("\u504f\u79bb\u9053\u8def !", this.offroadText.sprite.width * 0.5, this.offroadText.sprite.height * 0.5);
  10064. this.offroadText.scaleX = 0;
  10065. this.offroadText.scaleY = 0;
  10066. this.timerBase = new Drawable();
  10067. this.timerBase.init(content.circleTimerBase, 0, 48);
  10068. this.timerBase.originX = this.timerBase.sprite.width * 0.5;
  10069. this.timerBase.originY = this.timerBase.sprite.height * 0.5;
  10070. this.timerBase.scaleX = 0;
  10071. this.timerBase.scaleY = 0;
  10072. this.addChild(this.timerBase);
  10073. this.timerRing = new Drawable();
  10074. this.timerRing.init(content.circleTimerRing, 0, 48);
  10075. this.timerRing.originX = this.timerRing.sprite.width * 0.5;
  10076. this.timerRing.originY = this.timerRing.sprite.height * 0.5;
  10077. this.timerRing.scaleX = 0;
  10078. this.timerRing.scaleY = 0;
  10079. this.timerRing.useMask = true;
  10080. this.addChild(this.timerRing);
  10081. this.timerRingMask = document.createElement("canvas");
  10082. this.timerRingMask.width = this.timerRing.sprite.width;
  10083. this.timerRingMask.height = this.timerRing.sprite.height;
  10084. this.timerRing.mask = this.timerRingMask;
  10085. this.timerProgress = 0;
  10086. this.baseTime = 1;
  10087. this.timer = 0;
  10088. this.x = canvas.width * 0.5;
  10089. this.y = 160
  10090. };
  10091. OffroadNotification.prototype.update = function(e) {
  10092. this.timerProgress = Math.min(1, this.timer / this.baseTime);
  10093. if (this.state === OffroadNotificationState.OPEN || this.state === OffroadNotificationState.OPENING) {
  10094. this.starTimer -= e;
  10095. while (this.starTimer <= 0) {
  10096. this.starTimer += this.starTime;
  10097. var f = new Particle();
  10098. f.init(content.star, randFloatRange(0.25, 0.75) * 4);
  10099. f.useCamera = false;
  10100. f.x = this.starBuffer.sprite.width * 0.5 + randFloatRange(-115, 115);
  10101. f.y = this.starBuffer.sprite.height * 0.5 + randFloatRange(-18, 18);
  10102. f.originX = f.sprite.width * 0.5;
  10103. f.originY = f.sprite.height * 0.5;
  10104. var c = randFloatRange(0.75, 1) * 2;
  10105. f.startScaleX = 0.15;
  10106. f.startScaleY = 0.15;
  10107. f.endScaleX = c;
  10108. f.endScaleY = c;
  10109. f.startAlpha = 3;
  10110. f.endAlpha = 0;
  10111. f.depth = this.depth + 0.01;
  10112. f.dragX = 0.1;
  10113. f.dragY = f.dragX;
  10114. f.angularVelocity = randFloatRange(-1, 1) * 0.01;
  10115. var d = randFloatRange(0, Math.PI * 2);
  10116. var a = 0;
  10117. f.velocityX = a * Math.cos(d);
  10118. f.velocityY = a * Math.sin(d);
  10119. f.sceneManager = this.sceneManager;
  10120. f.start();
  10121. this.stars.push(f)
  10122. }
  10123. this.updateTimerMask(e)
  10124. }
  10125. this.x = canvas.width * 0.5;
  10126. for (var b = 0; b < this.stars.length; b++) {
  10127. if (this.stars[b].toBeRemoved) {
  10128. this.stars.splice(b, 1);
  10129. b--;
  10130. continue
  10131. }
  10132. this.stars[b].update(e)
  10133. }
  10134. this.removeChildren();
  10135. for (var b = 0; b < this.childCount; b++) {
  10136. this.children[b].update(e)
  10137. }
  10138. };
  10139. OffroadNotification.prototype.updateTimerMask = function(c) {
  10140. var d = this.timerRingMask.getContext("2d");
  10141. d.clearRect(0, 0, this.timerRingMask.width, this.timerRingMask.height);
  10142. d.fillStyle = "#FF0000";
  10143. d.beginPath();
  10144. d.moveTo(this.timerRingMask.width * 0.5, this.timerRingMask.height * 0.5);
  10145. for (var b = 0; b < 5; b++) {
  10146. if (this.timerProgress * 4 < b) {
  10147. break
  10148. }
  10149. var a = b - 1;
  10150. d.lineTo(this.timerRingMask.width * 0.5 + Math.cos(a * ((Math.PI * 2) / 4)) * this.timerRingMask.width * 0.75, this.timerRingMask.height * 0.5 + Math.sin(a * ((Math.PI * 2) / 4)) * this.timerRingMask.height * 0.75)
  10151. }
  10152. var a = (this.timerProgress * 4) - 1;
  10153. d.lineTo(this.timerRingMask.width * 0.5 + Math.cos(a * ((Math.PI * 2) / 4)) * this.timerRingMask.width * 0.75, this.timerRingMask.height * 0.5 + Math.sin(a * ((Math.PI * 2) / 4)) * this.timerRingMask.height * 0.75);
  10154. d.closePath();
  10155. d.fill()
  10156. };
  10157. OffroadNotification.prototype.draw = function(b) {
  10158. if (!this.visible) {
  10159. return
  10160. }
  10161. var c = this.starBuffer.sprite.getContext("2d");
  10162. c.clearRect(0, 0, this.starBuffer.sprite.width, this.starBuffer.sprite.height);
  10163. for (var a = 0; a < this.stars.length; a++) {
  10164. this.stars[a].draw(c)
  10165. }
  10166. for (var a = 0; a < this.childCount; a++) {
  10167. this.children[a].draw(b)
  10168. }
  10169. };
  10170. OffroadNotification.prototype.open = function() {
  10171. if (this.state === OffroadNotificationState.OPEN || this.state === OffroadNotificationState.OPENING) {
  10172. return
  10173. }
  10174. this.state = OffroadNotificationState.OPENING;
  10175. TweenLite.to(this.starBuffer, 0.25, {
  10176. alpha: 1,
  10177. ease: Elastic.easeOut,
  10178. overwrite: 1
  10179. });
  10180. TweenLite.to(this.timerRing, 0.65, {
  10181. scaleX: 1,
  10182. scaleY: 1,
  10183. ease: Elastic.easeOut,
  10184. overwrite: 1
  10185. });
  10186. TweenLite.to(this.timerBase, 0.65, {
  10187. scaleX: 1,
  10188. scaleY: 1,
  10189. ease: Elastic.easeOut,
  10190. overwrite: 1
  10191. });
  10192. TweenLite.to(this.offroadText, 0.5, {
  10193. scaleX: 1,
  10194. scaleY: 1,
  10195. ease: Elastic.easeOut,
  10196. overwrite: 1,
  10197. onCompleteParams: [this],
  10198. onComplete: function(a) {
  10199. a.state = OffroadNotificationState.OPEN
  10200. }
  10201. })
  10202. };
  10203. OffroadNotification.prototype.close = function() {
  10204. if (this.state === OffroadNotificationState.CLOSED || this.state === OffroadNotificationState.CLOSING) {
  10205. return
  10206. }
  10207. this.state = OffroadNotificationState.CLOSING;
  10208. TweenLite.to(this.starBuffer, 0.25, {
  10209. alpha: 0,
  10210. ease: Expo.easeOut,
  10211. overwrite: 1
  10212. });
  10213. TweenLite.to(this.timerRing, 0.25, {
  10214. scaleX: 0,
  10215. scaleY: 0,
  10216. ease: Elastic.easeOut,
  10217. overwrite: 1
  10218. });
  10219. TweenLite.to(this.timerBase, 0.25, {
  10220. scaleX: 0,
  10221. scaleY: 0,
  10222. ease: Elastic.easeOut,
  10223. overwrite: 1
  10224. });
  10225. TweenLite.to(this.offroadText, 0.5, {
  10226. scaleX: 0,
  10227. scaleY: 0,
  10228. ease: Expo.easeOut,
  10229. overwrite: 1,
  10230. onCompleteParams: [this],
  10231. onComplete: function(a) {
  10232. a.state = OffroadNotificationState.CLOSED
  10233. }
  10234. })
  10235. };
  10236. var DirtroadNotificationState = {
  10237. OPEN: 0,
  10238. CLOSED: 1,
  10239. OPENING: 2,
  10240. CLOSING: 3
  10241. };
  10242. function DirtroadNotification() {
  10243. SceneObject.call(this)
  10244. }
  10245. DirtroadNotification.prototype = new SceneObject();
  10246. DirtroadNotification.prototype.constructor = DirtroadNotification;
  10247. DirtroadNotification.prototype.init = function() {
  10248. this.state = DirtroadNotificationState.CLOSED;
  10249. this.useCamera = false;
  10250. this.x = 0;
  10251. this.y = 0;
  10252. this.banner = new Drawable();
  10253. this.banner.init(content.warningStripe, 0, 0);
  10254. this.banner.originX = this.banner.sprite.width * 0.5;
  10255. this.banner.originY = this.banner.sprite.height * 0.5;
  10256. this.banner.scaleY = 0;
  10257. this.addChild(this.banner);
  10258. this.leftArrow = new Drawable();
  10259. this.leftArrow.init(content.dirtArrow, -800, 0);
  10260. this.leftArrow.originX = this.leftArrow.sprite.width * 0.5;
  10261. this.leftArrow.originY = this.leftArrow.sprite.height * 0.5;
  10262. this.addChild(this.leftArrow);
  10263. this.rightArrow = new Drawable();
  10264. this.rightArrow.init(content.dirtArrow, 800, 0);
  10265. this.rightArrow.originX = this.rightArrow.sprite.width * 0.5;
  10266. this.rightArrow.originY = this.rightArrow.sprite.height * 0.5;
  10267. this.addChild(this.rightArrow);
  10268. this.sine = 0;
  10269. this.dirtroadText = new Drawable();
  10270. this.dirtroadText.init(null, 0, 0);
  10271. this.addChild(this.dirtroadText);
  10272. this.dirtroadText.sprite = document.createElement("canvas");
  10273. this.dirtroadText.sprite.width = 256;
  10274. this.dirtroadText.sprite.height = 50;
  10275. this.dirtroadText.originX = this.dirtroadText.sprite.width * 0.5;
  10276. this.dirtroadText.originY = this.dirtroadText.sprite.height * 0.5;
  10277. var a = this.dirtroadText.sprite.getContext("2d");
  10278. a.font = "normal normal normal " + 41 + "px chunkfive";
  10279. a.textAlign = "center";
  10280. a.textBaseline = "middle";
  10281. a.fillStyle = "#000000";
  10282. a.fillText("\u571f\u8def !", this.dirtroadText.sprite.width * 0.5 + 3, this.dirtroadText.sprite.height * 0.5 + 3);
  10283. a.fillStyle = "#FFFFFF";
  10284. a.fillText("\u571f\u8def !", this.dirtroadText.sprite.width * 0.5, this.dirtroadText.sprite.height * 0.5);
  10285. this.dirtroadText.scaleX = 0;
  10286. this.dirtroadText.scaleY = 0
  10287. };
  10288. DirtroadNotification.prototype.update = function(b) {
  10289. if (this.state === DirtroadNotificationState.OPEN || this.state === DirtroadNotificationState.OPENING) {
  10290. this.sine += b * 12;
  10291. while (this.sine > Math.PI * 2) {
  10292. this.sine -= Math.PI * 2
  10293. }
  10294. this.banner.scaleX = 1 + Math.sin(this.sine) * 0.01
  10295. }
  10296. this.rightArrow.y = -3 + Math.sin(this.sine) * 2;
  10297. this.leftArrow.y = -3 + Math.sin(this.sine) * 2;
  10298. this.x = canvas.width * 0.5;
  10299. this.y = 160;
  10300. this.removeChildren();
  10301. for (var a = 0; a < this.childCount; a++) {
  10302. this.children[a].update(b)
  10303. }
  10304. };
  10305. DirtroadNotification.prototype.draw = function(b) {
  10306. if (!this.visible) {
  10307. return
  10308. }
  10309. for (var a = 0; a < this.childCount; a++) {
  10310. this.children[a].draw(b)
  10311. }
  10312. };
  10313. DirtroadNotification.prototype.open = function() {
  10314. if (this.state === DirtroadNotificationState.OPEN || this.state === DirtroadNotificationState.OPENING) {
  10315. return
  10316. }
  10317. this.state = DirtroadNotificationState.OPENING;
  10318. TweenLite.to(this.leftArrow, 0.35, {
  10319. x: -150,
  10320. ease: Sine.easeOut,
  10321. overwrite: 1
  10322. });
  10323. TweenLite.to(this.rightArrow, 0.35, {
  10324. x: 150,
  10325. ease: Sine.easeOut,
  10326. overwrite: 1
  10327. });
  10328. TweenLite.to(this.banner, 0.5, {
  10329. scaleY: 1,
  10330. ease: Elastic.easeOut,
  10331. overwrite: 1
  10332. });
  10333. TweenLite.to(this.dirtroadText, 0.5, {
  10334. scaleX: 1,
  10335. scaleY: 1,
  10336. ease: Elastic.easeOut,
  10337. overwrite: 1,
  10338. onCompleteParams: [this],
  10339. onComplete: function(a) {
  10340. a.state = DirtroadNotificationState.OPEN
  10341. }
  10342. })
  10343. };
  10344. DirtroadNotification.prototype.close = function() {
  10345. if (this.state === DirtroadNotificationState.CLOSED || this.state === DirtroadNotificationState.CLOSING) {
  10346. return
  10347. }
  10348. this.state = DirtroadNotificationState.CLOSING;
  10349. TweenLite.to(this.leftArrow, 0.35, {
  10350. x: -800,
  10351. ease: Sine.easeOut,
  10352. overwrite: 1
  10353. });
  10354. TweenLite.to(this.rightArrow, 0.35, {
  10355. x: 800,
  10356. ease: Sine.easeOut,
  10357. overwrite: 1
  10358. });
  10359. TweenLite.to(this.banner, 0.5, {
  10360. scaleY: 0,
  10361. ease: Expo.easeOut,
  10362. overwrite: 1
  10363. });
  10364. TweenLite.to(this.dirtroadText, 0.5, {
  10365. scaleX: 0,
  10366. scaleY: 0,
  10367. ease: Expo.easeOut,
  10368. overwrite: 1,
  10369. onCompleteParams: [this],
  10370. onComplete: function(a) {
  10371. a.state = DirtroadNotificationState.CLOSED
  10372. }
  10373. })
  10374. };
  10375. var EndBannerState = {
  10376. OPEN: 0,
  10377. CLOSED: 1,
  10378. OPENING: 2,
  10379. CLOSING: 3
  10380. };
  10381. function EndBanner() {
  10382. SceneObject.call(this)
  10383. }
  10384. EndBanner.prototype = new SceneObject();
  10385. EndBanner.prototype.constructor = EndBanner;
  10386. EndBanner.prototype.init = function(c) {
  10387. //updateShare(parseFloat(window.score) * 1000);
  10388. window.score = parseFloat(window.score) * 1000;
  10389. //Play68.setRankingScoreDesc(window.score);
  10390. this.state = EndBannerState.CLOSED;
  10391. this.useCamera = false;
  10392. this.x = 0;
  10393. this.y = 0;
  10394. this.depth = -0.99;
  10395. this.width = 300;
  10396. this.leftEdge = new Drawable();
  10397. this.leftEdge.init(content.bannerEdge, 0, 0);
  10398. this.leftEdge.originX = this.leftEdge.sprite.width;
  10399. this.addChild(this.leftEdge);
  10400. this.rightEdge = new Drawable();
  10401. this.rightEdge.init(content.bannerEdge, 0, 0);
  10402. this.rightEdge.originX = this.rightEdge.sprite.width;
  10403. this.rightEdge.scaleX = -1;
  10404. this.addChild(this.rightEdge);
  10405. this.spread = new Drawable();
  10406. this.spread.init(content.bannerSpread, 0, 0);
  10407. this.spread.originX = this.spread.sprite.width * 0.5;
  10408. this.spread.scaleX = (28 * 2) / 4;
  10409. this.addChild(this.spread);
  10410. this.shine = new Drawable();
  10411. this.shine.init(content.bannerShine, -128, 0);
  10412. this.shine.originY = -8;
  10413. this.shine.alpha = 0;
  10414. this.addChild(this.shine);
  10415. this.text = new Drawable();
  10416. this.text.init(null, 0, 54);
  10417. this.addChild(this.text);
  10418. this.text.sprite = document.createElement("canvas");
  10419. this.text.sprite.width = 392;
  10420. this.text.sprite.height = 64;
  10421. this.text.scaleX = 0;
  10422. this.text.scaleY = 0;
  10423. this.text.originX = this.text.sprite.width * 0.5;
  10424. this.text.originY = this.text.sprite.height * 0.5;
  10425. var b = this.text.sprite.getContext("2d");
  10426. var a = "NULL";
  10427. switch (c) {
  10428. case FailType.CRASH:
  10429. a = "\u649e\u6bc1 !";
  10430. b.font = "normal normal normal " + 68 + "px chunkfive";
  10431. break;
  10432. case FailType.SPIN:
  10433. a = "\u7ed3\u675f !";
  10434. b.font = "normal normal normal " + 68 + "px chunkfive";
  10435. break;
  10436. case FailType.EXPLODED:
  10437. a = "\u7206\u70b8 !";
  10438. b.font = "normal normal normal " + 64 + "px chunkfive";
  10439. break;
  10440. case FailType.BROKEDOWN:
  10441. a = "\u6545\u969c !";
  10442. b.font = "normal normal normal " + 52 + "px chunkfive";
  10443. break;
  10444. default:
  10445. a = "NULL";
  10446. b.font = "normal normal normal " + 68 + "px chunkfive";
  10447. break
  10448. }
  10449. b.textAlign = "center";
  10450. b.textBaseline = "middle";
  10451. b.fillStyle = "#000000";
  10452. b.fillText(a, this.text.sprite.width * 0.5 + 4, this.text.sprite.height * 0.5 + 4);
  10453. b.fillStyle = "#FFFFFF";
  10454. b.fillText(a, this.text.sprite.width * 0.5, this.text.sprite.height * 0.5)
  10455. };
  10456. EndBanner.prototype.update = function(b) {
  10457. this.removeChildren();
  10458. for (var a = 0; a < this.childCount; a++) {
  10459. this.children[a].update(b)
  10460. }
  10461. };
  10462. EndBanner.prototype.draw = function(b) {
  10463. if (!this.visible) {
  10464. return
  10465. }
  10466. for (var a = 0; a < this.childCount; a++) {
  10467. this.children[a].draw(b)
  10468. }
  10469. };
  10470. EndBanner.prototype.open = function() {
  10471. if (this.state === EndBannerState.OPEN || this.state === EndBannerState.OPENING) {
  10472. return
  10473. }
  10474. this.state = EndBannerState.OPENING;
  10475. var a = 0.35;
  10476. TweenLite.to(this.leftEdge, a, {
  10477. x: -this.width * 0.5,
  10478. ease: Cubic.easeIn,
  10479. overwrite: 1
  10480. });
  10481. TweenLite.to(this.rightEdge, a, {
  10482. x: this.width * 0.5,
  10483. ease: Cubic.easeIn,
  10484. overwrite: 1
  10485. });
  10486. TweenLite.to(this.spread, a, {
  10487. scaleX: (this.width + 28 * 2) / 4 + 1,
  10488. ease: Cubic.easeIn,
  10489. overwrite: 1
  10490. });
  10491. TweenLite.to(this.text, a * 2, {
  10492. scaleX: 1,
  10493. scaleY: 1,
  10494. ease: Elastic.easeOut,
  10495. delay: a,
  10496. overwrite: 1
  10497. });
  10498. TweenLite.to(this.shine, a, {
  10499. alpha: 0.15,
  10500. ease: Sine.easeOut,
  10501. delay: a,
  10502. overwrite: 1
  10503. })
  10504. };
  10505. EndBanner.prototype.close = function() {
  10506. if (this.state === EndBannerState.CLOSED || this.state === EndBannerState.CLOSING) {
  10507. return
  10508. }
  10509. this.state = EndBannerState.CLOSING;
  10510. var a = 2;
  10511. TweenLite.to(this.leftEdge, a, {
  10512. x: 0,
  10513. ease: Expo.easeOut,
  10514. delay: 0.25,
  10515. overwrite: 1
  10516. });
  10517. TweenLite.to(this.rightEdge, a, {
  10518. x: 0,
  10519. ease: Expo.easeOut,
  10520. delay: 0.25,
  10521. overwrite: 1
  10522. });
  10523. TweenLite.to(this.spread, a, {
  10524. scaleX: 0,
  10525. ease: Expo.easeOut,
  10526. delay: 0.25,
  10527. overwrite: 1
  10528. });
  10529. TweenLite.to(this.text, a, {
  10530. scaleX: 0,
  10531. scaleY: 0,
  10532. ease: Expo.easeIn,
  10533. overwrite: 1
  10534. })
  10535. };
  10536. function Hud() {
  10537. SceneObject.call(this);
  10538. this.buttons = [];
  10539. this.state;
  10540. this.pauseButton;
  10541. this.backButton;
  10542. this.backing;
  10543. this.distance;
  10544. this.distanceBuffer;
  10545. this.distanceContext;
  10546. this.lastDistanceText;
  10547. this.offroad;
  10548. this.dirtroad;
  10549. this.hits = []
  10550. }
  10551. Hud.prototype = new SceneObject();
  10552. Hud.prototype.constructor = Hud;
  10553. Hud.prototype.init = function(c) {
  10554. this.useCamera = false;
  10555. this.state = c;
  10556. this.distance = 0;
  10557. this.depth = -0.99;
  10558. this.backing = new Drawable();
  10559. this.backing.init(content.roadBacking, 0, 0);
  10560. this.backing.originX = this.backing.sprite.width * 0.5;
  10561. this.addChild(this.backing);
  10562. this.distanceBuffer = document.createElement("canvas");
  10563. this.distanceBuffer.width = 175;
  10564. this.distanceBuffer.height = 51;
  10565. this.distanceContext = this.distanceBuffer.getContext("2d");
  10566. this.distanceX = 0;
  10567. this.distanceY = 0;
  10568. this.offroad = new OffroadNotification();
  10569. this.offroad.init();
  10570. this.dirtroad = new DirtroadNotification();
  10571. this.dirtroad.init();
  10572. this.soundButton = new Button();
  10573. this.soundButton.defaultGraphic = content.soundOff;
  10574. this.soundButton.callback = this.onSoundHit;
  10575. this.soundButton.parentState = this.state;
  10576. this.soundButton.init();
  10577. this.soundButton.originX = this.soundButton.defaultGraphic.width * 0.5;
  10578. this.soundButton.originY = this.soundButton.defaultGraphic.height * 0.5;
  10579. this.soundButton.scaleX = 0.95;
  10580. this.soundButton.scaleY = 0.95;
  10581. this.buttons.push(this.soundButton);
  10582. this.state.buttons.push(this.soundButton);
  10583. if (!soundMuted) {
  10584. this.soundButton.defaultGraphic = content.soundOn
  10585. }
  10586. this.backButton = new Button();
  10587. this.backButton.defaultGraphic = content.backBtn;
  10588. this.backButton.callback = this.onBackHit;
  10589. this.backButton.parentState = this.state;
  10590. this.backButton.init();
  10591. this.backButton.originX = this.backButton.defaultGraphic.width * 0.5;
  10592. this.backButton.originY = this.backButton.defaultGraphic.height * 0.5;
  10593. this.backButton.scaleX = 0.95;
  10594. this.backButton.scaleY = 0.95;
  10595. this.buttons.push(this.backButton);
  10596. this.state.buttons.push(this.backButton);
  10597. this.lastDistanceText = "XXX";
  10598. for (var a = 0; a < 3; a++) {
  10599. var b = new Drawable();
  10600. b.init(content.hitOff, 0, 0);
  10601. b.originX = b.sprite.width * 0.5;
  10602. b.originY = b.sprite.height * 0.5;
  10603. this.hits.push(b);
  10604. this.addChild(b)
  10605. }
  10606. this.hitCount = 0
  10607. };
  10608. Hud.prototype.onAddedToSceneManager = function() {
  10609. this.offroad.sceneManager = this.sceneManager;
  10610. this.dirtroad.sceneManager = this.sceneManager
  10611. };
  10612. Hud.prototype.onPauseHit = function(a) {
  10613. a.paused = !a.paused;
  10614. a.pauseOverlay.children[1].scaleX = 0;
  10615. a.pauseOverlay.children[1].scaleY = 0;
  10616. TweenLite.to(a.pauseOverlay.children[1], 0.5, {
  10617. scaleX: 1,
  10618. scaleY: 1,
  10619. ease: Elastic.easeOut
  10620. })
  10621. };
  10622. Hud.prototype.onSoundHit = function(a) {
  10623. setSoundMute(!soundMuted);
  10624. setMusicMute(soundMuted);
  10625. if (soundMuted) {
  10626. a.hud.soundButton.defaultGraphic = content.soundOff
  10627. } else {
  10628. a.hud.soundButton.defaultGraphic = content.soundOn
  10629. }
  10630. };
  10631. Hud.prototype.onBackHit = function(a) {
  10632. var b = new MainMenuState();
  10633. b.init();
  10634. a.stateManager.setState(b)
  10635. };
  10636. Hud.prototype.update = function(b) {
  10637. if (this.state.paused) {
  10638. this.soundButton.visible = false;
  10639. this.backButton.visible = false
  10640. } else {
  10641. this.soundButton.visible = true;
  10642. this.backButton.visible = true
  10643. }
  10644. this.soundButton.screenSizeOffsetX = canvas.width - this.soundButton.defaultGraphic.width * 0.5;
  10645. this.soundButton.screenSizeOffsetY = 36;
  10646. this.backButton.screenSizeOffsetX = this.backButton.defaultGraphic.width * 0.5;
  10647. this.backButton.screenSizeOffsetY = 36;
  10648. this.backing.x = canvas.width * 0.5;
  10649. this.offroad.update(b);
  10650. this.dirtroad.update(b);
  10651. if (this.state.playState != PlayState.DYING) {
  10652. for (var a = 0; a < this.hits.length; a++) {
  10653. this.hits[a].x = canvas.width * 0.5 + 45 + a * 39;
  10654. this.hits[a].y = 26
  10655. }
  10656. }
  10657. if (this.offroad.state === OffroadNotificationState.OPEN || this.offroad.state === OffroadNotificationState.OPENING) {
  10658. if (this.dirtroad.state === DirtroadNotificationState.OPEN || this.dirtroad.state === DirtroadNotificationState.OPENING) {
  10659. var c = 160 + 80;
  10660. this.offroad.y = this.offroad.y + (c - this.offroad.y) * 0.1
  10661. }
  10662. } else {
  10663. var c = 160;
  10664. this.offroad.y = this.offroad.y + (c - this.offroad.y) * 0.1
  10665. }
  10666. for (var a = 0; a < this.childCount; a++) {
  10667. this.children[a].update(b)
  10668. }
  10669. };
  10670. Hud.prototype.draw = function(b) {
  10671. if (!this.visible) {
  10672. return
  10673. }
  10674. for (var a = 0; a < this.childCount; a++) {
  10675. this.children[a].draw(b)
  10676. }
  10677. this.offroad.draw(b);
  10678. this.dirtroad.draw(b);
  10679. var c = (Math.floor(this.distance) / 1000).toString();
  10680. if (c.length > 4) {
  10681. c = c.substring(0, 4)
  10682. }
  10683. while (c.length < 4) {
  10684. c += "0"
  10685. }
  10686. c += " km";
  10687. window.score = c;
  10688. console.log(c);
  10689. if (c != this.lastDistanceText) {
  10690. this.distanceContext.clearRect(0, 0, 175, 51);
  10691. this.distanceContext.fillStyle = "#FFFFFF";
  10692. this.distanceContext.font = "normal normal normal " + 36 + "px chunkfive";
  10693. this.distanceContext.textAlign = "right";
  10694. this.distanceContext.fillText(c, 175 - 8, 38);
  10695. this.distanceContext.globalAlpha = 1
  10696. }
  10697. this.lastDistanceText = c;
  10698. ctx.drawImage(this.distanceBuffer, (canvas.width * 0.5 - 175) + this.distanceX, this.distanceY)
  10699. };
  10700. Hud.prototype.endGame = function(a) {
  10701. this.offroad.close();
  10702. this.dirtroad.close();
  10703. this.soundButton.active = false;
  10704. this.backButton.active = false;
  10705. TweenLite.to(this.soundButton, 0.25, {
  10706. y: -80,
  10707. ease: Sine.easeOut,
  10708. overwrite: 1
  10709. });
  10710. TweenLite.to(this.backButton, 0.25, {
  10711. y: -80,
  10712. ease: Sine.easeOut,
  10713. overwrite: 1
  10714. });
  10715. TweenLite.to(this, 0.5, {
  10716. distanceY: -80,
  10717. ease: Sine.easeOut
  10718. });
  10719. for (var b = 0; b < this.hits.length; b++) {
  10720. if (a == FailType.BROKEDOWN) {
  10721. TweenLite.to(this.hits[b], 1, {
  10722. x: canvas.width * 0.5 + (b - 1) * 39,
  10723. y: 64,
  10724. ease: Sine.easeOut,
  10725. delay: b * 0.25
  10726. })
  10727. } else {
  10728. TweenLite.to(this.hits[b], 1, {
  10729. y: -80,
  10730. ease: Sine.easeOut
  10731. })
  10732. }
  10733. }
  10734. };
  10735. Hud.prototype.setHitCount = function(b) {
  10736. b = Math.max(0, Math.min(b));
  10737. if (this.hitCount == b) {
  10738. return
  10739. }
  10740. if (b < this.hitCount) {
  10741. for (var a = 0; a < this.hits.length; a++) {
  10742. if (a + 1 > b) {
  10743. this.hits[a].sprite = content.hitOff;
  10744. var c = new Particle();
  10745. c.init(content.hitOn, 0.25);
  10746. c.x = this.x + this.hits[a].x;
  10747. c.y = this.y + this.hits[a].y;
  10748. c.originX = c.sprite.width * 0.5;
  10749. c.originY = c.sprite.height * 0.5;
  10750. c.startScaleX = 1;
  10751. c.startScaleY = 1;
  10752. c.endScaleX = 0;
  10753. c.endScaleY = 0;
  10754. c.startAlpha = 1;
  10755. c.endAlpha = 0;
  10756. c.depth = this.depth - 0.01;
  10757. c.useCamera = false;
  10758. c.start();
  10759. this.sceneManager.addEntity(c);
  10760. break
  10761. }
  10762. }
  10763. } else {
  10764. for (var a = this.hits.length - 1; a > -1; a--) {
  10765. if (a < b) {
  10766. this.hits[a].sprite = content.hitOn;
  10767. this.hits[a].scaleX = 0;
  10768. this.hits[a].scaleY = 0;
  10769. TweenLite.to(this.hits[a], 0.75, {
  10770. scaleX: 1,
  10771. scaleY: 1,
  10772. ease: Elastic.easeOut,
  10773. overwrite: 1
  10774. });
  10775. break
  10776. }
  10777. }
  10778. }
  10779. this.hitCount = b
  10780. };
  10781. function Crate() {
  10782. SceneObject.call(this);
  10783. this.currentAngle = 0
  10784. }
  10785. Crate.prototype = new SceneObject();
  10786. Crate.prototype.constructor = Crate;
  10787. Crate.prototype.init = function(a, g, f, c) {
  10788. this.x = a;
  10789. this.y = g;
  10790. this.currentAngle = f;
  10791. this.gameState = c;
  10792. this.explosive = false;
  10793. this.children = [];
  10794. this.childCount = 0;
  10795. this.toBeRemoved = false;
  10796. this.useCamera = true;
  10797. this.collider = null;
  10798. this.collisionEnabled = true;
  10799. this.mass = 0.35;
  10800. this.restitution = 1;
  10801. this.immovable = false;
  10802. this.contactLessCollision = false;
  10803. this.oldVelocityX = 0;
  10804. this.oldVelocityY = 0;
  10805. this.velocityX = 0;
  10806. this.velocityY = 0;
  10807. this.accelerationX = 0;
  10808. this.accelerationY = 0;
  10809. this.dragX = 0.25;
  10810. this.dragY = 0.25;
  10811. this.collisionVelocityAccumulatorX = 0;
  10812. this.collisionVelocityAccumulatorY = 0;
  10813. this.angularAcceleration = 0;
  10814. this.angularVelocity = 0;
  10815. this.angularDrag = 0.45;
  10816. this.oldAngularVelocity = 0;
  10817. this.colliders = [];
  10818. var b = new CircleCollider();
  10819. b.init(this.x, this.y, 18.5);
  10820. this.colliders.push(b);
  10821. this.updateColliders();
  10822. var e = new Drawable();
  10823. e.init(content.crate, 0, 0);
  10824. e.originX = e.sprite.width * 0.5;
  10825. e.originY = e.sprite.height * 0.5;
  10826. this.addChild(e);
  10827. this.depth = -0.1 + randFloatRange(-0.01, 0.01);
  10828. this.spawner = null
  10829. };
  10830. Crate.prototype.doSpawnAnimation = function() {
  10831. this.children[0].scaleX = 1.15;
  10832. this.children[0].scaleY = 1.15;
  10833. TweenLite.to(this.children[0], 0.5, {
  10834. scaleX: 1,
  10835. scaleY: 1,
  10836. delay: 0.25,
  10837. ease: Bounce.easeOut
  10838. })
  10839. };
  10840. Crate.prototype.setExplosive = function(a) {
  10841. if (this.explosive === a) {
  10842. return
  10843. }
  10844. this.explosive = a;
  10845. if (this.explosive) {
  10846. this.children[0].sprite = content.explodingCrate
  10847. } else {
  10848. this.children[0].sprite = content.crate
  10849. }
  10850. };
  10851. Crate.prototype.update = function(c) {
  10852. if (!this.immovable) {
  10853. if (isNaN(this.collisionVelocityAccumulatorX) || isNaN(this.collisionVelocityAccumulatorY)) {
  10854. this.collisionVelocityAccumulatorX = 0;
  10855. this.collisionVelocityAccumulatorY = 0
  10856. }
  10857. this.velocityX += this.collisionVelocityAccumulatorX;
  10858. this.velocityY += this.collisionVelocityAccumulatorY;
  10859. if (this.collisionVelocityAccumulatorX != 0 || this.collisionVelocityAccumulatorY != 0) {
  10860. var d = Math.sqrt((this.collisionVelocityAccumulatorX * this.collisionVelocityAccumulatorX) + (this.collisionVelocityAccumulatorY * this.collisionVelocityAccumulatorY));
  10861. this.angularVelocity = d * c;
  10862. var a = ((this.collisionVelocityAccumulatorX / d) * (1)) + ((this.collisionVelocityAccumulatorY / d) * (0));
  10863. if (a < 0) {
  10864. this.angularVelocity *= -1
  10865. }
  10866. }
  10867. this.collisionVelocityAccumulatorX = 0;
  10868. this.collisionVelocityAccumulatorY = 0;
  10869. this.oldVelocityX = this.velocityX;
  10870. this.oldVelocityY = this.velocityY;
  10871. this.velocityX += this.accelerationX * c;
  10872. this.velocityY += this.accelerationY * c;
  10873. this.x += (this.oldVelocityX + this.velocityX) * 0.5 * c;
  10874. this.y += (this.oldVelocityY + this.velocityY) * 0.5 * c;
  10875. if (this.dragX != 1) {
  10876. this.velocityX *= Math.pow(this.dragX, c)
  10877. }
  10878. if (this.dragY != 1) {
  10879. this.velocityY *= Math.pow(this.dragY, c)
  10880. }
  10881. this.oldAngularVelocity = this.angularVelocity;
  10882. this.angularVelocity += this.angularAcceleration * c;
  10883. this.currentAngle += (this.oldAngularVelocity + this.angularVelocity) * 0.5 * c;
  10884. if (this.angularDrag != 1) {
  10885. this.angularVelocity *= Math.pow(this.angularDrag, c)
  10886. }
  10887. }
  10888. this.accelerationX = 0;
  10889. this.accelerationY = 0;
  10890. this.angularAcceleration = 0;
  10891. this.updateColliders();
  10892. for (var b = 0; b < this.childCount; b++) {
  10893. this.children[b].angle = this.currentAngle;
  10894. this.children[b].update(c)
  10895. }
  10896. };
  10897. Crate.prototype.draw = function() {
  10898. for (var a = 0; a < this.childCount; a++) {
  10899. this.children[a].draw()
  10900. }
  10901. };
  10902. Crate.prototype.updateColliders = function() {
  10903. if (!this.colliders) {
  10904. return
  10905. }
  10906. this.colliders[0].x = this.x;
  10907. this.colliders[0].y = this.y
  10908. };
  10909. Crate.prototype.checkCollision = function(f) {
  10910. if (!this.colliders || !f.colliders) {
  10911. return
  10912. }
  10913. for (var e = 0; e < this.colliders.length; e++) {
  10914. for (var d = 0; d < f.colliders.length; d++) {
  10915. var c = Collision.getCollision(this.colliders[e], f.colliders[d]);
  10916. if (this.colliders[e].colliding) {
  10917. this.colliders[e].lastCollisionObject = f
  10918. }
  10919. if (f.colliders[d].colliding) {
  10920. f.colliders[d].lastCollisionObject = this
  10921. }
  10922. if (c) {
  10923. this.onCollision(c, f);
  10924. c.directionX *= -1;
  10925. c.directionY *= -1;
  10926. f.onCollision(c, this)
  10927. }
  10928. }
  10929. }
  10930. };
  10931. Crate.prototype.onCollision = function(m, g) {
  10932. if (!this.collisionEnabled || this.immovable) {
  10933. return
  10934. }
  10935. if (!this.colliders) {
  10936. this.collisionEnabled = false;
  10937. return
  10938. }
  10939. if (this.explosive && Car.prototype.isPrototypeOf(g)) {
  10940. if (!soundMuted && PlayerCar.prototype.isPrototypeOf(g)) {
  10941. var i = "explosion";
  10942. playSound(i)
  10943. }
  10944. var l = new Explosion();
  10945. l.init(this.x, this.y, 1, 2);
  10946. l.depth = g.depth - 0.01;
  10947. this.sceneManager.addEntity(l);
  10948. l.trigger(0, null, this.gameState);
  10949. this.flagForRemoval();
  10950. g.explode();
  10951. if (g === this.gameState.player) {
  10952. g.gameState.endGame(FailType.EXPLODED)
  10953. }
  10954. return
  10955. }
  10956. if (!soundMuted && PlayerCar.prototype.isPrototypeOf(g)) {
  10957. var i = "crateHit";
  10958. playSound(i)
  10959. }
  10960. this.x += m.directionX * m.magnitude;
  10961. this.y += m.directionY * m.magnitude;
  10962. if (this.mass == 0) {
  10963. return
  10964. }
  10965. var e = this.velocityX - g.velocityX;
  10966. var c = this.velocityY - g.velocityY;
  10967. var k = (e * m.directionX) + (c * m.directionY);
  10968. var a = Math.min(this.restitution, g.restitution);
  10969. var h = -(1 + a) * k;
  10970. if (g.mass == 0) {
  10971. h /= (1 / this.mass)
  10972. } else {
  10973. h /= (1 / this.mass) + (1 / g.mass)
  10974. }
  10975. var d = h * m.directionX;
  10976. var b = h * m.directionY;
  10977. var f = 1 / this.mass;
  10978. this.collisionVelocityAccumulatorX += f * d;
  10979. this.collisionVelocityAccumulatorY += f * b;
  10980. this.updateColliders()
  10981. };
  10982. function Wall() {
  10983. SceneObject.call(this)
  10984. }
  10985. Wall.prototype = new SceneObject();
  10986. Wall.prototype.constructor = Wall;
  10987. Wall.prototype.init = function(a, f, c) {
  10988. this.x = a;
  10989. this.y = f;
  10990. this.gameState = c;
  10991. this.children = [];
  10992. this.childCount = 0;
  10993. this.toBeRemoved = false;
  10994. this.useCamera = true;
  10995. this.collider = null;
  10996. this.collisionEnabled = true;
  10997. this.mass = 0;
  10998. this.restitution = 1;
  10999. this.immovable = true;
  11000. this.contactLessCollision = false;
  11001. this.velocityX = 0;
  11002. this.velocityY = 0;
  11003. this.colliders = [];
  11004. var b = new LineCollider();
  11005. b.init(this.x - 81, this.y, this.x + 81, this.y);
  11006. this.colliders.push(b);
  11007. b = new CircleCollider();
  11008. b.init(this.x, this.y, 50);
  11009. this.colliders.push(b);
  11010. b = new CircleCollider();
  11011. b.init(this.x, this.y, 50);
  11012. this.colliders.push(b);
  11013. this.updateColliders();
  11014. var e = new Drawable();
  11015. e.init(content.wall, 0, 0);
  11016. e.originX = 86;
  11017. e.originY = 101;
  11018. this.addChild(e);
  11019. this.depth = -0.3 + randFloatRange(-0.01, 0.01)
  11020. };
  11021. Wall.prototype.update = function(b) {
  11022. this.updateColliders();
  11023. for (var a = 0; a < this.childCount; a++) {
  11024. this.children[a].update(b)
  11025. }
  11026. };
  11027. Wall.prototype.draw = function() {
  11028. for (var a = 0; a < this.childCount; a++) {
  11029. this.children[a].draw()
  11030. }
  11031. };
  11032. Wall.prototype.updateColliders = function() {
  11033. if (!this.colliders) {
  11034. return
  11035. }
  11036. this.colliders[0].x0 = this.x - 72;
  11037. this.colliders[0].y0 = this.y;
  11038. this.colliders[0].x1 = this.x + 72;
  11039. this.colliders[0].y1 = this.y;
  11040. this.colliders[1].x = this.x - 32;
  11041. this.colliders[1].y = this.y - 52;
  11042. this.colliders[2].x = this.x + 32;
  11043. this.colliders[2].y = this.y - 52
  11044. };
  11045. Wall.prototype.checkCollision = function(f) {
  11046. if (!this.colliders || !f.colliders) {
  11047. return
  11048. }
  11049. for (var e = 0; e < this.colliders.length; e++) {
  11050. for (var d = 0; d < f.colliders.length; d++) {
  11051. var c = Collision.getCollision(this.colliders[e], f.colliders[d]);
  11052. if (this.colliders[e].colliding) {
  11053. this.colliders[e].lastCollisionObject = f
  11054. }
  11055. if (f.colliders[d].colliding) {
  11056. f.colliders[d].lastCollisionObject = this
  11057. }
  11058. if (c) {
  11059. this.onCollision(c, f);
  11060. c.directionX *= -1;
  11061. c.directionY *= -1;
  11062. f.onCollision(c, this)
  11063. }
  11064. }
  11065. }
  11066. };
  11067. Wall.prototype.onCollision = function(k, g) {
  11068. if (!this.collisionEnabled || this.immovable) {
  11069. return
  11070. }
  11071. if (!this.colliders) {
  11072. this.collisionEnabled = false;
  11073. return
  11074. }
  11075. this.x += k.directionX * k.magnitude;
  11076. this.y += k.directionY * k.magnitude;
  11077. if (this.mass == 0) {
  11078. return
  11079. }
  11080. var d = this.velocityX - g.velocityX;
  11081. var c = this.velocityY - g.velocityY;
  11082. var i = (d * k.directionX) + (c * k.directionY);
  11083. var a = Math.min(this.restitution, g.restitution);
  11084. var h = -(1 + a) * i;
  11085. if (g.mass == 0) {
  11086. h /= (1 / this.mass)
  11087. } else {
  11088. h /= (1 / this.mass) + (1 / g.mass)
  11089. }
  11090. var e = h * k.directionX;
  11091. var b = h * k.directionY;
  11092. var f = 1 / this.mass;
  11093. this.collisionVelocityAccumulatorX += f * e;
  11094. this.collisionVelocityAccumulatorY += f * b;
  11095. this.updateColliders()
  11096. };
  11097. function Pothole() {
  11098. SceneObject.call(this)
  11099. }
  11100. Pothole.prototype = new SceneObject();
  11101. Pothole.prototype.constructor = Pothole;
  11102. Pothole.prototype.init = function(a, g, e) {
  11103. this.x = a;
  11104. this.y = g;
  11105. this.gameState = e;
  11106. this.children = [];
  11107. this.childCount = 0;
  11108. this.toBeRemoved = false;
  11109. this.useCamera = true;
  11110. this.collider = null;
  11111. this.collisionEnabled = true;
  11112. this.mass = 0;
  11113. this.restitution = 1;
  11114. this.immovable = true;
  11115. this.contactLessCollision = false;
  11116. this.colliders = [];
  11117. var b = new CircleCollider();
  11118. b.init(this.x, this.y, 20);
  11119. b.sensor = true;
  11120. this.colliders.push(b);
  11121. this.updateColliders();
  11122. var c = null;
  11123. switch (randIntRange(0, 2)) {
  11124. case 0:
  11125. c = content.pothole0;
  11126. break;
  11127. case 1:
  11128. c = content.pothole1;
  11129. break;
  11130. case 2:
  11131. c = content.pothole2;
  11132. break
  11133. }
  11134. var f = new Drawable();
  11135. f.init(c, 0, 0);
  11136. f.originX = f.sprite.width * 0.5;
  11137. f.originY = f.sprite.height * 0.5;
  11138. this.addChild(f);
  11139. this.depth = -0.1 + randFloatRange(-0.01, 0.01);
  11140. this.potholeActive = true
  11141. };
  11142. Pothole.prototype.update = function(d) {
  11143. this.updateColliders();
  11144. for (var c = 0; c < this.childCount; c++) {
  11145. this.children[c].update(d)
  11146. }
  11147. if (this.potholeActive) {
  11148. if (this.colliders[0].colliding) {
  11149. this.colliders[0].colliding = false;
  11150. if (this.colliders[0].lastCollisionObject && Car.prototype.isPrototypeOf(this.colliders[0].lastCollisionObject)) {
  11151. if (!soundMuted && PlayerCar.prototype.isPrototypeOf(this.colliders[0].lastCollisionObject)) {
  11152. var b = "pothole01";
  11153. switch (randIntRange(0, 3)) {
  11154. case 0:
  11155. b = "pothole01";
  11156. break;
  11157. case 1:
  11158. b = "pothole02";
  11159. break;
  11160. case 2:
  11161. b = "pothole03";
  11162. break
  11163. }
  11164. playSound(b)
  11165. }
  11166. var a = 5000 / this.colliders[0].lastCollisionObject.mass;
  11167. if (randFloatRange(0, 1) < 0.5) {
  11168. a *= -1
  11169. }
  11170. this.colliders[0].lastCollisionObject.accelerationX += a;
  11171. this.colliders[0].lastCollisionObject.carAngle -= a * 0.00003;
  11172. this.colliders[0].lastCollisionObject.velocityX *= 0.75;
  11173. this.colliders[0].lastCollisionObject.velocityY *= 0.75;
  11174. this.potholeActive = false;
  11175. this.colliders[0].active = false
  11176. }
  11177. }
  11178. }
  11179. this.colliders[0].lastCollisionObject = null
  11180. };
  11181. Pothole.prototype.updateColliders = function() {
  11182. if (!this.colliders) {
  11183. return
  11184. }
  11185. this.colliders[0].x = this.x;
  11186. this.colliders[0].y = this.y
  11187. };
  11188. function Oil() {
  11189. SceneObject.call(this)
  11190. }
  11191. Oil.prototype = new SceneObject();
  11192. Oil.prototype.constructor = Oil;
  11193. Oil.prototype.init = function(a, f, c) {
  11194. this.x = a;
  11195. this.y = f;
  11196. this.gameState = c;
  11197. this.children = [];
  11198. this.childCount = 0;
  11199. this.toBeRemoved = false;
  11200. this.useCamera = true;
  11201. this.collider = null;
  11202. this.collisionEnabled = true;
  11203. this.mass = 0;
  11204. this.restitution = 1;
  11205. this.immovable = true;
  11206. this.contactLessCollision = false;
  11207. this.colliders = [];
  11208. var b = new CircleCollider();
  11209. b.init(this.x, this.y, 50);
  11210. b.sensor = true;
  11211. this.colliders.push(b);
  11212. this.updateColliders();
  11213. var e = new Drawable();
  11214. e.init(content.oil, 0, 0);
  11215. e.originX = e.sprite.width * 0.5;
  11216. e.originY = e.sprite.height * 0.5;
  11217. this.addChild(e);
  11218. this.depth = -0.1 + randFloatRange(-0.01, 0.01)
  11219. };
  11220. Oil.prototype.update = function(b) {
  11221. this.updateColliders();
  11222. for (var a = 0; a < this.childCount; a++) {
  11223. this.children[a].update(b)
  11224. }
  11225. if (true) {
  11226. if (this.colliders[0].colliding) {
  11227. this.colliders[0].colliding = false;
  11228. if (this.colliders[0].lastCollisionObject && Car.prototype.isPrototypeOf(this.colliders[0].lastCollisionObject)) {
  11229. this.colliders[0].lastCollisionObject.spinOut();
  11230. if (PlayerCar.prototype.isPrototypeOf(this.colliders[0].lastCollisionObject)) {
  11231. this.gameState.endGame(FailType.SPIN)
  11232. }
  11233. }
  11234. }
  11235. }
  11236. this.colliders[0].lastCollisionObject = null
  11237. };
  11238. Oil.prototype.updateColliders = function() {
  11239. if (!this.colliders) {
  11240. return
  11241. }
  11242. this.colliders[0].x = this.x;
  11243. this.colliders[0].y = this.y
  11244. };
  11245. function HeliShadow() {
  11246. SceneObject.call(this)
  11247. }
  11248. HeliShadow.prototype = new SceneObject();
  11249. HeliShadow.prototype.constructor = HeliShadow;
  11250. HeliShadow.prototype.init = function(a, c, b) {
  11251. this.x = a;
  11252. this.y = c;
  11253. this.gameState = b;
  11254. this.children = [];
  11255. this.childCount = 0;
  11256. this.toBeRemoved = false;
  11257. this.useCamera = false;
  11258. this.collider = null;
  11259. this.collisionEnabled = false;
  11260. this.mass = 0;
  11261. this.restitution = 1;
  11262. this.immovable = true;
  11263. this.contactLessCollision = false;
  11264. this.velocityX = 0;
  11265. this.velocityY = 0;
  11266. this.colliders = [];
  11267. this.body = new Drawable();
  11268. this.body.init(content.heliBody, 90, 90);
  11269. this.body.originX = 95;
  11270. this.body.originY = this.body.sprite.height * 0.5;
  11271. this.blades = new Drawable();
  11272. this.blades.init(content.heliBlades, 90, 90);
  11273. this.blades.originX = this.blades.sprite.width * 0.5;
  11274. this.blades.originY = this.blades.sprite.height * 0.5;
  11275. this.buffer = new Drawable();
  11276. this.buffer.init(null, 0, 0);
  11277. this.buffer.sprite = document.createElement("canvas");
  11278. this.buffer.sprite.width = 180;
  11279. this.buffer.sprite.height = 180;
  11280. this.buffer.originX = this.buffer.sprite.width * 0.5;
  11281. this.buffer.originY = this.buffer.sprite.height * 0.5;
  11282. this.buffer.alpha = 0.5;
  11283. this.addChild(this.buffer);
  11284. this.depth = -0.9
  11285. };
  11286. HeliShadow.prototype.update = function(b) {
  11287. this.body.angle = -Math.PI * 0.5;
  11288. this.blades.angle += b * 8;
  11289. while (this.blades.angle >= Math.PI * 2) {
  11290. this.blades.angle -= Math.PI * 2
  11291. }
  11292. for (var a = 0; a < this.childCount; a++) {
  11293. this.children[a].update(b)
  11294. }
  11295. this.body.update(b);
  11296. this.blades.update(b);
  11297. this.x = mouseX;
  11298. this.y = mouseY
  11299. };
  11300. HeliShadow.prototype.draw = function(b) {
  11301. if (!this.visible) {
  11302. return
  11303. }
  11304. var c = this.buffer.sprite.getContext("2d");
  11305. c.clearRect(0, 0, 180, 180);
  11306. this.body.draw(c);
  11307. this.blades.draw(c);
  11308. for (var a = 0; a < this.childCount; a++) {
  11309. this.children[a].draw(b)
  11310. }
  11311. };
  11312. function RoadBlock() {
  11313. SceneObject.call(this);
  11314. this.currentAngle = 0
  11315. }
  11316. RoadBlock.prototype = new SceneObject();
  11317. RoadBlock.prototype.constructor = RoadBlock;
  11318. RoadBlock.prototype.init = function(a, f, c) {
  11319. this.x = a;
  11320. this.y = f;
  11321. this.currentAngle = 0;
  11322. this.gameState = c;
  11323. this.children = [];
  11324. this.childCount = 0;
  11325. this.knockedOver = false;
  11326. this.toBeRemoved = false;
  11327. this.useCamera = true;
  11328. this.collider = null;
  11329. this.collisionEnabled = true;
  11330. this.mass = 0.15;
  11331. this.restitution = 1;
  11332. this.immovable = false;
  11333. this.contactLessCollision = false;
  11334. this.oldVelocityX = 0;
  11335. this.oldVelocityY = 0;
  11336. this.velocityX = 0;
  11337. this.velocityY = 0;
  11338. this.accelerationX = 0;
  11339. this.accelerationY = 0;
  11340. this.dragX = 0.25;
  11341. this.dragY = 0.25;
  11342. this.collisionVelocityAccumulatorX = 0;
  11343. this.collisionVelocityAccumulatorY = 0;
  11344. this.angularAcceleration = 0;
  11345. this.angularVelocity = 0;
  11346. this.angularDrag = 0.35;
  11347. this.oldAngularVelocity = 0;
  11348. this.colliders = [];
  11349. var b = new CircleCollider();
  11350. b.init(this.x, this.y, 19);
  11351. this.colliders.push(b);
  11352. b = new CircleCollider();
  11353. b.init(this.x, this.y, 19);
  11354. this.colliders.push(b);
  11355. this.updateColliders();
  11356. var e = new Drawable();
  11357. e.init(content.blockStanding, 0, 0);
  11358. e.originX = e.sprite.width * 0.5;
  11359. e.originY = e.sprite.height * 0.5;
  11360. this.addChild(e);
  11361. this.depth = -0.15 + randFloatRange(-0.01, 0.01)
  11362. };
  11363. RoadBlock.prototype.update = function(c) {
  11364. if (!this.immovable) {
  11365. if (isNaN(this.collisionVelocityAccumulatorX) || isNaN(this.collisionVelocityAccumulatorY)) {
  11366. this.collisionVelocityAccumulatorX = 0;
  11367. this.collisionVelocityAccumulatorY = 0
  11368. }
  11369. this.velocityX += this.collisionVelocityAccumulatorX;
  11370. this.velocityY += this.collisionVelocityAccumulatorY;
  11371. if (this.collisionVelocityAccumulatorX != 0 || this.collisionVelocityAccumulatorY != 0) {
  11372. var d = Math.sqrt((this.collisionVelocityAccumulatorX * this.collisionVelocityAccumulatorX) + (this.collisionVelocityAccumulatorY * this.collisionVelocityAccumulatorY));
  11373. this.angularVelocity = d * c;
  11374. var a = ((this.collisionVelocityAccumulatorX / d) * (1)) + ((this.collisionVelocityAccumulatorY / d) * (0));
  11375. if (a < 0) {
  11376. this.angularVelocity *= -1
  11377. }
  11378. }
  11379. this.collisionVelocityAccumulatorX = 0;
  11380. this.collisionVelocityAccumulatorY = 0;
  11381. this.oldVelocityX = this.velocityX;
  11382. this.oldVelocityY = this.velocityY;
  11383. this.velocityX += this.accelerationX * c;
  11384. this.velocityY += this.accelerationY * c;
  11385. this.x += (this.oldVelocityX + this.velocityX) * 0.5 * c;
  11386. this.y += (this.oldVelocityY + this.velocityY) * 0.5 * c;
  11387. if (this.dragX != 1) {
  11388. this.velocityX *= Math.pow(this.dragX, c)
  11389. }
  11390. if (this.dragY != 1) {
  11391. this.velocityY *= Math.pow(this.dragY, c)
  11392. }
  11393. this.oldAngularVelocity = this.angularVelocity;
  11394. this.angularVelocity += this.angularAcceleration * c;
  11395. this.currentAngle += (this.oldAngularVelocity + this.angularVelocity) * 0.5 * c;
  11396. if (this.angularDrag != 1) {
  11397. this.angularVelocity *= Math.pow(this.angularDrag, c)
  11398. }
  11399. }
  11400. this.accelerationX = 0;
  11401. this.accelerationY = 0;
  11402. this.angularAcceleration = 0;
  11403. this.updateColliders();
  11404. for (var b = 0; b < this.childCount; b++) {
  11405. this.children[b].angle = this.currentAngle;
  11406. this.children[b].update(c)
  11407. }
  11408. };
  11409. RoadBlock.prototype.draw = function() {
  11410. for (var a = 0; a < this.childCount; a++) {
  11411. this.children[a].draw()
  11412. }
  11413. };
  11414. RoadBlock.prototype.updateColliders = function() {
  11415. if (!this.colliders) {
  11416. return
  11417. }
  11418. this.colliders[0].x = this.x + Math.cos(this.currentAngle) * 30;
  11419. this.colliders[0].y = this.y + Math.sin(this.currentAngle) * 30;
  11420. this.colliders[1].x = this.x - Math.cos(this.currentAngle) * 30;
  11421. this.colliders[1].y = this.y - Math.sin(this.currentAngle) * 30
  11422. };
  11423. RoadBlock.prototype.checkCollision = function(f) {
  11424. if (!this.colliders || !f.colliders) {
  11425. return
  11426. }
  11427. for (var e = 0; e < this.colliders.length; e++) {
  11428. for (var d = 0; d < f.colliders.length; d++) {
  11429. var c = Collision.getCollision(this.colliders[e], f.colliders[d]);
  11430. if (this.colliders[e].colliding) {
  11431. this.colliders[e].lastCollisionObject = f
  11432. }
  11433. if (f.colliders[d].colliding) {
  11434. f.colliders[d].lastCollisionObject = this
  11435. }
  11436. if (c) {
  11437. this.onCollision(c, f);
  11438. c.directionX *= -1;
  11439. c.directionY *= -1;
  11440. f.onCollision(c, this)
  11441. }
  11442. }
  11443. }
  11444. };
  11445. RoadBlock.prototype.onCollision = function(l, g) {
  11446. if (!this.collisionEnabled || this.immovable) {
  11447. return
  11448. }
  11449. if (!this.knockedOver) {
  11450. this.children[0].sprite = content.blockFallen;
  11451. this.children[0].originX = this.children[0].sprite.width * 0.5;
  11452. this.children[0].originY = this.children[0].sprite.height * 0.35
  11453. }
  11454. if (!this.colliders) {
  11455. this.collisionEnabled = false;
  11456. return
  11457. }
  11458. this.x += l.directionX * l.magnitude;
  11459. this.y += l.directionY * l.magnitude;
  11460. if (this.mass == 0) {
  11461. return
  11462. }
  11463. var d = this.velocityX - g.velocityX;
  11464. var c = this.velocityY - g.velocityY;
  11465. var k = (d * l.directionX) + (c * l.directionY);
  11466. var a = Math.min(this.restitution, g.restitution);
  11467. var h = -(1 + a) * k;
  11468. if (g.mass == 0) {
  11469. h /= (1 / this.mass)
  11470. } else {
  11471. h /= (1 / this.mass) + (1 / g.mass)
  11472. }
  11473. var e = h * l.directionX;
  11474. var b = h * l.directionY;
  11475. var f = 1 / this.mass;
  11476. this.collisionVelocityAccumulatorX += f * e;
  11477. this.collisionVelocityAccumulatorY += f * b;
  11478. this.updateColliders();
  11479. if (!soundMuted && PlayerCar.prototype.isPrototypeOf(g)) {
  11480. var i = "roadBlockHit";
  11481. playSound(i)
  11482. }
  11483. };
  11484. function Wrench() {
  11485. SceneObject.call(this)
  11486. }
  11487. Wrench.prototype = new SceneObject();
  11488. Wrench.prototype.constructor = Wrench;
  11489. Wrench.prototype.init = function(a, f, c) {
  11490. this.x = a;
  11491. this.y = f;
  11492. this.gameState = c;
  11493. this.children = [];
  11494. this.childCount = 0;
  11495. this.toBeRemoved = false;
  11496. this.useCamera = true;
  11497. this.collider = null;
  11498. this.collisionEnabled = true;
  11499. this.mass = 0;
  11500. this.restitution = 1;
  11501. this.immovable = true;
  11502. this.contactLessCollision = false;
  11503. this.colliders = [];
  11504. var b = new CircleCollider();
  11505. b.init(this.x, this.y, 64);
  11506. b.sensor = true;
  11507. this.colliders.push(b);
  11508. this.updateColliders();
  11509. var e = new Drawable();
  11510. e.init(content.wrenchStar, 0, 0);
  11511. e.originX = e.sprite.width * 0.5;
  11512. e.originY = e.sprite.height * 0.5;
  11513. this.addChild(e);
  11514. e = new Drawable();
  11515. e.init(content.wrench, 0, 0);
  11516. e.originX = e.sprite.width * 0.5;
  11517. e.originY = e.sprite.height * 0.5;
  11518. this.addChild(e);
  11519. this.depth = -0.1 + randFloatRange(-0.01, 0.01);
  11520. this.pulseSine = 0;
  11521. this.wrenchActive = true
  11522. };
  11523. Wrench.prototype.update = function(b) {
  11524. this.updateColliders();
  11525. this.pulseSine += b * 4;
  11526. while (this.pulseSine > Math.PI * 2) {
  11527. this.pulseSine -= Math.PI * 2
  11528. }
  11529. this.children[1].scaleX = 1 + Math.sin(this.pulseSine) * 0.025;
  11530. this.children[1].scaleY = this.children[1].scaleX;
  11531. this.children[0].angle += b;
  11532. while (this.children[0].angle > Math.PI * 2) {
  11533. this.children[0].angle -= Math.PI * 2
  11534. }
  11535. for (var a = 0; a < this.childCount; a++) {
  11536. this.children[a].update(b)
  11537. }
  11538. };
  11539. Wrench.prototype.updateColliders = function() {
  11540. if (!this.colliders) {
  11541. return
  11542. }
  11543. this.colliders[0].x = this.x;
  11544. this.colliders[0].y = this.y
  11545. };
  11546. Wrench.prototype.onPickup = function() {
  11547. this.wrenchActive = false;
  11548. this.flagForRemoval();
  11549. if (!soundMuted) {
  11550. var c = "wrench";
  11551. playSound(c)
  11552. }
  11553. for (var d = 0; d < 8; d++) {
  11554. var b = new Particle();
  11555. b.init(content.wrenchParticle, randFloatRange(0.5, 1));
  11556. b.x = this.x;
  11557. b.y = this.y;
  11558. b.originX = b.sprite.width * 0.5;
  11559. b.originY = b.sprite.height * 0.5;
  11560. var e = randFloatRange(0.75, 1.25) * 1.5;
  11561. b.startScaleX = e;
  11562. b.startScaleY = e;
  11563. b.endScaleX = 0;
  11564. b.endScaleY = 0;
  11565. b.startAlpha = 1;
  11566. b.endAlpha = 0;
  11567. b.depth = -0.8;
  11568. b.dragX = 0.001;
  11569. b.dragY = 0.001;
  11570. var f = randFloatRange(0, Math.PI * 2);
  11571. var a = randFloatRange(5, 15) * 0.5;
  11572. b.velocityX = Math.cos(f) * a;
  11573. b.velocityY = Math.sin(f) * a;
  11574. b.start();
  11575. this.sceneManager.addEntity(b)
  11576. }
  11577. };
  11578. function GameGenerator() {}
  11579. GameGenerator.prototype = new GameGenerator();
  11580. GameGenerator.prototype.constructor = GameGenerator;
  11581. GameGenerator.prototype.init = function(a) {
  11582. this.gameState = a;
  11583. this.rockDistanceTime = 32;
  11584. this.rockDistanceTimer = this.rockDistanceTime * randFloatRange(0, 1);
  11585. this.rockChance = 0.15;
  11586. this.truckStartDistance = 1200;
  11587. this.copStartDistance = 2750;
  11588. this.regularCarChance = 0.005;
  11589. this.truckChance = 0.002;
  11590. this.copChance = 0.001;
  11591. this.truckCrateDropStartDistance = this.truckStartDistance + 800;
  11592. this.truckExplosiveCrateStartDistance = this.truckCrateDropStartDistance + 1000;
  11593. this.wallStartDistance = 3300;
  11594. this.wallDistanceTime = 800;
  11595. this.wallDistanceTimer = this.wallDistanceTime * randFloatRange(0, 1);
  11596. this.wallChance = 0.2;
  11597. this.potholeStartDistance = 650;
  11598. this.potholeDistanceTime = 256;
  11599. this.potholeDistanceTimer = this.potholeDistanceTime * randFloatRange(0, 1);
  11600. this.oilStartDistance = 2350;
  11601. this.oilDistanceTime = 512;
  11602. this.oilDistanceTimer = this.oilDistanceTime * randFloatRange(0, 1);
  11603. this.dirtRoadStartDistance = 1400;
  11604. this.dirtRoadDistanceTime = 2048;
  11605. this.dirtRoadDistanceTimer = this.dirtRoadDistanceTime * randFloatRange(0, 1);
  11606. this.dirtRoadChance = 0.25;
  11607. this.roadBlockStartDistance = 225;
  11608. this.roadBlockDistanceTime = 512;
  11609. this.roadBlockDistanceTimer = this.roadBlockDistanceTime * randFloatRange(0, 1);
  11610. this.wrenchStartDistance = 0;
  11611. this.wrenchDistanceTime = 1024;
  11612. this.wrenchDistanceTimer = this.wrenchDistanceTime * randFloatRange(0, 1);
  11613. this.wrenchChance = 0.075;
  11614. this.truckDistanceTime = 512;
  11615. this.truckDistanceTimer = this.truckDistanceTime * randFloatRange(0, 1);
  11616. this.copDistanceTime = 512;
  11617. this.copDistanceTimer = this.copDistanceTime * randFloatRange(0, 1);
  11618. this.lastCameraY = 0;
  11619. this.diffY = 0;
  11620. this.distance = 0
  11621. };
  11622. GameGenerator.prototype.reset = function() {};
  11623. GameGenerator.prototype.update = function(a) {
  11624. if (this.gameState.playState != PlayState.GAME) {
  11625. return
  11626. }
  11627. this.diffY = Math.max(0, this.gameState.sceneManager.camera.positionY - this.lastCameraY);
  11628. this.lastCameraY = this.gameState.sceneManager.camera.positionY;
  11629. this.distance = this.gameState.hud.distance;
  11630. this.updateCarSpawning(a);
  11631. this.updateObstacleSpawning(a);
  11632. this.updateDetritusSpawning(a)
  11633. };
  11634. GameGenerator.prototype.updateCarSpawning = function(b) {
  11635. if (this.distance < this.truckStartDistance) {
  11636. this.spawnRegularCar(b)
  11637. } else {
  11638. if (this.distance < this.copStartDistance) {
  11639. if (randFloatRange(0, 1) < 0.5) {
  11640. this.spawnRegularCar(b)
  11641. } else {
  11642. this.spawnTruck(b)
  11643. }
  11644. } else {
  11645. var a = randFloatRange(0, 1);
  11646. if (a < 0.33) {
  11647. this.spawnRegularCar(b)
  11648. } else {
  11649. if (a < 0.66) {
  11650. this.spawnTruck(b)
  11651. } else {
  11652. this.spawnCop(b)
  11653. }
  11654. }
  11655. }
  11656. }
  11657. };
  11658. GameGenerator.prototype.spawnRegularCar = function(b) {
  11659. if (this.gameState.cars.length < 7 && randFloatRange(0, 1) < this.regularCarChance) {
  11660. var a = new Car();
  11661. a.init(randFloatRange(0, 1) < 0.5 ? 80 : -80, -this.gameState.sceneManager.camera.positionY - 768, this.gameState);
  11662. this.gameState.sceneManager.addEntity(a);
  11663. this.gameState.cars.push(a);
  11664. a.setDesiredState(CarState.CRUSING)
  11665. }
  11666. };
  11667. GameGenerator.prototype.spawnTruck = function(a) {
  11668. if (this.gameState.cars.length < 7 && randFloatRange(0, 1) < this.truckChance) {
  11669. var b = new Truck();
  11670. b.init(randFloatRange(0, 1) < 0.5 ? 80 : -80, -this.gameState.sceneManager.camera.positionY - 768, this.gameState);
  11671. this.gameState.sceneManager.addEntity(b);
  11672. this.gameState.cars.push(b);
  11673. b.setDesiredState(CarState.CRUSING);
  11674. if (this.distance >= this.truckCrateDropStartDistance) {
  11675. b.crateDroppingActive = true
  11676. }
  11677. if (this.distance >= this.truckExplosiveCrateStartDistance) {
  11678. b.explodingCrates = true
  11679. }
  11680. }
  11681. };
  11682. GameGenerator.prototype.spawnCop = function(a) {
  11683. if (this.gameState.cars.length < 7 && randFloatRange(0, 1) < this.copChance) {
  11684. var b = new CopCar();
  11685. b.init(randFloatRange(0, 1) < 0.5 ? 80 : -80, -this.gameState.sceneManager.camera.positionY - 768, this.gameState);
  11686. this.gameState.sceneManager.addEntity(b);
  11687. this.gameState.cars.push(b);
  11688. b.setDesiredState(CarState.CRUSING)
  11689. }
  11690. };
  11691. GameGenerator.prototype.updateObstacleSpawning = function(a) {
  11692. if (this.distance > this.roadBlockStartDistance) {
  11693. this.spawnRoadBlock(a)
  11694. }
  11695. if (this.distance > this.dirtRoadStartDistance) {
  11696. this.spawnDirtRoadSection(a)
  11697. }
  11698. if (this.distance > this.oilStartDistance) {
  11699. this.spawnOil(a)
  11700. }
  11701. if (this.distance > this.potholeStartDistance) {
  11702. this.spawnPothole(a)
  11703. }
  11704. if (this.distance > this.wallStartDistance) {
  11705. this.spawnWall(a)
  11706. }
  11707. if (this.distance > this.wrenchStartDistance) {
  11708. this.spawnWrench(a)
  11709. }
  11710. };
  11711. GameGenerator.prototype.spawnRoadBlock = function(b) {
  11712. this.roadBlockChance = 0.35;
  11713. if (this.distance > 650) {
  11714. this.roadBlockChance = 0.175
  11715. }
  11716. this.roadBlockDistanceTimer -= this.diffY;
  11717. if (this.roadBlockDistanceTimer <= 0) {
  11718. this.roadBlockDistanceTimer = this.roadBlockDistanceTime;
  11719. if (randFloatRange(0, 1) <= this.roadBlockChance) {
  11720. var a = new RoadBlock();
  11721. a.init((randFloatRange(0, 1) < 0.5 ? -1 : 1) * 80, -this.gameState.sceneManager.camera.positionY - 512, this.gameState);
  11722. this.gameState.sceneManager.addEntity(a);
  11723. this.gameState.roadBlocks.push(a)
  11724. }
  11725. }
  11726. };
  11727. GameGenerator.prototype.spawnDirtRoadSection = function(a) {
  11728. if (!this.gameState.road.dirtRoad) {
  11729. this.dirtRoadDistanceTimer -= this.diffY;
  11730. if (this.dirtRoadDistanceTimer <= 0) {
  11731. this.dirtRoadDistanceTimer = this.dirtRoadDistanceTime;
  11732. if (randFloatRange(0, 1) <= this.dirtRoadChance) {
  11733. this.gameState.road.startDirtRoad(this.gameState.sceneManager.camera.positionY + 1600, randFloatRange(512, 2048))
  11734. }
  11735. }
  11736. }
  11737. };
  11738. GameGenerator.prototype.spawnOil = function(a) {
  11739. this.oilChance = 0.25;
  11740. if (this.distance > 2800) {
  11741. this.oilChance = 0.075
  11742. }
  11743. this.oilDistanceTimer -= this.diffY;
  11744. if (this.oilDistanceTimer <= 0) {
  11745. this.oilDistanceTimer = this.oilDistanceTime;
  11746. if (randFloatRange(0, 1) <= this.oilChance) {
  11747. var b = new Oil();
  11748. b.init((randFloatRange(0, 1) < 0.5 ? -1 : 1) * 80, -this.gameState.sceneManager.camera.positionY - 512, this.gameState);
  11749. this.gameState.sceneManager.addEntity(b);
  11750. this.gameState.oilSlicks.push(b)
  11751. }
  11752. }
  11753. };
  11754. GameGenerator.prototype.spawnPothole = function(a) {
  11755. if (this.gameState.road.dirtRoad) {
  11756. return
  11757. }
  11758. this.potholeChance = 0.25;
  11759. if (this.distance > 1250) {
  11760. this.potholeChance = 0.05
  11761. }
  11762. this.potholeDistanceTimer -= this.diffY;
  11763. if (this.potholeDistanceTimer <= 0) {
  11764. this.potholeDistanceTimer = this.potholeDistanceTime;
  11765. if (randFloatRange(0, 1) <= this.potholeChance) {
  11766. var b = new Pothole();
  11767. b.init((randFloatRange(0, 1) < 0.5 ? -1 : 1) * 80, -this.gameState.sceneManager.camera.positionY - 512, this.gameState);
  11768. this.gameState.sceneManager.addEntity(b);
  11769. this.gameState.potholes.push(b)
  11770. }
  11771. }
  11772. };
  11773. GameGenerator.prototype.spawnWall = function(b) {
  11774. this.wallDistanceTimer -= this.diffY;
  11775. if (this.wallDistanceTimer <= 0) {
  11776. this.wallDistanceTimer = this.wallDistanceTime;
  11777. if (randFloatRange(0, 1) <= this.wallChance) {
  11778. var a = new Wall();
  11779. a.init((randFloatRange(0, 1) < 0.5 ? -1 : 1) * 80, -this.gameState.sceneManager.camera.positionY - 512, this.gameState);
  11780. this.gameState.sceneManager.addEntity(a);
  11781. this.gameState.walls.push(a)
  11782. }
  11783. }
  11784. };
  11785. GameGenerator.prototype.spawnWrench = function(b) {
  11786. if (this.gameState.player.hitCount <= 0) {
  11787. return
  11788. }
  11789. this.wrenchDistanceTimer -= this.diffY;
  11790. if (this.wrenchDistanceTimer <= 0) {
  11791. this.wrenchDistanceTimer = this.wrenchDistanceTime;
  11792. if (randFloatRange(0, 1) <= this.wrenchChance) {
  11793. var a = new Wrench();
  11794. a.init((randFloatRange(0, 1) < 0.5 ? -1 : 1) * 80, -this.gameState.sceneManager.camera.positionY - 512, this.gameState);
  11795. this.gameState.sceneManager.addEntity(a);
  11796. this.gameState.wrenches.push(a)
  11797. }
  11798. }
  11799. };
  11800. GameGenerator.prototype.updateDetritusSpawning = function(b) {
  11801. this.rockDistanceTimer -= this.diffY;
  11802. if (this.rockDistanceTimer <= 0) {
  11803. this.rockDistanceTimer = this.rockDistanceTime;
  11804. if (randFloatRange(0, 1) <= this.rockChance) {
  11805. var c = new Drawable();
  11806. var a;
  11807. switch (randIntRange(0, 4)) {
  11808. case 0:
  11809. a = content.rock01;
  11810. break;
  11811. case 1:
  11812. a = content.rock02;
  11813. break;
  11814. case 2:
  11815. a = content.rock03;
  11816. break;
  11817. case 3:
  11818. a = content.rock04;
  11819. break
  11820. }
  11821. if (randFloatRange(0, 1) < 0.5) {
  11822. c.init(a, -200 - randFloatRange(0, 32), -this.gameState.sceneManager.camera.positionY - 512)
  11823. } else {
  11824. c.init(a, 200 + randFloatRange(0, 32), -this.gameState.sceneManager.camera.positionY - 512)
  11825. }
  11826. c.originX = c.sprite.width * 0.5;
  11827. if (randFloatRange(0, 1) < 0.5) {
  11828. c.scaleX = -1
  11829. }
  11830. this.gameState.sceneManager.addEntity(c);
  11831. this.gameState.detritus.push(c)
  11832. }
  11833. }
  11834. };