game.min.js 231 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920
  1. (function (g) {
  2. Number.prototype.map = function (i, j, h, k) {
  3. return h + (k - h) * ((this - i) / (j - i))
  4. };
  5. Number.prototype.limit = function (i, h) {
  6. return Math.min(h, Math.max(i, this))
  7. };
  8. Number.prototype.round = function (h) {
  9. h = Math.pow(10, h || 0);
  10. return Math.round(this * h) / h
  11. };
  12. Number.prototype.floor = function () {
  13. return Math.floor(this)
  14. };
  15. Number.prototype.ceil = function () {
  16. return Math.ceil(this)
  17. };
  18. Number.prototype.toInt = function () {
  19. return (this | 0)
  20. };
  21. Number.prototype.toRad = function () {
  22. return (this / 180) * Math.PI
  23. };
  24. Number.prototype.toDeg = function () {
  25. return (this * 180) / Math.PI
  26. };
  27. Array.prototype.erase = function (j) {
  28. for (var h = this.length; h--;) {
  29. if (this[h] === j) {
  30. this.splice(h, 1)
  31. }
  32. }
  33. return this
  34. };
  35. Array.prototype.random = function () {
  36. return this[Math.floor(Math.random() * this.length)]
  37. };
  38. Function.prototype.bind = Function.prototype.bind || function (h) {
  39. if (typeof this !== "function") {
  40. throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable")
  41. }
  42. var l = Array.prototype.slice.call(arguments, 1),
  43. k = this,
  44. i = function () {},
  45. j = function () {
  46. return k.apply((this instanceof i && h ? this : h), l.concat(Array.prototype.slice.call(arguments)))
  47. };
  48. i.prototype = this.prototype;
  49. j.prototype = new i();
  50. return j
  51. };
  52. g.ig = {
  53. game: null,
  54. debug: null,
  55. version: "1.23",
  56. global: g,
  57. modules: {},
  58. resources: [],
  59. ready: false,
  60. baked: false,
  61. nocache: "",
  62. ua: {},
  63. prefix: (g.ImpactPrefix || ""),
  64. lib: "lib/",
  65. _current: null,
  66. _loadQueue: [],
  67. _waitForOnload: 0,
  68. $: function (h) {
  69. return h.charAt(0) == "#" ? document.getElementById(h.substr(1)) : document.getElementsByTagName(h)
  70. },
  71. $new: function (h) {
  72. return document.createElement(h)
  73. },
  74. copy: function (j) {
  75. if (!j || typeof (j) != "object" || j instanceof HTMLElement || j instanceof ig.Class) {
  76. return j
  77. } else {
  78. if (j instanceof Array) {
  79. var m = [];
  80. for (var k = 0, h = j.length; k < h; k++) {
  81. m[k] = ig.copy(j[k])
  82. }
  83. return m
  84. } else {
  85. var m = {};
  86. for (var k in j) {
  87. m[k] = ig.copy(j[k])
  88. }
  89. return m
  90. }
  91. }
  92. },
  93. merge: function (j, h) {
  94. for (var i in h) {
  95. var k = h[i];
  96. if (typeof (k) != "object" || k instanceof HTMLElement || k instanceof ig.Class || k === null) {
  97. j[i] = k
  98. } else {
  99. if (!j[i] || typeof (j[i]) != "object") {
  100. j[i] = (k instanceof Array) ? [] : {}
  101. }
  102. ig.merge(j[i], k)
  103. }
  104. }
  105. return j
  106. },
  107. ksort: function (l) {
  108. if (!l || typeof (l) != "object") {
  109. return []
  110. }
  111. var k = [],
  112. h = [];
  113. for (var j in l) {
  114. k.push(j)
  115. }
  116. k.sort();
  117. for (var j = 0; j < k.length; j++) {
  118. h.push(l[k[j]])
  119. }
  120. return h
  121. },
  122. setVendorAttribute: function (j, h, k) {
  123. var i = h.charAt(0).toUpperCase() + h.substr(1);
  124. j[h] = j["ms" + i] = j["moz" + i] = j["webkit" + i] = j["o" + i] = k
  125. },
  126. getVendorAttribute: function (j, h) {
  127. var i = h.charAt(0).toUpperCase() + h.substr(1);
  128. return j[h] || j["ms" + i] || j["moz" + i] || j["webkit" + i] || j["o" + i]
  129. },
  130. normalizeVendorAttribute: function (j, h) {
  131. var i = ig.getVendorAttribute(j, h);
  132. if (!j[h] && i) {
  133. j[h] = i
  134. }
  135. },
  136. getImagePixels: function (j, n, m, h, p) {
  137. var i = ig.$new("canvas");
  138. i.width = j.width;
  139. i.height = j.height;
  140. var q = i.getContext("2d");
  141. ig.System.SCALE.CRISP(i, q);
  142. var l = ig.getVendorAttribute(q, "backingStorePixelRatio") || 1;
  143. ig.normalizeVendorAttribute(q, "getImageDataHD");
  144. var o = j.width / l,
  145. k = j.height / l;
  146. i.width = Math.ceil(o);
  147. i.height = Math.ceil(k);
  148. q.drawImage(j, 0, 0, o, k);
  149. return (l === 1) ? q.getImageData(n, m, h, p) : q.getImageDataHD(n, m, h, p)
  150. },
  151. module: function (h) {
  152. if (ig._current) {
  153. throw ("Module '" + ig._current.name + "' defines nothing")
  154. }
  155. if (ig.modules[h] && ig.modules[h].body) {
  156. throw ("Module '" + h + "' is already defined")
  157. }
  158. ig._current = {
  159. name: h,
  160. requires: [],
  161. loaded: false,
  162. body: null
  163. };
  164. ig.modules[h] = ig._current;
  165. ig._loadQueue.push(ig._current);
  166. return ig
  167. },
  168. requires: function () {
  169. ig._current.requires = Array.prototype.slice.call(arguments);
  170. return ig
  171. },
  172. defines: function (h) {
  173. ig._current.body = h;
  174. ig._current = null;
  175. ig._initDOMReady()
  176. },
  177. addResource: function (h) {
  178. ig.resources.push(h)
  179. },
  180. setNocache: function (h) {
  181. ig.nocache = h ? "?" + Date.now() : ""
  182. },
  183. log: function () {},
  184. assert: function (i, h) {},
  185. show: function (h, i) {},
  186. mark: function (i, h) {},
  187. _loadScript: function (j, i) {
  188. ig.modules[j] = {
  189. name: j,
  190. requires: [],
  191. loaded: false,
  192. body: null
  193. };
  194. ig._waitForOnload++;
  195. var k = ig.prefix + ig.lib + j.replace(/\./g, "/") + ".js" + ig.nocache;
  196. var h = ig.$new("script");
  197. h.type = "text/javascript";
  198. h.src = k;
  199. h.onload = function () {
  200. ig._waitForOnload--;
  201. ig._execModules()
  202. };
  203. h.onerror = function () {
  204. throw ("Failed to load module " + j + " at " + k + " required from " + i)
  205. };
  206. ig.$("head")[0].appendChild(h)
  207. },
  208. _execModules: function () {
  209. var k = false;
  210. for (var p = 0; p < ig._loadQueue.length; p++) {
  211. var n = ig._loadQueue[p];
  212. var h = true;
  213. for (var o = 0; o < n.requires.length; o++) {
  214. var l = n.requires[o];
  215. if (!ig.modules[l]) {
  216. h = false;
  217. ig._loadScript(l, n.name)
  218. } else {
  219. if (!ig.modules[l].loaded) {
  220. h = false
  221. }
  222. }
  223. }
  224. if (h && n.body) {
  225. ig._loadQueue.splice(p, 1);
  226. n.loaded = true;
  227. n.body();
  228. k = true;
  229. p--
  230. }
  231. }
  232. if (k) {
  233. ig._execModules()
  234. } else {
  235. if (!ig.baked && ig._waitForOnload == 0 && ig._loadQueue.length != 0) {
  236. var q = [];
  237. for (var p = 0; p < ig._loadQueue.length; p++) {
  238. var s = [];
  239. var r = ig._loadQueue[p].requires;
  240. for (var o = 0; o < r.length; o++) {
  241. var n = ig.modules[r[o]];
  242. if (!n || !n.loaded) {
  243. s.push(r[o])
  244. }
  245. }
  246. q.push(ig._loadQueue[p].name + " (requires: " + s.join(", ") + ")")
  247. }
  248. throw ("Unresolved (or circular?) dependencies. Most likely there's a name/path mismatch for one of the listed modules or a previous syntax error prevents a module from loading:\n" + q.join("\n"))
  249. }
  250. }
  251. },
  252. _DOMReady: function () {
  253. if (!ig.modules["dom.ready"].loaded) {
  254. if (!document.body) {
  255. return setTimeout(ig._DOMReady, 13)
  256. }
  257. ig.modules["dom.ready"].loaded = true;
  258. ig._waitForOnload--;
  259. ig._execModules()
  260. }
  261. return 0
  262. },
  263. _boot: function () {
  264. if (document.location.href.match(/\?nocache/)) {
  265. ig.setNocache(true)
  266. }
  267. ig.ua.pixelRatio = g.devicePixelRatio || 1;
  268. ig.ua.viewport = {
  269. width: g.innerWidth,
  270. height: g.innerHeight
  271. };
  272. ig.ua.screen = {
  273. width: g.screen.availWidth * ig.ua.pixelRatio,
  274. height: g.screen.availHeight * ig.ua.pixelRatio
  275. };
  276. ig.ua.iPhone = /iPhone/i.test(navigator.userAgent);
  277. ig.ua.iPhone4 = (ig.ua.iPhone && ig.ua.pixelRatio == 2);
  278. ig.ua.iPad = /iPad/i.test(navigator.userAgent);
  279. ig.ua.android = /android/i.test(navigator.userAgent);
  280. ig.ua.winPhone = /Windows Phone/i.test(navigator.userAgent);
  281. ig.ua.iOS = ig.ua.iPhone || ig.ua.iPad;
  282. ig.ua.iOS71 = (ig.ua.iOS && (/OS 7_1/i.test(navigator.userAgent) || /OS 71/i.test(navigator.userAgent)));
  283. ig.ua.mobile = ig.ua.iOS || ig.ua.android || ig.ua.winPhone || /mobile/i.test(navigator.userAgent);
  284. ig.ua.touchDevice = (("ontouchstart" in g) || (g.navigator.msMaxTouchPoints))
  285. },
  286. _initDOMReady: function () {
  287. if (ig.modules["dom.ready"]) {
  288. ig._execModules();
  289. return
  290. }
  291. ig._boot();
  292. ig.modules["dom.ready"] = {
  293. requires: [],
  294. loaded: false,
  295. body: null
  296. };
  297. ig._waitForOnload++;
  298. if (document.readyState === "complete") {
  299. ig._DOMReady()
  300. } else {
  301. document.addEventListener("DOMContentLoaded", ig._DOMReady, false);
  302. g.addEventListener("load", ig._DOMReady, false)
  303. }
  304. }
  305. };
  306. ig.normalizeVendorAttribute(g, "requestAnimationFrame");
  307. if (g.requestAnimationFrame) {
  308. var e = 1,
  309. a = {};
  310. g.ig.setAnimation = function (k, i) {
  311. var j = e++;
  312. a[j] = true;
  313. var h = function () {
  314. if (!a[j]) {
  315. return
  316. }
  317. g.requestAnimationFrame(h, i);
  318. k()
  319. };
  320. g.requestAnimationFrame(h, i);
  321. return j
  322. };
  323. g.ig.clearAnimation = function (h) {
  324. delete a[h]
  325. }
  326. } else {
  327. g.ig.setAnimation = function (i, h) {
  328. return g.setInterval(i, 1000 / 60)
  329. };
  330. g.ig.clearAnimation = function (h) {
  331. g.clearInterval(h)
  332. }
  333. }
  334. var c = false,
  335. f = /xyz/.test(function () {
  336. xyz
  337. }) ? /\bparent\b/ : /.*/;
  338. var b = 0;
  339. g.ig.Class = function () {};
  340. var d = function (k) {
  341. var j = this.prototype;
  342. var i = {};
  343. for (var h in k) {
  344. if (typeof (k[h]) == "function" && typeof (j[h]) == "function" && f.test(k[h])) {
  345. i[h] = j[h];
  346. j[h] = (function (l, m) {
  347. return function () {
  348. var o = this.parent;
  349. this.parent = i[l];
  350. var n = m.apply(this, arguments);
  351. this.parent = o;
  352. return n
  353. }
  354. })(h, k[h])
  355. } else {
  356. j[h] = k[h]
  357. }
  358. }
  359. };
  360. g.ig.Class.extend = function (l) {
  361. var k = this.prototype;
  362. c = true;
  363. var j = new this();
  364. c = false;
  365. for (var i in l) {
  366. if (typeof (l[i]) == "function" && typeof (k[i]) == "function" && f.test(l[i])) {
  367. j[i] = (function (m, n) {
  368. return function () {
  369. var p = this.parent;
  370. this.parent = k[m];
  371. var o = n.apply(this, arguments);
  372. this.parent = p;
  373. return o
  374. }
  375. })(i, l[i])
  376. } else {
  377. j[i] = l[i]
  378. }
  379. }
  380. function h() {
  381. if (!c) {
  382. if (this.staticInstantiate) {
  383. var n = this.staticInstantiate.apply(this, arguments);
  384. if (n) {
  385. return n
  386. }
  387. }
  388. for (var m in this) {
  389. if (typeof (this[m]) == "object") {
  390. this[m] = ig.copy(this[m])
  391. }
  392. }
  393. if (this.init) {
  394. this.init.apply(this, arguments)
  395. }
  396. }
  397. return this
  398. }
  399. h.prototype = j;
  400. h.prototype.constructor = h;
  401. h.extend = g.ig.Class.extend;
  402. h.inject = d;
  403. h.classId = j.classId = ++b;
  404. return h
  405. };
  406. if (g.ImpactMixin) {
  407. ig.merge(ig, g.ImpactMixin)
  408. }
  409. })(window);
  410. ig.baked = true;
  411. ig.module("impact.image").defines(function () {
  412. ig.Image = ig.Class.extend({
  413. data: null,
  414. width: 0,
  415. height: 0,
  416. loaded: false,
  417. failed: false,
  418. loadCallback: null,
  419. path: "",
  420. staticInstantiate: function (a) {
  421. return ig.Image.cache[a] || null
  422. },
  423. init: function (a) {
  424. this.path = a;
  425. this.load()
  426. },
  427. load: function (a) {
  428. if (this.loaded) {
  429. if (a) {
  430. a(this.path, true)
  431. }
  432. return
  433. } else {
  434. if (!this.loaded && ig.ready) {
  435. this.loadCallback = a || null;
  436. this.data = new Image();
  437. this.data.onload = this.onload.bind(this);
  438. this.data.onerror = this.onerror.bind(this);
  439. this.data.src = ig.prefix + this.path + ig.nocache
  440. } else {
  441. ig.addResource(this)
  442. }
  443. }
  444. ig.Image.cache[this.path] = this
  445. },
  446. reload: function () {
  447. this.loaded = false;
  448. this.data = new Image();
  449. this.data.onload = this.onload.bind(this);
  450. this.data.src = this.path + "?" + Date.now()
  451. },
  452. onload: function (a) {
  453. this.width = this.data.width;
  454. this.height = this.data.height;
  455. this.loaded = true;
  456. if (ig.system.scale != 1) {
  457. this.resize(ig.system.scale)
  458. }
  459. if (this.loadCallback) {
  460. this.loadCallback(this.path, true)
  461. }
  462. },
  463. onerror: function (a) {
  464. this.failed = true;
  465. if (this.loadCallback) {
  466. this.loadCallback(this.path, false)
  467. }
  468. },
  469. resize: function (b) {
  470. var c = ig.getImagePixels(this.data, 0, 0, this.width, this.height);
  471. var a = this.width * b;
  472. var k = this.height * b;
  473. var d = ig.$new("canvas");
  474. d.width = a;
  475. d.height = k;
  476. var i = d.getContext("2d");
  477. var j = i.getImageData(0, 0, a, k);
  478. for (var g = 0; g < k; g++) {
  479. for (var h = 0; h < a; h++) {
  480. var f = (Math.floor(g / b) * this.width + Math.floor(h / b)) * 4;
  481. var e = (g * a + h) * 4;
  482. j.data[e] = c.data[f];
  483. j.data[e + 1] = c.data[f + 1];
  484. j.data[e + 2] = c.data[f + 2];
  485. j.data[e + 3] = c.data[f + 3]
  486. }
  487. }
  488. i.putImageData(j, 0, 0);
  489. this.data = d
  490. },
  491. draw: function (d, c, f, e, b, a) {
  492. if (!this.loaded) {
  493. return
  494. }
  495. var g = ig.system.scale;
  496. f = f ? f * g : 0;
  497. e = e ? e * g : 0;
  498. b = (b ? b : this.width) * g;
  499. a = (a ? a : this.height) * g;
  500. ig.system.context.drawImage(this.data, f, e, b, a, ig.system.getDrawPos(d), ig.system.getDrawPos(c), b, a);
  501. ig.Image.drawCount++
  502. },
  503. drawTile: function (g, f, d, h, c, l, k) {
  504. c = c ? c : h;
  505. if (!this.loaded || h > this.width || c > this.height) {
  506. return
  507. }
  508. var b = ig.system.scale;
  509. var a = Math.floor(h * b);
  510. var e = Math.floor(c * b);
  511. var j = l ? -1 : 1;
  512. var i = k ? -1 : 1;
  513. if (l || k) {
  514. ig.system.context.save();
  515. ig.system.context.scale(j, i)
  516. }
  517. ig.system.context.drawImage(this.data, (Math.floor(d * h) % this.width) * b, (Math.floor(d * h / this.width) * c) * b, a, e, ig.system.getDrawPos(g) * j - (l ? a : 0), ig.system.getDrawPos(f) * i - (k ? e : 0), a, e);
  518. if (l || k) {
  519. ig.system.context.restore()
  520. }
  521. ig.Image.drawCount++
  522. }
  523. });
  524. ig.Image.drawCount = 0;
  525. ig.Image.cache = {};
  526. ig.Image.reloadCache = function () {
  527. for (var a in ig.Image.cache) {
  528. ig.Image.cache[a].reload()
  529. }
  530. }
  531. });
  532. ig.baked = true;
  533. ig.module("impact.font").requires("impact.image").defines(function () {
  534. ig.Font = ig.Image.extend({
  535. widthMap: [],
  536. indices: [],
  537. firstChar: 32,
  538. alpha: 1,
  539. letterSpacing: 1,
  540. lineSpacing: 0,
  541. onload: function (a) {
  542. this._loadMetrics(this.data);
  543. this.parent(a)
  544. },
  545. widthForString: function (d) {
  546. if (d.indexOf("\n") !== -1) {
  547. var a = d.split("\n");
  548. var c = 0;
  549. for (var b = 0; b < a.length; b++) {
  550. c = Math.max(c, this._widthForLine(a[b]))
  551. }
  552. return c
  553. } else {
  554. return this._widthForLine(d)
  555. }
  556. },
  557. _widthForLine: function (c) {
  558. var b = 0;
  559. for (var a = 0; a < c.length; a++) {
  560. b += this.widthMap[c.charCodeAt(a) - this.firstChar] + this.letterSpacing
  561. }
  562. return b
  563. },
  564. heightForString: function (a) {
  565. return a.split("\n").length * (this.height + this.lineSpacing)
  566. },
  567. draw: function (j, g, f, d) {
  568. if (typeof (j) != "string") {
  569. j = j.toString()
  570. }
  571. if (j.indexOf("\n") !== -1) {
  572. var k = j.split("\n");
  573. var h = this.height + this.lineSpacing;
  574. for (var b = 0; b < k.length; b++) {
  575. this.draw(k[b], g, f + b * h, d)
  576. }
  577. return
  578. }
  579. if (d == ig.Font.ALIGN.RIGHT || d == ig.Font.ALIGN.CENTER) {
  580. var a = this._widthForLine(j);
  581. g -= d == ig.Font.ALIGN.CENTER ? a / 2 : a
  582. }
  583. if (this.alpha !== 1) {
  584. ig.system.context.globalAlpha = this.alpha
  585. }
  586. for (var b = 0; b < j.length; b++) {
  587. var e = j.charCodeAt(b);
  588. g += this._drawChar(e - this.firstChar, g, f)
  589. }
  590. if (this.alpha !== 1) {
  591. ig.system.context.globalAlpha = 1
  592. }
  593. ig.Image.drawCount += j.length
  594. },
  595. _drawChar: function (i, e, d) {
  596. if (!this.loaded || i < 0 || i >= this.indices.length) {
  597. return 0
  598. }
  599. var g = ig.system.scale;
  600. var b = this.indices[i] * g;
  601. var h = 0;
  602. var a = this.widthMap[i] * g;
  603. var f = (this.height - 2) * g;
  604. ig.system.context.drawImage(this.data, b, h, a, f, ig.system.getDrawPos(e), ig.system.getDrawPos(d), a, f);
  605. return this.widthMap[i] + this.letterSpacing
  606. },
  607. _loadMetrics: function (f) {
  608. this.height = f.height - 1;
  609. this.widthMap = [];
  610. this.indices = [];
  611. var e = ig.getImagePixels(f, 0, f.height - 1, f.width, 1);
  612. var b = 0;
  613. var d = 0;
  614. for (var a = 0; a < f.width; a++) {
  615. var c = a * 4 + 3;
  616. if (e.data[c] > 127) {
  617. d++
  618. } else {
  619. if (e.data[c] < 128 && d) {
  620. this.widthMap.push(d);
  621. this.indices.push(a - d);
  622. b++;
  623. d = 0
  624. }
  625. }
  626. }
  627. this.widthMap.push(d);
  628. this.indices.push(a - d)
  629. }
  630. });
  631. ig.Font.ALIGN = {
  632. LEFT: 0,
  633. RIGHT: 1,
  634. CENTER: 2
  635. }
  636. });
  637. ig.baked = true;
  638. ig.module("impact.sound").defines(function () {
  639. ig.SoundManager = ig.Class.extend({
  640. clips: {},
  641. volume: 1,
  642. format: null,
  643. init: function () {
  644. if (!ig.Sound.enabled || !window.Audio) {
  645. ig.Sound.enabled = false;
  646. return
  647. }
  648. var a = new Audio();
  649. for (var b = 0; b < ig.Sound.use.length; b++) {
  650. var c = ig.Sound.use[b];
  651. if (a.canPlayType(c.mime)) {
  652. this.format = c;
  653. break
  654. }
  655. }
  656. if (!this.format) {
  657. ig.Sound.enabled = false
  658. }
  659. if (ig.Sound.enabled && ig.Sound.useWebAudio) {
  660. this.audioContext = new AudioContext()
  661. }
  662. },
  663. load: function (c, b, a) {
  664. if (b && ig.Sound.useWebAudio) {
  665. return this.loadWebAudio(c, b, a)
  666. } else {
  667. return this.loadHTML5Audio(c, b, a)
  668. }
  669. },
  670. loadWebAudio: function (g, f, a) {
  671. var e = ig.prefix + g.replace(/[^\.]+$/, this.format.ext) + ig.nocache;
  672. if (this.clips[g]) {
  673. return this.clips[g]
  674. }
  675. var b = new ig.Sound.WebAudioSource();
  676. this.clips[g] = b;
  677. var d = new XMLHttpRequest();
  678. d.open("GET", e, true);
  679. d.responseType = "arraybuffer";
  680. var c = this;
  681. d.onload = function (h) {
  682. c.audioContext.decodeAudioData(d.response, function (i) {
  683. b.buffer = i;
  684. a(g, true, h)
  685. }, function (i) {
  686. a(g, false, i)
  687. })
  688. };
  689. d.onerror = function (h) {
  690. a(g, false, h)
  691. };
  692. d.send();
  693. return b
  694. },
  695. loadHTML5Audio: function (j, h, d) {
  696. var g = ig.prefix + j.replace(/[^\.]+$/, this.format.ext) + ig.nocache;
  697. if (this.clips[j]) {
  698. if (this.clips[j] instanceof ig.Sound.WebAudioSource) {
  699. return this.clips[j]
  700. }
  701. if (h && this.clips[j].length < ig.Sound.channels) {
  702. for (var e = this.clips[j].length; e < ig.Sound.channels; e++) {
  703. var c = new Audio(g);
  704. c.load();
  705. this.clips[j].push(c)
  706. }
  707. }
  708. return this.clips[j][0]
  709. }
  710. var f = new Audio(g);
  711. if (d) {
  712. f.addEventListener("canplaythrough", function b(a) {
  713. f.removeEventListener("canplaythrough", b, false);
  714. d(j, true, a)
  715. }, false);
  716. f.addEventListener("error", function (a) {
  717. d(j, false, a)
  718. }, false)
  719. }
  720. f.preload = "auto";
  721. f.load();
  722. this.clips[j] = [f];
  723. if (h) {
  724. for (var e = 1; e < ig.Sound.channels; e++) {
  725. var c = new Audio(g);
  726. c.load();
  727. this.clips[j].push(c)
  728. }
  729. }
  730. return f
  731. },
  732. get: function (d) {
  733. var a = this.clips[d];
  734. if (a && a instanceof ig.Sound.WebAudioSource) {
  735. return a
  736. }
  737. for (var b = 0, c; c = a[b++];) {
  738. if (c.paused || c.ended) {
  739. if (c.ended) {
  740. c.currentTime = 0
  741. }
  742. return c
  743. }
  744. }
  745. a[0].pause();
  746. a[0].currentTime = 0;
  747. return a[0]
  748. }
  749. });
  750. ig.Music = ig.Class.extend({
  751. tracks: [],
  752. namedTracks: {},
  753. currentTrack: null,
  754. currentIndex: 0,
  755. random: false,
  756. _volume: 1,
  757. _loop: false,
  758. _fadeInterval: 0,
  759. _fadeTimer: null,
  760. _endedCallbackBound: null,
  761. init: function () {
  762. this._endedCallbackBound = this._endedCallback.bind(this);
  763. Object.defineProperty(this, "volume", {
  764. get: this.getVolume.bind(this),
  765. set: this.setVolume.bind(this)
  766. });
  767. Object.defineProperty(this, "loop", {
  768. get: this.getLooping.bind(this),
  769. set: this.setLooping.bind(this)
  770. })
  771. },
  772. add: function (d, b) {
  773. if (!ig.Sound.enabled) {
  774. return
  775. }
  776. var c = d instanceof ig.Sound ? d.path : d;
  777. var a = ig.soundManager.load(c, false);
  778. if (a instanceof ig.Sound.WebAudioSource) {
  779. ig.system.stopRunLoop();
  780. throw ("Sound '" + c + "' loaded as Multichannel but used for Music. Set the multiChannel param to false when loading, e.g.: new ig.Sound(path, false)")
  781. }
  782. a.loop = this._loop;
  783. a.volume = this._volume;
  784. a.addEventListener("ended", this._endedCallbackBound, false);
  785. this.tracks.push(a);
  786. if (b) {
  787. this.namedTracks[b] = a
  788. }
  789. if (!this.currentTrack) {
  790. this.currentTrack = a
  791. }
  792. },
  793. next: function () {
  794. if (!this.tracks.length) {
  795. return
  796. }
  797. this.stop();
  798. this.currentIndex = this.random ? Math.floor(Math.random() * this.tracks.length) : (this.currentIndex + 1) % this.tracks.length;
  799. this.currentTrack = this.tracks[this.currentIndex];
  800. this.play()
  801. },
  802. pause: function () {
  803. if (!this.currentTrack) {
  804. return
  805. }
  806. this.currentTrack.pause()
  807. },
  808. stop: function () {
  809. if (!this.currentTrack) {
  810. return
  811. }
  812. this.currentTrack.pause();
  813. this.currentTrack.currentTime = 0
  814. },
  815. play: function (b) {
  816. if (b && this.namedTracks[b]) {
  817. var a = this.namedTracks[b];
  818. if (a != this.currentTrack) {
  819. this.stop();
  820. this.currentTrack = a
  821. }
  822. } else {
  823. if (!this.currentTrack) {
  824. return
  825. }
  826. }
  827. this.currentTrack.play()
  828. },
  829. getLooping: function () {
  830. return this._loop
  831. },
  832. setLooping: function (a) {
  833. this._loop = a;
  834. for (var b in this.tracks) {
  835. this.tracks[b].loop = a
  836. }
  837. },
  838. getVolume: function () {
  839. return this._volume
  840. },
  841. setVolume: function (a) {
  842. this._volume = a.limit(0, 1);
  843. for (var b in this.tracks) {
  844. this.tracks[b].volume = this._volume
  845. }
  846. },
  847. fadeOut: function (a) {
  848. if (!this.currentTrack) {
  849. return
  850. }
  851. clearInterval(this._fadeInterval);
  852. this.fadeTimer = new ig.Timer(a);
  853. this._fadeInterval = setInterval(this._fadeStep.bind(this), 50)
  854. },
  855. _fadeStep: function () {
  856. var a = this.fadeTimer.delta().map(-this.fadeTimer.target, 0, 1, 0).limit(0, 1) * this._volume;
  857. if (a <= 0.01) {
  858. this.stop();
  859. this.currentTrack.volume = this._volume;
  860. clearInterval(this._fadeInterval)
  861. } else {
  862. this.currentTrack.volume = a
  863. }
  864. },
  865. _endedCallback: function () {
  866. if (this._loop) {
  867. this.play()
  868. } else {
  869. this.next()
  870. }
  871. }
  872. });
  873. ig.Sound = ig.Class.extend({
  874. path: "",
  875. volume: 1,
  876. currentClip: null,
  877. multiChannel: true,
  878. _loop: false,
  879. init: function (b, a) {
  880. this.path = b;
  881. this.multiChannel = (a !== false);
  882. Object.defineProperty(this, "loop", {
  883. get: this.getLooping.bind(this),
  884. set: this.setLooping.bind(this)
  885. });
  886. this.load()
  887. },
  888. getLooping: function () {
  889. return this._loop
  890. },
  891. setLooping: function (a) {
  892. this._loop = a;
  893. if (this.currentClip) {
  894. this.currentClip.loop = a
  895. }
  896. },
  897. load: function (a) {
  898. if (!ig.Sound.enabled) {
  899. if (a) {
  900. a(this.path, true)
  901. }
  902. return
  903. }
  904. if (ig.ready) {
  905. ig.soundManager.load(this.path, this.multiChannel, a)
  906. } else {
  907. ig.addResource(this)
  908. }
  909. },
  910. play: function () {
  911. if (!ig.Sound.enabled) {
  912. return
  913. }
  914. this.currentClip = ig.soundManager.get(this.path);
  915. this.currentClip.loop = this._loop;
  916. this.currentClip.volume = ig.soundManager.volume * this.volume;
  917. this.currentClip.play()
  918. },
  919. stop: function () {
  920. if (this.currentClip) {
  921. this.currentClip.pause();
  922. this.currentClip.currentTime = 0
  923. }
  924. }
  925. });
  926. ig.Sound.WebAudioSource = ig.Class.extend({
  927. sources: [],
  928. gain: null,
  929. buffer: null,
  930. _loop: false,
  931. init: function () {
  932. this.gain = ig.soundManager.audioContext.createGain();
  933. this.gain.connect(ig.soundManager.audioContext.destination);
  934. Object.defineProperty(this, "loop", {
  935. get: this.getLooping.bind(this),
  936. set: this.setLooping.bind(this)
  937. });
  938. Object.defineProperty(this, "volume", {
  939. get: this.getVolume.bind(this),
  940. set: this.setVolume.bind(this)
  941. })
  942. },
  943. play: function () {
  944. if (!this.buffer) {
  945. return
  946. }
  947. var b = ig.soundManager.audioContext.createBufferSource();
  948. b.buffer = this.buffer;
  949. b.connect(this.gain);
  950. b.loop = this._loop;
  951. var a = this;
  952. this.sources.push(b);
  953. b.onended = function () {
  954. a.sources.erase(b)
  955. };
  956. b.start(0)
  957. },
  958. pause: function () {
  959. for (var a = 0; a < this.sources.length; a++) {
  960. try {
  961. this.sources[a].stop()
  962. } catch (b) {}
  963. }
  964. },
  965. getLooping: function () {
  966. return this._loop
  967. },
  968. setLooping: function (a) {
  969. this._loop = a;
  970. for (var b = 0; b < this.sources.length; b++) {
  971. this.sources[b].loop = a
  972. }
  973. },
  974. getVolume: function () {
  975. return this.gain.gain.value
  976. },
  977. setVolume: function (a) {
  978. this.gain.gain.value = a
  979. }
  980. });
  981. ig.Sound.FORMAT = {
  982. MP3: {
  983. ext: "mp3",
  984. mime: "audio/mpeg"
  985. },
  986. M4A: {
  987. ext: "m4a",
  988. mime: "audio/mp4; codecs=mp4a"
  989. },
  990. OGG: {
  991. ext: "ogg",
  992. mime: "audio/ogg; codecs=vorbis"
  993. },
  994. WEBM: {
  995. ext: "webm",
  996. mime: "audio/webm; codecs=vorbis"
  997. },
  998. CAF: {
  999. ext: "caf",
  1000. mime: "audio/x-caf"
  1001. }
  1002. };
  1003. ig.Sound.use = [ig.Sound.FORMAT.OGG, ig.Sound.FORMAT.MP3];
  1004. ig.Sound.channels = 4;
  1005. ig.Sound.enabled = true;
  1006. ig.normalizeVendorAttribute(window, "AudioContext");
  1007. ig.Sound.useWebAudio = !!window.AudioContext
  1008. });
  1009. ig.baked = true;
  1010. ig.module("impact.loader").requires("impact.image", "impact.font", "impact.sound").defines(function () {
  1011. ig.Loader = ig.Class.extend({
  1012. resources: [],
  1013. gameClass: null,
  1014. status: 0,
  1015. done: false,
  1016. _unloaded: [],
  1017. _drawStatus: 0,
  1018. _intervalId: 0,
  1019. _loadCallbackBound: null,
  1020. init: function (b, c) {
  1021. this.gameClass = b;
  1022. this.resources = c;
  1023. this._loadCallbackBound = this._loadCallback.bind(this);
  1024. for (var a = 0; a < this.resources.length; a++) {
  1025. this._unloaded.push(this.resources[a].path)
  1026. }
  1027. },
  1028. load: function () {
  1029. ig.system.clear("#000");
  1030. if (!this.resources.length) {
  1031. this.end();
  1032. return
  1033. }
  1034. for (var a = 0; a < this.resources.length; a++) {
  1035. this.loadResource(this.resources[a])
  1036. }
  1037. this._intervalId = setInterval(this.draw.bind(this), 16)
  1038. },
  1039. loadResource: function (a) {
  1040. a.load(this._loadCallbackBound)
  1041. },
  1042. end: function () {
  1043. if (this.done) {
  1044. return
  1045. }
  1046. this.done = true;
  1047. clearInterval(this._intervalId);
  1048. ig.system.setGame(this.gameClass)
  1049. },
  1050. draw: function () {
  1051. this._drawStatus += (this.status - this._drawStatus) / 5;
  1052. var d = ig.system.scale;
  1053. var b = ig.system.width * 0.6;
  1054. var c = ig.system.height * 0.1;
  1055. var a = ig.system.width * 0.5 - b / 2;
  1056. var e = ig.system.height * 0.5 - c / 2;
  1057. ig.system.context.fillStyle = "#000";
  1058. ig.system.context.fillRect(0, 0, 480, 320);
  1059. ig.system.context.fillStyle = "#fff";
  1060. ig.system.context.fillRect(a * d, e * d, b * d, c * d);
  1061. ig.system.context.fillStyle = "#000";
  1062. ig.system.context.fillRect(a * d + d, e * d + d, b * d - d - d, c * d - d - d);
  1063. ig.system.context.fillStyle = "#fff";
  1064. ig.system.context.fillRect(a * d, e * d, b * d * this._drawStatus, c * d)
  1065. },
  1066. _loadCallback: function (b, a) {
  1067. if (a) {
  1068. this._unloaded.erase(b)
  1069. } else {
  1070. throw ("Failed to load resource: " + b)
  1071. }
  1072. this.status = 1 - (this._unloaded.length / this.resources.length);
  1073. if (this._unloaded.length == 0) {
  1074. setTimeout(this.end.bind(this), 250)
  1075. }
  1076. }
  1077. })
  1078. });
  1079. ig.baked = true;
  1080. ig.module("impact.timer").defines(function () {
  1081. ig.Timer = ig.Class.extend({
  1082. target: 0,
  1083. base: 0,
  1084. last: 0,
  1085. pausedAt: 0,
  1086. init: function (a) {
  1087. this.base = ig.Timer.time;
  1088. this.last = ig.Timer.time;
  1089. this.target = a || 0
  1090. },
  1091. set: function (a) {
  1092. this.target = a || 0;
  1093. this.base = ig.Timer.time;
  1094. this.pausedAt = 0
  1095. },
  1096. reset: function () {
  1097. this.base = ig.Timer.time;
  1098. this.pausedAt = 0
  1099. },
  1100. tick: function () {
  1101. var a = ig.Timer.time - this.last;
  1102. this.last = ig.Timer.time;
  1103. return (this.pausedAt ? 0 : a)
  1104. },
  1105. delta: function () {
  1106. return (this.pausedAt || ig.Timer.time) - this.base - this.target
  1107. },
  1108. pause: function () {
  1109. if (!this.pausedAt) {
  1110. this.pausedAt = ig.Timer.time
  1111. }
  1112. },
  1113. unpause: function () {
  1114. if (this.pausedAt) {
  1115. this.base += ig.Timer.time - this.pausedAt;
  1116. this.pausedAt = 0
  1117. }
  1118. }
  1119. });
  1120. ig.Timer._last = 0;
  1121. ig.Timer.time = Number.MIN_VALUE;
  1122. ig.Timer.timeScale = 1;
  1123. ig.Timer.maxStep = 0.05;
  1124. ig.Timer.step = function () {
  1125. var a = Date.now();
  1126. var b = (a - ig.Timer._last) / 1000;
  1127. ig.Timer.time += Math.min(b, ig.Timer.maxStep) * ig.Timer.timeScale;
  1128. ig.Timer._last = a
  1129. }
  1130. });
  1131. ig.baked = true;
  1132. ig.module("impact.system").requires("impact.timer", "impact.image").defines(function () {
  1133. ig.System = ig.Class.extend({
  1134. fps: 30,
  1135. width: 320,
  1136. height: 240,
  1137. realWidth: 320,
  1138. realHeight: 240,
  1139. scale: 1,
  1140. tick: 0,
  1141. animationId: 0,
  1142. newGameClass: null,
  1143. running: false,
  1144. delegate: null,
  1145. clock: null,
  1146. canvas: null,
  1147. context: null,
  1148. init: function (e, c, b, a, d) {
  1149. this.fps = c;
  1150. this.clock = new ig.Timer();
  1151. this.canvas = ig.$(e);
  1152. this.resize(b, a, d);
  1153. this.context = this.canvas.getContext("2d");
  1154. this.getDrawPos = ig.System.drawMode;
  1155. if (this.scale != 1) {
  1156. ig.System.scaleMode = ig.System.SCALE.CRISP
  1157. }
  1158. ig.System.scaleMode(this.canvas, this.context)
  1159. },
  1160. resize: function (b, a, c) {
  1161. this.width = b;
  1162. this.height = a;
  1163. this.scale = c || this.scale;
  1164. this.realWidth = this.width * this.scale;
  1165. this.realHeight = this.height * this.scale;
  1166. this.canvas.width = this.realWidth;
  1167. this.canvas.height = this.realHeight
  1168. },
  1169. setGame: function (a) {
  1170. if (this.running) {
  1171. this.newGameClass = a
  1172. } else {
  1173. this.setGameNow(a)
  1174. }
  1175. },
  1176. setGameNow: function (a) {
  1177. ig.game = new(a)();
  1178. ig.system.setDelegate(ig.game)
  1179. },
  1180. setDelegate: function (a) {
  1181. if (typeof (a.run) == "function") {
  1182. this.delegate = a;
  1183. this.startRunLoop()
  1184. } else {
  1185. throw ("System.setDelegate: No run() function in object")
  1186. }
  1187. },
  1188. stopRunLoop: function () {
  1189. ig.clearAnimation(this.animationId);
  1190. this.running = false
  1191. },
  1192. startRunLoop: function () {
  1193. this.stopRunLoop();
  1194. this.animationId = ig.setAnimation(this.run.bind(this), this.canvas);
  1195. this.running = true
  1196. },
  1197. clear: function (a) {
  1198. this.context.fillStyle = a;
  1199. this.context.fillRect(0, 0, this.realWidth, this.realHeight)
  1200. },
  1201. run: function () {
  1202. ig.Timer.step();
  1203. this.tick = this.clock.tick();
  1204. this.delegate.run();
  1205. ig.input.clearPressed();
  1206. if (this.newGameClass) {
  1207. this.setGameNow(this.newGameClass);
  1208. this.newGameClass = null
  1209. }
  1210. },
  1211. getDrawPos: null
  1212. });
  1213. ig.System.DRAW = {
  1214. AUTHENTIC: function (a) {
  1215. return Math.round(a) * this.scale
  1216. },
  1217. SMOOTH: function (a) {
  1218. return Math.round(a * this.scale)
  1219. },
  1220. SUBPIXEL: function (a) {
  1221. return a * this.scale
  1222. }
  1223. };
  1224. ig.System.drawMode = ig.System.DRAW.SMOOTH;
  1225. ig.System.SCALE = {
  1226. CRISP: function (a, b) {
  1227. ig.setVendorAttribute(b, "imageSmoothingEnabled", false);
  1228. a.style.imageRendering = "-moz-crisp-edges";
  1229. a.style.imageRendering = "-o-crisp-edges";
  1230. a.style.imageRendering = "-webkit-optimize-contrast";
  1231. a.style.imageRendering = "crisp-edges";
  1232. a.style.msInterpolationMode = "nearest-neighbor"
  1233. },
  1234. SMOOTH: function (a, b) {
  1235. ig.setVendorAttribute(b, "imageSmoothingEnabled", true);
  1236. a.style.imageRendering = "";
  1237. a.style.msInterpolationMode = ""
  1238. }
  1239. };
  1240. ig.System.scaleMode = ig.System.SCALE.SMOOTH
  1241. });
  1242. ig.baked = true;
  1243. ig.module("impact.input").defines(function () {
  1244. ig.KEY = {
  1245. MOUSE1: -1,
  1246. MOUSE2: -3,
  1247. MWHEEL_UP: -4,
  1248. MWHEEL_DOWN: -5,
  1249. BACKSPACE: 8,
  1250. TAB: 9,
  1251. ENTER: 13,
  1252. PAUSE: 19,
  1253. CAPS: 20,
  1254. ESC: 27,
  1255. SPACE: 32,
  1256. PAGE_UP: 33,
  1257. PAGE_DOWN: 34,
  1258. END: 35,
  1259. HOME: 36,
  1260. LEFT_ARROW: 37,
  1261. UP_ARROW: 38,
  1262. RIGHT_ARROW: 39,
  1263. DOWN_ARROW: 40,
  1264. INSERT: 45,
  1265. DELETE: 46,
  1266. _0: 48,
  1267. _1: 49,
  1268. _2: 50,
  1269. _3: 51,
  1270. _4: 52,
  1271. _5: 53,
  1272. _6: 54,
  1273. _7: 55,
  1274. _8: 56,
  1275. _9: 57,
  1276. A: 65,
  1277. B: 66,
  1278. C: 67,
  1279. D: 68,
  1280. E: 69,
  1281. F: 70,
  1282. G: 71,
  1283. H: 72,
  1284. I: 73,
  1285. J: 74,
  1286. K: 75,
  1287. L: 76,
  1288. M: 77,
  1289. N: 78,
  1290. O: 79,
  1291. P: 80,
  1292. Q: 81,
  1293. R: 82,
  1294. S: 83,
  1295. T: 84,
  1296. U: 85,
  1297. V: 86,
  1298. W: 87,
  1299. X: 88,
  1300. Y: 89,
  1301. Z: 90,
  1302. NUMPAD_0: 96,
  1303. NUMPAD_1: 97,
  1304. NUMPAD_2: 98,
  1305. NUMPAD_3: 99,
  1306. NUMPAD_4: 100,
  1307. NUMPAD_5: 101,
  1308. NUMPAD_6: 102,
  1309. NUMPAD_7: 103,
  1310. NUMPAD_8: 104,
  1311. NUMPAD_9: 105,
  1312. MULTIPLY: 106,
  1313. ADD: 107,
  1314. SUBSTRACT: 109,
  1315. DECIMAL: 110,
  1316. DIVIDE: 111,
  1317. F1: 112,
  1318. F2: 113,
  1319. F3: 114,
  1320. F4: 115,
  1321. F5: 116,
  1322. F6: 117,
  1323. F7: 118,
  1324. F8: 119,
  1325. F9: 120,
  1326. F10: 121,
  1327. F11: 122,
  1328. F12: 123,
  1329. SHIFT: 16,
  1330. CTRL: 17,
  1331. ALT: 18,
  1332. PLUS: 187,
  1333. COMMA: 188,
  1334. MINUS: 189,
  1335. PERIOD: 190
  1336. };
  1337. ig.Input = ig.Class.extend({
  1338. bindings: {},
  1339. actions: {},
  1340. presses: {},
  1341. locks: {},
  1342. delayedKeyup: {},
  1343. isUsingMouse: false,
  1344. isUsingKeyboard: false,
  1345. isUsingAccelerometer: false,
  1346. mouse: {
  1347. x: 0,
  1348. y: 0
  1349. },
  1350. accel: {
  1351. x: 0,
  1352. y: 0,
  1353. z: 0
  1354. },
  1355. initMouse: function () {
  1356. if (this.isUsingMouse) {
  1357. return
  1358. }
  1359. this.isUsingMouse = true;
  1360. var a = this.mousewheel.bind(this);
  1361. ig.system.canvas.addEventListener("mousewheel", a, false);
  1362. ig.system.canvas.addEventListener("DOMMouseScroll", a, false);
  1363. ig.system.canvas.addEventListener("contextmenu", this.contextmenu.bind(this), false);
  1364. ig.system.canvas.addEventListener("mousedown", this.keydown.bind(this), false);
  1365. ig.system.canvas.addEventListener("mouseup", this.keyup.bind(this), false);
  1366. ig.system.canvas.addEventListener("mousemove", this.mousemove.bind(this), false);
  1367. if (ig.ua.touchDevice) {
  1368. ig.system.canvas.addEventListener("touchstart", this.keydown.bind(this), false);
  1369. ig.system.canvas.addEventListener("touchend", this.keyup.bind(this), false);
  1370. ig.system.canvas.addEventListener("touchmove", this.mousemove.bind(this), false);
  1371. ig.system.canvas.addEventListener("MSPointerDown", this.keydown.bind(this), false);
  1372. ig.system.canvas.addEventListener("MSPointerUp", this.keyup.bind(this), false);
  1373. ig.system.canvas.addEventListener("MSPointerMove", this.mousemove.bind(this), false);
  1374. ig.system.canvas.style.msTouchAction = "none"
  1375. }
  1376. },
  1377. initKeyboard: function () {
  1378. if (this.isUsingKeyboard) {
  1379. return
  1380. }
  1381. this.isUsingKeyboard = true;
  1382. window.addEventListener("keydown", this.keydown.bind(this), false);
  1383. window.addEventListener("keyup", this.keyup.bind(this), false)
  1384. },
  1385. initAccelerometer: function () {
  1386. if (this.isUsingAccelerometer) {
  1387. return
  1388. }
  1389. window.addEventListener("devicemotion", this.devicemotion.bind(this), false)
  1390. },
  1391. mousewheel: function (b) {
  1392. var d = b.wheelDelta ? b.wheelDelta : (b.detail * -1);
  1393. var a = d > 0 ? ig.KEY.MWHEEL_UP : ig.KEY.MWHEEL_DOWN;
  1394. var c = this.bindings[a];
  1395. if (c) {
  1396. this.actions[c] = true;
  1397. this.presses[c] = true;
  1398. this.delayedKeyup[c] = true;
  1399. b.stopPropagation();
  1400. b.preventDefault()
  1401. }
  1402. },
  1403. mousemove: function (c) {
  1404. var a = parseInt(ig.system.canvas.offsetWidth) || ig.system.realWidth;
  1405. var d = ig.system.scale * (a / ig.system.realWidth);
  1406. var e = {
  1407. left: 0,
  1408. top: 0
  1409. };
  1410. if (ig.system.canvas.getBoundingClientRect) {
  1411. e = ig.system.canvas.getBoundingClientRect()
  1412. }
  1413. var b = c.touches ? c.touches[0] : c;
  1414. this.mouse.x = (b.clientX - e.left) / d;
  1415. this.mouse.y = (b.clientY - e.top) / d
  1416. },
  1417. contextmenu: function (a) {
  1418. if (this.bindings[ig.KEY.MOUSE2]) {
  1419. a.stopPropagation();
  1420. a.preventDefault()
  1421. }
  1422. },
  1423. keydown: function (c) {
  1424. var a = c.target.tagName;
  1425. if (a == "INPUT" || a == "TEXTAREA") {
  1426. return
  1427. }
  1428. var b = c.type == "keydown" ? c.keyCode : (c.button == 2 ? ig.KEY.MOUSE2 : ig.KEY.MOUSE1);
  1429. if (c.type == "touchstart" || c.type == "mousedown") {
  1430. this.mousemove(c)
  1431. }
  1432. var d = this.bindings[b];
  1433. if (d) {
  1434. this.actions[d] = true;
  1435. if (!this.locks[d]) {
  1436. this.presses[d] = true;
  1437. this.locks[d] = true
  1438. }
  1439. c.stopPropagation();
  1440. c.preventDefault()
  1441. }
  1442. },
  1443. keyup: function (c) {
  1444. var a = c.target.tagName;
  1445. if (a == "INPUT" || a == "TEXTAREA") {
  1446. return
  1447. }
  1448. var b = c.type == "keyup" ? c.keyCode : (c.button == 2 ? ig.KEY.MOUSE2 : ig.KEY.MOUSE1);
  1449. var d = this.bindings[b];
  1450. if (d) {
  1451. this.delayedKeyup[d] = true;
  1452. c.stopPropagation();
  1453. c.preventDefault()
  1454. }
  1455. },
  1456. devicemotion: function (a) {
  1457. this.accel = a.accelerationIncludingGravity
  1458. },
  1459. bind: function (a, b) {
  1460. if (a < 0) {
  1461. this.initMouse()
  1462. } else {
  1463. if (a > 0) {
  1464. this.initKeyboard()
  1465. }
  1466. }
  1467. this.bindings[a] = b
  1468. },
  1469. bindTouch: function (a, d) {
  1470. var b = ig.$(a);
  1471. var c = this;
  1472. b.addEventListener("touchstart", function (e) {
  1473. c.touchStart(e, d)
  1474. }, false);
  1475. b.addEventListener("touchend", function (e) {
  1476. c.touchEnd(e, d)
  1477. }, false);
  1478. b.addEventListener("MSPointerDown", function (e) {
  1479. c.touchStart(e, d)
  1480. }, false);
  1481. b.addEventListener("MSPointerUp", function (e) {
  1482. c.touchEnd(e, d)
  1483. }, false)
  1484. },
  1485. unbind: function (a) {
  1486. var b = this.bindings[a];
  1487. this.delayedKeyup[b] = true;
  1488. this.bindings[a] = null
  1489. },
  1490. unbindAll: function () {
  1491. this.bindings = {};
  1492. this.actions = {};
  1493. this.presses = {};
  1494. this.locks = {};
  1495. this.delayedKeyup = {}
  1496. },
  1497. state: function (a) {
  1498. return this.actions[a]
  1499. },
  1500. pressed: function (a) {
  1501. return this.presses[a]
  1502. },
  1503. released: function (a) {
  1504. return !!this.delayedKeyup[a]
  1505. },
  1506. clearPressed: function () {
  1507. for (var a in this.delayedKeyup) {
  1508. this.actions[a] = false;
  1509. this.locks[a] = false
  1510. }
  1511. this.delayedKeyup = {};
  1512. this.presses = {}
  1513. },
  1514. touchStart: function (a, b) {
  1515. this.actions[b] = true;
  1516. this.presses[b] = true;
  1517. a.stopPropagation();
  1518. a.preventDefault();
  1519. return false
  1520. },
  1521. touchEnd: function (a, b) {
  1522. this.delayedKeyup[b] = true;
  1523. a.stopPropagation();
  1524. a.preventDefault();
  1525. return false
  1526. }
  1527. })
  1528. });
  1529. ig.baked = true;
  1530. ig.module("impact.impact").requires("dom.ready", "impact.loader", "impact.system", "impact.input", "impact.sound").defines(function () {
  1531. ig.main = function (h, e, f, d, b, g, c) {
  1532. ig.system = new ig.System(h, f, d, b, g || 1);
  1533. ig.input = new ig.Input();
  1534. ig.soundManager = new ig.SoundManager();
  1535. ig.music = new ig.Music();
  1536. ig.ready = true;
  1537. var a = new(c || ig.Loader)(e, ig.resources);
  1538. a.load()
  1539. }
  1540. });
  1541. ig.baked = true;
  1542. ig.module("impact.animation").requires("impact.timer", "impact.image").defines(function () {
  1543. ig.AnimationSheet = ig.Class.extend({
  1544. width: 8,
  1545. height: 8,
  1546. image: null,
  1547. init: function (c, b, a) {
  1548. this.width = b;
  1549. this.height = a;
  1550. this.image = new ig.Image(c)
  1551. }
  1552. });
  1553. ig.Animation = ig.Class.extend({
  1554. sheet: null,
  1555. timer: null,
  1556. sequence: [],
  1557. flip: {
  1558. x: false,
  1559. y: false
  1560. },
  1561. pivot: {
  1562. x: 0,
  1563. y: 0
  1564. },
  1565. frame: 0,
  1566. tile: 0,
  1567. loopCount: 0,
  1568. alpha: 1,
  1569. angle: 0,
  1570. init: function (b, c, d, a) {
  1571. this.sheet = b;
  1572. this.pivot = {
  1573. x: b.width / 2,
  1574. y: b.height / 2
  1575. };
  1576. this.timer = new ig.Timer();
  1577. this.frameTime = c;
  1578. this.sequence = d;
  1579. this.stop = !!a;
  1580. this.tile = this.sequence[0]
  1581. },
  1582. rewind: function () {
  1583. this.timer.set();
  1584. this.loopCount = 0;
  1585. this.frame = 0;
  1586. this.tile = this.sequence[0];
  1587. return this
  1588. },
  1589. gotoFrame: function (a) {
  1590. this.timer.set(this.frameTime * -a - 0.0001);
  1591. this.update()
  1592. },
  1593. gotoRandomFrame: function () {
  1594. this.gotoFrame(Math.floor(Math.random() * this.sequence.length))
  1595. },
  1596. update: function () {
  1597. var a = Math.floor(this.timer.delta() / this.frameTime);
  1598. this.loopCount = Math.floor(a / this.sequence.length);
  1599. if (this.stop && this.loopCount > 0) {
  1600. this.frame = this.sequence.length - 1
  1601. } else {
  1602. this.frame = a % this.sequence.length
  1603. }
  1604. this.tile = this.sequence[this.frame]
  1605. },
  1606. draw: function (c, b) {
  1607. var a = Math.max(this.sheet.width, this.sheet.height);
  1608. if (c > ig.system.width || b > ig.system.height || c + a < 0 || b + a < 0) {
  1609. return
  1610. }
  1611. if (this.alpha != 1) {
  1612. ig.system.context.globalAlpha = this.alpha
  1613. }
  1614. if (this.angle == 0) {
  1615. this.sheet.image.drawTile(c, b, this.tile, this.sheet.width, this.sheet.height, this.flip.x, this.flip.y)
  1616. } else {
  1617. ig.system.context.save();
  1618. ig.system.context.translate(ig.system.getDrawPos(c + this.pivot.x), ig.system.getDrawPos(b + this.pivot.y));
  1619. ig.system.context.rotate(this.angle);
  1620. this.sheet.image.drawTile(-this.pivot.x, -this.pivot.y, this.tile, this.sheet.width, this.sheet.height, this.flip.x, this.flip.y);
  1621. ig.system.context.restore()
  1622. } if (this.alpha != 1) {
  1623. ig.system.context.globalAlpha = 1
  1624. }
  1625. }
  1626. })
  1627. });
  1628. ig.baked = true;
  1629. ig.module("impact.entity").requires("impact.animation", "impact.impact").defines(function () {
  1630. ig.Entity = ig.Class.extend({
  1631. id: 0,
  1632. settings: {},
  1633. size: {
  1634. x: 16,
  1635. y: 16
  1636. },
  1637. offset: {
  1638. x: 0,
  1639. y: 0
  1640. },
  1641. pos: {
  1642. x: 0,
  1643. y: 0
  1644. },
  1645. last: {
  1646. x: 0,
  1647. y: 0
  1648. },
  1649. vel: {
  1650. x: 0,
  1651. y: 0
  1652. },
  1653. accel: {
  1654. x: 0,
  1655. y: 0
  1656. },
  1657. friction: {
  1658. x: 0,
  1659. y: 0
  1660. },
  1661. maxVel: {
  1662. x: 100,
  1663. y: 100
  1664. },
  1665. zIndex: 0,
  1666. gravityFactor: 1,
  1667. standing: false,
  1668. bounciness: 0,
  1669. minBounceVelocity: 40,
  1670. anims: {},
  1671. animSheet: null,
  1672. currentAnim: null,
  1673. health: 10,
  1674. type: 0,
  1675. checkAgainst: 0,
  1676. collides: 0,
  1677. _killed: false,
  1678. slopeStanding: {
  1679. min: (44).toRad(),
  1680. max: (136).toRad()
  1681. },
  1682. init: function (a, c, b) {
  1683. this.id = ++ig.Entity._lastId;
  1684. this.pos.x = this.last.x = a;
  1685. this.pos.y = this.last.y = c;
  1686. ig.merge(this, b)
  1687. },
  1688. reset: function (a, d, b) {
  1689. var c = this.constructor.prototype;
  1690. this.pos.x = a;
  1691. this.pos.y = d;
  1692. this.last.x = a;
  1693. this.last.y = d;
  1694. this.vel.x = c.vel.x;
  1695. this.vel.y = c.vel.y;
  1696. this.accel.x = c.accel.x;
  1697. this.accel.y = c.accel.y;
  1698. this.health = c.health;
  1699. this._killed = c._killed;
  1700. this.standing = c.standing;
  1701. this.type = c.type;
  1702. this.checkAgainst = c.checkAgainst;
  1703. this.collides = c.collides;
  1704. ig.merge(this, b)
  1705. },
  1706. addAnim: function (c, e, f, d) {
  1707. if (!this.animSheet) {
  1708. throw ("No animSheet to add the animation " + c + " to.")
  1709. }
  1710. var b = new ig.Animation(this.animSheet, e, f, d);
  1711. this.anims[c] = b;
  1712. if (!this.currentAnim) {
  1713. this.currentAnim = b
  1714. }
  1715. return b
  1716. },
  1717. update: function () {
  1718. this.last.x = this.pos.x;
  1719. this.last.y = this.pos.y;
  1720. this.vel.y += ig.game.gravity * ig.system.tick * this.gravityFactor;
  1721. this.vel.x = this.getNewVelocity(this.vel.x, this.accel.x, this.friction.x, this.maxVel.x);
  1722. this.vel.y = this.getNewVelocity(this.vel.y, this.accel.y, this.friction.y, this.maxVel.y);
  1723. var c = this.vel.x * ig.system.tick;
  1724. var b = this.vel.y * ig.system.tick;
  1725. var a = ig.game.collisionMap.trace(this.pos.x, this.pos.y, c, b, this.size.x, this.size.y);
  1726. this.handleMovementTrace(a);
  1727. if (this.currentAnim) {
  1728. this.currentAnim.update()
  1729. }
  1730. },
  1731. getNewVelocity: function (c, b, d, a) {
  1732. if (b) {
  1733. return (c + b * ig.system.tick).limit(-a, a)
  1734. } else {
  1735. if (d) {
  1736. var e = d * ig.system.tick;
  1737. if (c - e > 0) {
  1738. return c - e
  1739. } else {
  1740. if (c + e < 0) {
  1741. return c + e
  1742. } else {
  1743. return 0
  1744. }
  1745. }
  1746. }
  1747. }
  1748. return c.limit(-a, a)
  1749. },
  1750. handleMovementTrace: function (c) {
  1751. this.standing = false;
  1752. if (c.collision.y) {
  1753. if (this.bounciness > 0 && Math.abs(this.vel.y) > this.minBounceVelocity) {
  1754. this.vel.y *= -this.bounciness
  1755. } else {
  1756. if (this.vel.y > 0) {
  1757. this.standing = true
  1758. }
  1759. this.vel.y = 0
  1760. }
  1761. }
  1762. if (c.collision.x) {
  1763. if (this.bounciness > 0 && Math.abs(this.vel.x) > this.minBounceVelocity) {
  1764. this.vel.x *= -this.bounciness
  1765. } else {
  1766. this.vel.x = 0
  1767. }
  1768. }
  1769. if (c.collision.slope) {
  1770. var e = c.collision.slope;
  1771. if (this.bounciness > 0) {
  1772. var d = this.vel.x * e.nx + this.vel.y * e.ny;
  1773. this.vel.x = (this.vel.x - e.nx * d * 2) * this.bounciness;
  1774. this.vel.y = (this.vel.y - e.ny * d * 2) * this.bounciness
  1775. } else {
  1776. var b = e.x * e.x + e.y * e.y;
  1777. var a = (this.vel.x * e.x + this.vel.y * e.y) / b;
  1778. this.vel.x = e.x * a;
  1779. this.vel.y = e.y * a;
  1780. var f = Math.atan2(e.x, e.y);
  1781. if (f > this.slopeStanding.min && f < this.slopeStanding.max) {
  1782. this.standing = true
  1783. }
  1784. }
  1785. }
  1786. this.pos = c.pos
  1787. },
  1788. draw: function () {
  1789. if (this.currentAnim) {
  1790. this.currentAnim.draw(this.pos.x - this.offset.x - ig.game._rscreen.x, this.pos.y - this.offset.y - ig.game._rscreen.y)
  1791. }
  1792. },
  1793. kill: function () {
  1794. ig.game.removeEntity(this)
  1795. },
  1796. receiveDamage: function (a, b) {
  1797. this.health -= a;
  1798. if (this.health <= 0) {
  1799. this.kill()
  1800. }
  1801. },
  1802. touches: function (a) {
  1803. return !(this.pos.x >= a.pos.x + a.size.x || this.pos.x + this.size.x <= a.pos.x || this.pos.y >= a.pos.y + a.size.y || this.pos.y + this.size.y <= a.pos.y)
  1804. },
  1805. distanceTo: function (a) {
  1806. var b = (this.pos.x + this.size.x / 2) - (a.pos.x + a.size.x / 2);
  1807. var c = (this.pos.y + this.size.y / 2) - (a.pos.y + a.size.y / 2);
  1808. return Math.sqrt(b * b + c * c)
  1809. },
  1810. angleTo: function (a) {
  1811. return Math.atan2((a.pos.y + a.size.y / 2) - (this.pos.y + this.size.y / 2), (a.pos.x + a.size.x / 2) - (this.pos.x + this.size.x / 2))
  1812. },
  1813. check: function (a) {},
  1814. collideWith: function (a, b) {},
  1815. ready: function () {},
  1816. erase: function () {}
  1817. });
  1818. ig.Entity._lastId = 0;
  1819. ig.Entity.COLLIDES = {
  1820. NEVER: 0,
  1821. LITE: 1,
  1822. PASSIVE: 2,
  1823. ACTIVE: 4,
  1824. FIXED: 8
  1825. };
  1826. ig.Entity.TYPE = {
  1827. NONE: 0,
  1828. A: 1,
  1829. B: 2,
  1830. BOTH: 3
  1831. };
  1832. ig.Entity.checkPair = function (d, c) {
  1833. if (d.checkAgainst & c.type) {
  1834. d.check(c)
  1835. }
  1836. if (c.checkAgainst & d.type) {
  1837. c.check(d)
  1838. }
  1839. if (d.collides && c.collides && d.collides + c.collides > ig.Entity.COLLIDES.ACTIVE) {
  1840. ig.Entity.solveCollision(d, c)
  1841. }
  1842. };
  1843. ig.Entity.solveCollision = function (d, c) {
  1844. var e = null;
  1845. if (d.collides == ig.Entity.COLLIDES.LITE || c.collides == ig.Entity.COLLIDES.FIXED) {
  1846. e = d
  1847. } else {
  1848. if (c.collides == ig.Entity.COLLIDES.LITE || d.collides == ig.Entity.COLLIDES.FIXED) {
  1849. e = c
  1850. }
  1851. } if (d.last.x + d.size.x > c.last.x && d.last.x < c.last.x + c.size.x) {
  1852. if (d.last.y < c.last.y) {
  1853. ig.Entity.seperateOnYAxis(d, c, e)
  1854. } else {
  1855. ig.Entity.seperateOnYAxis(c, d, e)
  1856. }
  1857. d.collideWith(c, "y");
  1858. c.collideWith(d, "y")
  1859. } else {
  1860. if (d.last.y + d.size.y > c.last.y && d.last.y < c.last.y + c.size.y) {
  1861. if (d.last.x < c.last.x) {
  1862. ig.Entity.seperateOnXAxis(d, c, e)
  1863. } else {
  1864. ig.Entity.seperateOnXAxis(c, d, e)
  1865. }
  1866. d.collideWith(c, "x");
  1867. c.collideWith(d, "x")
  1868. }
  1869. }
  1870. };
  1871. ig.Entity.seperateOnXAxis = function (b, i, e) {
  1872. var d = (b.pos.x + b.size.x - i.pos.x);
  1873. if (e) {
  1874. var h = b === e ? i : b;
  1875. e.vel.x = -e.vel.x * e.bounciness + h.vel.x;
  1876. var f = ig.game.collisionMap.trace(e.pos.x, e.pos.y, e == b ? -d : d, 0, e.size.x, e.size.y);
  1877. e.pos.x = f.pos.x
  1878. } else {
  1879. var g = (b.vel.x - i.vel.x) / 2;
  1880. b.vel.x = -g;
  1881. i.vel.x = g;
  1882. var c = ig.game.collisionMap.trace(b.pos.x, b.pos.y, -d / 2, 0, b.size.x, b.size.y);
  1883. b.pos.x = Math.floor(c.pos.x);
  1884. var a = ig.game.collisionMap.trace(i.pos.x, i.pos.y, d / 2, 0, i.size.x, i.size.y);
  1885. i.pos.x = Math.ceil(a.pos.x)
  1886. }
  1887. };
  1888. ig.Entity.seperateOnYAxis = function (f, a, c) {
  1889. var b = (f.pos.y + f.size.y - a.pos.y);
  1890. if (c) {
  1891. var h = f === c ? a : f;
  1892. c.vel.y = -c.vel.y * c.bounciness + h.vel.y;
  1893. var i = 0;
  1894. if (c == f && Math.abs(c.vel.y - h.vel.y) < c.minBounceVelocity) {
  1895. c.standing = true;
  1896. i = h.vel.x * ig.system.tick
  1897. }
  1898. var d = ig.game.collisionMap.trace(c.pos.x, c.pos.y, i, c == f ? -b : b, c.size.x, c.size.y);
  1899. c.pos.y = d.pos.y;
  1900. c.pos.x = d.pos.x
  1901. } else {
  1902. if (ig.game.gravity && (a.standing || f.vel.y > 0)) {
  1903. var j = ig.game.collisionMap.trace(f.pos.x, f.pos.y, 0, -(f.pos.y + f.size.y - a.pos.y), f.size.x, f.size.y);
  1904. f.pos.y = j.pos.y;
  1905. if (f.bounciness > 0 && f.vel.y > f.minBounceVelocity) {
  1906. f.vel.y *= -f.bounciness
  1907. } else {
  1908. f.standing = true;
  1909. f.vel.y = 0
  1910. }
  1911. } else {
  1912. var g = (f.vel.y - a.vel.y) / 2;
  1913. f.vel.y = -g;
  1914. a.vel.y = g;
  1915. var i = a.vel.x * ig.system.tick;
  1916. var j = ig.game.collisionMap.trace(f.pos.x, f.pos.y, i, -b / 2, f.size.x, f.size.y);
  1917. f.pos.y = j.pos.y;
  1918. var e = ig.game.collisionMap.trace(a.pos.x, a.pos.y, 0, b / 2, a.size.x, a.size.y);
  1919. a.pos.y = e.pos.y
  1920. }
  1921. }
  1922. }
  1923. });
  1924. ig.baked = true;
  1925. ig.module("impact.map").defines(function () {
  1926. ig.Map = ig.Class.extend({
  1927. tilesize: 8,
  1928. width: 1,
  1929. height: 1,
  1930. data: [
  1931. []
  1932. ],
  1933. name: null,
  1934. init: function (b, a) {
  1935. this.tilesize = b;
  1936. this.data = a;
  1937. this.height = a.length;
  1938. this.width = a[0].length;
  1939. this.pxWidth = this.width * this.tilesize;
  1940. this.pxHeight = this.height * this.tilesize
  1941. },
  1942. getTile: function (b, d) {
  1943. var c = Math.floor(b / this.tilesize);
  1944. var a = Math.floor(d / this.tilesize);
  1945. if ((c >= 0 && c < this.width) && (a >= 0 && a < this.height)) {
  1946. return this.data[a][c]
  1947. } else {
  1948. return 0
  1949. }
  1950. },
  1951. setTile: function (b, e, d) {
  1952. var c = Math.floor(b / this.tilesize);
  1953. var a = Math.floor(e / this.tilesize);
  1954. if ((c >= 0 && c < this.width) && (a >= 0 && a < this.height)) {
  1955. this.data[a][c] = d
  1956. }
  1957. }
  1958. })
  1959. });
  1960. ig.baked = true;
  1961. ig.module("impact.collision-map").requires("impact.map").defines(function () {
  1962. ig.CollisionMap = ig.Map.extend({
  1963. lastSlope: 1,
  1964. tiledef: null,
  1965. init: function (i, h, g) {
  1966. this.parent(i, h);
  1967. this.tiledef = g || ig.CollisionMap.defaultTileDef;
  1968. for (var f in this.tiledef) {
  1969. if (f | 0 > this.lastSlope) {
  1970. this.lastSlope = f | 0
  1971. }
  1972. }
  1973. },
  1974. trace: function (q, m, n, k, g, f) {
  1975. var j = {
  1976. collision: {
  1977. x: false,
  1978. y: false,
  1979. slope: false
  1980. },
  1981. pos: {
  1982. x: q,
  1983. y: m
  1984. },
  1985. tile: {
  1986. x: 0,
  1987. y: 0
  1988. }
  1989. };
  1990. var o = Math.ceil(Math.max(Math.abs(n), Math.abs(k)) / this.tilesize);
  1991. if (o > 1) {
  1992. var p = n / o;
  1993. var l = k / o;
  1994. for (var h = 0; h < o && (p || l); h++) {
  1995. this._traceStep(j, q, m, p, l, g, f, n, k, h);
  1996. q = j.pos.x;
  1997. m = j.pos.y;
  1998. if (j.collision.x) {
  1999. p = 0;
  2000. n = 0
  2001. }
  2002. if (j.collision.y) {
  2003. l = 0;
  2004. k = 0
  2005. }
  2006. if (j.collision.slope) {
  2007. break
  2008. }
  2009. }
  2010. } else {
  2011. this._traceStep(j, q, m, n, k, g, f, n, k, 0)
  2012. }
  2013. return j
  2014. },
  2015. _traceStep: function (E, l, i, u, s, w, r, A, v, h) {
  2016. E.pos.x += u;
  2017. E.pos.y += s;
  2018. var q = 0;
  2019. if (u) {
  2020. var B = (u > 0 ? w : 0);
  2021. var m = (u < 0 ? this.tilesize : 0);
  2022. var f = Math.max(Math.floor(i / this.tilesize), 0);
  2023. var C = Math.min(Math.ceil((i + r) / this.tilesize), this.height);
  2024. var n = Math.floor((E.pos.x + B) / this.tilesize);
  2025. var p = Math.floor((l + B) / this.tilesize);
  2026. if (h > 0 || n == p || p < 0 || p >= this.width) {
  2027. p = -1
  2028. }
  2029. if (n >= 0 && n < this.width) {
  2030. for (var k = f; k < C; k++) {
  2031. if (p != -1) {
  2032. q = this.data[k][p];
  2033. if (q > 1 && q <= this.lastSlope && this._checkTileDef(E, q, l, i, A, v, w, r, p, k)) {
  2034. break
  2035. }
  2036. }
  2037. q = this.data[k][n];
  2038. if (q == 1 || q > this.lastSlope || (q > 1 && this._checkTileDef(E, q, l, i, A, v, w, r, n, k))) {
  2039. if (q > 1 && q <= this.lastSlope && E.collision.slope) {
  2040. break
  2041. }
  2042. E.collision.x = true;
  2043. E.tile.x = q;
  2044. l = E.pos.x = n * this.tilesize - B + m;
  2045. A = 0;
  2046. break
  2047. }
  2048. }
  2049. }
  2050. }
  2051. if (s) {
  2052. var z = (s > 0 ? r : 0);
  2053. var j = (s < 0 ? this.tilesize : 0);
  2054. var g = Math.max(Math.floor(E.pos.x / this.tilesize), 0);
  2055. var D = Math.min(Math.ceil((E.pos.x + w) / this.tilesize), this.width);
  2056. var k = Math.floor((E.pos.y + z) / this.tilesize);
  2057. var o = Math.floor((i + z) / this.tilesize);
  2058. if (h > 0 || k == o || o < 0 || o >= this.height) {
  2059. o = -1
  2060. }
  2061. if (k >= 0 && k < this.height) {
  2062. for (var n = g; n < D; n++) {
  2063. if (o != -1) {
  2064. q = this.data[o][n];
  2065. if (q > 1 && q <= this.lastSlope && this._checkTileDef(E, q, l, i, A, v, w, r, n, o)) {
  2066. break
  2067. }
  2068. }
  2069. q = this.data[k][n];
  2070. if (q == 1 || q > this.lastSlope || (q > 1 && this._checkTileDef(E, q, l, i, A, v, w, r, n, k))) {
  2071. if (q > 1 && q <= this.lastSlope && E.collision.slope) {
  2072. break
  2073. }
  2074. E.collision.y = true;
  2075. E.tile.y = q;
  2076. E.pos.y = k * this.tilesize - z + j;
  2077. break
  2078. }
  2079. }
  2080. }
  2081. }
  2082. },
  2083. _checkTileDef: function (F, p, n, l, w, v, z, u, o, m) {
  2084. var q = this.tiledef[p];
  2085. if (!q) {
  2086. return false
  2087. }
  2088. var h = (o + q[0]) * this.tilesize,
  2089. g = (m + q[1]) * this.tilesize,
  2090. k = (q[2] - q[0]) * this.tilesize,
  2091. j = (q[3] - q[1]) * this.tilesize,
  2092. A = q[4];
  2093. var E = n + w + (j < 0 ? z : 0) - h,
  2094. D = l + v + (k > 0 ? u : 0) - g;
  2095. if (k * D - j * E > 0) {
  2096. if (w * -j + v * k < 0) {
  2097. return A
  2098. }
  2099. var f = Math.sqrt(k * k + j * j);
  2100. var C = j / f,
  2101. B = -k / f;
  2102. var i = E * C + D * B;
  2103. var s = C * i,
  2104. r = B * i;
  2105. if (s * s + r * r >= w * w + v * v) {
  2106. return A || (k * (D - v) - j * (E - w) < 0.5)
  2107. }
  2108. F.pos.x = n + w - s;
  2109. F.pos.y = l + v - r;
  2110. F.collision.slope = {
  2111. x: k,
  2112. y: j,
  2113. nx: C,
  2114. ny: B
  2115. };
  2116. return true
  2117. }
  2118. return false
  2119. }
  2120. });
  2121. var c = 1 / 2,
  2122. d = 1 / 3,
  2123. e = 2 / 3,
  2124. a = true,
  2125. b = false;
  2126. ig.CollisionMap.defaultTileDef = {
  2127. 5: [0, 1, 1, e, a],
  2128. 6: [0, e, 1, d, a],
  2129. 7: [0, d, 1, 0, a],
  2130. 3: [0, 1, 1, c, a],
  2131. 4: [0, c, 1, 0, a],
  2132. 2: [0, 1, 1, 0, a],
  2133. 10: [c, 1, 1, 0, a],
  2134. 21: [0, 1, c, 0, a],
  2135. 32: [e, 1, 1, 0, a],
  2136. 43: [d, 1, e, 0, a],
  2137. 54: [0, 1, d, 0, a],
  2138. 27: [0, 0, 1, d, a],
  2139. 28: [0, d, 1, e, a],
  2140. 29: [0, e, 1, 1, a],
  2141. 25: [0, 0, 1, c, a],
  2142. 26: [0, c, 1, 1, a],
  2143. 24: [0, 0, 1, 1, a],
  2144. 11: [0, 0, c, 1, a],
  2145. 22: [c, 0, 1, 1, a],
  2146. 33: [0, 0, d, 1, a],
  2147. 44: [d, 0, e, 1, a],
  2148. 55: [e, 0, 1, 1, a],
  2149. 16: [1, d, 0, 0, a],
  2150. 17: [1, e, 0, d, a],
  2151. 18: [1, 1, 0, e, a],
  2152. 14: [1, c, 0, 0, a],
  2153. 15: [1, 1, 0, c, a],
  2154. 13: [1, 1, 0, 0, a],
  2155. 8: [c, 1, 0, 0, a],
  2156. 19: [1, 1, c, 0, a],
  2157. 30: [d, 1, 0, 0, a],
  2158. 41: [e, 1, d, 0, a],
  2159. 52: [1, 1, e, 0, a],
  2160. 38: [1, e, 0, 1, a],
  2161. 39: [1, d, 0, e, a],
  2162. 40: [1, 0, 0, d, a],
  2163. 36: [1, c, 0, 1, a],
  2164. 37: [1, 0, 0, c, a],
  2165. 35: [1, 0, 0, 1, a],
  2166. 9: [1, 0, c, 1, a],
  2167. 20: [c, 0, 0, 1, a],
  2168. 31: [1, 0, e, 1, a],
  2169. 42: [e, 0, d, 1, a],
  2170. 53: [d, 0, 0, 1, a],
  2171. 12: [0, 0, 1, 0, b],
  2172. 23: [1, 1, 0, 1, b],
  2173. 34: [1, 0, 1, 1, b],
  2174. 45: [0, 1, 0, 0, b]
  2175. };
  2176. ig.CollisionMap.staticNoCollision = {
  2177. trace: function (f, i, h, g) {
  2178. return {
  2179. collision: {
  2180. x: false,
  2181. y: false,
  2182. slope: false
  2183. },
  2184. pos: {
  2185. x: f + h,
  2186. y: i + g
  2187. },
  2188. tile: {
  2189. x: 0,
  2190. y: 0
  2191. }
  2192. }
  2193. }
  2194. }
  2195. });
  2196. ig.baked = true;
  2197. ig.module("impact.background-map").requires("impact.map", "impact.image").defines(function () {
  2198. ig.BackgroundMap = ig.Map.extend({
  2199. tiles: null,
  2200. scroll: {
  2201. x: 0,
  2202. y: 0
  2203. },
  2204. distance: 1,
  2205. repeat: false,
  2206. tilesetName: "",
  2207. foreground: false,
  2208. enabled: true,
  2209. preRender: false,
  2210. preRenderedChunks: null,
  2211. chunkSize: 512,
  2212. debugChunks: false,
  2213. anims: {},
  2214. init: function (c, a, b) {
  2215. this.parent(c, a);
  2216. this.setTileset(b)
  2217. },
  2218. setTileset: function (a) {
  2219. this.tilesetName = a instanceof ig.Image ? a.path : a;
  2220. this.tiles = new ig.Image(this.tilesetName);
  2221. this.preRenderedChunks = null
  2222. },
  2223. setScreenPos: function (a, b) {
  2224. this.scroll.x = a / this.distance;
  2225. this.scroll.y = b / this.distance
  2226. },
  2227. preRenderMapToChunks: function () {
  2228. var b = this.width * this.tilesize * ig.system.scale,
  2229. e = this.height * this.tilesize * ig.system.scale;
  2230. this.chunkSize = Math.min(Math.max(b, e), this.chunkSize);
  2231. var d = Math.ceil(b / this.chunkSize),
  2232. c = Math.ceil(e / this.chunkSize);
  2233. this.preRenderedChunks = [];
  2234. for (var h = 0; h < c; h++) {
  2235. this.preRenderedChunks[h] = [];
  2236. for (var a = 0; a < d; a++) {
  2237. var f = (a == d - 1) ? b - a * this.chunkSize : this.chunkSize;
  2238. var g = (h == c - 1) ? e - h * this.chunkSize : this.chunkSize;
  2239. this.preRenderedChunks[h][a] = this.preRenderChunk(a, h, f, g)
  2240. }
  2241. }
  2242. },
  2243. preRenderChunk: function (c, b, p, g) {
  2244. var i = p / this.tilesize / ig.system.scale + 1,
  2245. a = g / this.tilesize / ig.system.scale + 1;
  2246. var j = (c * this.chunkSize / ig.system.scale) % this.tilesize,
  2247. f = (b * this.chunkSize / ig.system.scale) % this.tilesize;
  2248. var e = Math.floor(c * this.chunkSize / this.tilesize / ig.system.scale),
  2249. d = Math.floor(b * this.chunkSize / this.tilesize / ig.system.scale);
  2250. var o = ig.$new("canvas");
  2251. o.width = p;
  2252. o.height = g;
  2253. o.retinaResolutionEnabled = false;
  2254. var k = o.getContext("2d");
  2255. ig.System.scaleMode(o, k);
  2256. var q = ig.system.context;
  2257. ig.system.context = k;
  2258. for (var n = 0; n < i; n++) {
  2259. for (var m = 0; m < a; m++) {
  2260. if (n + e < this.width && m + d < this.height) {
  2261. var l = this.data[m + d][n + e];
  2262. if (l) {
  2263. this.tiles.drawTile(n * this.tilesize - j, m * this.tilesize - f, l - 1, this.tilesize)
  2264. }
  2265. }
  2266. }
  2267. }
  2268. ig.system.context = q;
  2269. return o
  2270. },
  2271. draw: function () {
  2272. if (!this.tiles.loaded || !this.enabled) {
  2273. return
  2274. }
  2275. if (this.preRender) {
  2276. this.drawPreRendered()
  2277. } else {
  2278. this.drawTiled()
  2279. }
  2280. },
  2281. drawPreRendered: function () {
  2282. if (!this.preRenderedChunks) {
  2283. this.preRenderMapToChunks()
  2284. }
  2285. var r = ig.system.getDrawPos(this.scroll.x),
  2286. q = ig.system.getDrawPos(this.scroll.y);
  2287. if (this.repeat) {
  2288. var n = this.width * this.tilesize * ig.system.scale;
  2289. r = (r % n + n) % n;
  2290. var e = this.height * this.tilesize * ig.system.scale;
  2291. q = (q % e + e) % e
  2292. }
  2293. var j = Math.max(Math.floor(r / this.chunkSize), 0),
  2294. g = Math.max(Math.floor(q / this.chunkSize), 0),
  2295. i = Math.ceil((r + ig.system.realWidth) / this.chunkSize),
  2296. f = Math.ceil((q + ig.system.realHeight) / this.chunkSize),
  2297. b = this.preRenderedChunks[0].length,
  2298. a = this.preRenderedChunks.length;
  2299. if (!this.repeat) {
  2300. i = Math.min(i, b);
  2301. f = Math.min(f, a)
  2302. }
  2303. var o = 0;
  2304. for (var c = g; c < f; c++) {
  2305. var p = 0;
  2306. for (var d = j; d < i; d++) {
  2307. var m = this.preRenderedChunks[c % a][d % b];
  2308. var l = -r + d * this.chunkSize - p;
  2309. var k = -q + c * this.chunkSize - o;
  2310. ig.system.context.drawImage(m, l, k);
  2311. ig.Image.drawCount++;
  2312. if (this.debugChunks) {
  2313. ig.system.context.strokeStyle = "#f0f";
  2314. ig.system.context.strokeRect(l, k, this.chunkSize, this.chunkSize)
  2315. }
  2316. if (this.repeat && m.width < this.chunkSize && l + m.width < ig.system.realWidth) {
  2317. p += this.chunkSize - m.width;
  2318. i++
  2319. }
  2320. }
  2321. if (this.repeat && m.height < this.chunkSize && k + m.height < ig.system.realHeight) {
  2322. o += this.chunkSize - m.height;
  2323. f++
  2324. }
  2325. }
  2326. },
  2327. drawTiled: function () {
  2328. var j = 0,
  2329. e = null,
  2330. g = (this.scroll.x / this.tilesize).toInt(),
  2331. f = (this.scroll.y / this.tilesize).toInt(),
  2332. b = this.scroll.x % this.tilesize,
  2333. p = this.scroll.y % this.tilesize,
  2334. i = -b - this.tilesize,
  2335. h = -p - this.tilesize,
  2336. d = ig.system.width + this.tilesize - b,
  2337. c = ig.system.height + this.tilesize - p;
  2338. for (var m = -1, k = h; k < c; m++, k += this.tilesize) {
  2339. var o = m + f;
  2340. if (o >= this.height || o < 0) {
  2341. if (!this.repeat) {
  2342. continue
  2343. }
  2344. o = (o % this.height + this.height) % this.height
  2345. }
  2346. for (var n = -1, l = i; l < d; n++, l += this.tilesize) {
  2347. var a = n + g;
  2348. if (a >= this.width || a < 0) {
  2349. if (!this.repeat) {
  2350. continue
  2351. }
  2352. a = (a % this.width + this.width) % this.width
  2353. }
  2354. if ((j = this.data[o][a])) {
  2355. if ((e = this.anims[j - 1])) {
  2356. e.draw(l, k)
  2357. } else {
  2358. this.tiles.drawTile(l, k, j - 1, this.tilesize)
  2359. }
  2360. }
  2361. }
  2362. }
  2363. }
  2364. })
  2365. });
  2366. ig.baked = true;
  2367. ig.module("impact.game").requires("impact.impact", "impact.entity", "impact.collision-map", "impact.background-map").defines(function () {
  2368. ig.Game = ig.Class.extend({
  2369. clearColor: "#000000",
  2370. gravity: 0,
  2371. screen: {
  2372. x: 0,
  2373. y: 0
  2374. },
  2375. _rscreen: {
  2376. x: 0,
  2377. y: 0
  2378. },
  2379. entities: [],
  2380. namedEntities: {},
  2381. collisionMap: ig.CollisionMap.staticNoCollision,
  2382. backgroundMaps: [],
  2383. backgroundAnims: {},
  2384. autoSort: false,
  2385. sortBy: null,
  2386. cellSize: 64,
  2387. _deferredKill: [],
  2388. _levelToLoad: null,
  2389. _doSortEntities: false,
  2390. staticInstantiate: function () {
  2391. this.sortBy = this.sortBy || ig.Game.SORT.Z_INDEX;
  2392. ig.game = this;
  2393. return null
  2394. },
  2395. loadLevel: function (e) {
  2396. this.screen = {
  2397. x: 0,
  2398. y: 0
  2399. };
  2400. this.entities = [];
  2401. this.namedEntities = {};
  2402. for (var b = 0; b < e.entities.length; b++) {
  2403. var d = e.entities[b];
  2404. this.spawnEntity(d.type, d.x, d.y, d.settings)
  2405. }
  2406. this.sortEntities();
  2407. this.collisionMap = ig.CollisionMap.staticNoCollision;
  2408. this.backgroundMaps = [];
  2409. for (var b = 0; b < e.layer.length; b++) {
  2410. var c = e.layer[b];
  2411. if (c.name == "collision") {
  2412. this.collisionMap = new ig.CollisionMap(c.tilesize, c.data)
  2413. } else {
  2414. var a = new ig.BackgroundMap(c.tilesize, c.data, c.tilesetName);
  2415. a.anims = this.backgroundAnims[c.tilesetName] || {};
  2416. a.repeat = c.repeat;
  2417. a.distance = c.distance;
  2418. a.foreground = !!c.foreground;
  2419. a.preRender = !!c.preRender;
  2420. a.name = c.name;
  2421. this.backgroundMaps.push(a)
  2422. }
  2423. }
  2424. for (var b = 0; b < this.entities.length; b++) {
  2425. this.entities[b].ready()
  2426. }
  2427. },
  2428. loadLevelDeferred: function (a) {
  2429. this._levelToLoad = a
  2430. },
  2431. getMapByName: function (a) {
  2432. if (a == "collision") {
  2433. return this.collisionMap
  2434. }
  2435. for (var b = 0; b < this.backgroundMaps.length; b++) {
  2436. if (this.backgroundMaps[b].name == a) {
  2437. return this.backgroundMaps[b]
  2438. }
  2439. }
  2440. return null
  2441. },
  2442. getEntityByName: function (a) {
  2443. return this.namedEntities[a]
  2444. },
  2445. getEntitiesByType: function (e) {
  2446. var c = typeof (e) === "string" ? ig.global[e] : e;
  2447. var b = [];
  2448. for (var d = 0; d < this.entities.length; d++) {
  2449. var f = this.entities[d];
  2450. if (f instanceof c && !f._killed) {
  2451. b.push(f)
  2452. }
  2453. }
  2454. return b
  2455. },
  2456. spawnEntity: function (d, a, f, c) {
  2457. var b = typeof (d) === "string" ? ig.global[d] : d;
  2458. if (!b) {
  2459. throw ("Can't spawn entity of type " + d)
  2460. }
  2461. var e = new(b)(a, f, c || {});
  2462. this.entities.push(e);
  2463. if (e.name) {
  2464. this.namedEntities[e.name] = e
  2465. }
  2466. return e
  2467. },
  2468. sortEntities: function () {
  2469. this.entities.sort(this.sortBy)
  2470. },
  2471. sortEntitiesDeferred: function () {
  2472. this._doSortEntities = true
  2473. },
  2474. removeEntity: function (a) {
  2475. if (a.name) {
  2476. delete this.namedEntities[a.name]
  2477. }
  2478. a._killed = true;
  2479. a.type = ig.Entity.TYPE.NONE;
  2480. a.checkAgainst = ig.Entity.TYPE.NONE;
  2481. a.collides = ig.Entity.COLLIDES.NEVER;
  2482. this._deferredKill.push(a)
  2483. },
  2484. run: function () {
  2485. this.update();
  2486. this.draw()
  2487. },
  2488. update: function () {
  2489. if (this._levelToLoad) {
  2490. this.loadLevel(this._levelToLoad);
  2491. this._levelToLoad = null
  2492. }
  2493. this.updateEntities();
  2494. this.checkEntities();
  2495. for (var d = 0; d < this._deferredKill.length; d++) {
  2496. this._deferredKill[d].erase();
  2497. this.entities.erase(this._deferredKill[d])
  2498. }
  2499. this._deferredKill = [];
  2500. if (this._doSortEntities || this.autoSort) {
  2501. this.sortEntities();
  2502. this._doSortEntities = false
  2503. }
  2504. for (var e in this.backgroundAnims) {
  2505. var b = this.backgroundAnims[e];
  2506. for (var c in b) {
  2507. b[c].update()
  2508. }
  2509. }
  2510. },
  2511. updateEntities: function () {
  2512. for (var a = 0; a < this.entities.length; a++) {
  2513. var b = this.entities[a];
  2514. if (!b._killed) {
  2515. b.update()
  2516. }
  2517. }
  2518. },
  2519. draw: function () {
  2520. if (this.clearColor) {
  2521. ig.system.clear(this.clearColor)
  2522. }
  2523. this._rscreen.x = ig.system.getDrawPos(this.screen.x) / ig.system.scale;
  2524. this._rscreen.y = ig.system.getDrawPos(this.screen.y) / ig.system.scale;
  2525. var a;
  2526. for (a = 0; a < this.backgroundMaps.length; a++) {
  2527. var b = this.backgroundMaps[a];
  2528. if (b.foreground) {
  2529. break
  2530. }
  2531. b.setScreenPos(this.screen.x, this.screen.y);
  2532. b.draw()
  2533. }
  2534. this.drawEntities();
  2535. for (a; a < this.backgroundMaps.length; a++) {
  2536. var b = this.backgroundMaps[a];
  2537. b.setScreenPos(this.screen.x, this.screen.y);
  2538. b.draw()
  2539. }
  2540. },
  2541. drawEntities: function () {
  2542. for (var a = 0; a < this.entities.length; a++) {
  2543. this.entities[a].draw()
  2544. }
  2545. },
  2546. checkEntities: function () {
  2547. var f = {};
  2548. for (var h = 0; h < this.entities.length; h++) {
  2549. var d = this.entities[h];
  2550. if (d.type == ig.Entity.TYPE.NONE && d.checkAgainst == ig.Entity.TYPE.NONE && d.collides == ig.Entity.COLLIDES.NEVER) {
  2551. continue
  2552. }
  2553. var l = {},
  2554. a = Math.floor(d.pos.x / this.cellSize),
  2555. m = Math.floor(d.pos.y / this.cellSize),
  2556. g = Math.floor((d.pos.x + d.size.x) / this.cellSize) + 1,
  2557. b = Math.floor((d.pos.y + d.size.y) / this.cellSize) + 1;
  2558. for (var k = a; k < g; k++) {
  2559. for (var j = m; j < b; j++) {
  2560. if (!f[k]) {
  2561. f[k] = {};
  2562. f[k][j] = [d]
  2563. } else {
  2564. if (!f[k][j]) {
  2565. f[k][j] = [d]
  2566. } else {
  2567. var n = f[k][j];
  2568. for (var i = 0; i < n.length; i++) {
  2569. if (d.touches(n[i]) && !l[n[i].id]) {
  2570. l[n[i].id] = true;
  2571. ig.Entity.checkPair(d, n[i])
  2572. }
  2573. }
  2574. n.push(d)
  2575. }
  2576. }
  2577. }
  2578. }
  2579. }
  2580. }
  2581. });
  2582. ig.Game.SORT = {
  2583. Z_INDEX: function (d, c) {
  2584. return d.zIndex - c.zIndex
  2585. },
  2586. POS_X: function (d, c) {
  2587. return (d.pos.x + d.size.x) - (c.pos.x + c.size.x)
  2588. },
  2589. POS_Y: function (d, c) {
  2590. return (d.pos.y + d.size.y) - (c.pos.y + c.size.y)
  2591. }
  2592. }
  2593. });
  2594. ig.baked = true;
  2595. ig.module("plugins.impact-tween.entity").requires("impact.entity").defines(function () {
  2596. if (!Array.prototype.indexOf) {
  2597. Array.prototype.indexOf = function (b, c) {
  2598. var c = c || 0;
  2599. for (var a = 0; a < this.length; ++a) {
  2600. if (this[a] === b) {
  2601. return a
  2602. }
  2603. }
  2604. return -1
  2605. }
  2606. }
  2607. ig.Entity.inject({
  2608. tweens: [],
  2609. update: function () {
  2610. this.parent();
  2611. if (this.tweens.length > 0) {
  2612. var b = [];
  2613. for (var a = 0; a < this.tweens.length; a++) {
  2614. this.tweens[a].update();
  2615. if (!this.tweens[a].complete) {
  2616. b.push(this.tweens[a])
  2617. }
  2618. }
  2619. this.tweens = b
  2620. }
  2621. },
  2622. tween: function (c, d, b) {
  2623. var a = new ig.Tween(this, c, d, b);
  2624. this.tweens.push(a);
  2625. return a
  2626. },
  2627. pauseTweens: function () {
  2628. for (var a = 0; a < this.tweens.length; a++) {
  2629. this.tweens[a].pause()
  2630. }
  2631. },
  2632. resumeTweens: function () {
  2633. for (var a = 0; a < this.tweens.length; a++) {
  2634. this.tweens[a].resume()
  2635. }
  2636. },
  2637. stopTweens: function (b) {
  2638. for (var a = 0; a < this.tweens.length; a++) {
  2639. this.tweens[a].stop(b)
  2640. }
  2641. }
  2642. })
  2643. });
  2644. ig.baked = true;
  2645. ig.module("plugins.impact-tween.tween").requires("plugins.impact-tween.entity").defines(function () {
  2646. if (!Array.prototype.indexOf) {
  2647. Array.prototype.indexOf = function (b, c) {
  2648. var c = c || 0;
  2649. for (var a = 0; a < this.length; ++a) {
  2650. if (this[a] === b) {
  2651. return a
  2652. }
  2653. }
  2654. return -1
  2655. }
  2656. }
  2657. ig.Tween = ig.Class.extend({
  2658. _objects: null,
  2659. valuesStart: [],
  2660. valuesEnd: [],
  2661. valuesDelta: [],
  2662. _elapsed: 0,
  2663. timer: false,
  2664. started: false,
  2665. _props: {},
  2666. _chained: false,
  2667. duration: 0,
  2668. complete: false,
  2669. paused: false,
  2670. easing: null,
  2671. onComplete: false,
  2672. delay: 0,
  2673. loop: 0,
  2674. loopCount: -1,
  2675. loopNum: -1,
  2676. init: function (e, b, d, c) {
  2677. this.easing = ig.Tween.Easing.Linear.EaseNone;
  2678. this.duration = d;
  2679. ig.merge(this, c);
  2680. this.loopNum = this.loopCount;
  2681. if (typeof b == "object" && b.constructor === (new Array).constructor) {
  2682. this._props = b
  2683. } else {
  2684. this._props = [b]
  2685. } if (typeof e == "object" && e.constructor === (new Array).constructor) {
  2686. this._objects = e
  2687. } else {
  2688. this._objects = [e]
  2689. }
  2690. for (var a = 0; a < this._objects.length; a++) {
  2691. this.valuesStart.push({});
  2692. this.valuesEnd.push({});
  2693. this.valuesDelta.push({})
  2694. }
  2695. },
  2696. chain: function (a) {
  2697. this._chained = a
  2698. },
  2699. initEnd: function (d, c, b) {
  2700. if (typeof (c[d]) !== "object") {
  2701. b[d] = c[d]
  2702. } else {
  2703. for (var a in c[d]) {
  2704. if (!b[d]) {
  2705. b[d] = {}
  2706. }
  2707. this.initEnd(a, c[d], b[d])
  2708. }
  2709. }
  2710. },
  2711. initStart: function (e, a, d, c) {
  2712. if (typeof d.tweenInitStart === "function") {
  2713. return d.tweenInitStart(e, a, c)
  2714. }
  2715. if (typeof (d[e]) !== "object") {
  2716. if (typeof (a[e]) !== "undefined") {
  2717. c[e] = d[e]
  2718. }
  2719. } else {
  2720. for (var b in d[e]) {
  2721. if (!c[e]) {
  2722. c[e] = {}
  2723. }
  2724. if (typeof (a[e]) !== "undefined") {
  2725. this.initStart(b, a[e], d[e], c[e])
  2726. }
  2727. }
  2728. }
  2729. },
  2730. start: function () {
  2731. this.complete = false;
  2732. this.paused = false;
  2733. this.loopNum = this.loopCount;
  2734. this._elapsed = 0;
  2735. this.started = true;
  2736. this.timer = new ig.Timer();
  2737. for (var a = 0; a < this._objects.length; a++) {
  2738. if (this._objects[a].tweens.indexOf(this) == -1) {
  2739. this._objects[a].tweens.push(this)
  2740. }
  2741. for (var b in this._props[a]) {
  2742. this.initEnd(b, this._props[a], this.valuesEnd[a])
  2743. }
  2744. for (var b in this.valuesEnd[a]) {
  2745. this.initStart(b, this.valuesEnd[a], this._objects[a], this.valuesStart[a]);
  2746. this.initDelta(b, this.valuesDelta[a], this._objects[a], this.valuesEnd[a])
  2747. }
  2748. }
  2749. },
  2750. initDelta: function (e, d, c, a) {
  2751. if (typeof c.tweenInitDelta === "function") {
  2752. return c.tweenInitDelta(e, d, a)
  2753. }
  2754. if (typeof (a[e]) !== "object") {
  2755. d[e] = a[e] - c[e]
  2756. } else {
  2757. for (var b in a[e]) {
  2758. if (!d[e]) {
  2759. d[e] = {}
  2760. }
  2761. this.initDelta(b, d[e], c[e], a[e])
  2762. }
  2763. }
  2764. },
  2765. propUpdate: function (f, c, e, d, b) {
  2766. if (typeof c.tweenPropUpdate === "function") {
  2767. return c.tweenPropUpdate(f, e, d, b)
  2768. }
  2769. if (typeof (e[f]) !== "object") {
  2770. if (typeof e[f] != "undefined") {
  2771. c[f] = e[f] + d[f] * b
  2772. } else {
  2773. c[f] = c[f]
  2774. }
  2775. } else {
  2776. for (var a in e[f]) {
  2777. this.propUpdate(a, c[f], e[f], d[f], b)
  2778. }
  2779. }
  2780. },
  2781. propSet: function (c, b, a) {
  2782. if (typeof a.tweenPropSet === "function") {
  2783. return a.tweenPropSet(c, b)
  2784. }
  2785. if (typeof (b[c]) !== "object") {
  2786. a[c] = b[c]
  2787. } else {
  2788. for (subprop in b[c]) {
  2789. if (!a[c]) {
  2790. a[c] = {}
  2791. }
  2792. this.propSet(subprop, b[c], a[c])
  2793. }
  2794. }
  2795. },
  2796. update: function () {
  2797. if (!this.started) {
  2798. return false
  2799. }
  2800. if (this.delay) {
  2801. if (this.timer.delta() < this.delay) {
  2802. return
  2803. }
  2804. this.delay = 0;
  2805. this.timer.reset()
  2806. }
  2807. if (this.paused || this.complete) {
  2808. return false
  2809. }
  2810. var a = (this.timer.delta() + this._elapsed) / this.duration;
  2811. a = a > 1 ? 1 : a;
  2812. var g = this.easing(a);
  2813. for (var c = 0; c < this._objects.length; c++) {
  2814. for (var f in this.valuesDelta[c]) {
  2815. this.propUpdate(f, this._objects[c], this.valuesStart[c], this.valuesDelta[c], g)
  2816. }
  2817. if (a >= 1) {
  2818. if (this.loopNum == 0 || !this.loop) {
  2819. this.complete = true;
  2820. if (this.onComplete) {
  2821. this.onComplete()
  2822. }
  2823. if (this._chained) {
  2824. this._chained.start()
  2825. }
  2826. return false
  2827. } else {
  2828. if (this.loop == ig.Tween.Loop.Revert) {
  2829. for (var f in this.valuesStart[c]) {
  2830. this.propSet(f, this.valuesStart[c], this._objects[c])
  2831. }
  2832. this._elapsed = 0;
  2833. this.timer.reset();
  2834. if (this.loopNum != -1) {
  2835. this.loopNum--
  2836. }
  2837. } else {
  2838. if (this.loop == ig.Tween.Loop.Reverse) {
  2839. var e = {},
  2840. b = {},
  2841. d = {};
  2842. ig.merge(e, this.valuesEnd[c]);
  2843. ig.merge(b, this.valuesStart[c]);
  2844. ig.merge(this.valuesStart[c], e);
  2845. ig.merge(this.valuesEnd[c], b);
  2846. for (var f in this.valuesEnd[c]) {
  2847. this.initDelta(f, this.valuesDelta[c], this._objects[c], this.valuesEnd[c])
  2848. }
  2849. this._elapsed = 0;
  2850. this.timer.reset();
  2851. if (this.loopNum != -1) {
  2852. this.loopNum--
  2853. }
  2854. }
  2855. }
  2856. }
  2857. }
  2858. }
  2859. },
  2860. pause: function () {
  2861. this.paused = true;
  2862. this._elapsed += this.timer.delta()
  2863. },
  2864. resume: function () {
  2865. this.paused = false;
  2866. this.timer.reset()
  2867. },
  2868. stop: function (a) {
  2869. if (a) {
  2870. this.paused = false;
  2871. this.complete = false;
  2872. this.loop = false;
  2873. this._elapsed += this.duration;
  2874. this.update()
  2875. }
  2876. this.complete = true
  2877. },
  2878. rewind: function () {
  2879. var a = this.loop;
  2880. this.complete = false;
  2881. this.paused = false;
  2882. this.loopNum = -1;
  2883. this.loop = ig.Tween.Loop.Revert;
  2884. this.update();
  2885. this.loop = a
  2886. }
  2887. });
  2888. ig.Tween.Loop = {
  2889. Revert: 1,
  2890. Reverse: 2
  2891. };
  2892. ig.Tween.Easing = {
  2893. Linear: {},
  2894. Quadratic: {},
  2895. Cubic: {},
  2896. Quartic: {},
  2897. Quintic: {},
  2898. Sinusoidal: {},
  2899. Exponential: {},
  2900. Circular: {},
  2901. Elastic: {},
  2902. Back: {},
  2903. Bounce: {}
  2904. };
  2905. ig.Tween.Easing.Linear.EaseNone = function (a) {
  2906. return a
  2907. };
  2908. ig.Tween.Easing.Quadratic.EaseIn = function (a) {
  2909. return a * a
  2910. };
  2911. ig.Tween.Easing.Quadratic.EaseOut = function (a) {
  2912. return -a * (a - 2)
  2913. };
  2914. ig.Tween.Easing.Quadratic.EaseInOut = function (a) {
  2915. if ((a *= 2) < 1) {
  2916. return 0.5 * a * a
  2917. }
  2918. return -0.5 * (--a * (a - 2) - 1)
  2919. };
  2920. ig.Tween.Easing.Cubic.EaseIn = function (a) {
  2921. return a * a * a
  2922. };
  2923. ig.Tween.Easing.Cubic.EaseOut = function (a) {
  2924. return --a * a * a + 1
  2925. };
  2926. ig.Tween.Easing.Cubic.EaseInOut = function (a) {
  2927. if ((a *= 2) < 1) {
  2928. return 0.5 * a * a * a
  2929. }
  2930. return 0.5 * ((a -= 2) * a * a + 2)
  2931. };
  2932. ig.Tween.Easing.Quartic.EaseIn = function (a) {
  2933. return a * a * a * a
  2934. };
  2935. ig.Tween.Easing.Quartic.EaseOut = function (a) {
  2936. return -(--a * a * a * a - 1)
  2937. };
  2938. ig.Tween.Easing.Quartic.EaseInOut = function (a) {
  2939. if ((a *= 2) < 1) {
  2940. return 0.5 * a * a * a * a
  2941. }
  2942. return -0.5 * ((a -= 2) * a * a * a - 2)
  2943. };
  2944. ig.Tween.Easing.Quintic.EaseIn = function (a) {
  2945. return a * a * a * a * a
  2946. };
  2947. ig.Tween.Easing.Quintic.EaseOut = function (a) {
  2948. return (a = a - 1) * a * a * a * a + 1
  2949. };
  2950. ig.Tween.Easing.Quintic.EaseInOut = function (a) {
  2951. if ((a *= 2) < 1) {
  2952. return 0.5 * a * a * a * a * a
  2953. }
  2954. return 0.5 * ((a -= 2) * a * a * a * a + 2)
  2955. };
  2956. ig.Tween.Easing.Sinusoidal.EaseIn = function (a) {
  2957. return -Math.cos(a * Math.PI / 2) + 1
  2958. };
  2959. ig.Tween.Easing.Sinusoidal.EaseOut = function (a) {
  2960. return Math.sin(a * Math.PI / 2)
  2961. };
  2962. ig.Tween.Easing.Sinusoidal.EaseInOut = function (a) {
  2963. return -0.5 * (Math.cos(Math.PI * a) - 1)
  2964. };
  2965. ig.Tween.Easing.Exponential.EaseIn = function (a) {
  2966. return a == 0 ? 0 : Math.pow(2, 10 * (a - 1))
  2967. };
  2968. ig.Tween.Easing.Exponential.EaseOut = function (a) {
  2969. return a == 1 ? 1 : -Math.pow(2, -10 * a) + 1
  2970. };
  2971. ig.Tween.Easing.Exponential.EaseInOut = function (a) {
  2972. if (a == 0) {
  2973. return 0
  2974. }
  2975. if (a == 1) {
  2976. return 1
  2977. }
  2978. if ((a *= 2) < 1) {
  2979. return 0.5 * Math.pow(2, 10 * (a - 1))
  2980. }
  2981. return 0.5 * (-Math.pow(2, -10 * (a - 1)) + 2)
  2982. };
  2983. ig.Tween.Easing.Circular.EaseIn = function (a) {
  2984. return -(Math.sqrt(1 - a * a) - 1)
  2985. };
  2986. ig.Tween.Easing.Circular.EaseOut = function (a) {
  2987. return Math.sqrt(1 - (--a) * a)
  2988. };
  2989. ig.Tween.Easing.Circular.EaseInOut = function (a) {
  2990. if ((a /= 0.5) < 1) {
  2991. return -0.5 * (Math.sqrt(1 - a * a) - 1)
  2992. }
  2993. return 0.5 * (Math.sqrt(1 - (a -= 2) * a) + 1)
  2994. };
  2995. ig.Tween.Easing.Elastic.EaseIn = function (c) {
  2996. var d, b = 0.1,
  2997. e = 0.4;
  2998. if (c == 0) {
  2999. return 0
  3000. }
  3001. if (c == 1) {
  3002. return 1
  3003. }
  3004. if (!e) {
  3005. e = 0.3
  3006. }
  3007. if (!b || b < 1) {
  3008. b = 1;
  3009. d = e / 4
  3010. } else {
  3011. d = e / (2 * Math.PI) * Math.asin(1 / b)
  3012. }
  3013. return -(b * Math.pow(2, 10 * (c -= 1)) * Math.sin((c - d) * (2 * Math.PI) / e))
  3014. };
  3015. ig.Tween.Easing.Elastic.EaseOut = function (c) {
  3016. var d, b = 0.1,
  3017. e = 0.4;
  3018. if (c == 0) {
  3019. return 0
  3020. }
  3021. if (c == 1) {
  3022. return 1
  3023. }
  3024. if (!e) {
  3025. e = 0.3
  3026. }
  3027. if (!b || b < 1) {
  3028. b = 1;
  3029. d = e / 4
  3030. } else {
  3031. d = e / (2 * Math.PI) * Math.asin(1 / b)
  3032. }
  3033. return (b * Math.pow(2, -10 * c) * Math.sin((c - d) * (2 * Math.PI) / e) + 1)
  3034. };
  3035. ig.Tween.Easing.Elastic.EaseInOut = function (c) {
  3036. var d, b = 0.1,
  3037. e = 0.4;
  3038. if (c == 0) {
  3039. return 0
  3040. }
  3041. if (c == 1) {
  3042. return 1
  3043. }
  3044. if (!e) {
  3045. e = 0.3
  3046. }
  3047. if (!b || b < 1) {
  3048. b = 1;
  3049. d = e / 4
  3050. } else {
  3051. d = e / (2 * Math.PI) * Math.asin(1 / b)
  3052. } if ((c *= 2) < 1) {
  3053. return -0.5 * (b * Math.pow(2, 10 * (c -= 1)) * Math.sin((c - d) * (2 * Math.PI) / e))
  3054. }
  3055. return b * Math.pow(2, -10 * (c -= 1)) * Math.sin((c - d) * (2 * Math.PI) / e) * 0.5 + 1
  3056. };
  3057. ig.Tween.Easing.Back.EaseIn = function (a) {
  3058. var b = 1.70158;
  3059. return a * a * ((b + 1) * a - b)
  3060. };
  3061. ig.Tween.Easing.Back.EaseOut = function (a) {
  3062. var b = 1.70158;
  3063. return (a = a - 1) * a * ((b + 1) * a + b) + 1
  3064. };
  3065. ig.Tween.Easing.Back.EaseInOut = function (a) {
  3066. var b = 1.70158 * 1.525;
  3067. if ((a *= 2) < 1) {
  3068. return 0.5 * (a * a * ((b + 1) * a - b))
  3069. }
  3070. return 0.5 * ((a -= 2) * a * ((b + 1) * a + b) + 2)
  3071. };
  3072. ig.Tween.Easing.Bounce.EaseIn = function (a) {
  3073. return 1 - ig.Tween.Easing.Bounce.EaseOut(1 - a)
  3074. };
  3075. ig.Tween.Easing.Bounce.EaseOut = function (a) {
  3076. if ((a /= 1) < (1 / 2.75)) {
  3077. return 7.5625 * a * a
  3078. } else {
  3079. if (a < (2 / 2.75)) {
  3080. return 7.5625 * (a -= (1.5 / 2.75)) * a + 0.75
  3081. } else {
  3082. if (a < (2.5 / 2.75)) {
  3083. return 7.5625 * (a -= (2.25 / 2.75)) * a + 0.9375
  3084. } else {
  3085. return 7.5625 * (a -= (2.625 / 2.75)) * a + 0.984375
  3086. }
  3087. }
  3088. }
  3089. };
  3090. ig.Tween.Easing.Bounce.EaseInOut = function (a) {
  3091. if (a < 0.5) {
  3092. return ig.Tween.Easing.Bounce.EaseIn(a * 2) * 0.5
  3093. }
  3094. return ig.Tween.Easing.Bounce.EaseOut(a * 2 - 1) * 0.5 + 0.5
  3095. }
  3096. });
  3097. ig.baked = true;
  3098. ig.module("game.config").defines(function () {
  3099. ig.CONFIG = {
  3100. TILESIZE: 17,
  3101. FIELD_ROWS: 19,
  3102. FIELD_COLS: 10,
  3103. MIN_HIGHSCORE: 0,
  3104. // MORE_GAMES_URL: "http://www.play68.com",
  3105. LANG: ["en", "es", "de", "fr", "it", "pt", "tr", "ru", "zh"],//langs
  3106. CONTENTS: [{
  3107. Start: "开始",
  3108. Help: "排行榜",
  3109. MoreGames: "更多游戏",
  3110. Back: "返回"
  3111. }, {
  3112. Start: "Jugar",
  3113. Help: "Ayudar",
  3114. MoreGames: "Más Juegos",
  3115. Back: "Volver"
  3116. }, {
  3117. Start: "Spielen",
  3118. Help: "Hilfe",
  3119. MoreGames: "Mehr Spiele",
  3120. Back: "Zurück"
  3121. }, {
  3122. Start: "Jouer",
  3123. Help: "Aider",
  3124. MoreGames: "Plus de Jeux",
  3125. Back: "Retour"
  3126. }, {
  3127. Start: "Giocare",
  3128. Help: "Aiuto",
  3129. MoreGames: "Altre partite",
  3130. Back: "Indietro"
  3131. }, {
  3132. Start: "Jogar",
  3133. Help: "Ajudar",
  3134. MoreGames: "Mais jogos",
  3135. Back: "Retroceder"
  3136. }, {
  3137. Start: "taşlar",
  3138. Help: "Yardım",
  3139. MoreGames: "Daha Fazla Oyun",
  3140. Back: "Geri"
  3141. }, {
  3142. Start: "Играть",
  3143. Help: "Помощь",
  3144. MoreGames: "Еще игры",
  3145. Back: "Назад"
  3146. }, {
  3147. Start: "开始",
  3148. Help: "帮助",
  3149. MoreGames: "更多游戏",
  3150. Back: "返回"
  3151. }]
  3152. };
  3153. ig.CONFIG.GEMS = {
  3154. TILESIZE: 17,
  3155. FIELD_ROWS: 19,
  3156. FIELD_COLS: 10,
  3157. SHAPES: 7,
  3158. LOCKIN_DELAY: 0.5,
  3159. PRESSED_DELAY: 0.25,
  3160. REPEAT_LEFT_RIGHT_DELAY: 0.07,
  3161. REPEAT_DOWN_DELAY: 0.05,
  3162. CLEAN_LINES_DELAY: 0.42,
  3163. DROP_POS_X: 68,
  3164. DROP_POS_Y: 34,
  3165. SPAWN_POS_X: 210,
  3166. SPAWN_POS_Y: 88,
  3167. SPEED_INCREASE_PER_STAGE: 0.4,
  3168. MIN_HIGHSCORE: 10,
  3169. SLOW_DURITION: 4.2,
  3170. BOMB_PROBABILITY: 0.012,
  3171. SLOW_PROBABILITY: 0.016,
  3172. BOMB_OVER_SLOW_PROBABILITY: 0.5
  3173. };
  3174. ig.CONFIG.CLASSIC = {
  3175. TILESIZE: 17,
  3176. FIELD_ROWS: 19,
  3177. FIELD_COLS: 10,
  3178. SHAPES: 7,
  3179. LOCKIN_DELAY: 0.5,
  3180. PRESSED_DELAY: 0.25,
  3181. REPEAT_LEFT_RIGHT_DELAY: 0.07,
  3182. REPEAT_DOWN_DELAY: 0.05,
  3183. CLEAN_LINES_DELAY: 0.42,
  3184. DROP_POS_X: 68,
  3185. DROP_POS_Y: 34,
  3186. SPAWN_POS_X: 218,
  3187. SPAWN_POS_Y: 78,
  3188. SPEED_INCREASE_PER_STAGE: 0.4,
  3189. MIN_HIGHSCORE: 10
  3190. }
  3191. });
  3192. ig.baked = true;
  3193. ig.module("game.scenes.title").requires("impact.game", "impact.entity", "plugins.impact-tween.tween", "game.config").defines(function () {
  3194. var h = ig.CONFIG;
  3195. var d = 0,
  3196. a = 1,
  3197. j = 2;
  3198. var m = ig.Entity.extend({
  3199. _layer: "bg",
  3200. size: {
  3201. x: 320,
  3202. y: 480
  3203. },
  3204. animSheet: new ig.AnimationSheet("media/title-bg-empty.png", 320, 480),
  3205. init: function (o, q, p) {
  3206. this.parent(o, q, p);
  3207. this.addAnim("idle", 1, [0])
  3208. }
  3209. });
  3210. var g = ig.Entity.extend({
  3211. _layer: "gui",
  3212. enable: false,
  3213. touched: false,
  3214. pressed: false,
  3215. released: false,
  3216. animSheet: new ig.AnimationSheet("media/big-button.png", 166, 61),
  3217. size: {
  3218. x: 166,
  3219. y: 61
  3220. },
  3221. fontSize: 24,
  3222. content: "",
  3223. visible: true,
  3224. init: function (o, q, p) {
  3225. this.parent(o, q, p);
  3226. this.addAnim("up", 1, [0], true);
  3227. this.addAnim("down", 1, [1], true)
  3228. },
  3229. update: function () {
  3230. this.parent();
  3231. if (this.pressed) {
  3232. this.pressed = false
  3233. }
  3234. if (this.released) {
  3235. this.released = false;
  3236. if (this.enable) {
  3237. this.activated()
  3238. }
  3239. }
  3240. },
  3241. draw: function () {
  3242. if (this.visible) {
  3243. this.parent();
  3244. ig.system.context.save();
  3245. ig.system.context.translate(ig.system.getDrawPos(this.pos.x - this.offset.x - ig.game._rscreen.x), ig.system.getDrawPos(this.pos.y - this.offset.y - ig.game._rscreen.y));
  3246. ig.system.context.fillStyle = "#f8d396";
  3247. ig.system.context.shadowColor = "rgba(0, 0, 0, 0.8)";
  3248. ig.system.context.shadowOffsetX = 2;
  3249. ig.system.context.shadowOffsetX = 2;
  3250. ig.system.context.shadowBlur = 5;
  3251. ig.system.context.font = this.fontSize + "px Sofia";
  3252. ig.system.context.textBaseline = "center";
  3253. ig.system.context.textAlign = "center";
  3254. ig.system.context.fillText(this.content, this.size.x / 2, this.size.y / 2 + 2);
  3255. ig.system.context.restore()
  3256. }
  3257. },
  3258. onTouch: function () {
  3259. this.touched = true;
  3260. this.pressed = true;
  3261. this.currentAnim = this.anims.down
  3262. },
  3263. onRelease: function () {
  3264. this.touched = false;
  3265. this.released = true;
  3266. this.currentAnim = this.anims.up
  3267. },
  3268. activated: function () {}
  3269. });
  3270. var n = g.extend({
  3271. animSheet: new ig.AnimationSheet("media/title-word.png", 214, 197),
  3272. size: {
  3273. x: 214,
  3274. y: 197
  3275. },
  3276. init: function (o, q, p) {
  3277. this.parent(o, q, p);
  3278. this.addAnim("idle", 1, [0], true)
  3279. },
  3280. moveIn: function () {
  3281. this.tween({
  3282. pos: {
  3283. y: (ig.ua.iPad ? 4 : 16)
  3284. }
  3285. }, 1.6, {
  3286. delay: 0.4,
  3287. easing: ig.Tween.Easing.Elastic.EaseOut,
  3288. onComplete: function () {
  3289. this.offsetToStage = {
  3290. x: this.pos.x,
  3291. y: this.pos.y
  3292. }
  3293. }.bind(this)
  3294. }).start()
  3295. }
  3296. });
  3297. var k = g.extend({
  3298. activated: function () {
  3299. if (ig.game.state === d) {
  3300. ig.gameManager.newGemsRound()
  3301. }
  3302. },
  3303. moveIn: function () {
  3304. this.content = h.CONTENTS[ig.gameManager.langIndex].Start;
  3305. this.tween({
  3306. pos: {
  3307. y: (ig.ua.iPad ? 196 : 234)
  3308. }
  3309. }, 0.8, {
  3310. delay: 0.25,
  3311. easing: ig.Tween.Easing.Quartic.EaseOut,
  3312. onComplete: function () {
  3313. this.offsetToStage = {
  3314. x: this.pos.x,
  3315. y: this.pos.y
  3316. };
  3317. this.enable = true
  3318. }.bind(this)
  3319. }).start()
  3320. }
  3321. });
  3322. var i = g.extend({
  3323. activated: function () {
  3324. if (ig.game.state === d) {
  3325. ig.game.transToHelp()
  3326. }
  3327. },
  3328. moveIn: function () {
  3329. this.content = h.CONTENTS[ig.gameManager.langIndex].Help;
  3330. this.tween({
  3331. pos: {
  3332. y: (ig.ua.iPad ? 260 : 308)
  3333. }
  3334. }, 0.8, {
  3335. delay: 0.25,
  3336. easing: ig.Tween.Easing.Quartic.EaseOut,
  3337. onComplete: function () {
  3338. this.offsetToStage = {
  3339. x: this.pos.x,
  3340. y: this.pos.y
  3341. };
  3342. this.enable = true
  3343. }.bind(this)
  3344. }).start()
  3345. }
  3346. });
  3347. var b = g.extend({
  3348. fontSize: 18,
  3349. activated: function () {
  3350. if (ig.game.state === d) {
  3351. //window.open(h.MORE_GAMES_URL, "_top")
  3352. SG.redirectToPortal();
  3353. }
  3354. },
  3355. moveIn: function () {
  3356. this.content = h.CONTENTS[ig.gameManager.langIndex].MoreGames;
  3357. this.tween({
  3358. pos: {
  3359. y: (ig.ua.iPad ? 322 : 382)
  3360. }
  3361. }, 0.8, {
  3362. delay: 0.3,
  3363. easing: ig.Tween.Easing.Quartic.EaseOut,
  3364. onComplete: function () {
  3365. this.offsetToStage = {
  3366. x: this.pos.x,
  3367. y: this.pos.y
  3368. };
  3369. this.enable = true;
  3370. ig.game.state = d
  3371. }.bind(this)
  3372. }).start()
  3373. }
  3374. });
  3375. var f = g.extend({
  3376. enable: false,
  3377. visible: false,
  3378. init: function (o, q, p) {
  3379. this.parent(o, q, p);
  3380. this.content = h.CONTENTS[ig.gameManager.langIndex].Back
  3381. },
  3382. activated: function () {
  3383. if (ig.game.state === a) {
  3384. ig.game.transToTitle()
  3385. }
  3386. }
  3387. });
  3388. var e = g.extend({
  3389. animSheet: new ig.AnimationSheet("media/touch-tut.png", 88, 79),
  3390. size: {
  3391. x: 88,
  3392. y: 79
  3393. },
  3394. visible: false,
  3395. init: function (o, q, p) {
  3396. this.parent(o, q, p);
  3397. this.addAnim("idle", 1, [0], true);
  3398. this.offsetToStage = {
  3399. x: o,
  3400. y: q
  3401. }
  3402. }
  3403. });
  3404. var c = g.extend({
  3405. animSheet: new ig.AnimationSheet("media/keyboard-tut.png", 86, 61),
  3406. size: {
  3407. x: 86,
  3408. y: 61
  3409. },
  3410. visible: false,
  3411. init: function (o, q, p) {
  3412. this.parent(o, q, p);
  3413. this.addAnim("idle", 1, [0], true);
  3414. this.offsetToStage = {
  3415. x: o,
  3416. y: q
  3417. }
  3418. }
  3419. });
  3420. var l = ig.Game.extend({
  3421. state: 0,
  3422. clearColor: "#fff",
  3423. bg: null,
  3424. stageTouched: false,
  3425. stagePressed: false,
  3426. stageReleased: false,
  3427. init: function () {
  3428. this.createLayer("bg");
  3429. this.createLayer("gui");
  3430. this.setLayerSort(["bg", "gui"]);
  3431. ig.gameManager.inputManager.on("touch", this.touched.bind(this));
  3432. ig.gameManager.inputManager.on("release", this.released.bind(this));
  3433. this.state = j;
  3434. this.bg = this.spawnEntity(m, 0, 0);
  3435. this.startBtn = this.spawnEntity(k, 78, 480);
  3436. this.startBtn.moveIn();
  3437. this.helpBtn = this.spawnEntity(i, 78, 480);
  3438. this.helpBtn.moveIn();
  3439. this.moreBtn = this.spawnEntity(b, 78, 480);
  3440. this.moreBtn.moveIn();
  3441. this.gameTitle = this.spawnEntity(n, 56, -197);
  3442. this.gameTitle.moveIn();
  3443. this.helpBackBtn = this.spawnEntity(f, 78, 60);
  3444. this.tutTouch = this.spawnEntity(e, 116, (ig.ua.iPad ? 150 : 180));
  3445. this.tutKeyboard = this.spawnEntity(c, 116, (ig.ua.iPad ? 270 : 300))
  3446. },
  3447. update: function () {
  3448. this.stagePressed = false;
  3449. this.stageReleased = false;
  3450. this.parent()
  3451. },
  3452. transToHelp: function () {
  3453. /*this.state = a;
  3454. this.gameTitle.visible = false;
  3455. this.startBtn.visible = false;
  3456. this.helpBtn.visible = false;
  3457. this.moreBtn.visible = false;
  3458. this.gameTitle.enable = false;
  3459. this.startBtn.enable = false;
  3460. this.helpBtn.enable = false;
  3461. this.moreBtn.enable = false;*/
  3462. // this.helpBackBtn.visible = true;
  3463. // this.helpBackBtn.enable = true;
  3464. // this.tutTouch.visible = true;
  3465. // this.tutKeyboard.visible = true
  3466. //Play68.showRanking();
  3467. },
  3468. transToTitle: function () {
  3469. this.state = d;
  3470. this.gameTitle.visible = true;
  3471. this.startBtn.visible = true;
  3472. this.helpBtn.visible = true;
  3473. this.moreBtn.visible = true;
  3474. this.gameTitle.enable = true;
  3475. this.startBtn.enable = true;
  3476. this.helpBtn.enable = true;
  3477. this.moreBtn.enable = true;
  3478. this.helpBackBtn.visible = false;
  3479. this.helpBackBtn.enable = false;
  3480. this.tutTouch.visible = false;
  3481. this.tutKeyboard.visible = false
  3482. },
  3483. touched: function (s) {
  3484. var t = this.getPointPos(s),
  3485. p = this.layers.gui.items,
  3486. r;
  3487. for (var q = 0, o = p.length; q < o; ++q) {
  3488. r = p[q];
  3489. if (r.enable && r.visible && this.intersect(r, t.x, t.y)) {
  3490. r.onTouch();
  3491. return false
  3492. }
  3493. }
  3494. this.stageTouched = true;
  3495. this.stagePressed = true
  3496. },
  3497. released: function (s) {
  3498. var t = this.getPointPos(s),
  3499. p = this.layers.gui.items,
  3500. r;
  3501. for (var q = 0, o = p.length; q < o; ++q) {
  3502. r = p[q];
  3503. if (r.enable && r.visible && this.intersect(r, t.x, t.y)) {
  3504. r.onRelease();
  3505. return false
  3506. }
  3507. }
  3508. this.stageTouched = false;
  3509. this.stageReleased = true
  3510. },
  3511. getPointPos: function (r) {
  3512. var p = r.gesture.center,
  3513. q = ig.system.canvas.getBoundingClientRect();
  3514. var o = (p.pageX - q.left) / ig.gameManager.stageScale.x,
  3515. s = (p.pageY - q.top) / ig.gameManager.stageScale.y;
  3516. return {
  3517. x: o,
  3518. y: s
  3519. }
  3520. },
  3521. intersect: function (r, o, u) {
  3522. var t = r.pos.x,
  3523. q = r.pos.x + r.size.x,
  3524. s = r.pos.y,
  3525. p = r.pos.y + r.size.y;
  3526. return !(o < t || o > q || u < s || u > p)
  3527. }
  3528. });
  3529. ig.SceneTitle = l
  3530. });
  3531. ig.baked = true;
  3532. ig.module("impact.entity-pool").requires("impact.game").defines(function () {
  3533. ig.EntityPool = {
  3534. pools: {},
  3535. mixin: {
  3536. staticInstantiate: function (a, c, b) {
  3537. return ig.EntityPool.getFromPool(this.classId, a, c, b)
  3538. },
  3539. erase: function () {
  3540. ig.EntityPool.putInPool(this)
  3541. }
  3542. },
  3543. enableFor: function (a) {
  3544. a.inject(this.mixin)
  3545. },
  3546. getFromPool: function (e, b, f, d) {
  3547. var c = this.pools[e];
  3548. if (!c || !c.length) {
  3549. return null
  3550. }
  3551. var a = c.pop();
  3552. a.reset(b, f, d);
  3553. return a
  3554. },
  3555. putInPool: function (a) {
  3556. if (!this.pools[a.classId]) {
  3557. this.pools[a.classId] = [a]
  3558. } else {
  3559. this.pools[a.classId].push(a)
  3560. }
  3561. },
  3562. drainPool: function (a) {
  3563. delete this.pools[a]
  3564. },
  3565. drainAllPools: function () {
  3566. this.pools = {}
  3567. }
  3568. };
  3569. ig.Game.inject({
  3570. loadLevel: function (a) {
  3571. ig.EntityPool.drainAllPools();
  3572. this.parent(a)
  3573. }
  3574. })
  3575. });
  3576. ig.baked = true;
  3577. ig.module("plugins.layers").requires("impact.game", "impact.background-map", "impact.entity", "impact.entity-pool").defines(function () {
  3578. var a = parseFloat(window.ig.version) || 0;
  3579. if (!a || a < 1.23) {
  3580. throw new Error("layers.js requires ImpactJS v1.23 or above, current version: " + a)
  3581. }
  3582. ig.Game.inject({
  3583. layerOrder: [],
  3584. onPreRun: [],
  3585. onPostRun: [],
  3586. layers: {},
  3587. init: function () {
  3588. this.createLayer("backgroundMaps", {
  3589. clearOnLoad: true,
  3590. mapLayer: true
  3591. });
  3592. this.createLayer("entities", {
  3593. clearOnLoad: true,
  3594. entityLayer: true,
  3595. autoSort: this.autoSort,
  3596. sortBy: this.sortBy,
  3597. _doSortEntities: false
  3598. });
  3599. this.createLayer("foregroundMaps", {
  3600. clearOnLoad: true,
  3601. mapLayer: true
  3602. })
  3603. },
  3604. setLayerProperties: function (b, c) {
  3605. this._layerProperties.push([b, c]);
  3606. return this
  3607. },
  3608. setLayerSort: function (b) {
  3609. this._layerOrder = (b && b.length) ? b : null;
  3610. return this
  3611. },
  3612. createLayer: function (b, d, e) {
  3613. var c = this.layers[b] = ig.merge(this.layers[b] || {}, d);
  3614. if (!c.items) {
  3615. c.items = []
  3616. }
  3617. if (b === "entities") {
  3618. this.entities = c.items
  3619. }
  3620. if (b === "backgroundMaps") {
  3621. this.backgroundMaps = c.items
  3622. }
  3623. if (e) {
  3624. return this
  3625. }
  3626. this.layerOrder.push(b);
  3627. return this
  3628. },
  3629. _layerProperties: [],
  3630. _layersToRemove: [],
  3631. _itemsToRemove: [],
  3632. _layersToPush: [],
  3633. _layersToPop: [],
  3634. removeLayer: function (c) {
  3635. var b = this._layersToRemove.indexOf(c);
  3636. if (b === -1) {
  3637. this._layersToRemove.push(c)
  3638. }
  3639. return this
  3640. },
  3641. pushLayer: function (c) {
  3642. var b = this._layersToPush.indexOf(c);
  3643. if (b === -1) {
  3644. this._layersToPush.push(c)
  3645. }
  3646. return this
  3647. },
  3648. popLayer: function (c) {
  3649. var b = this._layersToPop.indexOf(c);
  3650. if (b === -1) {
  3651. this._layersToPop.push(c)
  3652. }
  3653. return this
  3654. },
  3655. clearLayer: function (b) {
  3656. this._itemsToRemove = this._itemsToRemove.concat(this.layers[b].items);
  3657. return this
  3658. },
  3659. addItem: function (d, b) {
  3660. var c;
  3661. b = b || d._layer;
  3662. c = this.layers[b];
  3663. if (!c) {
  3664. throw new Error("Attempting to add to a layer that doesn't exist: " + b)
  3665. }
  3666. d._layer = b;
  3667. c.items.push(d);
  3668. return this
  3669. },
  3670. removeItem: function (b) {
  3671. if (!b || !b._layer) {
  3672. throw new Error("Layers: Cannot remove an item that doesn't exist or has no ._layer property")
  3673. }
  3674. this._itemsToRemove.push(b);
  3675. return this
  3676. },
  3677. sortEntitiesDeferred: function (b) {
  3678. b = b || "entities";
  3679. this.layers[b]._doSortEntities = true
  3680. },
  3681. sortEntities: function (b) {
  3682. b = this.layers[b || "entities"];
  3683. if (!b) {
  3684. return this
  3685. }
  3686. b.items.sort(b.sortBy);
  3687. return this
  3688. },
  3689. updateEntities: function (b) {
  3690. var e = this.layers[b || "entities"].items,
  3691. d, c;
  3692. for (c = 0; c < e.length; c++) {
  3693. d = e[c];
  3694. if (!d._killed) {
  3695. d.update()
  3696. }
  3697. }
  3698. return this
  3699. },
  3700. checkEntities: function (j) {
  3701. var h = {},
  3702. i, k, l, f, q, b, p, g, d, o, n, r, m;
  3703. i = this.layers[j || "entities"];
  3704. if (!i || !i.entityLayer) {
  3705. return
  3706. }
  3707. j = i.items;
  3708. k = j.length;
  3709. for (l = 0; l < k; l++) {
  3710. f = j[l];
  3711. if (f.type === ig.Entity.TYPE.NONE && f.checkAgainst === ig.Entity.TYPE.NONE && f.collides === ig.Entity.COLLIDES.NEVER) {
  3712. continue
  3713. }
  3714. q = {};
  3715. b = Math.floor(f.pos.x / this.cellSize);
  3716. p = Math.floor(f.pos.y / this.cellSize);
  3717. g = Math.floor((f.pos.x + f.size.x) / this.cellSize) + 1;
  3718. d = Math.floor((f.pos.y + f.size.y) / this.cellSize) + 1;
  3719. for (o = b; o < g; o++) {
  3720. for (n = p; n < d; n++) {
  3721. if (!h[o]) {
  3722. h[o] = {};
  3723. h[o][n] = [f]
  3724. } else {
  3725. if (!h[o][n]) {
  3726. h[o][n] = [f]
  3727. } else {
  3728. r = h[o][n];
  3729. for (m = 0; m < r.length; m++) {
  3730. if (f.touches(r[m]) && !q[r[m].id]) {
  3731. q[r[m].id] = true;
  3732. ig.Entity.checkPair(f, r[m])
  3733. }
  3734. }
  3735. r.push(f)
  3736. }
  3737. }
  3738. }
  3739. }
  3740. }
  3741. },
  3742. getEntitiesByType: function (g, e) {
  3743. var c = typeof (g) === "string" ? ig.global[g] : g,
  3744. b = [],
  3745. d, h, j, f;
  3746. j = this.layers[e || "entities"].items;
  3747. f = j.length;
  3748. for (d = 0; d < f; d++) {
  3749. h = j[d];
  3750. if (h instanceof c && !h._killed) {
  3751. b.push(h)
  3752. }
  3753. }
  3754. return b
  3755. },
  3756. getMapByName: function (d) {
  3757. var b, f, c, e;
  3758. if (d === "collision") {
  3759. return this.collisionMap
  3760. }
  3761. for (b = 0; b < this.layerOrder.length; b++) {
  3762. e = this.layers[this.layerOrder[b]];
  3763. c = e.items;
  3764. if (!e.mapLayer) {
  3765. continue
  3766. }
  3767. for (f = 0; f < c.length; f++) {
  3768. if (c[f].name === d) {
  3769. return c[f]
  3770. }
  3771. }
  3772. }
  3773. return null
  3774. },
  3775. update: function () {
  3776. var e, d, h, b, g, j, c, i, f;
  3777. while (this._layerProperties.length) {
  3778. d = this._layerProperties.shift();
  3779. if (!this.layers[d[0]]) {
  3780. continue
  3781. }
  3782. ig.merge(this.layers[d[0]], d[1])
  3783. }
  3784. while (this._layersToRemove.length) {
  3785. e = this._layersToRemove.shift();
  3786. d = this.layers[e];
  3787. if (!d) {
  3788. continue
  3789. }
  3790. this._itemsToRemove = this._itemsToRemove.concat(d.items);
  3791. this.layers[e] = null
  3792. }
  3793. while (this._itemsToRemove.length) {
  3794. j = this._itemsToRemove.shift();
  3795. g = this.layers[j._layer] ? this.layers[j._layer].items : null;
  3796. if (j._itemCleanUp) {
  3797. j._itemCleanUp()
  3798. }
  3799. if (!g) {
  3800. continue
  3801. }
  3802. h = g.indexOf(j);
  3803. if (h < 0) {
  3804. continue
  3805. }
  3806. g.splice(h, 1)
  3807. }
  3808. if (this._layerOrder) {
  3809. this.layerOrder = this._layerOrder;
  3810. this._layerOrder = null
  3811. }
  3812. if (this._layersToPush.length) {
  3813. for (h = 0; h < this._layersToPush.length; h++) {
  3814. this.layerOrder.push(this._layersToPush[h])
  3815. }
  3816. this._layersToPush = []
  3817. }
  3818. if (this._layersToPop.length) {
  3819. for (h = 0; h < this._layersToPop.length; h++) {
  3820. f = this.layerOrder.indexOf(this._layersToPop[h]);
  3821. if (f !== -1) {
  3822. this.layerOrder.splice(f, 1)
  3823. }
  3824. }
  3825. this._layersToPop = []
  3826. }
  3827. if (this._levelToLoad) {
  3828. this.loadLevel(this._levelToLoad);
  3829. this._levelToLoad = null
  3830. }
  3831. for (h = 0; h < this.layerOrder.length; h++) {
  3832. e = this.layerOrder[h];
  3833. d = this.layers[e];
  3834. g = d.items;
  3835. if (d.noUpdate || d.mapLayer) {
  3836. continue
  3837. }
  3838. for (b = 0; b < g.length; b++) {
  3839. g[b].update()
  3840. }
  3841. if (d.entityLayer && (d._doSortEntities || d.autoSort)) {
  3842. g.sort(d.sortBy || this.sortBy);
  3843. d._doSortEntities = false
  3844. }
  3845. if (d.entityLayer) {
  3846. this.checkEntities(e)
  3847. }
  3848. }
  3849. while (this._deferredKill.length) {
  3850. j = this._deferredKill.shift();
  3851. g = this.layers[j._layer].items;
  3852. h = g.indexOf(j);
  3853. if (j.erase) {
  3854. j.erase()
  3855. }
  3856. if (j._itemCleanUp) {
  3857. j._itemCleanUp()
  3858. }
  3859. if (h < 0) {
  3860. continue
  3861. }
  3862. g.splice(h, 1)
  3863. }
  3864. for (c in this.backgroundAnims) {
  3865. i = this.backgroundAnims[c];
  3866. for (h in i) {
  3867. i[h].update()
  3868. }
  3869. }
  3870. },
  3871. draw: function () {
  3872. var d, b, e, c;
  3873. if (this.clearColor) {
  3874. ig.system.clear(this.clearColor)
  3875. }
  3876. this._rscreen.x = ig.system.getDrawPos(this.screen.x) / ig.system.scale;
  3877. this._rscreen.y = ig.system.getDrawPos(this.screen.y) / ig.system.scale;
  3878. for (b = 0; b < this.layerOrder.length; b++) {
  3879. d = this.layers[this.layerOrder[b]];
  3880. c = d.items;
  3881. if (d.noDraw) {
  3882. continue
  3883. }
  3884. for (e = 0; e < c.length; e++) {
  3885. c[e].draw()
  3886. }
  3887. }
  3888. },
  3889. spawnEntity: function (e, b, g, d) {
  3890. var c = typeof (e) === "string" ? ig.global[e] : e,
  3891. f;
  3892. if (!c) {
  3893. throw new Error("Can't spawn entity of type: " + e)
  3894. }
  3895. f = new(c)(b, g, d || {});
  3896. this.addItem(f);
  3897. if (f.name) {
  3898. this.namedEntities[f.name] = f
  3899. }
  3900. return f
  3901. },
  3902. loadLevel: function (e) {
  3903. var j = this.layerOrder.length,
  3904. f, l, c, b, d, h, g, m, k;
  3905. ig.EntityPool.drainAllPools();
  3906. this.screen = {
  3907. x: 0,
  3908. y: 0
  3909. };
  3910. for (m = 0; m < j; m++) {
  3911. g = this.layerOrder[m];
  3912. h = this.layers[g];
  3913. if (!h) {
  3914. continue
  3915. }
  3916. if (h.clearOnLoad) {
  3917. h.items.length = 0
  3918. }
  3919. }
  3920. this.namedEntities = {};
  3921. for (f = 0; f < e.entities.length; f++) {
  3922. l = e.entities[f];
  3923. if (this._validateEntitySettings) {
  3924. this.spawnEntity(l.type, l.x, l.y, l.settings)
  3925. }
  3926. }
  3927. this.sortEntities();
  3928. this.collisionMap = ig.CollisionMap.staticNoCollision;
  3929. for (f = 0; f < e.layer.length; f++) {
  3930. c = e.layer[f];
  3931. if (c.name === "collision") {
  3932. this.collisionMap = new ig.CollisionMap(c.tilesize, c.data)
  3933. } else {
  3934. b = new ig.BackgroundMap(c.tilesize, c.data, c.tilesetName);
  3935. b.anims = this.backgroundAnims[c.tilesetName] || {};
  3936. b.repeat = c.repeat;
  3937. b.distance = c.distance;
  3938. b.foreground = !!c.foreground;
  3939. b.preRender = !!c.preRender;
  3940. b.name = c.name;
  3941. if (!b._layer && b.foreground) {
  3942. b._layer = "foregroundMaps"
  3943. } else {
  3944. if (!b._layer) {
  3945. b._layer = "backgroundMaps"
  3946. }
  3947. }
  3948. this.addItem(b)
  3949. }
  3950. }
  3951. for (m = 0; m < j; m++) {
  3952. g = this.layerOrder[m];
  3953. h = this.layers[g];
  3954. k = h.items;
  3955. d = k.length;
  3956. if (h.entityLayer) {
  3957. for (f = 0; f < d; f++) {
  3958. k[f].ready()
  3959. }
  3960. }
  3961. }
  3962. },
  3963. drawEntities: function (b) {
  3964. var e, d, c;
  3965. b = b || "entities";
  3966. e = this.layers[b].items;
  3967. for (c = 0; c < d; c++) {
  3968. e[c].draw()
  3969. }
  3970. },
  3971. run: function () {
  3972. var b;
  3973. if (this._checkRotatePrompt()) {
  3974. return
  3975. }
  3976. if (this.onPreRun.length) {
  3977. for (b = 0; b < this.onPreRun.length; b++) {
  3978. this.onPreRun[b]()
  3979. }
  3980. this.onPreRun.length = 0
  3981. }
  3982. if (!this._pauseRun) {
  3983. this.update();
  3984. this.draw()
  3985. }
  3986. if (this.onPostRun.length) {
  3987. for (b = 0; b < this.onPostRun.length; b++) {
  3988. this.onPostRun[b]()
  3989. }
  3990. this.onPostRun.length = 0
  3991. }
  3992. },
  3993. _checkRotatePrompt: function () {
  3994. ig.gameManager.checkOrientationFlag();
  3995. if (ig.gameManager && ig.gameManager._promptPause) {
  3996. this._pauseRun = true
  3997. } else {
  3998. if (ig.gameManager && !ig.gameManager._promptPause) {
  3999. this._pauseRun = false
  4000. }
  4001. }
  4002. },
  4003. _validateEntitySettings: function () {
  4004. return true
  4005. }
  4006. });
  4007. ig.Entity.inject({
  4008. _layer: "entities"
  4009. });
  4010. ig.BackgroundMap.inject({
  4011. draw: function () {
  4012. this.setScreenPos(ig.game.screen.x, ig.game.screen.y);
  4013. if (!this.tiles.loaded || !this.enabled) {
  4014. return
  4015. }
  4016. if (this.preRender) {
  4017. this.drawPreRendered()
  4018. } else {
  4019. this.drawTiled()
  4020. }
  4021. }
  4022. })
  4023. });
  4024. ig.baked = true;
  4025. ig.module("game.entities.button-left").requires("impact.entity").defines(function () {
  4026. ig.global.EntityButtonLeft = ig.Entity.extend({
  4027. _layer: "gui",
  4028. size: {
  4029. x: 45,
  4030. y: 45
  4031. },
  4032. animSheet: new ig.AnimationSheet("media/button-left.png", 45, 45),
  4033. touched: false,
  4034. pressed: false,
  4035. released: false,
  4036. init: function (a, d, b) {
  4037. this.parent(a, d, b);
  4038. var c = this.addAnim("up", 1, [0]);
  4039. if (ig.ua.iPad) {
  4040. c.alpha = 0.5
  4041. }
  4042. c = this.addAnim("down", 1, [1]);
  4043. if (ig.ua.iPad) {
  4044. c.alpha = 0.5
  4045. }
  4046. },
  4047. update: function () {
  4048. this.parent();
  4049. if (this.pressed) {
  4050. this.pressed = false
  4051. }
  4052. if (this.released) {
  4053. this.released = false
  4054. }
  4055. },
  4056. onTouch: function () {
  4057. this.touched = true;
  4058. this.pressed = true;
  4059. this.currentAnim = this.anims.down
  4060. },
  4061. onRelease: function () {
  4062. if (this.touched) {
  4063. this.touched = false;
  4064. this.released = true
  4065. }
  4066. this.currentAnim = this.anims.up
  4067. }
  4068. })
  4069. });
  4070. ig.baked = true;
  4071. ig.module("game.entities.button-right").requires("impact.entity").defines(function () {
  4072. ig.global.EntityButtonRight = ig.Entity.extend({
  4073. _layer: "gui",
  4074. size: {
  4075. x: 45,
  4076. y: 45
  4077. },
  4078. animSheet: new ig.AnimationSheet("media/button-right.png", 45, 45),
  4079. touched: false,
  4080. pressed: false,
  4081. released: false,
  4082. init: function (a, d, b) {
  4083. this.parent(a, d, b);
  4084. var c = this.addAnim("up", 1, [0]);
  4085. if (ig.ua.iPad) {
  4086. c.alpha = 0.5
  4087. }
  4088. c = this.addAnim("down", 1, [1]);
  4089. if (ig.ua.iPad) {
  4090. c.alpha = 0.5
  4091. }
  4092. },
  4093. update: function () {
  4094. this.parent();
  4095. if (this.pressed) {
  4096. this.pressed = false
  4097. }
  4098. if (this.released) {
  4099. this.released = false
  4100. }
  4101. },
  4102. onTouch: function () {
  4103. this.touched = true;
  4104. this.pressed = true;
  4105. this.currentAnim = this.anims.down
  4106. },
  4107. onRelease: function () {
  4108. if (this.touched) {
  4109. this.touched = false;
  4110. this.released = true
  4111. }
  4112. this.currentAnim = this.anims.up
  4113. }
  4114. })
  4115. });
  4116. ig.baked = true;
  4117. ig.module("game.entities.button-down").requires("impact.entity").defines(function () {
  4118. ig.global.EntityButtonDown = ig.Entity.extend({
  4119. _layer: "gui",
  4120. size: {
  4121. x: 45,
  4122. y: 45
  4123. },
  4124. animSheet: new ig.AnimationSheet("media/button-down.png", 45, 45),
  4125. touched: false,
  4126. pressed: false,
  4127. released: false,
  4128. init: function (a, d, b) {
  4129. this.parent(a, d, b);
  4130. var c = this.addAnim("up", 1, [0]);
  4131. if (ig.ua.iPad) {
  4132. c.alpha = 0.5
  4133. }
  4134. c = this.addAnim("down", 1, [1]);
  4135. if (ig.ua.iPad) {
  4136. c.alpha = 0.5
  4137. }
  4138. },
  4139. update: function () {
  4140. this.parent();
  4141. if (this.pressed) {
  4142. this.pressed = false
  4143. }
  4144. if (this.released) {
  4145. this.released = false
  4146. }
  4147. },
  4148. onTouch: function () {
  4149. this.touched = true;
  4150. this.pressed = true;
  4151. this.currentAnim = this.anims.down
  4152. },
  4153. onRelease: function () {
  4154. if (this.touched) {
  4155. this.touched = false;
  4156. this.released = true
  4157. }
  4158. this.currentAnim = this.anims.up
  4159. }
  4160. })
  4161. });
  4162. ig.baked = true;
  4163. ig.module("game.entities.button-rotate").requires("impact.entity").defines(function () {
  4164. ig.global.EntityButtonRotate = ig.Entity.extend({
  4165. _layer: "gui",
  4166. size: {
  4167. x: 45,
  4168. y: 45
  4169. },
  4170. animSheet: new ig.AnimationSheet("media/button-rotate.png", 45, 45),
  4171. touched: false,
  4172. pressed: false,
  4173. released: false,
  4174. init: function (a, d, b) {
  4175. this.parent(a, d, b);
  4176. var c = this.addAnim("up", 1, [0]);
  4177. if (ig.ua.iPad) {
  4178. c.alpha = 0.5
  4179. }
  4180. c = this.addAnim("down", 1, [1]);
  4181. if (ig.ua.iPad) {
  4182. c.alpha = 0.5
  4183. }
  4184. },
  4185. update: function () {
  4186. this.parent();
  4187. if (this.pressed) {
  4188. this.pressed = false
  4189. }
  4190. if (this.released) {
  4191. this.released = false
  4192. }
  4193. },
  4194. onTouch: function () {
  4195. this.touched = true;
  4196. this.pressed = true;
  4197. this.currentAnim = this.anims.down;
  4198. return true
  4199. },
  4200. onRelease: function () {
  4201. if (this.touched) {
  4202. this.touched = false;
  4203. this.released = true;
  4204. this.activated()
  4205. }
  4206. this.currentAnim = this.anims.up
  4207. },
  4208. activated: function () {
  4209. ig.game.activeBlock.rotateRight()
  4210. }
  4211. })
  4212. });
  4213. ig.baked = true;
  4214. ig.module("game.entities.button-menu").requires("impact.entity").defines(function () {
  4215. ig.global.EntityButtonMenu = ig.Entity.extend({
  4216. _layer: "gui",
  4217. size: {
  4218. x: 47,
  4219. y: 47
  4220. },
  4221. animSheet: new ig.AnimationSheet("media/button-menu.png", 47, 47),
  4222. touched: false,
  4223. pressed: false,
  4224. released: false,
  4225. enable: false,
  4226. init: function (a, c, b) {
  4227. this.parent(a, c, b);
  4228. this.addAnim("up", 1, [0]);
  4229. this.addAnim("down", 1, [1])
  4230. },
  4231. update: function () {
  4232. this.parent();
  4233. if (this.pressed) {
  4234. this.pressed = false
  4235. }
  4236. if (this.released) {
  4237. this.released = false
  4238. }
  4239. },
  4240. onTouch: function () {
  4241. this.touched = true;
  4242. this.pressed = true;
  4243. this.currentAnim = this.anims.down
  4244. },
  4245. onRelease: function () {
  4246. if (this.touched && this.enable) {
  4247. this.touched = false;
  4248. this.released = true;
  4249. this.activate()
  4250. }
  4251. this.currentAnim = this.anims.up
  4252. },
  4253. activate: function () {
  4254. if (ig.game.gameScene) {
  4255. ig.game.pause();
  4256. ig.game.playBtn.moveIn();
  4257. ig.game.quitBtn.moveIn()
  4258. }
  4259. }
  4260. })
  4261. });
  4262. ig.baked = true;
  4263. ig.module("game.entities.button-play").requires("impact.entity").defines(function () {
  4264. ig.global.EntityButtonPlay = ig.Entity.extend({
  4265. _layer: "gui",
  4266. size: {
  4267. x: 45,
  4268. y: 45
  4269. },
  4270. animSheet: new ig.AnimationSheet("media/button-down.png", 45, 45),
  4271. touched: false,
  4272. pressed: false,
  4273. released: false,
  4274. enable: false,
  4275. init: function (a, c, b) {
  4276. this.parent(a, c, b);
  4277. this.addAnim("up", 1, [0]);
  4278. this.addAnim("down", 1, [1])
  4279. },
  4280. update: function () {
  4281. this.parent();
  4282. if (this.pressed) {
  4283. this.pressed = false
  4284. }
  4285. if (this.released) {
  4286. this.released = false
  4287. }
  4288. },
  4289. onTouch: function () {
  4290. this.touched = true;
  4291. this.pressed = true;
  4292. this.currentAnim = this.anims.down
  4293. },
  4294. onRelease: function () {
  4295. if (this.touched && this.enable) {
  4296. this.touched = false;
  4297. this.released = true;
  4298. this.activate()
  4299. }
  4300. this.currentAnim = this.anims.up
  4301. },
  4302. activate: function () {
  4303. this.moveOut();
  4304. if (ig.game.quitBtn) {
  4305. ig.game.quitBtn.moveOut()
  4306. }
  4307. this.enable = false
  4308. },
  4309. moveIn: function () {
  4310. console.log("starting");
  4311. this.tween({
  4312. pos: {
  4313. y: 120
  4314. }
  4315. }, 0.8, {
  4316. easing: ig.Tween.Easing.Cubic.EaseOut,
  4317. onComplete: function () {
  4318. this.enable = true
  4319. }.bind(this)
  4320. }).start()
  4321. console.log("started");
  4322. },
  4323. moveOut: function () {
  4324. this.tween({
  4325. pos: {
  4326. y: -100
  4327. }
  4328. }, 0.6, {
  4329. easing: ig.Tween.Easing.Cubic.EaseIn,
  4330. onComplete: function () {
  4331. this.enable = false;
  4332. ig.game.unpause()
  4333. }
  4334. }).start()
  4335. }
  4336. })
  4337. });
  4338. ig.baked = true;
  4339. ig.module("game.entities.button-quit").requires("impact.entity").defines(function () {
  4340. ig.global.EntityButtonQuit = ig.Entity.extend({
  4341. _layer: "gui",
  4342. size: {
  4343. x: 47,
  4344. y: 47
  4345. },
  4346. animSheet: new ig.AnimationSheet("media/button-home.png", 47, 47),
  4347. touched: false,
  4348. pressed: false,
  4349. released: false,
  4350. enable: false,
  4351. init: function (a, c, b) {
  4352. this.parent(a, c, b);
  4353. this.addAnim("up", 1, [0]);
  4354. this.addAnim("down", 1, [1])
  4355. },
  4356. update: function () {
  4357. this.parent();
  4358. if (this.pressed) {
  4359. this.pressed = false
  4360. }
  4361. if (this.released) {
  4362. this.released = false
  4363. }
  4364. },
  4365. onTouch: function () {
  4366. this.touched = true;
  4367. this.pressed = true;
  4368. this.currentAnim = this.anims.down
  4369. },
  4370. onRelease: function () {
  4371. if (this.touched && this.enable) {
  4372. this.touched = false;
  4373. this.released = true;
  4374. this.activate()
  4375. }
  4376. this.currentAnim = this.anims.up
  4377. },
  4378. activate: function () {
  4379. this.enable = false;
  4380. ig.gameManager.switchToTitle()
  4381. },
  4382. moveIn: function () {
  4383. this.tween({
  4384. pos: {
  4385. y: 120
  4386. }
  4387. }, 0.8, {
  4388. easing: ig.Tween.Easing.Cubic.EaseOut,
  4389. onComplete: function () {
  4390. this.enable = true
  4391. }.bind(this)
  4392. }).start()
  4393. },
  4394. moveOut: function () {
  4395. this.tween({
  4396. pos: {
  4397. y: -100
  4398. }
  4399. }, 0.6, {
  4400. easing: ig.Tween.Easing.Cubic.EaseIn,
  4401. onComplete: function () {
  4402. this.enable = false
  4403. }.bind(this)
  4404. }).start()
  4405. }
  4406. })
  4407. });
  4408. ig.baked = true;
  4409. ig.module("game.entities.button-restart").requires("impact.entity").defines(function () {
  4410. ig.global.EntityButtonRestart = ig.Entity.extend({
  4411. _layer: "gui",
  4412. size: {
  4413. x: 47,
  4414. y: 47
  4415. },
  4416. animSheet: new ig.AnimationSheet("media/button-replay.png", 47, 47),
  4417. touched: false,
  4418. pressed: false,
  4419. released: false,
  4420. enable: false,
  4421. init: function (a, c, b) {
  4422. this.parent(a, c, b);
  4423. this.addAnim("up", 1, [0]);
  4424. this.addAnim("down", 1, [1])
  4425. },
  4426. update: function () {
  4427. this.parent();
  4428. if (this.pressed) {
  4429. this.pressed = false
  4430. }
  4431. if (this.released) {
  4432. this.released = false
  4433. }
  4434. },
  4435. onTouch: function () {
  4436. this.touched = true;
  4437. this.pressed = true;
  4438. this.currentAnim = this.anims.down
  4439. },
  4440. onRelease: function () {
  4441. if (this.touched && this.enable) {
  4442. this.touched = false;
  4443. this.released = true;
  4444. this.activate()
  4445. }
  4446. this.currentAnim = this.anims.up
  4447. },
  4448. activate: function () {
  4449. this.enable = false;
  4450. if (ig.game.quitBtn) {
  4451. ig.game.quitBtn.enable = false
  4452. }
  4453. if (ig.game.gemsMode) {
  4454. ig.gameManager.newGemsRound()
  4455. } else {
  4456. ig.gameManager.newClassicRound()
  4457. }
  4458. },
  4459. moveIn: function () {
  4460. this.tween({
  4461. pos: {
  4462. y: 120
  4463. }
  4464. }, 0.8, {
  4465. easing: ig.Tween.Easing.Cubic.EaseOut,
  4466. onComplete: function () {
  4467. this.enable = true
  4468. }.bind(this)
  4469. }).start()
  4470. },
  4471. moveOut: function () {
  4472. this.tween({
  4473. pos: {
  4474. y: -100
  4475. }
  4476. }, 0.6, {
  4477. easing: ig.Tween.Easing.Cubic.EaseIn,
  4478. onComplete: function () {
  4479. this.enable = false
  4480. }.bind(this)
  4481. }).start()
  4482. }
  4483. })
  4484. });
  4485. ig.baked = true;
  4486. ig.module("plugins.gridmovement").requires("impact.impact").defines(function () {
  4487. var a = window.GridMovement = ig.Class.extend({
  4488. entity: null,
  4489. init: function (b) {
  4490. this.entity = b
  4491. },
  4492. move: function (e) {
  4493. if (this.canMove(e)) {
  4494. var c = this.getCurrentTile();
  4495. var d = this.getAdjacentTile(c.x, c.y, e);
  4496. var b = this.tileToPixelPos(d.x, d.y);
  4497. this.entity.pos.x = b.x;
  4498. this.entity.pos.y = b.y
  4499. }
  4500. },
  4501. getCurrentTile: function () {
  4502. var d = ig.game.collisionMap.tilesize;
  4503. var c = this.entity.pos.x / d;
  4504. var b = this.entity.pos.y / d;
  4505. return {
  4506. x: c,
  4507. y: b
  4508. }
  4509. },
  4510. getAdjacentTile: function (c, b, d) {
  4511. if (d === a.direction.UP) {
  4512. b += -1
  4513. } else {
  4514. if (d === a.direction.DOWN) {
  4515. b += 1
  4516. } else {
  4517. if (d === a.direction.LEFT) {
  4518. c += -1
  4519. } else {
  4520. if (d === a.direction.RIGHT) {
  4521. c += 1
  4522. }
  4523. }
  4524. }
  4525. }
  4526. return {
  4527. x: c,
  4528. y: b
  4529. }
  4530. },
  4531. snapToTile: function (b, d) {
  4532. var c = ig.game.collisionMap.tilesize;
  4533. this.entity.pos.x = b * c;
  4534. this.entity.pos.y = d * c
  4535. },
  4536. canMoveFromTile: function (d, c, e) {
  4537. var b = this.getAdjacentTile(d, c, e);
  4538. return ig.game.collisionMap.data[Math.round(b.y)][Math.round(b.x)] === 0
  4539. },
  4540. canMove: function (c) {
  4541. var b = this.getCurrentTile();
  4542. return this.canMoveFromTile(b.x, b.y, c)
  4543. },
  4544. tileToPixelPos: function (c, b) {
  4545. return {
  4546. x: c * ig.game.collisionMap.tilesize,
  4547. y: b * ig.game.collisionMap.tilesize
  4548. }
  4549. }
  4550. });
  4551. a.direction = {
  4552. UP: 1,
  4553. DOWN: 2,
  4554. LEFT: 4,
  4555. RIGHT: 8
  4556. }
  4557. });
  4558. ig.baked = true;
  4559. ig.module("game.entities.destruct").requires("impact.entity").defines(function () {
  4560. ig.global.EntityDestruct = ig.Entity.extend({
  4561. _layer: "effect",
  4562. animSheet: new ig.AnimationSheet("media/block-destruct.png", 33, 33),
  4563. init: function (a, c, b) {
  4564. this.parent(a, c, b);
  4565. this.addAnim("play", 0.06, [0, 1, 2, 3, 4, 5, 6, 7, 8], false)
  4566. },
  4567. update: function () {
  4568. this.parent();
  4569. if (this.currentAnim.loopCount > 0) {
  4570. this.kill()
  4571. }
  4572. }
  4573. })
  4574. });
  4575. ig.baked = true;
  4576. ig.module("game.entities.explosion").requires("impact.entity").defines(function () {
  4577. ig.global.EntityExplosion = ig.Entity.extend({
  4578. _layer: "effect",
  4579. size: {
  4580. x: 186,
  4581. y: 157
  4582. },
  4583. animSheet: new ig.AnimationSheet("media/bang.png", 186, 157),
  4584. init: function (a, c, b) {
  4585. this.parent(a, c, b);
  4586. this.addAnim("play", 0.12, [0, 1, 2, 3, 4, 5, 6, 7, 8], false)
  4587. },
  4588. update: function () {
  4589. this.parent();
  4590. if (this.currentAnim.loopCount > 0) {
  4591. this.kill()
  4592. }
  4593. }
  4594. })
  4595. });
  4596. ig.baked = true;
  4597. ig.module("game.entities.slowlight").requires("impact.entity").defines(function () {
  4598. ig.global.EntitySlowlight = ig.Entity.extend({
  4599. _layer: "effect",
  4600. timeScale: 0.6,
  4601. animSheet: new ig.AnimationSheet("media/slow.png", 181, 54),
  4602. collides: ig.Entity.COLLIDES.NEVER,
  4603. init: function (a, c, b) {
  4604. this.parent(a, c, b);
  4605. this.addAnim("idle", 1, [0], true)
  4606. },
  4607. update: function () {
  4608. this.pos.y -= 320 * ig.system.tick;
  4609. if (this.pos.y < -64) {
  4610. this.kill()
  4611. }
  4612. }
  4613. })
  4614. });
  4615. ig.baked = true;
  4616. ig.module("game.entities.block").requires("impact.entity", "plugins.gridmovement", "game.entities.destruct", "game.entities.explosion", "game.entities.slowlight", "game.config").defines(function () {
  4617. var a = ig.CONFIG;
  4618. var b = ig.global.EntityBlock = ig.Entity.extend({
  4619. _layer: "block",
  4620. size: {
  4621. x: a.TILESIZE,
  4622. y: a.TILESIZE
  4623. },
  4624. collides: ig.Entity.COLLIDES.NEVER,
  4625. animSheet: null,
  4626. gridMover: null,
  4627. destroyState: false,
  4628. init: function (c, e, d) {
  4629. this.parent(c, e, d);
  4630. this.gridMover = new GridMovement(this)
  4631. },
  4632. setColor: function (c) {
  4633. this.initAnim(c)
  4634. },
  4635. initAnim: function (c) {
  4636. switch (c) {
  4637. case b.color.COLOR_L:
  4638. if (!ig.game.gemsMode) {
  4639. this.animSheet = new ig.AnimationSheet("media/block-l.png", a.TILESIZE, a.TILESIZE)
  4640. } else {
  4641. this.animSheet = new ig.AnimationSheet("media/gems-01.png", a.TILESIZE, a.TILESIZE)
  4642. }
  4643. break;
  4644. case b.color.COLOR_S:
  4645. if (!ig.game.gemsMode) {
  4646. this.animSheet = new ig.AnimationSheet("media/block-s.png", a.TILESIZE, a.TILESIZE)
  4647. } else {
  4648. this.animSheet = new ig.AnimationSheet("media/gems-02.png", a.TILESIZE, a.TILESIZE)
  4649. }
  4650. break;
  4651. case b.color.COLOR_SQUARE:
  4652. if (!ig.game.gemsMode) {
  4653. this.animSheet = new ig.AnimationSheet("media/block-square.png", a.TILESIZE, a.TILESIZE)
  4654. } else {
  4655. this.animSheet = new ig.AnimationSheet("media/gems-03.png", a.TILESIZE, a.TILESIZE)
  4656. }
  4657. break;
  4658. case b.color.COLOR_LINE:
  4659. if (!ig.game.gemsMode) {
  4660. this.animSheet = new ig.AnimationSheet("media/block-line.png", a.TILESIZE, a.TILESIZE)
  4661. } else {
  4662. this.animSheet = new ig.AnimationSheet("media/gems-04.png", a.TILESIZE, a.TILESIZE)
  4663. }
  4664. break;
  4665. case b.color.COLOR_TRIANGLE:
  4666. if (!ig.game.gemsMode) {
  4667. this.animSheet = new ig.AnimationSheet("media/block-triangle.png", a.TILESIZE, a.TILESIZE)
  4668. } else {
  4669. this.animSheet = new ig.AnimationSheet("media/gems-05.png", a.TILESIZE, a.TILESIZE)
  4670. }
  4671. break;
  4672. case b.color.COLOR_LR:
  4673. if (!ig.game.gemsMode) {
  4674. this.animSheet = new ig.AnimationSheet("media/block-lr.png", a.TILESIZE, a.TILESIZE)
  4675. } else {
  4676. this.animSheet = new ig.AnimationSheet("media/gems-06.png", a.TILESIZE, a.TILESIZE)
  4677. }
  4678. break;
  4679. case b.color.COLOR_SR:
  4680. if (!ig.game.gemsMode) {
  4681. this.animSheet = new ig.AnimationSheet("media/block-sr.png", a.TILESIZE, a.TILESIZE)
  4682. } else {
  4683. this.animSheet = new ig.AnimationSheet("media/gems-03.png", a.TILESIZE, a.TILESIZE)
  4684. }
  4685. break;
  4686. default:
  4687. if (!ig.game.gemsMode) {
  4688. this.animSheet = new ig.AnimationSheet("media/single-block.png", a.TILESIZE, a.TILESIZE)
  4689. } else {
  4690. this.animSheet = new ig.AnimationSheet("media/gems-06.png", a.TILESIZE, a.TILESIZE)
  4691. }
  4692. break
  4693. }
  4694. this.addAnim("idle", 1, [0]);
  4695. this.addAnim("blink", 0.07, [0, 1, 2, 3, 2, 1]);
  4696. this.anims.blink.timer = b.animationTimer
  4697. },
  4698. update: function () {
  4699. if (this.destroyState) {
  4700. if (this.currentAnim !== this.anims.blink) {
  4701. this.currentAnim = this.anims.blink.rewind()
  4702. }
  4703. } else {
  4704. if (this.currentAnim !== this.anims.idle) {
  4705. this.currentAnim = this.anims.idle.rewind()
  4706. }
  4707. }
  4708. this.parent()
  4709. },
  4710. check: function () {
  4711. this.parent()
  4712. },
  4713. moveLeft: function () {
  4714. this.gridMover.move(GridMovement.direction.LEFT)
  4715. },
  4716. moveRight: function () {
  4717. this.gridMover.move(GridMovement.direction.RIGHT)
  4718. },
  4719. moveDown: function () {
  4720. this.gridMover.move(GridMovement.direction.DOWN)
  4721. },
  4722. canMoveLeft: function () {
  4723. return this.gridMover.canMove(GridMovement.direction.LEFT)
  4724. },
  4725. canMoveRight: function () {
  4726. return this.gridMover.canMove(GridMovement.direction.RIGHT)
  4727. },
  4728. canMoveDown: function () {
  4729. return this.gridMover.canMove(GridMovement.direction.DOWN)
  4730. },
  4731. lock: function () {
  4732. var c = this.getCurrentTile();
  4733. ig.game.collisionMap.data[c.y][c.x] = 1
  4734. },
  4735. freeCollisionMap: function () {
  4736. var c = this.getCurrentTile();
  4737. ig.game.collisionMap.data[c.y][c.x] = 0
  4738. },
  4739. overlapsCollisionMap: function () {
  4740. var c = this.getCurrentTile();
  4741. return ig.game.collisionMap.data[c.y][c.x] !== 0
  4742. },
  4743. getCurrentTile: function () {
  4744. return {
  4745. x: Math.round(this.pos.x / a.TILESIZE),
  4746. y: Math.round(this.pos.y / a.TILESIZE)
  4747. }
  4748. },
  4749. startDestruction: function () {
  4750. this.destroyState = true;
  4751. if (ig.game.gemsMode) {
  4752. ig.game.spawnEntity(ig.global.EntityDestruct, this.pos.x + (this.size.x - 1) / 2 - 16, this.pos.y + (this.size.y - 1) / 2 - 16)
  4753. }
  4754. }
  4755. });
  4756. b.color = {
  4757. COLOR_L: "1",
  4758. COLOR_LR: "2",
  4759. COLOR_LINE: "3",
  4760. COLOR_S: "4",
  4761. COLOR_SR: "5",
  4762. COLOR_SQUARE: "6",
  4763. COLOR_TRIANGLE: "7"
  4764. }, b.animationTimer = new ig.Timer();
  4765. ig.global.EntityBombBlock = b.extend({
  4766. imBomb: true,
  4767. setColor: function () {
  4768. this.animSheet = new ig.AnimationSheet("media/bomb-block.png", a.TILESIZE, a.TILESIZE);
  4769. this.addAnim("idle", 0.1, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6], false);
  4770. this.addAnim("blink", 1, [0], false)
  4771. },
  4772. startDestruction: function () {
  4773. this.destroyState = true;
  4774. ig.game.spawnEntity(ig.global.EntityExplosion, this.pos.x + this.size.x / 2 - 93, this.pos.y + this.size.y / 2 - 78)
  4775. }
  4776. });
  4777. ig.global.EntitySlowBlock = b.extend({
  4778. setColor: function () {
  4779. this.animSheet = new ig.AnimationSheet("media/slow-block.png", a.TILESIZE, a.TILESIZE);
  4780. this.addAnim("idle", 0.1, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6], false);
  4781. this.addAnim("blink", 1, [0], false)
  4782. },
  4783. startDestruction: function () {
  4784. this.destroyState = true;
  4785. ig.game.slowdown()
  4786. }
  4787. })
  4788. });
  4789. ig.baked = true;
  4790. ig.module("game.entities.block-container").requires("impact.entity", "game.entities.block", "game.config").defines(function () {
  4791. var c = ig.CONFIG,
  4792. b = ig.CONFIG.GEMS;
  4793. var a = ig.global.EntityBlockContainer = ig.Entity.extend({
  4794. _layer: "proxy",
  4795. size: {
  4796. x: c.TILESIZE * 4,
  4797. y: c.TILESIZE * 4
  4798. },
  4799. collides: ig.Entity.COLLIDES.NEVER,
  4800. spawnOffset: {
  4801. x: 0,
  4802. y: 0
  4803. },
  4804. rotationState: 0,
  4805. rotationShapes: [],
  4806. rotationStates: 0,
  4807. blocks: [],
  4808. initialized: false,
  4809. init: function (d, f, e) {
  4810. this.parent(d, f, e);
  4811. this.rotationStates = this.rotationShapes.length;
  4812. this.initBlocks();
  4813. this.initialized = true
  4814. },
  4815. initBlocks: function () {
  4816. var m = this.getCurrentShape();
  4817. for (var k = 0; k < m.length; k++) {
  4818. for (var d = 0; d < m[k].length; d++) {
  4819. if (m[k][d] === 1) {
  4820. var f = ig.global.EntityBlock;
  4821. if (ig.game.gemsMode) {
  4822. var j = Math.random(),
  4823. i = Math.random();
  4824. var h = (j < b.BOMB_PROBABILITY),
  4825. l = (i < b.SLOW_PROBABILITY);
  4826. if (h && !l) {
  4827. f = ig.global.EntityBombBlock
  4828. } else {
  4829. if (l && !h) {
  4830. f = ig.global.EntitySlowBlock
  4831. } else {
  4832. if (h && l) {
  4833. var e = Math.random();
  4834. if (e < b.BOMB_OVER_SLOW_PROBABILITY) {
  4835. f = ig.global.EntityBombBlock
  4836. } else {
  4837. f = ig.global.EntitySlowBlock
  4838. }
  4839. }
  4840. }
  4841. }
  4842. }
  4843. var g = ig.game.spawnEntity(f, this.pos.x + (c.TILESIZE * d), this.pos.y + (c.TILESIZE * k));
  4844. g.setColor(this.color);
  4845. this.blocks.push(g)
  4846. }
  4847. }
  4848. }
  4849. },
  4850. rotateRight: function () {
  4851. var d = this._doRotateRight()
  4852. },
  4853. _doRotateRight: function () {
  4854. this.rotationState = mmod(this.rotationState + 1, this.rotationStates);
  4855. var d = this.getCurrentShape();
  4856. this.adjustBlockPositions(d);
  4857. if (this.blocksHaveCollision()) {
  4858. this._doRotateLeft();
  4859. return false
  4860. }
  4861. return true
  4862. },
  4863. rotateLeft: function () {
  4864. var d = this._doRotateLeft()
  4865. },
  4866. _doRotateLeft: function () {
  4867. this.rotationState = mmod(this.rotationState - 1, this.rotationStates);
  4868. var d = this.getCurrentShape();
  4869. this.adjustBlockPositions(d);
  4870. if (this.blocksHaveCollision()) {
  4871. this._doRotateRight();
  4872. return false
  4873. }
  4874. return true
  4875. },
  4876. moveLeft: function () {
  4877. for (var d = 0; d < this.blocks.length; d++) {
  4878. if (this.blocks[d].canMoveLeft() === false) {
  4879. return false
  4880. }
  4881. }
  4882. this.pos.x -= c.TILESIZE;
  4883. for (var d = 0; d < this.blocks.length; d++) {
  4884. this.blocks[d].moveLeft()
  4885. }
  4886. return true
  4887. },
  4888. moveRight: function () {
  4889. for (var d = 0; d < this.blocks.length; d++) {
  4890. if (this.blocks[d].canMoveRight() === false) {
  4891. return false
  4892. }
  4893. }
  4894. this.pos.x += c.TILESIZE;
  4895. for (var d = 0; d < this.blocks.length; d++) {
  4896. this.blocks[d].moveRight()
  4897. }
  4898. return true
  4899. },
  4900. moveDown: function () {
  4901. for (var d = 0; d < this.blocks.length; d++) {
  4902. if (this.blocks[d].canMoveDown() === false) {
  4903. return false
  4904. }
  4905. }
  4906. this.pos.y += c.TILESIZE;
  4907. for (var d = 0; d < this.blocks.length; d++) {
  4908. this.blocks[d].moveDown()
  4909. }
  4910. return true
  4911. },
  4912. canMoveDown: function () {
  4913. for (var d = 0; d < this.blocks.length; d++) {
  4914. if (this.blocks[d].canMoveDown() === false) {
  4915. return false
  4916. }
  4917. }
  4918. return true
  4919. },
  4920. teleportPos: function (e) {
  4921. this.pos.x = e.x;
  4922. this.pos.y = e.y;
  4923. var d = this.getCurrentShape();
  4924. this.adjustBlockPositions(d)
  4925. },
  4926. adjustBlockPositions: function (d) {
  4927. var f = 0;
  4928. for (var h = 0; h < d.length; h++) {
  4929. for (var e = 0; e < d[h].length; e++) {
  4930. if (d[h][e] === 1) {
  4931. var g = this.blocks[f];
  4932. g.pos.x = this.pos.x + (c.TILESIZE * e);
  4933. g.pos.y = this.pos.y + (c.TILESIZE * h);
  4934. f++
  4935. }
  4936. }
  4937. }
  4938. },
  4939. blocksHaveCollision: function () {
  4940. for (var d = 0; d < this.blocks.length; d++) {
  4941. if (this.blocks[d].overlapsCollisionMap()) {
  4942. return true
  4943. }
  4944. }
  4945. return false
  4946. },
  4947. getCurrentShape: function () {
  4948. return this.rotationShapes[this.rotationState]
  4949. },
  4950. lock: function () {
  4951. this.initialized = false;
  4952. for (var d = 0; d < this.blocks.length; d++) {
  4953. this.blocks[d].lock()
  4954. }
  4955. return this.blocks
  4956. },
  4957. isInitialized: function () {
  4958. return this.initialized
  4959. }
  4960. })
  4961. });
  4962. ig.baked = true;
  4963. ig.module("game.entities.block-shape-single").requires("game.entities.block", "game.entities.block-container").defines(function () {
  4964. var a = ig.global.EntityBlockShapeSingle = EntityBlockContainer.extend({
  4965. rotationShapes: [
  4966. [
  4967. [1]
  4968. ]
  4969. ]
  4970. })
  4971. });
  4972. ig.baked = true;
  4973. ig.module("game.entities.block-shape-l").requires("game.entities.block", "game.entities.block-container").defines(function () {
  4974. var a = ig.global.EntityBlockShapeL = EntityBlockContainer.extend({
  4975. color: EntityBlock.color.COLOR_L,
  4976. rotationShapes: [
  4977. [
  4978. [0, 0, 0],
  4979. [1, 1, 1],
  4980. [1, 0, 0]
  4981. ],
  4982. [
  4983. [1, 1, 0],
  4984. [0, 1, 0],
  4985. [0, 1, 0]
  4986. ],
  4987. [
  4988. [0, 0, 1],
  4989. [1, 1, 1],
  4990. [0, 0, 0]
  4991. ],
  4992. [
  4993. [0, 1, 0],
  4994. [0, 1, 0],
  4995. [0, 1, 1]
  4996. ]
  4997. ]
  4998. })
  4999. });
  5000. ig.baked = true;
  5001. ig.module("game.entities.block-shape-lr").requires("game.entities.block", "game.entities.block-container").defines(function () {
  5002. var a = ig.global.EntityBlockShapeLr = EntityBlockContainer.extend({
  5003. color: EntityBlock.color.COLOR_LR,
  5004. rotationShapes: [
  5005. [
  5006. [0, 0, 0],
  5007. [1, 1, 1],
  5008. [0, 0, 1]
  5009. ],
  5010. [
  5011. [0, 1, 0],
  5012. [0, 1, 0],
  5013. [1, 1, 0]
  5014. ],
  5015. [
  5016. [1, 0, 0],
  5017. [1, 1, 1],
  5018. [0, 0, 0]
  5019. ],
  5020. [
  5021. [0, 1, 1],
  5022. [0, 1, 0],
  5023. [0, 1, 0]
  5024. ]
  5025. ]
  5026. })
  5027. });
  5028. ig.baked = true;
  5029. ig.module("game.entities.block-shape-line").requires("game.entities.block", "game.entities.block-container").defines(function () {
  5030. var a = ig.global.EntityBlockShapeLine = EntityBlockContainer.extend({
  5031. color: EntityBlock.color.COLOR_LINE,
  5032. rotationShapes: [
  5033. [
  5034. [0, 0, 0, 0],
  5035. [0, 0, 0, 0],
  5036. [1, 1, 1, 1]
  5037. ],
  5038. [
  5039. [0, 1, 0],
  5040. [0, 1, 0],
  5041. [0, 1, 0],
  5042. [0, 1, 0]
  5043. ]
  5044. ]
  5045. })
  5046. });
  5047. ig.baked = true;
  5048. ig.module("game.entities.block-shape-square").requires("game.entities.block", "game.entities.block-container").defines(function () {
  5049. var a = ig.global.EntityBlockShapeSquare = EntityBlockContainer.extend({
  5050. color: EntityBlock.color.COLOR_SQUARE,
  5051. rotationShapes: [
  5052. [
  5053. [1, 1],
  5054. [1, 1]
  5055. ]
  5056. ]
  5057. })
  5058. });
  5059. ig.baked = true;
  5060. ig.module("game.entities.block-shape-s").requires("game.entities.block", "game.entities.block-container").defines(function () {
  5061. var a = ig.global.EntityBlockShapeS = EntityBlockContainer.extend({
  5062. color: EntityBlock.color.COLOR_S,
  5063. rotationShapes: [
  5064. [
  5065. [0, 1, 1],
  5066. [1, 1, 0]
  5067. ],
  5068. [
  5069. [1, 0],
  5070. [1, 1],
  5071. [0, 1]
  5072. ]
  5073. ]
  5074. })
  5075. });
  5076. ig.baked = true;
  5077. ig.module("game.entities.block-shape-sr").requires("game.entities.block", "game.entities.block-container").defines(function () {
  5078. var a = ig.global.EntityBlockShapeSr = EntityBlockContainer.extend({
  5079. color: EntityBlock.color.COLOR_SR,
  5080. rotationShapes: [
  5081. [
  5082. [1, 1, 0],
  5083. [0, 1, 1]
  5084. ],
  5085. [
  5086. [0, 1],
  5087. [1, 1],
  5088. [1, 0]
  5089. ]
  5090. ]
  5091. })
  5092. });
  5093. ig.baked = true;
  5094. ig.module("game.entities.block-shape-triangle").requires("game.entities.block", "game.entities.block-container").defines(function () {
  5095. var a = ig.global.EntityBlockShapeTriangle = EntityBlockContainer.extend({
  5096. color: EntityBlock.color.COLOR_TRIANGLE,
  5097. rotationShapes: [
  5098. [
  5099. [0, 0, 0],
  5100. [1, 1, 1],
  5101. [0, 1, 0]
  5102. ],
  5103. [
  5104. [0, 1, 0],
  5105. [1, 1, 0],
  5106. [0, 1, 0]
  5107. ],
  5108. [
  5109. [0, 1, 0],
  5110. [1, 1, 1],
  5111. [0, 0, 0]
  5112. ],
  5113. [
  5114. [0, 1, 0],
  5115. [0, 1, 1],
  5116. [0, 1, 0]
  5117. ]
  5118. ]
  5119. })
  5120. });
  5121. ig.baked = true;
  5122. ig.module("game.levels.main").requires("impact.image").defines(function () {
  5123. LevelMain = {
  5124. entities: [],
  5125. layer: [{
  5126. name: "collision",
  5127. width: 22,
  5128. height: 20,
  5129. linkWithCollision: false,
  5130. visible: 1,
  5131. tilesetName: "",
  5132. repeat: false,
  5133. preRender: true,
  5134. distance: 1,
  5135. tilesize: 17,
  5136. foreground: false,
  5137. data: [
  5138. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5139. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5140. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5141. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5142. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5143. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5144. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5145. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5146. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5147. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5148. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5149. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5150. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5151. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5152. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5153. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5154. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5155. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5156. [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  5157. [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  5158. ]
  5159. }]
  5160. }
  5161. });
  5162. ig.baked = true;
  5163. ig.module("game.utils.field-manager").requires("game.entities.block", "game.entities.block-container", "game.config").defines(function () {
  5164. var a = ig.CONFIG;
  5165. var b = ig.Class.extend({
  5166. field: [],
  5167. init: function () {
  5168. this.initField()
  5169. },
  5170. initField: function () {
  5171. this.field = [];
  5172. for (var d = 0; d < a.FIELD_ROWS; d++) {
  5173. var e = [];
  5174. for (var c = 0; c < a.FIELD_COLS; c++) {
  5175. e.push(null)
  5176. }
  5177. this.field.push(e)
  5178. }
  5179. },
  5180. lockBlock: function (c) {
  5181. var f = c.lock();
  5182. c.kill();
  5183. for (var d = 0; d < f.length; d++) {
  5184. var e = f[d].getCurrentTile();
  5185. this.field[e.y][e.x - 1] = f[d]
  5186. }
  5187. },
  5188. handleLineCleaning: function () {
  5189. var c = this.checkFullLines();
  5190. return this.cleanFullRows(c)
  5191. },
  5192. checkFullLines: function () {
  5193. var d = [],
  5194. h, c = false;
  5195. for (var g = 0; g < a.FIELD_ROWS; g++) {
  5196. var f = 0;
  5197. for (var e = 0; e < a.FIELD_COLS; e++) {
  5198. h = this.field[g][e];
  5199. if (!h) {
  5200. break
  5201. }
  5202. f++;
  5203. if (h.imBomb) {
  5204. c = true
  5205. }
  5206. h = undefined
  5207. }
  5208. if (f === a.FIELD_COLS) {
  5209. if (c) {
  5210. if (g > 0) {
  5211. d.push(g - 1)
  5212. }
  5213. if (g < a.FIELD_ROWS - 2) {
  5214. d.push(a.FIELD_ROWS - 1)
  5215. }
  5216. }
  5217. d.push(g)
  5218. }
  5219. c = false
  5220. }
  5221. return d
  5222. },
  5223. cleanFullRows: function (d) {
  5224. var c = d.length;
  5225. if (c <= 0) {
  5226. return 0
  5227. }
  5228. d.sort(function (j, i) {
  5229. return j - i
  5230. });
  5231. for (var g = 0; g < d.length; g++) {
  5232. var h = d[g];
  5233. for (var e = 0; e < a.FIELD_COLS; e++) {
  5234. var f = this.field[h][e];
  5235. if (f) {
  5236. f.freeCollisionMap();
  5237. f.kill()
  5238. }
  5239. this.field[h][e] = null
  5240. }
  5241. this.moveUpperRowsDown(h, 1)
  5242. }
  5243. return c
  5244. },
  5245. moveUpperRowsDown: function (e, c) {
  5246. for (var h = e; h >= 0; h--) {
  5247. for (var d = 0; d < a.FIELD_COLS; d++) {
  5248. var g = this.field[h][d];
  5249. if (!g) {
  5250. continue
  5251. }
  5252. g.freeCollisionMap();
  5253. for (var f = 0; f < c; f++) {
  5254. g.moveDown()
  5255. }
  5256. g.lock();
  5257. this.field[h][d] = null;
  5258. this.field[h + c][d] = g
  5259. }
  5260. }
  5261. },
  5262. startLineDestruction: function (c) {
  5263. for (var f = 0; f < c.length; f++) {
  5264. var g = c[f];
  5265. for (var d = 0; d < a.FIELD_COLS; d++) {
  5266. var e = this.field[g][d];
  5267. if (e) {
  5268. e.startDestruction()
  5269. }
  5270. }
  5271. }
  5272. },
  5273. logField: function () {
  5274. for (var e = 0; e < a.FIELD_ROWS; e++) {
  5275. var d = "";
  5276. for (var c = 0; c < a.FIELD_COLS; c++) {
  5277. d += (this.field[e][c] !== null ? "1" : 0)
  5278. }
  5279. console.log(e + ": " + d)
  5280. }
  5281. }
  5282. });
  5283. ig.FieldManager = b
  5284. });
  5285. ig.baked = true;
  5286. ig.module("game.scenes.gems").requires("impact.game", "plugins.layers", "game.entities.button-left", "game.entities.button-right", "game.entities.button-down", "game.entities.button-rotate", "game.entities.button-menu", "game.entities.button-play", "game.entities.button-quit", "game.entities.button-restart", "game.entities.block", "game.entities.block-container", "game.entities.block-shape-single", "game.entities.block-shape-l", "game.entities.block-shape-lr", "game.entities.block-shape-line", "game.entities.block-shape-square", "game.entities.block-shape-s", "game.entities.block-shape-sr", "game.entities.block-shape-triangle", "game.levels.main", "game.config", "game.utils.field-manager").defines(function () {
  5287. var b = ig.CONFIG.GEMS;
  5288. var a = ig.Entity.extend({
  5289. _layer: "bg",
  5290. animSheet: new ig.AnimationSheet("media/gems-bg.png", 320, 480),
  5291. size: {
  5292. x: 320,
  5293. y: 480
  5294. },
  5295. init: function (g, i, h) {
  5296. this.parent(g, i, h);
  5297. this.addAnim("idle", 1, [0], true)
  5298. }
  5299. });
  5300. var d = ig.Entity.extend({
  5301. _layer: "bg",
  5302. animSheet: new ig.AnimationSheet("media/bg-anim-top.png", 320, 98),
  5303. size: {
  5304. x: 320,
  5305. y: 98
  5306. },
  5307. init: function (g, i, h) {
  5308. this.parent(g, i, h);
  5309. this.addAnim("idle", 0.16, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])
  5310. }
  5311. });
  5312. var f = ig.Entity.extend({
  5313. _layer: "bg",
  5314. animSheet: new ig.AnimationSheet("media/bg-anim-bottom.png", 320, 113),
  5315. size: {
  5316. x: 320,
  5317. y: 113
  5318. },
  5319. init: function (g, i, h) {
  5320. this.parent(g, i, h);
  5321. this.addAnim("idle", 0.2, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26])
  5322. }
  5323. });
  5324. var e = ig.Entity.extend({
  5325. _layer: "bg",
  5326. animSheet: new ig.AnimationSheet("media/pirate.png", 171, 149),
  5327. size: {
  5328. x: 171,
  5329. y: 149
  5330. },
  5331. switchRange: {
  5332. min: 4,
  5333. max: 8
  5334. },
  5335. switchTimer: null,
  5336. init: function (g, i, h) {
  5337. this.parent(g, i, h);
  5338. this.addAnim("idle", 0.2, [0, 1, 2, 3, 4, 5, 6, 7, 8], false);
  5339. this.addAnim("sword", 0.1, [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22], true);
  5340. this.switchTimer = new ig.Timer();
  5341. this.resetTimer()
  5342. },
  5343. update: function () {
  5344. this.parent();
  5345. if (this.currentAnim === this.anims.sword) {
  5346. if (this.currentAnim.loopCount > 0) {
  5347. this.resetTimer();
  5348. this.currentAnim = this.anims.idle.rewind()
  5349. }
  5350. } else {
  5351. if (this.switchTimer.delta() > 0) {
  5352. this.resetTimer()
  5353. }
  5354. }
  5355. },
  5356. resetTimer: function () {
  5357. this.switchTimer.set(Math.random().map(0, 1, this.switchRange.min, this.switchRange.max));
  5358. if (this.currentAnim === this.anims.idle) {
  5359. this.currentAnim = this.anims.sword.rewind()
  5360. } else {
  5361. this.currentAnim = this.anims.idle.rewind()
  5362. }
  5363. }
  5364. });
  5365. var c = ig.Game.extend({
  5366. gemsMode: true,
  5367. gameScene: true,
  5368. font: new ig.Font("media/bitdust2_16.font.png"),
  5369. bFont: new ig.Font("media/bitdust2_16_bold.font.png"),
  5370. bgOffset: {
  5371. x: -25,
  5372. y: -44
  5373. },
  5374. activeBlock: null,
  5375. nextBlock: null,
  5376. timerLeftRight: null,
  5377. timerDown: null,
  5378. timerAutoDown: null,
  5379. timerLock: null,
  5380. timerDestruction: null,
  5381. lockTimerRunning: false,
  5382. forceButtonDownRelease: false,
  5383. stage: 1,
  5384. fallSpeed: 1.1,
  5385. fieldManager: null,
  5386. currentFullRows: null,
  5387. lineCount: 0,
  5388. score: 0,
  5389. ended: false,
  5390. linesPosOnKeyDown: 0,
  5391. isCleaningLines: false,
  5392. timeScale: 0.6,
  5393. slowDurition: b.SLOW_DURITION,
  5394. leftBtn: null,
  5395. rightBtn: null,
  5396. downBtn: null,
  5397. rotateBtn: null,
  5398. stageTouched: false,
  5399. stagePressed: false,
  5400. stageReleased: false,
  5401. paused: false,
  5402. init: function () {
  5403. this.createLayer("bg");
  5404. this.createLayer("proxy", {
  5405. clearOnLoad: true,
  5406. entityLayer: true
  5407. });
  5408. this.createLayer("block", {
  5409. clearOnLoad: true,
  5410. entityLayer: true
  5411. });
  5412. this.createLayer("effect", {
  5413. clearOnLoad: true,
  5414. entityLayer: true
  5415. });
  5416. this.createLayer("gui", {
  5417. clearOnLoad: true,
  5418. entityLayer: true
  5419. });
  5420. this.setLayerSort(["bg", "proxy", "block", "effect", "gui"]);
  5421. this.activeBlock = null;
  5422. this.nextBlock = null;
  5423. this.timerLeftRight = new ig.Timer();
  5424. this.timerDown = new ig.Timer();
  5425. this.timerAutoDown = new ig.Timer();
  5426. this.timerLock = new ig.Timer();
  5427. this.timerLock.pause();
  5428. this.timerDestruction = new ig.Timer();
  5429. this.timerDestruction.pause();
  5430. this.slowTimer = new ig.Timer(this.slowDurition);
  5431. this.slowTimer.pause();
  5432. this.currentFullRows = [];
  5433. this.fieldManager = new ig.FieldManager();
  5434. ig.gameManager.inputManager.on("touch", this.touched.bind(this));
  5435. ig.gameManager.inputManager.on("release", this.released.bind(this));
  5436. if (ig.ua.mobile) {
  5437. this.handleControls = this.handleControlsTouch
  5438. } else {
  5439. this.handleControls = this.handleControlsKeyboard;
  5440. ig.input.bind(ig.KEY.LEFT_ARROW, "left");
  5441. ig.input.bind(ig.KEY.RIGHT_ARROW, "right");
  5442. ig.input.bind(ig.KEY.DOWN_ARROW, "down");
  5443. ig.input.bind(ig.KEY.UP_ARROW, "rotateRight")
  5444. }
  5445. this.start()
  5446. },
  5447. update: function () {
  5448. this.screen.x = this.bgOffset.x;
  5449. this.screen.y = this.bgOffset.y;
  5450. if (this.ended) {
  5451. var g = this.stagePressed;
  5452. if (g) {
  5453. ig.gameManager.gameOver()
  5454. }
  5455. } else {
  5456. if (!this.paused) {
  5457. if (this.isCleaningLines) {
  5458. this.cleanLines()
  5459. } else {
  5460. this.handleControls();
  5461. if (this.isSlowingdown) {
  5462. if (this.slowTimer.delta() > 0) {
  5463. this.restoreSlowmotion()
  5464. }
  5465. }
  5466. }
  5467. }
  5468. }
  5469. this.stagePressed = false;
  5470. this.stageReleased = false;
  5471. this.parent()
  5472. },
  5473. draw: function () {
  5474. this.parent();
  5475. if (this.ended) {
  5476. this.font.draw("GAME OVER", 126, 124, ig.Font.ALIGN.CENTER)
  5477. }
  5478. this.bFont.draw("Lv:", 244, 260, ig.Font.ALIGN.LEFT);
  5479. this.bFont.draw(this.stage, 300, 260, ig.Font.ALIGN.RIGHT);
  5480. this.font.draw("GEM:", 42, 12, ig.Font.ALIGN.LEFT);
  5481. this.font.draw(this.score, 210, 12, ig.Font.ALIGN.RIGHT);
  5482. this.font.draw("HI:", 42, 24, ig.Font.ALIGN.LEFT);
  5483. this.font.draw(ig.gameManager.gemsHigh, 210, 24, ig.Font.ALIGN.RIGHT)
  5484. },
  5485. handleControlsKeyboard: function () {
  5486. if (!this.activeBlock || !this.activeBlock.isInitialized()) {
  5487. return
  5488. }
  5489. if (this.lockTimerRunning && this.timerLock.delta() >= b.LOCKIN_DELAY) {
  5490. if (this.activeBlock.canMoveDown()) {
  5491. this.timerLock.pause();
  5492. this.lockTimerRunning = false
  5493. } else {
  5494. this.lockActiveBlock()
  5495. }
  5496. }
  5497. if (ig.input.pressed("rotateRight")) {
  5498. this.activeBlock.rotateRight()
  5499. }
  5500. var j = false;
  5501. var k = ig.input.pressed("left"),
  5502. h = ig.input.pressed("right");
  5503. if (k && !h) {
  5504. this.timerLeftRight.set(b.PRESSED_DELAY);
  5505. this.activeBlock.moveLeft();
  5506. j = true;
  5507. this.forceButtonDownRelease = true
  5508. } else {
  5509. if (h && !k) {
  5510. this.timerLeftRight.set(b.PRESSED_DELAY);
  5511. this.activeBlock.moveRight();
  5512. j = true;
  5513. this.forceButtonDownRelease = true
  5514. }
  5515. } if (ig.input.state("left") && ig.input.state("right")) {
  5516. this.timerLeftRight.set(b.PRESSED_DELAY);
  5517. j = true
  5518. }
  5519. if (ig.input.released("left") || ig.input.released("right")) {
  5520. this.forceButtonDownRelease = false
  5521. }
  5522. if (ig.input.state("left") && this.timerLeftRight.delta() >= 0 && !j) {
  5523. this.timerLeftRight.set(b.REPEAT_LEFT_RIGHT_DELAY);
  5524. this.activeBlock.moveLeft();
  5525. this.forceButtonDownRelease = true
  5526. }
  5527. if (ig.input.state("right") && this.timerLeftRight.delta() >= 0 && !j) {
  5528. this.timerLeftRight.set(b.REPEAT_LEFT_RIGHT_DELAY);
  5529. this.activeBlock.moveRight();
  5530. this.forceButtonDownRelease = true
  5531. }
  5532. if (ig.input.state("down") && this.forceButtonDownRelease === false && this.timerDown.delta() >= 0) {
  5533. this.timerDown.set(b.REPEAT_DOWN_DELAY);
  5534. if (this.linesPosOnKeyDown === 0) {
  5535. this.linesPosOnKeyDown = this.activeBlock.pos.y
  5536. }
  5537. var g = this.activeBlock.moveDown();
  5538. if (g === false) {
  5539. this.lockActiveBlock(true)
  5540. }
  5541. } else {
  5542. if (this.forceButtonDownRelease && ig.input.state("down") === false) {
  5543. this.forceButtonDownRelease = false
  5544. }
  5545. } if (!(ig.input.state("down") && this.forceButtonDownRelease === false) && this.timerAutoDown.delta() >= (1 / this.fallSpeed)) {
  5546. var i = this.activeBlock.moveDown();
  5547. this.timerAutoDown.set(0);
  5548. if (i === false && this.lockTimerRunning === false) {
  5549. this.timerLock.set(0);
  5550. this.timerLock.unpause();
  5551. this.lockTimerRunning = true
  5552. } else {
  5553. if (i) {
  5554. this.timerLock.pause();
  5555. this.lockTimerRunning = false
  5556. }
  5557. }
  5558. }
  5559. if (ig.input.released("down")) {
  5560. this.linesPosOnKeyDown = 0;
  5561. this.timerAutoDown.set(0)
  5562. }
  5563. },
  5564. handleControlsTouch: function () {
  5565. if (!this.activeBlock || !this.activeBlock.isInitialized()) {
  5566. return
  5567. }
  5568. if (this.lockTimerRunning && this.timerLock.delta() >= b.LOCKIN_DELAY) {
  5569. if (this.activeBlock.canMoveDown()) {
  5570. this.timerLock.pause();
  5571. this.lockTimerRunning = false
  5572. } else {
  5573. this.lockActiveBlock()
  5574. }
  5575. }
  5576. var h = this.stagePressed;
  5577. if (h) {}
  5578. var k = false;
  5579. var l = this.leftBtn.pressed,
  5580. i = this.rightBtn.pressed;
  5581. if (l && !i) {
  5582. this.timerLeftRight.set(b.PRESSED_DELAY);
  5583. this.activeBlock.moveLeft();
  5584. k = true;
  5585. this.forceButtonDownRelease = true
  5586. } else {
  5587. if (i && !l) {
  5588. this.timerLeftRight.set(b.PRESSED_DELAY);
  5589. this.activeBlock.moveRight();
  5590. k = true;
  5591. this.forceButtonDownRelease = true
  5592. }
  5593. }
  5594. l = this.leftBtn.touched;
  5595. i = this.rightBtn.touched;
  5596. if (l && i) {
  5597. this.timerLeftRight.set(b.PRESSED_DELAY);
  5598. k = true
  5599. }
  5600. l = !this.leftBtn.released;
  5601. i = !this.rightBtn.released;
  5602. if (l || i) {
  5603. this.forceButtonDownRelease = false
  5604. }
  5605. l = this.leftBtn.touched;
  5606. if (l && this.timerLeftRight.delta() >= 0 && !k) {
  5607. this.timerLeftRight.set(b.REPEAT_LEFT_RIGHT_DELAY);
  5608. this.activeBlock.moveLeft();
  5609. this.forceButtonDownRelease = true
  5610. }
  5611. i = this.rightBtn.touched;
  5612. if (i && this.timerLeftRight.delta() >= 0 && !k) {
  5613. this.timerLeftRight.set(b.REPEAT_LEFT_RIGHT_DELAY);
  5614. this.activeBlock.moveRight();
  5615. this.forceButtonDownRelease = true
  5616. }
  5617. var m = this.downBtn.touched;
  5618. if (m && this.forceButtonDownRelease === false && this.timerDown.delta() >= 0) {
  5619. this.timerDown.set(b.REPEAT_DOWN_DELAY);
  5620. if (this.linesPosOnKeyDown === 0) {
  5621. this.linesPosOnKeyDown = this.activeBlock.pos.y
  5622. }
  5623. var g = this.activeBlock.moveDown();
  5624. if (g === false) {
  5625. this.lockActiveBlock(true)
  5626. }
  5627. } else {
  5628. if (this.forceButtonDownRelease && !this.downBtn.touched) {
  5629. this.forceButtonDownRelease = false
  5630. }
  5631. }
  5632. m = this.downBtn.touched;
  5633. if (!(m && this.forceButtonDownRelease === false) && this.timerAutoDown.delta() >= (1 / this.fallSpeed)) {
  5634. var j = this.activeBlock.moveDown();
  5635. this.timerAutoDown.set(0);
  5636. if (j === false && this.lockTimerRunning === false) {
  5637. this.timerLock.set(0);
  5638. this.timerLock.unpause();
  5639. this.lockTimerRunning = true
  5640. } else {
  5641. if (j) {
  5642. this.timerLock.pause();
  5643. this.lockTimerRunning = false
  5644. }
  5645. }
  5646. }
  5647. m = this.downBtn.released;
  5648. if (m) {
  5649. this.linesPosOnKeyDown = 0;
  5650. this.timerAutoDown.set(0)
  5651. }
  5652. },
  5653. cleanLines: function () {
  5654. if (this.timerDestruction.delta() >= 0) {
  5655. this.fieldManager.cleanFullRows(this.currentFullRows);
  5656. this.currentFullRows.length = 0;
  5657. this.isCleaningLines = false;
  5658. this.timerDestruction.pause();
  5659. this.makeNextBlockActive();
  5660. if (!this.ended) {
  5661. this.generateBlock()
  5662. }
  5663. }
  5664. },
  5665. makeNextBlockActive: function () {
  5666. this.activeBlock = this.nextBlock;
  5667. var g = {
  5668. x: b.DROP_POS_X + this.activeBlock.spawnOffset.x,
  5669. y: b.DROP_POS_Y + this.activeBlock.spawnOffset.y
  5670. };
  5671. this.activeBlock.teleportPos(g);
  5672. this.checkSpawnFail();
  5673. this.nextBlock = null;
  5674. this.timerAutoDown.set(0);
  5675. this.timerDown.set(0)
  5676. },
  5677. checkSpawnFail: function () {
  5678. if (this.activeBlock.blocksHaveCollision()) {
  5679. this.gameOver()
  5680. }
  5681. },
  5682. gameOver: function () {
  5683. this.ended = true;
  5684. window.SG_Hooks.gameOver(this.stage, this.score);
  5685. this.restartBtn.moveIn();
  5686. this.quitBtn.moveIn()
  5687. },
  5688. generateBlock: function () {
  5689. var h = (Math.random().map(0, 1, 1, b.SHAPES) | 0);
  5690. var g = null;
  5691. var i = 0,
  5692. j = 0;
  5693. switch (h) {
  5694. case 1:
  5695. j = b.TILESIZE * -2;
  5696. g = ig.game.spawnEntity(ig.global.EntityBlockShapeLine, b.SPAWN_POS_X, b.SPAWN_POS_Y + j);
  5697. break;
  5698. case 2:
  5699. i = b.TILESIZE;
  5700. g = ig.game.spawnEntity(ig.global.EntityBlockShapeSquare, b.SPAWN_POS_X + i, b.SPAWN_POS_Y);
  5701. break;
  5702. case 3:
  5703. j = b.TILESIZE * -1;
  5704. g = ig.game.spawnEntity(ig.global.EntityBlockShapeTriangle, b.SPAWN_POS_X, b.SPAWN_POS_Y + j);
  5705. break;
  5706. case 4:
  5707. j = b.TILESIZE * -1;
  5708. g = ig.game.spawnEntity(ig.global.EntityBlockShapeL, b.SPAWN_POS_X, b.SPAWN_POS_Y + j);
  5709. break;
  5710. case 5:
  5711. j = b.TILESIZE * -1;
  5712. g = ig.game.spawnEntity(ig.global.EntityBlockShapeLr, b.SPAWN_POS_X, b.SPAWN_POS_Y + j);
  5713. break;
  5714. case 6:
  5715. g = ig.game.spawnEntity(ig.global.EntityBlockShapeS, b.SPAWN_POS_X, b.SPAWN_POS_Y);
  5716. break;
  5717. case 7:
  5718. g = ig.game.spawnEntity(ig.global.EntityBlockShapeSr, b.SPAWN_POS_X, b.SPAWN_POS_Y);
  5719. break
  5720. }
  5721. g.spawnOffset.x = i;
  5722. g.spawnOffset.y = j;
  5723. this.nextBlock = g
  5724. },
  5725. lockActiveBlock: function () {
  5726. this.forceButtonDownRelease = true;
  5727. this.fieldManager.lockBlock(this.activeBlock);
  5728. var g = this.fieldManager.checkFullLines();
  5729. var h = g.length;
  5730. if (h > 0) {
  5731. this.currentFullRows = g;
  5732. this.lineCount += h;
  5733. this.score += this.getLineClearingScore(h);
  5734. ig.gameManager.updateScore(this.score);
  5735. this.isCleaningLines = true;
  5736. this.fieldManager.startLineDestruction(g);
  5737. this.timerDestruction.set(b.CLEAN_LINES_DELAY);
  5738. this.timerDestruction.unpause();
  5739. this.checkAdvanceStageCondition()
  5740. } else {
  5741. this.makeNextBlockActive();
  5742. this.generateBlock()
  5743. }
  5744. this.lockTimerRunning = false;
  5745. this.timerLock.pause()
  5746. },
  5747. checkAdvanceStageCondition: function () {
  5748. var g = (this.lineCount + (this.startStage - 1) * 10) - this.stage * 10;
  5749. if (g >= 0 && g < 10) {
  5750. this.advanceStage()
  5751. }
  5752. },
  5753. start: function () {
  5754. this.loadLevel(ig.copy(ig.global.LevelMain));
  5755. this.spawnEntity(a, this.bgOffset.x, this.bgOffset.y);
  5756. this.spawnEntity(d, this.bgOffset.x, this.bgOffset.y);
  5757. this.spawnEntity(f, this.bgOffset.x, this.bgOffset.y + 367);
  5758. if (ig.ua.mobile) {
  5759. if (!ig.ua.iPad) {
  5760. this.leftBtn = this.spawnEntity(ig.global.EntityButtonLeft, -20, 332);
  5761. this.rightBtn = this.spawnEntity(ig.global.EntityButtonRight, 152, 332);
  5762. this.downBtn = this.spawnEntity(ig.global.EntityButtonDown, 37, 332);
  5763. this.rotateBtn = this.spawnEntity(ig.global.EntityButtonRotate, 95, 332)
  5764. } else {
  5765. this.leftBtn = this.spawnEntity(ig.global.EntityButtonLeft, -20, 296);
  5766. this.rightBtn = this.spawnEntity(ig.global.EntityButtonRight, 152, 296);
  5767. this.downBtn = this.spawnEntity(ig.global.EntityButtonDown, 37, 296);
  5768. this.rotateBtn = this.spawnEntity(ig.global.EntityButtonRotate, 95, 296)
  5769. }
  5770. }
  5771. this.menuBtn = this.spawnEntity(ig.global.EntityButtonMenu, 246, -32);
  5772. this.playBtn = this.spawnEntity(ig.global.EntityButtonPlay, 104, -100);
  5773. this.quitBtn = this.spawnEntity(ig.global.EntityButtonQuit, 48, -100);
  5774. this.restartBtn = this.spawnEntity(ig.global.EntityButtonRestart, 104, -100);
  5775. this.pirate = this.spawnEntity(e, 160, 244);
  5776. this.menuBtn.enable = true;
  5777. this.startStage = 1;
  5778. if (this.startStage > 1) {
  5779. var g = this.startStage - this.stage;
  5780. this.advanceStage(g)
  5781. }
  5782. this.generateBlock();
  5783. this.makeNextBlockActive();
  5784. this.generateBlock()
  5785. },
  5786. advanceStage: function (g) {
  5787. if (g <= 0 || g === null || g === undefined) {
  5788. g = 1
  5789. }
  5790. this.stage += g;
  5791. this.fallSpeed += (b.SPEED_INCREASE_PER_STAGE * g);
  5792. /*ig.game.pause();
  5793. console.log("game paused");*/
  5794. window.SG_Hooks.levelUp(this.stage, this.score/*,function(){ig.game.unpause();}*/)
  5795. },
  5796. getLineClearingScore: function (g) {
  5797. var h = 0;
  5798. var i = this.stage * this.stage;
  5799. switch (g) {
  5800. case 4:
  5801. h = 2560 * i;
  5802. break;
  5803. case 3:
  5804. h = 1080 * i;
  5805. break;
  5806. case 2:
  5807. h = 320 * i;
  5808. break;
  5809. default:
  5810. h = 40 * i;
  5811. break
  5812. }
  5813. return h
  5814. },
  5815. slowdown: function () {
  5816. if (!this.isSlowingdown) {
  5817. this.fallSpeedBackup = this.fallSpeed;
  5818. this.fallSpeed *= this.timeScale;
  5819. this.fallSpeed.limit(0, 1.1);
  5820. this.isSlowingdown = true;
  5821. this.slowTimer.reset();
  5822. ig.game.spawnEntity(ig.global.EntitySlowlight, 16, 312)
  5823. }
  5824. },
  5825. restoreSlowmotion: function () {
  5826. this.isSlowingdown = false;
  5827. this.fallSpeed = this.fallSpeedBackup
  5828. },
  5829. touched: function (m) {
  5830. var n = this.getPointPos(m),
  5831. j = this.layers.gui.items,
  5832. l;
  5833. for (var k = 0, h = j.length; k < h; ++k) {
  5834. l = j[k];
  5835. if (this.intersect(l, n.x, n.y)) {
  5836. var g = l.onTouch();
  5837. if (!g) {
  5838. return false
  5839. }
  5840. }
  5841. }
  5842. this.stageTouched = true;
  5843. this.stagePressed = true;
  5844. m.stopPropagation();
  5845. m.preventDefault()
  5846. },
  5847. released: function (k) {
  5848. this.getPointPos(k);
  5849. var h = this.layers.gui.items;
  5850. for (var j = 0, g = h.length; j < g; ++j) {
  5851. h[j].onRelease()
  5852. }
  5853. if (this.stageTouched) {
  5854. this.stageTouched = false;
  5855. this.stageReleased = true
  5856. }
  5857. k.stopPropagation();
  5858. k.preventDefault()
  5859. },
  5860. getPointPos: function (j) {
  5861. var h = j.gesture.center,
  5862. i = ig.system.canvas.getBoundingClientRect();
  5863. var g = (h.pageX - i.left) / ig.gameManager.stageScale.x,
  5864. k = (h.pageY - i.top) / ig.gameManager.stageScale.y;
  5865. return {
  5866. x: g + this.bgOffset.x,
  5867. y: k + this.bgOffset.y
  5868. }
  5869. },
  5870. intersect: function (j, g, m) {
  5871. var l = j.pos.x,
  5872. i = j.pos.x + j.size.x,
  5873. k = j.pos.y,
  5874. h = j.pos.y + j.size.y;
  5875. return !(g < l || g > i || m < k || m > h)
  5876. },
  5877. pause: function () {
  5878. this.paused = true
  5879. },
  5880. unpause: function () {
  5881. this.paused = false
  5882. }
  5883. });
  5884. ig.SceneGems = c
  5885. });
  5886. ig.baked = true;
  5887. ig.module("plugins.storage").defines(function () {
  5888. var a = ig.Class.extend({
  5889. staticInstantiate: function () {
  5890. return !ig.Storage.instance ? null : ig.Storage.instance
  5891. },
  5892. init: function () {
  5893. ig.Storage.instance = this
  5894. },
  5895. isCapable: function () {
  5896. var d = (typeof (window.localStorage) !== "undefined"),
  5897. b = d;
  5898. if (b) {
  5899. try {
  5900. window.localStorage.setItem("PixelPicoSean", "");
  5901. window.localStorage.removeItem("PixelPicoSean")
  5902. } catch (c) {
  5903. b = false
  5904. }
  5905. }
  5906. return b
  5907. },
  5908. isSet: function (b) {
  5909. return (this.get(b) !== null)
  5910. },
  5911. initUnset: function (b, c) {
  5912. if (this.get(b) === null) {
  5913. this.set(b, c)
  5914. }
  5915. },
  5916. get: function (b) {
  5917. if (!this.isCapable()) {
  5918. return null
  5919. }
  5920. try {
  5921. return JSON.parse(localStorage.getItem(b))
  5922. } catch (c) {
  5923. return window.localStorage.getItem(b)
  5924. }
  5925. },
  5926. getInt: function (b) {
  5927. return~~ this.get(b)
  5928. },
  5929. getFloat: function (b) {
  5930. return parseFloat(this.get(b))
  5931. },
  5932. getBool: function (b) {
  5933. return !!this.get(b)
  5934. },
  5935. key: function (b) {
  5936. return this.isCapable() ? window.localStorage.key(b) : null
  5937. },
  5938. set: function (b, c) {
  5939. if (!this.isCapable()) {
  5940. return null
  5941. }
  5942. try {
  5943. window.localStorage.setItem(b, JSON.stringify(c))
  5944. } catch (d) {
  5945. if (d == QUOTA_EXCEEDED_ERR) {
  5946. console.log("localStorage quota exceeded")
  5947. }
  5948. }
  5949. },
  5950. setHighest: function (b, c) {
  5951. if (c > this.getInt(b)) {
  5952. this.set(b, c)
  5953. }
  5954. },
  5955. remove: function (b) {
  5956. if (!this.isCapable()) {
  5957. return null
  5958. }
  5959. window.localStorage.removeItem(b)
  5960. },
  5961. clear: function () {
  5962. if (!this.isCapable()) {
  5963. return null
  5964. }
  5965. window.localStorage.clear()
  5966. }
  5967. });
  5968. ig.Storage = a
  5969. });
  5970. ig.baked = true;
  5971. ig.module("plugins.hammer").defines(function () {
  5972. var E = function (Z, Y) {
  5973. return new E.Instance(Z, Y || {})
  5974. };
  5975. E.defaults = {
  5976. stop_browser_behavior: {
  5977. userSelect: "none",
  5978. touchAction: "none",
  5979. touchCallout: "none",
  5980. contentZooming: "none",
  5981. userDrag: "none",
  5982. tapHighlightColor: "rgba(0,0,0,0)"
  5983. }
  5984. };
  5985. E.HAS_POINTEREVENTS = window.navigator.pointerEnabled || window.navigator.msPointerEnabled;
  5986. E.HAS_TOUCHEVENTS = ("ontouchstart" in window);
  5987. E.MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android|silk/i;
  5988. E.NO_MOUSEEVENTS = E.HAS_TOUCHEVENTS && window.navigator.userAgent.match(E.MOBILE_REGEX);
  5989. E.EVENT_TYPES = {};
  5990. E.UPDATE_VELOCITY_INTERVAL = 16;
  5991. E.DOCUMENT = window.document;
  5992. var A = E.DIRECTION_DOWN = "down";
  5993. var x = E.DIRECTION_LEFT = "left";
  5994. var T = E.DIRECTION_UP = "up";
  5995. var G = E.DIRECTION_RIGHT = "right";
  5996. var R = E.POINTER_MOUSE = "mouse";
  5997. var c = E.POINTER_TOUCH = "touch";
  5998. var r = E.POINTER_PEN = "pen";
  5999. var p = E.EVENT_START = "start";
  6000. var D = E.EVENT_MOVE = "move";
  6001. var w = E.EVENT_END = "end";
  6002. E.plugins = E.plugins || {};
  6003. E.gestures = E.gestures || {};
  6004. E.READY = false;
  6005. function f() {
  6006. if (E.READY) {
  6007. return
  6008. }
  6009. L.determineEventTypes();
  6010. M.each(E.gestures, function (Y) {
  6011. l.register(Y)
  6012. });
  6013. L.onTouch(E.DOCUMENT, D, l.detect);
  6014. L.onTouch(E.DOCUMENT, w, l.detect);
  6015. E.READY = true
  6016. }
  6017. var M = E.utils = {
  6018. extend: function j(Y, aa, ab) {
  6019. for (var Z in aa) {
  6020. if (Y[Z] !== undefined && ab) {
  6021. continue
  6022. }
  6023. Y[Z] = aa[Z]
  6024. }
  6025. return Y
  6026. },
  6027. each: function (ab, aa, Z) {
  6028. var Y, ac;
  6029. if ("forEach" in ab) {
  6030. ab.forEach(aa, Z)
  6031. } else {
  6032. if (ab.length !== undefined) {
  6033. for (Y = -1;
  6034. (ac = ab[++Y]);) {
  6035. if (aa.call(Z, ac, Y, ab) === false) {
  6036. return
  6037. }
  6038. }
  6039. } else {
  6040. for (Y in ab) {
  6041. if (ab.hasOwnProperty(Y) && aa.call(Z, ab[Y], Y, ab) === false) {
  6042. return
  6043. }
  6044. }
  6045. }
  6046. }
  6047. },
  6048. hasParent: function (Z, Y) {
  6049. while (Z) {
  6050. if (Z == Y) {
  6051. return true
  6052. }
  6053. Z = Z.parentNode
  6054. }
  6055. return false
  6056. },
  6057. getCenter: function F(Z) {
  6058. var aa = [],
  6059. Y = [];
  6060. M.each(Z, function (ab) {
  6061. aa.push(typeof ab.clientX !== "undefined" ? ab.clientX : ab.pageX);
  6062. Y.push(typeof ab.clientY !== "undefined" ? ab.clientY : ab.pageY)
  6063. });
  6064. return {
  6065. pageX: (Math.min.apply(Math, aa) + Math.max.apply(Math, aa)) / 2,
  6066. pageY: (Math.min.apply(Math, Y) + Math.max.apply(Math, Y)) / 2
  6067. }
  6068. },
  6069. getVelocity: function a(Y, aa, Z) {
  6070. return {
  6071. x: Math.abs(aa / Y) || 0,
  6072. y: Math.abs(Z / Y) || 0
  6073. }
  6074. },
  6075. getAngle: function o(aa, Z) {
  6076. var ab = Z.pageY - aa.pageY,
  6077. Y = Z.pageX - aa.pageX;
  6078. return Math.atan2(ab, Y) * 180 / Math.PI
  6079. },
  6080. getDirection: function k(aa, Z) {
  6081. var Y = Math.abs(aa.pageX - Z.pageX),
  6082. ab = Math.abs(aa.pageY - Z.pageY);
  6083. if (Y >= ab) {
  6084. return aa.pageX - Z.pageX > 0 ? x : G
  6085. }
  6086. return aa.pageY - Z.pageY > 0 ? T : A
  6087. },
  6088. getDistance: function n(aa, Z) {
  6089. var Y = Z.pageX - aa.pageX,
  6090. ab = Z.pageY - aa.pageY;
  6091. return Math.sqrt((Y * Y) + (ab * ab))
  6092. },
  6093. getScale: function C(Z, Y) {
  6094. if (Z.length >= 2 && Y.length >= 2) {
  6095. return this.getDistance(Y[0], Y[1]) / this.getDistance(Z[0], Z[1])
  6096. }
  6097. return 1
  6098. },
  6099. getRotation: function y(Z, Y) {
  6100. if (Z.length >= 2 && Y.length >= 2) {
  6101. return this.getAngle(Y[1], Y[0]) - this.getAngle(Z[1], Z[0])
  6102. }
  6103. return 0
  6104. },
  6105. isVertical: function K(Y) {
  6106. return Y == T || Y == A
  6107. },
  6108. toggleDefaultBehavior: function H(aa, Z, Y) {
  6109. if (!Z || !aa || !aa.style) {
  6110. return
  6111. }
  6112. M.each(["webkit", "moz", "Moz", "ms", "o", ""], function (ac) {
  6113. M.each(Z, function (ad, ae) {
  6114. if (ac) {
  6115. ae = ac + ae.substring(0, 1).toUpperCase() + ae.substring(1)
  6116. }
  6117. if (ae in aa.style) {
  6118. aa.style[ae] = !Y && ad
  6119. }
  6120. })
  6121. });
  6122. var ab = function () {
  6123. return false
  6124. };
  6125. if (Z.userSelect == "none") {
  6126. aa.onselectstart = !Y && ab
  6127. }
  6128. if (Z.userDrag == "none") {
  6129. aa.ondragstart = !Y && ab
  6130. }
  6131. }
  6132. };
  6133. E.Instance = function (aa, Z) {
  6134. var Y = this;
  6135. f();
  6136. this.element = aa;
  6137. this.enabled = true;
  6138. this.options = M.extend(M.extend({}, E.defaults), Z || {});
  6139. if (this.options.stop_browser_behavior) {
  6140. M.toggleDefaultBehavior(this.element, this.options.stop_browser_behavior, false)
  6141. }
  6142. this.eventStartHandler = L.onTouch(aa, p, function (ab) {
  6143. if (Y.enabled) {
  6144. l.startDetect(Y, ab)
  6145. }
  6146. });
  6147. this.eventHandlers = [];
  6148. return this
  6149. };
  6150. E.Instance.prototype = {
  6151. on: function N(Y, Z) {
  6152. var aa = Y.split(" ");
  6153. M.each(aa, function (ab) {
  6154. this.element.addEventListener(ab, Z, false);
  6155. this.eventHandlers.push({
  6156. gesture: ab,
  6157. handler: Z
  6158. })
  6159. }, this);
  6160. return this
  6161. },
  6162. off: function q(Z, aa) {
  6163. var ac = Z.split(" "),
  6164. Y, ab;
  6165. M.each(ac, function (ad) {
  6166. this.element.removeEventListener(ad, aa, false);
  6167. for (Y = -1;
  6168. (ab = this.eventHandlers[++Y]);) {
  6169. if (ab.gesture === ad && ab.handler === aa) {
  6170. this.eventHandlers.splice(Y, 1)
  6171. }
  6172. }
  6173. }, this);
  6174. return this
  6175. },
  6176. trigger: function S(Z, ab) {
  6177. if (!ab) {
  6178. ab = {}
  6179. }
  6180. var aa = E.DOCUMENT.createEvent("Event");
  6181. aa.initEvent(Z, true, true);
  6182. aa.gesture = ab;
  6183. var Y = this.element;
  6184. if (M.hasParent(ab.target, Y)) {
  6185. Y = ab.target
  6186. }
  6187. Y.dispatchEvent(aa);
  6188. return this
  6189. },
  6190. enable: function e(Y) {
  6191. this.enabled = Y;
  6192. return this
  6193. },
  6194. dispose: function z() {
  6195. var Y, Z;
  6196. if (this.options.stop_browser_behavior) {
  6197. M.toggleDefaultBehavior(this.element, this.options.stop_browser_behavior, true)
  6198. }
  6199. for (Y = -1;
  6200. (Z = this.eventHandlers[++Y]);) {
  6201. this.element.removeEventListener(Z.gesture, Z.handler, false)
  6202. }
  6203. this.eventHandlers = [];
  6204. L.unbindDom(this.element, E.EVENT_TYPES[p], this.eventStartHandler);
  6205. return null
  6206. }
  6207. };
  6208. var Q = null;
  6209. var m = false;
  6210. var i = false;
  6211. var L = E.event = {
  6212. bindDom: function (Z, ab, aa) {
  6213. var Y = ab.split(" ");
  6214. M.each(Y, function (ac) {
  6215. Z.addEventListener(ac, aa, false)
  6216. })
  6217. },
  6218. unbindDom: function (Z, ab, aa) {
  6219. var Y = ab.split(" ");
  6220. M.each(Y, function (ac) {
  6221. Z.removeEventListener(ac, aa, false)
  6222. })
  6223. },
  6224. onTouch: function J(aa, Z, ab) {
  6225. var Y = this;
  6226. var ac = function (af) {
  6227. var ae = af.type.toLowerCase();
  6228. if (ae.match(/mouse/) && i) {
  6229. return
  6230. } else {
  6231. if (ae.match(/touch/) || ae.match(/pointerdown/) || (ae.match(/mouse/) && af.which === 1)) {
  6232. m = true
  6233. } else {
  6234. if (ae.match(/mouse/) && !af.which) {
  6235. m = false
  6236. }
  6237. }
  6238. } if (ae.match(/touch|pointer/)) {
  6239. i = true
  6240. }
  6241. var ad = 0;
  6242. if (m) {
  6243. if (E.HAS_POINTEREVENTS && Z != w) {
  6244. ad = d.updatePointer(Z, af)
  6245. } else {
  6246. if (ae.match(/touch/)) {
  6247. ad = af.touches.length
  6248. } else {
  6249. if (!i) {
  6250. ad = ae.match(/up/) ? 0 : 1
  6251. }
  6252. }
  6253. } if (ad > 0 && Z == w) {
  6254. Z = D
  6255. } else {
  6256. if (!ad) {
  6257. Z = w
  6258. }
  6259. } if (ad || Q === null) {
  6260. Q = af
  6261. }
  6262. ab.call(l, Y.collectEventData(aa, Z, Y.getTouchList(Q, Z), af));
  6263. if (E.HAS_POINTEREVENTS && Z == w) {
  6264. ad = d.updatePointer(Z, af)
  6265. }
  6266. }
  6267. if (!ad) {
  6268. Q = null;
  6269. m = false;
  6270. i = false;
  6271. d.reset()
  6272. }
  6273. };
  6274. this.bindDom(aa, E.EVENT_TYPES[Z], ac);
  6275. return ac
  6276. },
  6277. determineEventTypes: function P() {
  6278. var Y;
  6279. if (E.HAS_POINTEREVENTS) {
  6280. Y = d.getEvents()
  6281. } else {
  6282. if (E.NO_MOUSEEVENTS) {
  6283. Y = ["touchstart", "touchmove", "touchend touchcancel"]
  6284. } else {
  6285. Y = ["touchstart mousedown", "touchmove mousemove", "touchend touchcancel mouseup"]
  6286. }
  6287. }
  6288. E.EVENT_TYPES[p] = Y[0];
  6289. E.EVENT_TYPES[D] = Y[1];
  6290. E.EVENT_TYPES[w] = Y[2]
  6291. },
  6292. getTouchList: function v(Y) {
  6293. if (E.HAS_POINTEREVENTS) {
  6294. return d.getTouchList()
  6295. }
  6296. if (Y.touches) {
  6297. return Y.touches
  6298. }
  6299. Y.identifier = 1;
  6300. return [Y]
  6301. },
  6302. collectEventData: function W(aa, Z, ac, ab) {
  6303. var Y = c;
  6304. if (ab.type.match(/mouse/) || d.matchType(R, ab)) {
  6305. Y = R
  6306. }
  6307. return {
  6308. center: M.getCenter(ac),
  6309. timeStamp: new Date().getTime(),
  6310. target: ab.target,
  6311. touches: ac,
  6312. eventType: Z,
  6313. pointerType: Y,
  6314. srcEvent: ab,
  6315. preventDefault: function () {
  6316. if (this.srcEvent.preventManipulation) {
  6317. this.srcEvent.preventManipulation()
  6318. }
  6319. if (this.srcEvent.preventDefault) {
  6320. this.srcEvent.preventDefault()
  6321. }
  6322. },
  6323. stopPropagation: function () {
  6324. this.srcEvent.stopPropagation()
  6325. },
  6326. stopDetect: function () {
  6327. return l.stopDetect()
  6328. }
  6329. }
  6330. }
  6331. };
  6332. var d = E.PointerEvent = {
  6333. pointers: {},
  6334. getTouchList: function () {
  6335. var Y = [];
  6336. M.each(this.pointers, function (Z) {
  6337. Y.push(Z)
  6338. });
  6339. return Y
  6340. },
  6341. updatePointer: function (Z, Y) {
  6342. if (Z == w) {
  6343. delete this.pointers[Y.pointerId]
  6344. } else {
  6345. Y.identifier = Y.pointerId;
  6346. this.pointers[Y.pointerId] = Y
  6347. }
  6348. return Object.keys(this.pointers).length
  6349. },
  6350. matchType: function (Y, aa) {
  6351. if (!aa.pointerType) {
  6352. return false
  6353. }
  6354. var ab = aa.pointerType,
  6355. Z = {};
  6356. Z[R] = (ab === R);
  6357. Z[c] = (ab === c);
  6358. Z[r] = (ab === r);
  6359. return Z[Y]
  6360. },
  6361. getEvents: function () {
  6362. return ["pointerdown MSPointerDown", "pointermove MSPointerMove", "pointerup pointercancel MSPointerUp MSPointerCancel"]
  6363. },
  6364. reset: function () {
  6365. this.pointers = {}
  6366. }
  6367. };
  6368. var l = E.detection = {
  6369. gestures: [],
  6370. current: null,
  6371. previous: null,
  6372. stopped: false,
  6373. startDetect: function I(Z, Y) {
  6374. if (this.current) {
  6375. return
  6376. }
  6377. this.stopped = false;
  6378. this.current = {
  6379. inst: Z,
  6380. startEvent: M.extend({}, Y),
  6381. lastEvent: false,
  6382. lastVelocityEvent: false,
  6383. velocity: false,
  6384. name: ""
  6385. };
  6386. this.detect(Y)
  6387. },
  6388. detect: function u(Y) {
  6389. if (!this.current || this.stopped) {
  6390. return
  6391. }
  6392. Y = this.extendEventData(Y);
  6393. var Z = this.current.inst.options;
  6394. M.each(this.gestures, function (aa) {
  6395. if (!this.stopped && Z[aa.name] !== false) {
  6396. if (aa.handler.call(aa, Y, this.current.inst) === false) {
  6397. this.stopDetect();
  6398. return false
  6399. }
  6400. }
  6401. }, this);
  6402. if (this.current) {
  6403. this.current.lastEvent = Y
  6404. }
  6405. if (Y.eventType == w && !Y.touches.length - 1) {
  6406. this.stopDetect()
  6407. }
  6408. return Y
  6409. },
  6410. stopDetect: function b() {
  6411. this.previous = M.extend({}, this.current);
  6412. this.current = null;
  6413. this.stopped = true
  6414. },
  6415. extendEventData: function B(ad) {
  6416. var ae = this.current,
  6417. ag = ae.startEvent;
  6418. if (ad.touches.length != ag.touches.length || ad.touches === ag.touches) {
  6419. ag.touches = [];
  6420. M.each(ad.touches, function (ai) {
  6421. ag.touches.push(M.extend({}, ai))
  6422. })
  6423. }
  6424. var ah = ad.timeStamp - ag.timeStamp,
  6425. ab = ad.center.pageX - ag.center.pageX,
  6426. Z = ad.center.pageY - ag.center.pageY,
  6427. ac, af, Y = ae.lastVelocityEvent,
  6428. aa = ae.velocity;
  6429. if (Y && ad.timeStamp - Y.timeStamp > E.UPDATE_VELOCITY_INTERVAL) {
  6430. aa = M.getVelocity(ad.timeStamp - Y.timeStamp, ad.center.pageX - Y.center.pageX, ad.center.pageY - Y.center.pageY);
  6431. ae.lastVelocityEvent = ad;
  6432. ae.velocity = aa
  6433. } else {
  6434. if (!ae.velocity) {
  6435. aa = M.getVelocity(ah, ab, Z);
  6436. ae.lastVelocityEvent = ad;
  6437. ae.velocity = aa
  6438. }
  6439. } if (ad.eventType == w) {
  6440. ac = ae.lastEvent && ae.lastEvent.interimAngle;
  6441. af = ae.lastEvent && ae.lastEvent.interimDirection
  6442. } else {
  6443. ac = ae.lastEvent && M.getAngle(ae.lastEvent.center, ad.center);
  6444. af = ae.lastEvent && M.getDirection(ae.lastEvent.center, ad.center)
  6445. }
  6446. M.extend(ad, {
  6447. deltaTime: ah,
  6448. deltaX: ab,
  6449. deltaY: Z,
  6450. velocityX: aa.x,
  6451. velocityY: aa.y,
  6452. distance: M.getDistance(ag.center, ad.center),
  6453. angle: M.getAngle(ag.center, ad.center),
  6454. interimAngle: ac,
  6455. direction: M.getDirection(ag.center, ad.center),
  6456. interimDirection: af,
  6457. scale: M.getScale(ag.touches, ad.touches),
  6458. rotation: M.getRotation(ag.touches, ad.touches),
  6459. startEvent: ag
  6460. });
  6461. return ad
  6462. },
  6463. register: function g(Z) {
  6464. var Y = Z.defaults || {};
  6465. if (Y[Z.name] === undefined) {
  6466. Y[Z.name] = true
  6467. }
  6468. M.extend(E.defaults, Y, true);
  6469. Z.index = Z.index || 1000;
  6470. this.gestures.push(Z);
  6471. this.gestures.sort(function (ab, aa) {
  6472. if (ab.index < aa.index) {
  6473. return -1
  6474. }
  6475. if (ab.index > aa.index) {
  6476. return 1
  6477. }
  6478. return 0
  6479. });
  6480. return this.gestures
  6481. }
  6482. };
  6483. E.gestures.Drag = {
  6484. name: "drag",
  6485. index: 50,
  6486. defaults: {
  6487. drag_min_distance: 10,
  6488. correct_for_drag_min_distance: true,
  6489. drag_max_touches: 1,
  6490. drag_block_horizontal: false,
  6491. drag_block_vertical: false,
  6492. drag_lock_to_axis: false,
  6493. drag_lock_min_distance: 25
  6494. },
  6495. triggered: false,
  6496. handler: function t(aa, ab) {
  6497. if (l.current.name != this.name && this.triggered) {
  6498. ab.trigger(this.name + "end", aa);
  6499. this.triggered = false;
  6500. return
  6501. }
  6502. if (ab.options.drag_max_touches > 0 && aa.touches.length > ab.options.drag_max_touches) {
  6503. return
  6504. }
  6505. switch (aa.eventType) {
  6506. case p:
  6507. this.triggered = false;
  6508. break;
  6509. case D:
  6510. if (aa.distance < ab.options.drag_min_distance && l.current.name != this.name) {
  6511. return
  6512. }
  6513. if (l.current.name != this.name) {
  6514. l.current.name = this.name;
  6515. if (ab.options.correct_for_drag_min_distance && aa.distance > 0) {
  6516. var Y = Math.abs(ab.options.drag_min_distance / aa.distance);
  6517. l.current.startEvent.center.pageX += aa.deltaX * Y;
  6518. l.current.startEvent.center.pageY += aa.deltaY * Y;
  6519. aa = l.extendEventData(aa)
  6520. }
  6521. }
  6522. if (l.current.lastEvent.drag_locked_to_axis || (ab.options.drag_lock_to_axis && ab.options.drag_lock_min_distance <= aa.distance)) {
  6523. aa.drag_locked_to_axis = true
  6524. }
  6525. var ac = l.current.lastEvent.direction;
  6526. if (aa.drag_locked_to_axis && ac !== aa.direction) {
  6527. if (M.isVertical(ac)) {
  6528. aa.direction = (aa.deltaY < 0) ? T : A
  6529. } else {
  6530. aa.direction = (aa.deltaX < 0) ? x : G
  6531. }
  6532. }
  6533. if (!this.triggered) {
  6534. ab.trigger(this.name + "start", aa);
  6535. this.triggered = true
  6536. }
  6537. ab.trigger(this.name, aa);
  6538. ab.trigger(this.name + aa.direction, aa);
  6539. var Z = M.isVertical(aa.direction);
  6540. if ((ab.options.drag_block_vertical && Z) || (ab.options.drag_block_horizontal && !Z)) {
  6541. aa.preventDefault()
  6542. }
  6543. break;
  6544. case w:
  6545. if (this.triggered) {
  6546. ab.trigger(this.name + "end", aa)
  6547. }
  6548. this.triggered = false;
  6549. break
  6550. }
  6551. }
  6552. };
  6553. E.gestures.Hold = {
  6554. name: "hold",
  6555. index: 10,
  6556. defaults: {
  6557. hold_timeout: 500,
  6558. hold_threshold: 1
  6559. },
  6560. timer: null,
  6561. handler: function V(Y, Z) {
  6562. switch (Y.eventType) {
  6563. case p:
  6564. clearTimeout(this.timer);
  6565. l.current.name = this.name;
  6566. this.timer = setTimeout(function () {
  6567. if (l.current.name == "hold") {
  6568. Z.trigger("hold", Y)
  6569. }
  6570. }, Z.options.hold_timeout);
  6571. break;
  6572. case D:
  6573. if (Y.distance > Z.options.hold_threshold) {
  6574. clearTimeout(this.timer)
  6575. }
  6576. break;
  6577. case w:
  6578. clearTimeout(this.timer);
  6579. break
  6580. }
  6581. }
  6582. };
  6583. E.gestures.Release = {
  6584. name: "release",
  6585. index: Infinity,
  6586. handler: function U(Y, Z) {
  6587. if (Y.eventType == w) {
  6588. Z.trigger(this.name, Y)
  6589. }
  6590. }
  6591. };
  6592. E.gestures.Swipe = {
  6593. name: "swipe",
  6594. index: 40,
  6595. defaults: {
  6596. swipe_min_touches: 1,
  6597. swipe_max_touches: 1,
  6598. swipe_velocity: 0.7
  6599. },
  6600. handler: function X(Y, Z) {
  6601. if (Y.eventType == w) {
  6602. if (Y.touches.length < Z.options.swipe_min_touches || Y.touches.length > Z.options.swipe_max_touches) {
  6603. return
  6604. }
  6605. if (Y.velocityX > Z.options.swipe_velocity || Y.velocityY > Z.options.swipe_velocity) {
  6606. Z.trigger(this.name, Y);
  6607. Z.trigger(this.name + Y.direction, Y)
  6608. }
  6609. }
  6610. }
  6611. };
  6612. E.gestures.Tap = {
  6613. name: "tap",
  6614. index: 100,
  6615. defaults: {
  6616. tap_max_touchtime: 250,
  6617. tap_max_distance: 10,
  6618. tap_always: true,
  6619. doubletap_distance: 20,
  6620. doubletap_interval: 300
  6621. },
  6622. has_moved: false,
  6623. handler: function O(ab, ac) {
  6624. var aa, Y, Z;
  6625. if (ab.eventType == p) {
  6626. this.has_moved = false
  6627. } else {
  6628. if (ab.eventType == D && !this.moved) {
  6629. this.has_moved = (ab.distance > ac.options.tap_max_distance)
  6630. } else {
  6631. if (ab.eventType == w && ab.srcEvent.type != "touchcancel" && ab.deltaTime < ac.options.tap_max_touchtime && !this.has_moved) {
  6632. aa = l.previous;
  6633. Y = aa && aa.lastEvent && ab.timeStamp - aa.lastEvent.timeStamp;
  6634. Z = false;
  6635. if (aa && aa.name == "tap" && (Y && Y < ac.options.doubletap_interval) && ab.distance < ac.options.doubletap_distance) {
  6636. ac.trigger("doubletap", ab);
  6637. Z = true
  6638. }
  6639. if (!Z || ac.options.tap_always) {
  6640. l.current.name = "tap";
  6641. ac.trigger(l.current.name, ab)
  6642. }
  6643. }
  6644. }
  6645. }
  6646. }
  6647. };
  6648. E.gestures.Touch = {
  6649. name: "touch",
  6650. index: -Infinity,
  6651. defaults: {
  6652. prevent_default: false,
  6653. prevent_mouseevents: false
  6654. },
  6655. handler: function h(Y, Z) {
  6656. if (Z.options.prevent_mouseevents && Y.pointerType == R) {
  6657. Y.stopDetect();
  6658. return
  6659. }
  6660. if (Z.options.prevent_default) {
  6661. Y.preventDefault()
  6662. }
  6663. if (Y.eventType == p) {
  6664. Z.trigger(this.name, Y)
  6665. }
  6666. }
  6667. };
  6668. E.gestures.Transform = {
  6669. name: "transform",
  6670. index: 45,
  6671. defaults: {
  6672. transform_min_scale: 0.01,
  6673. transform_min_rotation: 1,
  6674. transform_always_block: false,
  6675. transform_within_instance: false
  6676. },
  6677. triggered: false,
  6678. handler: function s(ab, ac) {
  6679. if (l.current.name != this.name && this.triggered) {
  6680. ac.trigger(this.name + "end", ab);
  6681. this.triggered = false;
  6682. return
  6683. }
  6684. if (ab.touches.length < 2) {
  6685. return
  6686. }
  6687. if (ac.options.transform_always_block) {
  6688. ab.preventDefault()
  6689. }
  6690. if (ac.options.transform_within_instance) {
  6691. for (var Y = -1; ab.touches[++Y];) {
  6692. if (!M.hasParent(ab.touches[Y].target, ac.element)) {
  6693. return
  6694. }
  6695. }
  6696. }
  6697. switch (ab.eventType) {
  6698. case p:
  6699. this.triggered = false;
  6700. break;
  6701. case D:
  6702. var aa = Math.abs(1 - ab.scale);
  6703. var Z = Math.abs(ab.rotation);
  6704. if (aa < ac.options.transform_min_scale && Z < ac.options.transform_min_rotation) {
  6705. return
  6706. }
  6707. l.current.name = this.name;
  6708. if (!this.triggered) {
  6709. ac.trigger(this.name + "start", ab);
  6710. this.triggered = true
  6711. }
  6712. ac.trigger(this.name, ab);
  6713. if (Z > ac.options.transform_min_rotation) {
  6714. ac.trigger("rotate", ab)
  6715. }
  6716. if (aa > ac.options.transform_min_scale) {
  6717. ac.trigger("pinch", ab);
  6718. ac.trigger("pinch" + (ab.scale < 1 ? "in" : "out"), ab)
  6719. }
  6720. break;
  6721. case w:
  6722. if (this.triggered) {
  6723. ac.trigger(this.name + "end", ab)
  6724. }
  6725. this.triggered = false;
  6726. break
  6727. }
  6728. }
  6729. };
  6730. ig.Hammer = E
  6731. });
  6732. ig.baked = true;
  6733. ig.module("game.game-manager").requires("game.scenes.title", "game.scenes.gems", "plugins.storage", "plugins.hammer", "game.config").defines(function () {
  6734. var a = ig.CONFIG;
  6735. var b = ig.Class.extend({
  6736. _promptPause: false,
  6737. storage: null,
  6738. inputManager: null,
  6739. highest: 0,
  6740. roundCounter: 0,
  6741. langIndex: 0,
  6742. _blockImageCache: [new ig.AnimationSheet("media/bomb-block.png", a.TILESIZE, a.TILESIZE), new ig.AnimationSheet("media/slow-block.png", a.TILESIZE, a.TILESIZE), new ig.AnimationSheet("media/gems-01.png", a.TILESIZE, a.TILESIZE), new ig.AnimationSheet("media/gems-02.png", a.TILESIZE, a.TILESIZE), new ig.AnimationSheet("media/gems-03.png", a.TILESIZE, a.TILESIZE), new ig.AnimationSheet("media/gems-04.png", a.TILESIZE, a.TILESIZE), new ig.AnimationSheet("media/gems-05.png", a.TILESIZE, a.TILESIZE), new ig.AnimationSheet("media/gems-06.png", a.TILESIZE, a.TILESIZE)],
  6743. screenRatio: 320 / 480,
  6744. init: function () {
  6745. ig.Sound.enabled = false;
  6746. this.storage = new ig.Storage();
  6747. if (this.storage.isCapable()) {
  6748. if (!this.storage.isSet("gemsHigh")) {
  6749. this.storage.initUnset("gemsHigh", a.MIN_HIGHSCORE)
  6750. } else {
  6751. if (this.storage.getInt("gemsHigh") < a.MIN_HIGHSCORE) {
  6752. this.storage.set("gemsHigh", a.MIN_HIGHSCORE)
  6753. }
  6754. }
  6755. this.gemsHigh = this.storage.get("gemsHigh");
  6756. if (!this.storage.isSet("classicHigh")) {
  6757. this.storage.initUnset("classicHigh", a.MIN_HIGHSCORE)
  6758. } else {
  6759. if (this.storage.getInt("classicHigh") < a.MIN_HIGHSCORE) {
  6760. this.storage.set("classicHigh", a.MIN_HIGHSCORE)
  6761. }
  6762. }
  6763. this.classicHigh = this.storage.get("classicHigh")
  6764. } else {
  6765. this.gemsHigh = this.classicHigh = a.MIN_HIGHSCORE
  6766. }
  6767. },
  6768. ready: function () {
  6769. window.addEventListener("resize", this.autoResize.bind(this), false);
  6770. window.addEventListener("orientationchange", this.autoResize.bind(this), false);
  6771. this.autoResize();
  6772. if (ig.ua.mobile && !ig.ua.iOS71) {
  6773. setInterval(function () {
  6774. window.scrollTo(0, 1)
  6775. }, 10)
  6776. }
  6777. this.inputManager = ig.Hammer(ig.system.canvas, {
  6778. drag: false,
  6779. hold: false,
  6780. prevent_default: true,
  6781. prevent_mouseevents: false,
  6782. show_touches: false,
  6783. swipe: false,
  6784. transform: false,
  6785. stop_browser_behavior: {
  6786. touchAction: true,
  6787. holdAction: true
  6788. }
  6789. })
  6790. },
  6791. firstScene: function () {
  6792. return ig.SceneTitle
  6793. },
  6794. newClassicRound: function () {
  6795. this.roundCounter++;
  6796. this.removeInputListeners();
  6797. ig.system.setGame(ig.SceneClassic)
  6798. },
  6799. newGemsRound: function () {
  6800. this.roundCounter++;
  6801. this.removeInputListeners();
  6802. ig.system.setGame(ig.SceneGems)
  6803. },
  6804. updateScore: function (c) {
  6805. if (this.storage.isCapable()) {
  6806. if (ig.game.gemsMode) {
  6807. this.storage.setHighest("gemsHigh", c);
  6808. this.gemsHigh = this.storage.get("gemsHigh")
  6809. } else {
  6810. this.storage.setHighest("classicHigh", c);
  6811. this.classicHigh = this.storage.get("classicHigh")
  6812. }
  6813. } else {
  6814. if (ig.game.gemsMode) {
  6815. this.gemsHigh = Math.max(this.gemsHigh, c)
  6816. } else {
  6817. this.classicHigh = Math.max(this.classicHigh, c)
  6818. }
  6819. }
  6820. },
  6821. gameOver: function () {
  6822. console.log("game over")
  6823. },
  6824. switchToTitle: function () {
  6825. ig.system.setGame(ig.SceneTitle)
  6826. },
  6827. autoResize: function () {
  6828. var h = window.innerWidth,
  6829. f = window.innerHeight;
  6830. var g = h / 320,
  6831. e = f / 480;
  6832. var d = h / f;
  6833. var c = (ig.ua.mobile) ? g : Math.min(g, e);
  6834. if (d > this.screenRatio - 0.016 && d < this.screenRatio + 0.016) {
  6835. ig.system.canvas.style.width = h + "px";
  6836. ig.system.canvas.style.height = f + "px";
  6837. this.stageScale = {
  6838. x: h / 320,
  6839. y: f / 480
  6840. }
  6841. } else {
  6842. if (d < 1 || !ig.ua.mobile) {
  6843. var i = 320 * c,
  6844. j = 480 * c;
  6845. ig.system.canvas.style.width = i + "px";
  6846. ig.system.canvas.style.height = j + "px";
  6847. this.stageScale = {
  6848. x: c,
  6849. y: c
  6850. }
  6851. }
  6852. } if (ig.ua.mobile) {
  6853. if (d > 1) {
  6854. this.promptRotate()
  6855. } else {
  6856. this.recoverFromRotatePrompt()
  6857. }
  6858. }
  6859. },
  6860. checkOrientationFlag: function () {
  6861. var c = window.innerWidth / window.innerHeight;
  6862. if (ig.ua.mobile) {
  6863. if (c > 1) {
  6864. this.promptRotate()
  6865. } else {
  6866. this.recoverFromRotatePrompt()
  6867. }
  6868. }
  6869. },
  6870. promptRotate: function () {
  6871. this._promptPause = true;
  6872. var c = document.getElementById("rotate-prompt");
  6873. c.style.width = "100%";
  6874. c.style.height = "100%";
  6875. c.style.visibility = "visible";
  6876. if (ig.game && ig.game.clearColor) {
  6877. ig.system.clear("#000")
  6878. }
  6879. },
  6880. recoverFromRotatePrompt: function () {
  6881. this._promptPause = false;
  6882. var c = document.getElementById("rotate-prompt");
  6883. c.style.visibility = "hidden"
  6884. },
  6885. removeInputListeners: function () {
  6886. this.inputManager.off("touch", ig.game.touched.bind(ig.game));
  6887. this.inputManager.off("release", ig.game.released.bind(ig.game))
  6888. }
  6889. });
  6890. ig.GameManager = b
  6891. });
  6892. function mmod(a, b) {
  6893. return ((a % b) + b) % b
  6894. }
  6895. //window.addEventListener("load", ); --> original load function was here
  6896. function startGame() {
  6897. var a = window.SG_Hooks;
  6898. var b = SG.lang; //a.getLanguage(ig.CONFIG.LANG);
  6899. ig.gameManager.langIndex = ig.CONFIG.LANG.indexOf(b);
  6900. a.setOrientationHandler(function () {
  6901. window.ig.gameManager.autoResize()
  6902. });
  6903. a.setResizeHandler(function () {
  6904. window.ig.gameManager.autoResize()
  6905. });
  6906. //a.start() -> not here
  6907. }
  6908. ig.baked = true;
  6909. ig.module("game.main").requires("game.game-manager").defines(function () {
  6910. ig.gameManager = new ig.GameManager();
  6911. ig.main("#canvas", ig.gameManager.firstScene(), 60, 320, 480);
  6912. ig.gameManager.ready()
  6913. });