12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920 |
- (function (g) {
- Number.prototype.map = function (i, j, h, k) {
- return h + (k - h) * ((this - i) / (j - i))
- };
- Number.prototype.limit = function (i, h) {
- return Math.min(h, Math.max(i, this))
- };
- Number.prototype.round = function (h) {
- h = Math.pow(10, h || 0);
- return Math.round(this * h) / h
- };
- Number.prototype.floor = function () {
- return Math.floor(this)
- };
- Number.prototype.ceil = function () {
- return Math.ceil(this)
- };
- Number.prototype.toInt = function () {
- return (this | 0)
- };
- Number.prototype.toRad = function () {
- return (this / 180) * Math.PI
- };
- Number.prototype.toDeg = function () {
- return (this * 180) / Math.PI
- };
- Array.prototype.erase = function (j) {
- for (var h = this.length; h--;) {
- if (this[h] === j) {
- this.splice(h, 1)
- }
- }
- return this
- };
- Array.prototype.random = function () {
- return this[Math.floor(Math.random() * this.length)]
- };
- Function.prototype.bind = Function.prototype.bind || function (h) {
- if (typeof this !== "function") {
- throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable")
- }
- var l = Array.prototype.slice.call(arguments, 1),
- k = this,
- i = function () {},
- j = function () {
- return k.apply((this instanceof i && h ? this : h), l.concat(Array.prototype.slice.call(arguments)))
- };
- i.prototype = this.prototype;
- j.prototype = new i();
- return j
- };
- g.ig = {
- game: null,
- debug: null,
- version: "1.23",
- global: g,
- modules: {},
- resources: [],
- ready: false,
- baked: false,
- nocache: "",
- ua: {},
- prefix: (g.ImpactPrefix || ""),
- lib: "lib/",
- _current: null,
- _loadQueue: [],
- _waitForOnload: 0,
- $: function (h) {
- return h.charAt(0) == "#" ? document.getElementById(h.substr(1)) : document.getElementsByTagName(h)
- },
- $new: function (h) {
- return document.createElement(h)
- },
- copy: function (j) {
- if (!j || typeof (j) != "object" || j instanceof HTMLElement || j instanceof ig.Class) {
- return j
- } else {
- if (j instanceof Array) {
- var m = [];
- for (var k = 0, h = j.length; k < h; k++) {
- m[k] = ig.copy(j[k])
- }
- return m
- } else {
- var m = {};
- for (var k in j) {
- m[k] = ig.copy(j[k])
- }
- return m
- }
- }
- },
- merge: function (j, h) {
- for (var i in h) {
- var k = h[i];
- if (typeof (k) != "object" || k instanceof HTMLElement || k instanceof ig.Class || k === null) {
- j[i] = k
- } else {
- if (!j[i] || typeof (j[i]) != "object") {
- j[i] = (k instanceof Array) ? [] : {}
- }
- ig.merge(j[i], k)
- }
- }
- return j
- },
- ksort: function (l) {
- if (!l || typeof (l) != "object") {
- return []
- }
- var k = [],
- h = [];
- for (var j in l) {
- k.push(j)
- }
- k.sort();
- for (var j = 0; j < k.length; j++) {
- h.push(l[k[j]])
- }
- return h
- },
- setVendorAttribute: function (j, h, k) {
- var i = h.charAt(0).toUpperCase() + h.substr(1);
- j[h] = j["ms" + i] = j["moz" + i] = j["webkit" + i] = j["o" + i] = k
- },
- getVendorAttribute: function (j, h) {
- var i = h.charAt(0).toUpperCase() + h.substr(1);
- return j[h] || j["ms" + i] || j["moz" + i] || j["webkit" + i] || j["o" + i]
- },
- normalizeVendorAttribute: function (j, h) {
- var i = ig.getVendorAttribute(j, h);
- if (!j[h] && i) {
- j[h] = i
- }
- },
- getImagePixels: function (j, n, m, h, p) {
- var i = ig.$new("canvas");
- i.width = j.width;
- i.height = j.height;
- var q = i.getContext("2d");
- ig.System.SCALE.CRISP(i, q);
- var l = ig.getVendorAttribute(q, "backingStorePixelRatio") || 1;
- ig.normalizeVendorAttribute(q, "getImageDataHD");
- var o = j.width / l,
- k = j.height / l;
- i.width = Math.ceil(o);
- i.height = Math.ceil(k);
- q.drawImage(j, 0, 0, o, k);
- return (l === 1) ? q.getImageData(n, m, h, p) : q.getImageDataHD(n, m, h, p)
- },
- module: function (h) {
- if (ig._current) {
- throw ("Module '" + ig._current.name + "' defines nothing")
- }
- if (ig.modules[h] && ig.modules[h].body) {
- throw ("Module '" + h + "' is already defined")
- }
- ig._current = {
- name: h,
- requires: [],
- loaded: false,
- body: null
- };
- ig.modules[h] = ig._current;
- ig._loadQueue.push(ig._current);
- return ig
- },
- requires: function () {
- ig._current.requires = Array.prototype.slice.call(arguments);
- return ig
- },
- defines: function (h) {
- ig._current.body = h;
- ig._current = null;
- ig._initDOMReady()
- },
- addResource: function (h) {
- ig.resources.push(h)
- },
- setNocache: function (h) {
- ig.nocache = h ? "?" + Date.now() : ""
- },
- log: function () {},
- assert: function (i, h) {},
- show: function (h, i) {},
- mark: function (i, h) {},
- _loadScript: function (j, i) {
- ig.modules[j] = {
- name: j,
- requires: [],
- loaded: false,
- body: null
- };
- ig._waitForOnload++;
- var k = ig.prefix + ig.lib + j.replace(/\./g, "/") + ".js" + ig.nocache;
- var h = ig.$new("script");
- h.type = "text/javascript";
- h.src = k;
- h.onload = function () {
- ig._waitForOnload--;
- ig._execModules()
- };
- h.onerror = function () {
- throw ("Failed to load module " + j + " at " + k + " required from " + i)
- };
- ig.$("head")[0].appendChild(h)
- },
- _execModules: function () {
- var k = false;
- for (var p = 0; p < ig._loadQueue.length; p++) {
- var n = ig._loadQueue[p];
- var h = true;
- for (var o = 0; o < n.requires.length; o++) {
- var l = n.requires[o];
- if (!ig.modules[l]) {
- h = false;
- ig._loadScript(l, n.name)
- } else {
- if (!ig.modules[l].loaded) {
- h = false
- }
- }
- }
- if (h && n.body) {
- ig._loadQueue.splice(p, 1);
- n.loaded = true;
- n.body();
- k = true;
- p--
- }
- }
- if (k) {
- ig._execModules()
- } else {
- if (!ig.baked && ig._waitForOnload == 0 && ig._loadQueue.length != 0) {
- var q = [];
- for (var p = 0; p < ig._loadQueue.length; p++) {
- var s = [];
- var r = ig._loadQueue[p].requires;
- for (var o = 0; o < r.length; o++) {
- var n = ig.modules[r[o]];
- if (!n || !n.loaded) {
- s.push(r[o])
- }
- }
- q.push(ig._loadQueue[p].name + " (requires: " + s.join(", ") + ")")
- }
- 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"))
- }
- }
- },
- _DOMReady: function () {
- if (!ig.modules["dom.ready"].loaded) {
- if (!document.body) {
- return setTimeout(ig._DOMReady, 13)
- }
- ig.modules["dom.ready"].loaded = true;
- ig._waitForOnload--;
- ig._execModules()
- }
- return 0
- },
- _boot: function () {
- if (document.location.href.match(/\?nocache/)) {
- ig.setNocache(true)
- }
- ig.ua.pixelRatio = g.devicePixelRatio || 1;
- ig.ua.viewport = {
- width: g.innerWidth,
- height: g.innerHeight
- };
- ig.ua.screen = {
- width: g.screen.availWidth * ig.ua.pixelRatio,
- height: g.screen.availHeight * ig.ua.pixelRatio
- };
- ig.ua.iPhone = /iPhone/i.test(navigator.userAgent);
- ig.ua.iPhone4 = (ig.ua.iPhone && ig.ua.pixelRatio == 2);
- ig.ua.iPad = /iPad/i.test(navigator.userAgent);
- ig.ua.android = /android/i.test(navigator.userAgent);
- ig.ua.winPhone = /Windows Phone/i.test(navigator.userAgent);
- ig.ua.iOS = ig.ua.iPhone || ig.ua.iPad;
- ig.ua.iOS71 = (ig.ua.iOS && (/OS 7_1/i.test(navigator.userAgent) || /OS 71/i.test(navigator.userAgent)));
- ig.ua.mobile = ig.ua.iOS || ig.ua.android || ig.ua.winPhone || /mobile/i.test(navigator.userAgent);
- ig.ua.touchDevice = (("ontouchstart" in g) || (g.navigator.msMaxTouchPoints))
- },
- _initDOMReady: function () {
- if (ig.modules["dom.ready"]) {
- ig._execModules();
- return
- }
- ig._boot();
- ig.modules["dom.ready"] = {
- requires: [],
- loaded: false,
- body: null
- };
- ig._waitForOnload++;
- if (document.readyState === "complete") {
- ig._DOMReady()
- } else {
- document.addEventListener("DOMContentLoaded", ig._DOMReady, false);
- g.addEventListener("load", ig._DOMReady, false)
- }
- }
- };
- ig.normalizeVendorAttribute(g, "requestAnimationFrame");
- if (g.requestAnimationFrame) {
- var e = 1,
- a = {};
- g.ig.setAnimation = function (k, i) {
- var j = e++;
- a[j] = true;
- var h = function () {
- if (!a[j]) {
- return
- }
- g.requestAnimationFrame(h, i);
- k()
- };
- g.requestAnimationFrame(h, i);
- return j
- };
- g.ig.clearAnimation = function (h) {
- delete a[h]
- }
- } else {
- g.ig.setAnimation = function (i, h) {
- return g.setInterval(i, 1000 / 60)
- };
- g.ig.clearAnimation = function (h) {
- g.clearInterval(h)
- }
- }
- var c = false,
- f = /xyz/.test(function () {
- xyz
- }) ? /\bparent\b/ : /.*/;
- var b = 0;
- g.ig.Class = function () {};
- var d = function (k) {
- var j = this.prototype;
- var i = {};
- for (var h in k) {
- if (typeof (k[h]) == "function" && typeof (j[h]) == "function" && f.test(k[h])) {
- i[h] = j[h];
- j[h] = (function (l, m) {
- return function () {
- var o = this.parent;
- this.parent = i[l];
- var n = m.apply(this, arguments);
- this.parent = o;
- return n
- }
- })(h, k[h])
- } else {
- j[h] = k[h]
- }
- }
- };
- g.ig.Class.extend = function (l) {
- var k = this.prototype;
- c = true;
- var j = new this();
- c = false;
- for (var i in l) {
- if (typeof (l[i]) == "function" && typeof (k[i]) == "function" && f.test(l[i])) {
- j[i] = (function (m, n) {
- return function () {
- var p = this.parent;
- this.parent = k[m];
- var o = n.apply(this, arguments);
- this.parent = p;
- return o
- }
- })(i, l[i])
- } else {
- j[i] = l[i]
- }
- }
- function h() {
- if (!c) {
- if (this.staticInstantiate) {
- var n = this.staticInstantiate.apply(this, arguments);
- if (n) {
- return n
- }
- }
- for (var m in this) {
- if (typeof (this[m]) == "object") {
- this[m] = ig.copy(this[m])
- }
- }
- if (this.init) {
- this.init.apply(this, arguments)
- }
- }
- return this
- }
- h.prototype = j;
- h.prototype.constructor = h;
- h.extend = g.ig.Class.extend;
- h.inject = d;
- h.classId = j.classId = ++b;
- return h
- };
- if (g.ImpactMixin) {
- ig.merge(ig, g.ImpactMixin)
- }
- })(window);
- ig.baked = true;
- ig.module("impact.image").defines(function () {
- ig.Image = ig.Class.extend({
- data: null,
- width: 0,
- height: 0,
- loaded: false,
- failed: false,
- loadCallback: null,
- path: "",
- staticInstantiate: function (a) {
- return ig.Image.cache[a] || null
- },
- init: function (a) {
- this.path = a;
- this.load()
- },
- load: function (a) {
- if (this.loaded) {
- if (a) {
- a(this.path, true)
- }
- return
- } else {
- if (!this.loaded && ig.ready) {
- this.loadCallback = a || null;
- this.data = new Image();
- this.data.onload = this.onload.bind(this);
- this.data.onerror = this.onerror.bind(this);
- this.data.src = ig.prefix + this.path + ig.nocache
- } else {
- ig.addResource(this)
- }
- }
- ig.Image.cache[this.path] = this
- },
- reload: function () {
- this.loaded = false;
- this.data = new Image();
- this.data.onload = this.onload.bind(this);
- this.data.src = this.path + "?" + Date.now()
- },
- onload: function (a) {
- this.width = this.data.width;
- this.height = this.data.height;
- this.loaded = true;
- if (ig.system.scale != 1) {
- this.resize(ig.system.scale)
- }
- if (this.loadCallback) {
- this.loadCallback(this.path, true)
- }
- },
- onerror: function (a) {
- this.failed = true;
- if (this.loadCallback) {
- this.loadCallback(this.path, false)
- }
- },
- resize: function (b) {
- var c = ig.getImagePixels(this.data, 0, 0, this.width, this.height);
- var a = this.width * b;
- var k = this.height * b;
- var d = ig.$new("canvas");
- d.width = a;
- d.height = k;
- var i = d.getContext("2d");
- var j = i.getImageData(0, 0, a, k);
- for (var g = 0; g < k; g++) {
- for (var h = 0; h < a; h++) {
- var f = (Math.floor(g / b) * this.width + Math.floor(h / b)) * 4;
- var e = (g * a + h) * 4;
- j.data[e] = c.data[f];
- j.data[e + 1] = c.data[f + 1];
- j.data[e + 2] = c.data[f + 2];
- j.data[e + 3] = c.data[f + 3]
- }
- }
- i.putImageData(j, 0, 0);
- this.data = d
- },
- draw: function (d, c, f, e, b, a) {
- if (!this.loaded) {
- return
- }
- var g = ig.system.scale;
- f = f ? f * g : 0;
- e = e ? e * g : 0;
- b = (b ? b : this.width) * g;
- a = (a ? a : this.height) * g;
- ig.system.context.drawImage(this.data, f, e, b, a, ig.system.getDrawPos(d), ig.system.getDrawPos(c), b, a);
- ig.Image.drawCount++
- },
- drawTile: function (g, f, d, h, c, l, k) {
- c = c ? c : h;
- if (!this.loaded || h > this.width || c > this.height) {
- return
- }
- var b = ig.system.scale;
- var a = Math.floor(h * b);
- var e = Math.floor(c * b);
- var j = l ? -1 : 1;
- var i = k ? -1 : 1;
- if (l || k) {
- ig.system.context.save();
- ig.system.context.scale(j, i)
- }
- 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);
- if (l || k) {
- ig.system.context.restore()
- }
- ig.Image.drawCount++
- }
- });
- ig.Image.drawCount = 0;
- ig.Image.cache = {};
- ig.Image.reloadCache = function () {
- for (var a in ig.Image.cache) {
- ig.Image.cache[a].reload()
- }
- }
- });
- ig.baked = true;
- ig.module("impact.font").requires("impact.image").defines(function () {
- ig.Font = ig.Image.extend({
- widthMap: [],
- indices: [],
- firstChar: 32,
- alpha: 1,
- letterSpacing: 1,
- lineSpacing: 0,
- onload: function (a) {
- this._loadMetrics(this.data);
- this.parent(a)
- },
- widthForString: function (d) {
- if (d.indexOf("\n") !== -1) {
- var a = d.split("\n");
- var c = 0;
- for (var b = 0; b < a.length; b++) {
- c = Math.max(c, this._widthForLine(a[b]))
- }
- return c
- } else {
- return this._widthForLine(d)
- }
- },
- _widthForLine: function (c) {
- var b = 0;
- for (var a = 0; a < c.length; a++) {
- b += this.widthMap[c.charCodeAt(a) - this.firstChar] + this.letterSpacing
- }
- return b
- },
- heightForString: function (a) {
- return a.split("\n").length * (this.height + this.lineSpacing)
- },
- draw: function (j, g, f, d) {
- if (typeof (j) != "string") {
- j = j.toString()
- }
- if (j.indexOf("\n") !== -1) {
- var k = j.split("\n");
- var h = this.height + this.lineSpacing;
- for (var b = 0; b < k.length; b++) {
- this.draw(k[b], g, f + b * h, d)
- }
- return
- }
- if (d == ig.Font.ALIGN.RIGHT || d == ig.Font.ALIGN.CENTER) {
- var a = this._widthForLine(j);
- g -= d == ig.Font.ALIGN.CENTER ? a / 2 : a
- }
- if (this.alpha !== 1) {
- ig.system.context.globalAlpha = this.alpha
- }
- for (var b = 0; b < j.length; b++) {
- var e = j.charCodeAt(b);
- g += this._drawChar(e - this.firstChar, g, f)
- }
- if (this.alpha !== 1) {
- ig.system.context.globalAlpha = 1
- }
- ig.Image.drawCount += j.length
- },
- _drawChar: function (i, e, d) {
- if (!this.loaded || i < 0 || i >= this.indices.length) {
- return 0
- }
- var g = ig.system.scale;
- var b = this.indices[i] * g;
- var h = 0;
- var a = this.widthMap[i] * g;
- var f = (this.height - 2) * g;
- ig.system.context.drawImage(this.data, b, h, a, f, ig.system.getDrawPos(e), ig.system.getDrawPos(d), a, f);
- return this.widthMap[i] + this.letterSpacing
- },
- _loadMetrics: function (f) {
- this.height = f.height - 1;
- this.widthMap = [];
- this.indices = [];
- var e = ig.getImagePixels(f, 0, f.height - 1, f.width, 1);
- var b = 0;
- var d = 0;
- for (var a = 0; a < f.width; a++) {
- var c = a * 4 + 3;
- if (e.data[c] > 127) {
- d++
- } else {
- if (e.data[c] < 128 && d) {
- this.widthMap.push(d);
- this.indices.push(a - d);
- b++;
- d = 0
- }
- }
- }
- this.widthMap.push(d);
- this.indices.push(a - d)
- }
- });
- ig.Font.ALIGN = {
- LEFT: 0,
- RIGHT: 1,
- CENTER: 2
- }
- });
- ig.baked = true;
- ig.module("impact.sound").defines(function () {
- ig.SoundManager = ig.Class.extend({
- clips: {},
- volume: 1,
- format: null,
- init: function () {
- if (!ig.Sound.enabled || !window.Audio) {
- ig.Sound.enabled = false;
- return
- }
- var a = new Audio();
- for (var b = 0; b < ig.Sound.use.length; b++) {
- var c = ig.Sound.use[b];
- if (a.canPlayType(c.mime)) {
- this.format = c;
- break
- }
- }
- if (!this.format) {
- ig.Sound.enabled = false
- }
- if (ig.Sound.enabled && ig.Sound.useWebAudio) {
- this.audioContext = new AudioContext()
- }
- },
- load: function (c, b, a) {
- if (b && ig.Sound.useWebAudio) {
- return this.loadWebAudio(c, b, a)
- } else {
- return this.loadHTML5Audio(c, b, a)
- }
- },
- loadWebAudio: function (g, f, a) {
- var e = ig.prefix + g.replace(/[^\.]+$/, this.format.ext) + ig.nocache;
- if (this.clips[g]) {
- return this.clips[g]
- }
- var b = new ig.Sound.WebAudioSource();
- this.clips[g] = b;
- var d = new XMLHttpRequest();
- d.open("GET", e, true);
- d.responseType = "arraybuffer";
- var c = this;
- d.onload = function (h) {
- c.audioContext.decodeAudioData(d.response, function (i) {
- b.buffer = i;
- a(g, true, h)
- }, function (i) {
- a(g, false, i)
- })
- };
- d.onerror = function (h) {
- a(g, false, h)
- };
- d.send();
- return b
- },
- loadHTML5Audio: function (j, h, d) {
- var g = ig.prefix + j.replace(/[^\.]+$/, this.format.ext) + ig.nocache;
- if (this.clips[j]) {
- if (this.clips[j] instanceof ig.Sound.WebAudioSource) {
- return this.clips[j]
- }
- if (h && this.clips[j].length < ig.Sound.channels) {
- for (var e = this.clips[j].length; e < ig.Sound.channels; e++) {
- var c = new Audio(g);
- c.load();
- this.clips[j].push(c)
- }
- }
- return this.clips[j][0]
- }
- var f = new Audio(g);
- if (d) {
- f.addEventListener("canplaythrough", function b(a) {
- f.removeEventListener("canplaythrough", b, false);
- d(j, true, a)
- }, false);
- f.addEventListener("error", function (a) {
- d(j, false, a)
- }, false)
- }
- f.preload = "auto";
- f.load();
- this.clips[j] = [f];
- if (h) {
- for (var e = 1; e < ig.Sound.channels; e++) {
- var c = new Audio(g);
- c.load();
- this.clips[j].push(c)
- }
- }
- return f
- },
- get: function (d) {
- var a = this.clips[d];
- if (a && a instanceof ig.Sound.WebAudioSource) {
- return a
- }
- for (var b = 0, c; c = a[b++];) {
- if (c.paused || c.ended) {
- if (c.ended) {
- c.currentTime = 0
- }
- return c
- }
- }
- a[0].pause();
- a[0].currentTime = 0;
- return a[0]
- }
- });
- ig.Music = ig.Class.extend({
- tracks: [],
- namedTracks: {},
- currentTrack: null,
- currentIndex: 0,
- random: false,
- _volume: 1,
- _loop: false,
- _fadeInterval: 0,
- _fadeTimer: null,
- _endedCallbackBound: null,
- init: function () {
- this._endedCallbackBound = this._endedCallback.bind(this);
- Object.defineProperty(this, "volume", {
- get: this.getVolume.bind(this),
- set: this.setVolume.bind(this)
- });
- Object.defineProperty(this, "loop", {
- get: this.getLooping.bind(this),
- set: this.setLooping.bind(this)
- })
- },
- add: function (d, b) {
- if (!ig.Sound.enabled) {
- return
- }
- var c = d instanceof ig.Sound ? d.path : d;
- var a = ig.soundManager.load(c, false);
- if (a instanceof ig.Sound.WebAudioSource) {
- ig.system.stopRunLoop();
- 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)")
- }
- a.loop = this._loop;
- a.volume = this._volume;
- a.addEventListener("ended", this._endedCallbackBound, false);
- this.tracks.push(a);
- if (b) {
- this.namedTracks[b] = a
- }
- if (!this.currentTrack) {
- this.currentTrack = a
- }
- },
- next: function () {
- if (!this.tracks.length) {
- return
- }
- this.stop();
- this.currentIndex = this.random ? Math.floor(Math.random() * this.tracks.length) : (this.currentIndex + 1) % this.tracks.length;
- this.currentTrack = this.tracks[this.currentIndex];
- this.play()
- },
- pause: function () {
- if (!this.currentTrack) {
- return
- }
- this.currentTrack.pause()
- },
- stop: function () {
- if (!this.currentTrack) {
- return
- }
- this.currentTrack.pause();
- this.currentTrack.currentTime = 0
- },
- play: function (b) {
- if (b && this.namedTracks[b]) {
- var a = this.namedTracks[b];
- if (a != this.currentTrack) {
- this.stop();
- this.currentTrack = a
- }
- } else {
- if (!this.currentTrack) {
- return
- }
- }
- this.currentTrack.play()
- },
- getLooping: function () {
- return this._loop
- },
- setLooping: function (a) {
- this._loop = a;
- for (var b in this.tracks) {
- this.tracks[b].loop = a
- }
- },
- getVolume: function () {
- return this._volume
- },
- setVolume: function (a) {
- this._volume = a.limit(0, 1);
- for (var b in this.tracks) {
- this.tracks[b].volume = this._volume
- }
- },
- fadeOut: function (a) {
- if (!this.currentTrack) {
- return
- }
- clearInterval(this._fadeInterval);
- this.fadeTimer = new ig.Timer(a);
- this._fadeInterval = setInterval(this._fadeStep.bind(this), 50)
- },
- _fadeStep: function () {
- var a = this.fadeTimer.delta().map(-this.fadeTimer.target, 0, 1, 0).limit(0, 1) * this._volume;
- if (a <= 0.01) {
- this.stop();
- this.currentTrack.volume = this._volume;
- clearInterval(this._fadeInterval)
- } else {
- this.currentTrack.volume = a
- }
- },
- _endedCallback: function () {
- if (this._loop) {
- this.play()
- } else {
- this.next()
- }
- }
- });
- ig.Sound = ig.Class.extend({
- path: "",
- volume: 1,
- currentClip: null,
- multiChannel: true,
- _loop: false,
- init: function (b, a) {
- this.path = b;
- this.multiChannel = (a !== false);
- Object.defineProperty(this, "loop", {
- get: this.getLooping.bind(this),
- set: this.setLooping.bind(this)
- });
- this.load()
- },
- getLooping: function () {
- return this._loop
- },
- setLooping: function (a) {
- this._loop = a;
- if (this.currentClip) {
- this.currentClip.loop = a
- }
- },
- load: function (a) {
- if (!ig.Sound.enabled) {
- if (a) {
- a(this.path, true)
- }
- return
- }
- if (ig.ready) {
- ig.soundManager.load(this.path, this.multiChannel, a)
- } else {
- ig.addResource(this)
- }
- },
- play: function () {
- if (!ig.Sound.enabled) {
- return
- }
- this.currentClip = ig.soundManager.get(this.path);
- this.currentClip.loop = this._loop;
- this.currentClip.volume = ig.soundManager.volume * this.volume;
- this.currentClip.play()
- },
- stop: function () {
- if (this.currentClip) {
- this.currentClip.pause();
- this.currentClip.currentTime = 0
- }
- }
- });
- ig.Sound.WebAudioSource = ig.Class.extend({
- sources: [],
- gain: null,
- buffer: null,
- _loop: false,
- init: function () {
- this.gain = ig.soundManager.audioContext.createGain();
- this.gain.connect(ig.soundManager.audioContext.destination);
- Object.defineProperty(this, "loop", {
- get: this.getLooping.bind(this),
- set: this.setLooping.bind(this)
- });
- Object.defineProperty(this, "volume", {
- get: this.getVolume.bind(this),
- set: this.setVolume.bind(this)
- })
- },
- play: function () {
- if (!this.buffer) {
- return
- }
- var b = ig.soundManager.audioContext.createBufferSource();
- b.buffer = this.buffer;
- b.connect(this.gain);
- b.loop = this._loop;
- var a = this;
- this.sources.push(b);
- b.onended = function () {
- a.sources.erase(b)
- };
- b.start(0)
- },
- pause: function () {
- for (var a = 0; a < this.sources.length; a++) {
- try {
- this.sources[a].stop()
- } catch (b) {}
- }
- },
- getLooping: function () {
- return this._loop
- },
- setLooping: function (a) {
- this._loop = a;
- for (var b = 0; b < this.sources.length; b++) {
- this.sources[b].loop = a
- }
- },
- getVolume: function () {
- return this.gain.gain.value
- },
- setVolume: function (a) {
- this.gain.gain.value = a
- }
- });
- ig.Sound.FORMAT = {
- MP3: {
- ext: "mp3",
- mime: "audio/mpeg"
- },
- M4A: {
- ext: "m4a",
- mime: "audio/mp4; codecs=mp4a"
- },
- OGG: {
- ext: "ogg",
- mime: "audio/ogg; codecs=vorbis"
- },
- WEBM: {
- ext: "webm",
- mime: "audio/webm; codecs=vorbis"
- },
- CAF: {
- ext: "caf",
- mime: "audio/x-caf"
- }
- };
- ig.Sound.use = [ig.Sound.FORMAT.OGG, ig.Sound.FORMAT.MP3];
- ig.Sound.channels = 4;
- ig.Sound.enabled = true;
- ig.normalizeVendorAttribute(window, "AudioContext");
- ig.Sound.useWebAudio = !!window.AudioContext
- });
- ig.baked = true;
- ig.module("impact.loader").requires("impact.image", "impact.font", "impact.sound").defines(function () {
- ig.Loader = ig.Class.extend({
- resources: [],
- gameClass: null,
- status: 0,
- done: false,
- _unloaded: [],
- _drawStatus: 0,
- _intervalId: 0,
- _loadCallbackBound: null,
- init: function (b, c) {
- this.gameClass = b;
- this.resources = c;
- this._loadCallbackBound = this._loadCallback.bind(this);
- for (var a = 0; a < this.resources.length; a++) {
- this._unloaded.push(this.resources[a].path)
- }
- },
- load: function () {
- ig.system.clear("#000");
- if (!this.resources.length) {
- this.end();
- return
- }
- for (var a = 0; a < this.resources.length; a++) {
- this.loadResource(this.resources[a])
- }
- this._intervalId = setInterval(this.draw.bind(this), 16)
- },
- loadResource: function (a) {
- a.load(this._loadCallbackBound)
- },
- end: function () {
- if (this.done) {
- return
- }
- this.done = true;
- clearInterval(this._intervalId);
- ig.system.setGame(this.gameClass)
- },
- draw: function () {
- this._drawStatus += (this.status - this._drawStatus) / 5;
- var d = ig.system.scale;
- var b = ig.system.width * 0.6;
- var c = ig.system.height * 0.1;
- var a = ig.system.width * 0.5 - b / 2;
- var e = ig.system.height * 0.5 - c / 2;
- ig.system.context.fillStyle = "#000";
- ig.system.context.fillRect(0, 0, 480, 320);
- ig.system.context.fillStyle = "#fff";
- ig.system.context.fillRect(a * d, e * d, b * d, c * d);
- ig.system.context.fillStyle = "#000";
- ig.system.context.fillRect(a * d + d, e * d + d, b * d - d - d, c * d - d - d);
- ig.system.context.fillStyle = "#fff";
- ig.system.context.fillRect(a * d, e * d, b * d * this._drawStatus, c * d)
- },
- _loadCallback: function (b, a) {
- if (a) {
- this._unloaded.erase(b)
- } else {
- throw ("Failed to load resource: " + b)
- }
- this.status = 1 - (this._unloaded.length / this.resources.length);
- if (this._unloaded.length == 0) {
- setTimeout(this.end.bind(this), 250)
- }
- }
- })
- });
- ig.baked = true;
- ig.module("impact.timer").defines(function () {
- ig.Timer = ig.Class.extend({
- target: 0,
- base: 0,
- last: 0,
- pausedAt: 0,
- init: function (a) {
- this.base = ig.Timer.time;
- this.last = ig.Timer.time;
- this.target = a || 0
- },
- set: function (a) {
- this.target = a || 0;
- this.base = ig.Timer.time;
- this.pausedAt = 0
- },
- reset: function () {
- this.base = ig.Timer.time;
- this.pausedAt = 0
- },
- tick: function () {
- var a = ig.Timer.time - this.last;
- this.last = ig.Timer.time;
- return (this.pausedAt ? 0 : a)
- },
- delta: function () {
- return (this.pausedAt || ig.Timer.time) - this.base - this.target
- },
- pause: function () {
- if (!this.pausedAt) {
- this.pausedAt = ig.Timer.time
- }
- },
- unpause: function () {
- if (this.pausedAt) {
- this.base += ig.Timer.time - this.pausedAt;
- this.pausedAt = 0
- }
- }
- });
- ig.Timer._last = 0;
- ig.Timer.time = Number.MIN_VALUE;
- ig.Timer.timeScale = 1;
- ig.Timer.maxStep = 0.05;
- ig.Timer.step = function () {
- var a = Date.now();
- var b = (a - ig.Timer._last) / 1000;
- ig.Timer.time += Math.min(b, ig.Timer.maxStep) * ig.Timer.timeScale;
- ig.Timer._last = a
- }
- });
- ig.baked = true;
- ig.module("impact.system").requires("impact.timer", "impact.image").defines(function () {
- ig.System = ig.Class.extend({
- fps: 30,
- width: 320,
- height: 240,
- realWidth: 320,
- realHeight: 240,
- scale: 1,
- tick: 0,
- animationId: 0,
- newGameClass: null,
- running: false,
- delegate: null,
- clock: null,
- canvas: null,
- context: null,
- init: function (e, c, b, a, d) {
- this.fps = c;
- this.clock = new ig.Timer();
- this.canvas = ig.$(e);
- this.resize(b, a, d);
- this.context = this.canvas.getContext("2d");
- this.getDrawPos = ig.System.drawMode;
- if (this.scale != 1) {
- ig.System.scaleMode = ig.System.SCALE.CRISP
- }
- ig.System.scaleMode(this.canvas, this.context)
- },
- resize: function (b, a, c) {
- this.width = b;
- this.height = a;
- this.scale = c || this.scale;
- this.realWidth = this.width * this.scale;
- this.realHeight = this.height * this.scale;
- this.canvas.width = this.realWidth;
- this.canvas.height = this.realHeight
- },
- setGame: function (a) {
- if (this.running) {
- this.newGameClass = a
- } else {
- this.setGameNow(a)
- }
- },
- setGameNow: function (a) {
- ig.game = new(a)();
- ig.system.setDelegate(ig.game)
- },
- setDelegate: function (a) {
- if (typeof (a.run) == "function") {
- this.delegate = a;
- this.startRunLoop()
- } else {
- throw ("System.setDelegate: No run() function in object")
- }
- },
- stopRunLoop: function () {
- ig.clearAnimation(this.animationId);
- this.running = false
- },
- startRunLoop: function () {
- this.stopRunLoop();
- this.animationId = ig.setAnimation(this.run.bind(this), this.canvas);
- this.running = true
- },
- clear: function (a) {
- this.context.fillStyle = a;
- this.context.fillRect(0, 0, this.realWidth, this.realHeight)
- },
- run: function () {
- ig.Timer.step();
- this.tick = this.clock.tick();
- this.delegate.run();
- ig.input.clearPressed();
- if (this.newGameClass) {
- this.setGameNow(this.newGameClass);
- this.newGameClass = null
- }
- },
- getDrawPos: null
- });
- ig.System.DRAW = {
- AUTHENTIC: function (a) {
- return Math.round(a) * this.scale
- },
- SMOOTH: function (a) {
- return Math.round(a * this.scale)
- },
- SUBPIXEL: function (a) {
- return a * this.scale
- }
- };
- ig.System.drawMode = ig.System.DRAW.SMOOTH;
- ig.System.SCALE = {
- CRISP: function (a, b) {
- ig.setVendorAttribute(b, "imageSmoothingEnabled", false);
- a.style.imageRendering = "-moz-crisp-edges";
- a.style.imageRendering = "-o-crisp-edges";
- a.style.imageRendering = "-webkit-optimize-contrast";
- a.style.imageRendering = "crisp-edges";
- a.style.msInterpolationMode = "nearest-neighbor"
- },
- SMOOTH: function (a, b) {
- ig.setVendorAttribute(b, "imageSmoothingEnabled", true);
- a.style.imageRendering = "";
- a.style.msInterpolationMode = ""
- }
- };
- ig.System.scaleMode = ig.System.SCALE.SMOOTH
- });
- ig.baked = true;
- ig.module("impact.input").defines(function () {
- ig.KEY = {
- MOUSE1: -1,
- MOUSE2: -3,
- MWHEEL_UP: -4,
- MWHEEL_DOWN: -5,
- BACKSPACE: 8,
- TAB: 9,
- ENTER: 13,
- PAUSE: 19,
- CAPS: 20,
- ESC: 27,
- SPACE: 32,
- PAGE_UP: 33,
- PAGE_DOWN: 34,
- END: 35,
- HOME: 36,
- LEFT_ARROW: 37,
- UP_ARROW: 38,
- RIGHT_ARROW: 39,
- DOWN_ARROW: 40,
- INSERT: 45,
- DELETE: 46,
- _0: 48,
- _1: 49,
- _2: 50,
- _3: 51,
- _4: 52,
- _5: 53,
- _6: 54,
- _7: 55,
- _8: 56,
- _9: 57,
- A: 65,
- B: 66,
- C: 67,
- D: 68,
- E: 69,
- F: 70,
- G: 71,
- H: 72,
- I: 73,
- J: 74,
- K: 75,
- L: 76,
- M: 77,
- N: 78,
- O: 79,
- P: 80,
- Q: 81,
- R: 82,
- S: 83,
- T: 84,
- U: 85,
- V: 86,
- W: 87,
- X: 88,
- Y: 89,
- Z: 90,
- NUMPAD_0: 96,
- NUMPAD_1: 97,
- NUMPAD_2: 98,
- NUMPAD_3: 99,
- NUMPAD_4: 100,
- NUMPAD_5: 101,
- NUMPAD_6: 102,
- NUMPAD_7: 103,
- NUMPAD_8: 104,
- NUMPAD_9: 105,
- MULTIPLY: 106,
- ADD: 107,
- SUBSTRACT: 109,
- DECIMAL: 110,
- DIVIDE: 111,
- F1: 112,
- F2: 113,
- F3: 114,
- F4: 115,
- F5: 116,
- F6: 117,
- F7: 118,
- F8: 119,
- F9: 120,
- F10: 121,
- F11: 122,
- F12: 123,
- SHIFT: 16,
- CTRL: 17,
- ALT: 18,
- PLUS: 187,
- COMMA: 188,
- MINUS: 189,
- PERIOD: 190
- };
- ig.Input = ig.Class.extend({
- bindings: {},
- actions: {},
- presses: {},
- locks: {},
- delayedKeyup: {},
- isUsingMouse: false,
- isUsingKeyboard: false,
- isUsingAccelerometer: false,
- mouse: {
- x: 0,
- y: 0
- },
- accel: {
- x: 0,
- y: 0,
- z: 0
- },
- initMouse: function () {
- if (this.isUsingMouse) {
- return
- }
- this.isUsingMouse = true;
- var a = this.mousewheel.bind(this);
- ig.system.canvas.addEventListener("mousewheel", a, false);
- ig.system.canvas.addEventListener("DOMMouseScroll", a, false);
- ig.system.canvas.addEventListener("contextmenu", this.contextmenu.bind(this), false);
- ig.system.canvas.addEventListener("mousedown", this.keydown.bind(this), false);
- ig.system.canvas.addEventListener("mouseup", this.keyup.bind(this), false);
- ig.system.canvas.addEventListener("mousemove", this.mousemove.bind(this), false);
- if (ig.ua.touchDevice) {
- ig.system.canvas.addEventListener("touchstart", this.keydown.bind(this), false);
- ig.system.canvas.addEventListener("touchend", this.keyup.bind(this), false);
- ig.system.canvas.addEventListener("touchmove", this.mousemove.bind(this), false);
- ig.system.canvas.addEventListener("MSPointerDown", this.keydown.bind(this), false);
- ig.system.canvas.addEventListener("MSPointerUp", this.keyup.bind(this), false);
- ig.system.canvas.addEventListener("MSPointerMove", this.mousemove.bind(this), false);
- ig.system.canvas.style.msTouchAction = "none"
- }
- },
- initKeyboard: function () {
- if (this.isUsingKeyboard) {
- return
- }
- this.isUsingKeyboard = true;
- window.addEventListener("keydown", this.keydown.bind(this), false);
- window.addEventListener("keyup", this.keyup.bind(this), false)
- },
- initAccelerometer: function () {
- if (this.isUsingAccelerometer) {
- return
- }
- window.addEventListener("devicemotion", this.devicemotion.bind(this), false)
- },
- mousewheel: function (b) {
- var d = b.wheelDelta ? b.wheelDelta : (b.detail * -1);
- var a = d > 0 ? ig.KEY.MWHEEL_UP : ig.KEY.MWHEEL_DOWN;
- var c = this.bindings[a];
- if (c) {
- this.actions[c] = true;
- this.presses[c] = true;
- this.delayedKeyup[c] = true;
- b.stopPropagation();
- b.preventDefault()
- }
- },
- mousemove: function (c) {
- var a = parseInt(ig.system.canvas.offsetWidth) || ig.system.realWidth;
- var d = ig.system.scale * (a / ig.system.realWidth);
- var e = {
- left: 0,
- top: 0
- };
- if (ig.system.canvas.getBoundingClientRect) {
- e = ig.system.canvas.getBoundingClientRect()
- }
- var b = c.touches ? c.touches[0] : c;
- this.mouse.x = (b.clientX - e.left) / d;
- this.mouse.y = (b.clientY - e.top) / d
- },
- contextmenu: function (a) {
- if (this.bindings[ig.KEY.MOUSE2]) {
- a.stopPropagation();
- a.preventDefault()
- }
- },
- keydown: function (c) {
- var a = c.target.tagName;
- if (a == "INPUT" || a == "TEXTAREA") {
- return
- }
- var b = c.type == "keydown" ? c.keyCode : (c.button == 2 ? ig.KEY.MOUSE2 : ig.KEY.MOUSE1);
- if (c.type == "touchstart" || c.type == "mousedown") {
- this.mousemove(c)
- }
- var d = this.bindings[b];
- if (d) {
- this.actions[d] = true;
- if (!this.locks[d]) {
- this.presses[d] = true;
- this.locks[d] = true
- }
- c.stopPropagation();
- c.preventDefault()
- }
- },
- keyup: function (c) {
- var a = c.target.tagName;
- if (a == "INPUT" || a == "TEXTAREA") {
- return
- }
- var b = c.type == "keyup" ? c.keyCode : (c.button == 2 ? ig.KEY.MOUSE2 : ig.KEY.MOUSE1);
- var d = this.bindings[b];
- if (d) {
- this.delayedKeyup[d] = true;
- c.stopPropagation();
- c.preventDefault()
- }
- },
- devicemotion: function (a) {
- this.accel = a.accelerationIncludingGravity
- },
- bind: function (a, b) {
- if (a < 0) {
- this.initMouse()
- } else {
- if (a > 0) {
- this.initKeyboard()
- }
- }
- this.bindings[a] = b
- },
- bindTouch: function (a, d) {
- var b = ig.$(a);
- var c = this;
- b.addEventListener("touchstart", function (e) {
- c.touchStart(e, d)
- }, false);
- b.addEventListener("touchend", function (e) {
- c.touchEnd(e, d)
- }, false);
- b.addEventListener("MSPointerDown", function (e) {
- c.touchStart(e, d)
- }, false);
- b.addEventListener("MSPointerUp", function (e) {
- c.touchEnd(e, d)
- }, false)
- },
- unbind: function (a) {
- var b = this.bindings[a];
- this.delayedKeyup[b] = true;
- this.bindings[a] = null
- },
- unbindAll: function () {
- this.bindings = {};
- this.actions = {};
- this.presses = {};
- this.locks = {};
- this.delayedKeyup = {}
- },
- state: function (a) {
- return this.actions[a]
- },
- pressed: function (a) {
- return this.presses[a]
- },
- released: function (a) {
- return !!this.delayedKeyup[a]
- },
- clearPressed: function () {
- for (var a in this.delayedKeyup) {
- this.actions[a] = false;
- this.locks[a] = false
- }
- this.delayedKeyup = {};
- this.presses = {}
- },
- touchStart: function (a, b) {
- this.actions[b] = true;
- this.presses[b] = true;
- a.stopPropagation();
- a.preventDefault();
- return false
- },
- touchEnd: function (a, b) {
- this.delayedKeyup[b] = true;
- a.stopPropagation();
- a.preventDefault();
- return false
- }
- })
- });
- ig.baked = true;
- ig.module("impact.impact").requires("dom.ready", "impact.loader", "impact.system", "impact.input", "impact.sound").defines(function () {
- ig.main = function (h, e, f, d, b, g, c) {
- ig.system = new ig.System(h, f, d, b, g || 1);
- ig.input = new ig.Input();
- ig.soundManager = new ig.SoundManager();
- ig.music = new ig.Music();
- ig.ready = true;
- var a = new(c || ig.Loader)(e, ig.resources);
- a.load()
- }
- });
- ig.baked = true;
- ig.module("impact.animation").requires("impact.timer", "impact.image").defines(function () {
- ig.AnimationSheet = ig.Class.extend({
- width: 8,
- height: 8,
- image: null,
- init: function (c, b, a) {
- this.width = b;
- this.height = a;
- this.image = new ig.Image(c)
- }
- });
- ig.Animation = ig.Class.extend({
- sheet: null,
- timer: null,
- sequence: [],
- flip: {
- x: false,
- y: false
- },
- pivot: {
- x: 0,
- y: 0
- },
- frame: 0,
- tile: 0,
- loopCount: 0,
- alpha: 1,
- angle: 0,
- init: function (b, c, d, a) {
- this.sheet = b;
- this.pivot = {
- x: b.width / 2,
- y: b.height / 2
- };
- this.timer = new ig.Timer();
- this.frameTime = c;
- this.sequence = d;
- this.stop = !!a;
- this.tile = this.sequence[0]
- },
- rewind: function () {
- this.timer.set();
- this.loopCount = 0;
- this.frame = 0;
- this.tile = this.sequence[0];
- return this
- },
- gotoFrame: function (a) {
- this.timer.set(this.frameTime * -a - 0.0001);
- this.update()
- },
- gotoRandomFrame: function () {
- this.gotoFrame(Math.floor(Math.random() * this.sequence.length))
- },
- update: function () {
- var a = Math.floor(this.timer.delta() / this.frameTime);
- this.loopCount = Math.floor(a / this.sequence.length);
- if (this.stop && this.loopCount > 0) {
- this.frame = this.sequence.length - 1
- } else {
- this.frame = a % this.sequence.length
- }
- this.tile = this.sequence[this.frame]
- },
- draw: function (c, b) {
- var a = Math.max(this.sheet.width, this.sheet.height);
- if (c > ig.system.width || b > ig.system.height || c + a < 0 || b + a < 0) {
- return
- }
- if (this.alpha != 1) {
- ig.system.context.globalAlpha = this.alpha
- }
- if (this.angle == 0) {
- this.sheet.image.drawTile(c, b, this.tile, this.sheet.width, this.sheet.height, this.flip.x, this.flip.y)
- } else {
- ig.system.context.save();
- ig.system.context.translate(ig.system.getDrawPos(c + this.pivot.x), ig.system.getDrawPos(b + this.pivot.y));
- ig.system.context.rotate(this.angle);
- this.sheet.image.drawTile(-this.pivot.x, -this.pivot.y, this.tile, this.sheet.width, this.sheet.height, this.flip.x, this.flip.y);
- ig.system.context.restore()
- } if (this.alpha != 1) {
- ig.system.context.globalAlpha = 1
- }
- }
- })
- });
- ig.baked = true;
- ig.module("impact.entity").requires("impact.animation", "impact.impact").defines(function () {
- ig.Entity = ig.Class.extend({
- id: 0,
- settings: {},
- size: {
- x: 16,
- y: 16
- },
- offset: {
- x: 0,
- y: 0
- },
- pos: {
- x: 0,
- y: 0
- },
- last: {
- x: 0,
- y: 0
- },
- vel: {
- x: 0,
- y: 0
- },
- accel: {
- x: 0,
- y: 0
- },
- friction: {
- x: 0,
- y: 0
- },
- maxVel: {
- x: 100,
- y: 100
- },
- zIndex: 0,
- gravityFactor: 1,
- standing: false,
- bounciness: 0,
- minBounceVelocity: 40,
- anims: {},
- animSheet: null,
- currentAnim: null,
- health: 10,
- type: 0,
- checkAgainst: 0,
- collides: 0,
- _killed: false,
- slopeStanding: {
- min: (44).toRad(),
- max: (136).toRad()
- },
- init: function (a, c, b) {
- this.id = ++ig.Entity._lastId;
- this.pos.x = this.last.x = a;
- this.pos.y = this.last.y = c;
- ig.merge(this, b)
- },
- reset: function (a, d, b) {
- var c = this.constructor.prototype;
- this.pos.x = a;
- this.pos.y = d;
- this.last.x = a;
- this.last.y = d;
- this.vel.x = c.vel.x;
- this.vel.y = c.vel.y;
- this.accel.x = c.accel.x;
- this.accel.y = c.accel.y;
- this.health = c.health;
- this._killed = c._killed;
- this.standing = c.standing;
- this.type = c.type;
- this.checkAgainst = c.checkAgainst;
- this.collides = c.collides;
- ig.merge(this, b)
- },
- addAnim: function (c, e, f, d) {
- if (!this.animSheet) {
- throw ("No animSheet to add the animation " + c + " to.")
- }
- var b = new ig.Animation(this.animSheet, e, f, d);
- this.anims[c] = b;
- if (!this.currentAnim) {
- this.currentAnim = b
- }
- return b
- },
- update: function () {
- this.last.x = this.pos.x;
- this.last.y = this.pos.y;
- this.vel.y += ig.game.gravity * ig.system.tick * this.gravityFactor;
- this.vel.x = this.getNewVelocity(this.vel.x, this.accel.x, this.friction.x, this.maxVel.x);
- this.vel.y = this.getNewVelocity(this.vel.y, this.accel.y, this.friction.y, this.maxVel.y);
- var c = this.vel.x * ig.system.tick;
- var b = this.vel.y * ig.system.tick;
- var a = ig.game.collisionMap.trace(this.pos.x, this.pos.y, c, b, this.size.x, this.size.y);
- this.handleMovementTrace(a);
- if (this.currentAnim) {
- this.currentAnim.update()
- }
- },
- getNewVelocity: function (c, b, d, a) {
- if (b) {
- return (c + b * ig.system.tick).limit(-a, a)
- } else {
- if (d) {
- var e = d * ig.system.tick;
- if (c - e > 0) {
- return c - e
- } else {
- if (c + e < 0) {
- return c + e
- } else {
- return 0
- }
- }
- }
- }
- return c.limit(-a, a)
- },
- handleMovementTrace: function (c) {
- this.standing = false;
- if (c.collision.y) {
- if (this.bounciness > 0 && Math.abs(this.vel.y) > this.minBounceVelocity) {
- this.vel.y *= -this.bounciness
- } else {
- if (this.vel.y > 0) {
- this.standing = true
- }
- this.vel.y = 0
- }
- }
- if (c.collision.x) {
- if (this.bounciness > 0 && Math.abs(this.vel.x) > this.minBounceVelocity) {
- this.vel.x *= -this.bounciness
- } else {
- this.vel.x = 0
- }
- }
- if (c.collision.slope) {
- var e = c.collision.slope;
- if (this.bounciness > 0) {
- var d = this.vel.x * e.nx + this.vel.y * e.ny;
- this.vel.x = (this.vel.x - e.nx * d * 2) * this.bounciness;
- this.vel.y = (this.vel.y - e.ny * d * 2) * this.bounciness
- } else {
- var b = e.x * e.x + e.y * e.y;
- var a = (this.vel.x * e.x + this.vel.y * e.y) / b;
- this.vel.x = e.x * a;
- this.vel.y = e.y * a;
- var f = Math.atan2(e.x, e.y);
- if (f > this.slopeStanding.min && f < this.slopeStanding.max) {
- this.standing = true
- }
- }
- }
- this.pos = c.pos
- },
- draw: function () {
- if (this.currentAnim) {
- this.currentAnim.draw(this.pos.x - this.offset.x - ig.game._rscreen.x, this.pos.y - this.offset.y - ig.game._rscreen.y)
- }
- },
- kill: function () {
- ig.game.removeEntity(this)
- },
- receiveDamage: function (a, b) {
- this.health -= a;
- if (this.health <= 0) {
- this.kill()
- }
- },
- touches: function (a) {
- 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)
- },
- distanceTo: function (a) {
- var b = (this.pos.x + this.size.x / 2) - (a.pos.x + a.size.x / 2);
- var c = (this.pos.y + this.size.y / 2) - (a.pos.y + a.size.y / 2);
- return Math.sqrt(b * b + c * c)
- },
- angleTo: function (a) {
- 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))
- },
- check: function (a) {},
- collideWith: function (a, b) {},
- ready: function () {},
- erase: function () {}
- });
- ig.Entity._lastId = 0;
- ig.Entity.COLLIDES = {
- NEVER: 0,
- LITE: 1,
- PASSIVE: 2,
- ACTIVE: 4,
- FIXED: 8
- };
- ig.Entity.TYPE = {
- NONE: 0,
- A: 1,
- B: 2,
- BOTH: 3
- };
- ig.Entity.checkPair = function (d, c) {
- if (d.checkAgainst & c.type) {
- d.check(c)
- }
- if (c.checkAgainst & d.type) {
- c.check(d)
- }
- if (d.collides && c.collides && d.collides + c.collides > ig.Entity.COLLIDES.ACTIVE) {
- ig.Entity.solveCollision(d, c)
- }
- };
- ig.Entity.solveCollision = function (d, c) {
- var e = null;
- if (d.collides == ig.Entity.COLLIDES.LITE || c.collides == ig.Entity.COLLIDES.FIXED) {
- e = d
- } else {
- if (c.collides == ig.Entity.COLLIDES.LITE || d.collides == ig.Entity.COLLIDES.FIXED) {
- e = c
- }
- } if (d.last.x + d.size.x > c.last.x && d.last.x < c.last.x + c.size.x) {
- if (d.last.y < c.last.y) {
- ig.Entity.seperateOnYAxis(d, c, e)
- } else {
- ig.Entity.seperateOnYAxis(c, d, e)
- }
- d.collideWith(c, "y");
- c.collideWith(d, "y")
- } else {
- if (d.last.y + d.size.y > c.last.y && d.last.y < c.last.y + c.size.y) {
- if (d.last.x < c.last.x) {
- ig.Entity.seperateOnXAxis(d, c, e)
- } else {
- ig.Entity.seperateOnXAxis(c, d, e)
- }
- d.collideWith(c, "x");
- c.collideWith(d, "x")
- }
- }
- };
- ig.Entity.seperateOnXAxis = function (b, i, e) {
- var d = (b.pos.x + b.size.x - i.pos.x);
- if (e) {
- var h = b === e ? i : b;
- e.vel.x = -e.vel.x * e.bounciness + h.vel.x;
- var f = ig.game.collisionMap.trace(e.pos.x, e.pos.y, e == b ? -d : d, 0, e.size.x, e.size.y);
- e.pos.x = f.pos.x
- } else {
- var g = (b.vel.x - i.vel.x) / 2;
- b.vel.x = -g;
- i.vel.x = g;
- var c = ig.game.collisionMap.trace(b.pos.x, b.pos.y, -d / 2, 0, b.size.x, b.size.y);
- b.pos.x = Math.floor(c.pos.x);
- var a = ig.game.collisionMap.trace(i.pos.x, i.pos.y, d / 2, 0, i.size.x, i.size.y);
- i.pos.x = Math.ceil(a.pos.x)
- }
- };
- ig.Entity.seperateOnYAxis = function (f, a, c) {
- var b = (f.pos.y + f.size.y - a.pos.y);
- if (c) {
- var h = f === c ? a : f;
- c.vel.y = -c.vel.y * c.bounciness + h.vel.y;
- var i = 0;
- if (c == f && Math.abs(c.vel.y - h.vel.y) < c.minBounceVelocity) {
- c.standing = true;
- i = h.vel.x * ig.system.tick
- }
- var d = ig.game.collisionMap.trace(c.pos.x, c.pos.y, i, c == f ? -b : b, c.size.x, c.size.y);
- c.pos.y = d.pos.y;
- c.pos.x = d.pos.x
- } else {
- if (ig.game.gravity && (a.standing || f.vel.y > 0)) {
- 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);
- f.pos.y = j.pos.y;
- if (f.bounciness > 0 && f.vel.y > f.minBounceVelocity) {
- f.vel.y *= -f.bounciness
- } else {
- f.standing = true;
- f.vel.y = 0
- }
- } else {
- var g = (f.vel.y - a.vel.y) / 2;
- f.vel.y = -g;
- a.vel.y = g;
- var i = a.vel.x * ig.system.tick;
- var j = ig.game.collisionMap.trace(f.pos.x, f.pos.y, i, -b / 2, f.size.x, f.size.y);
- f.pos.y = j.pos.y;
- var e = ig.game.collisionMap.trace(a.pos.x, a.pos.y, 0, b / 2, a.size.x, a.size.y);
- a.pos.y = e.pos.y
- }
- }
- }
- });
- ig.baked = true;
- ig.module("impact.map").defines(function () {
- ig.Map = ig.Class.extend({
- tilesize: 8,
- width: 1,
- height: 1,
- data: [
- []
- ],
- name: null,
- init: function (b, a) {
- this.tilesize = b;
- this.data = a;
- this.height = a.length;
- this.width = a[0].length;
- this.pxWidth = this.width * this.tilesize;
- this.pxHeight = this.height * this.tilesize
- },
- getTile: function (b, d) {
- var c = Math.floor(b / this.tilesize);
- var a = Math.floor(d / this.tilesize);
- if ((c >= 0 && c < this.width) && (a >= 0 && a < this.height)) {
- return this.data[a][c]
- } else {
- return 0
- }
- },
- setTile: function (b, e, d) {
- var c = Math.floor(b / this.tilesize);
- var a = Math.floor(e / this.tilesize);
- if ((c >= 0 && c < this.width) && (a >= 0 && a < this.height)) {
- this.data[a][c] = d
- }
- }
- })
- });
- ig.baked = true;
- ig.module("impact.collision-map").requires("impact.map").defines(function () {
- ig.CollisionMap = ig.Map.extend({
- lastSlope: 1,
- tiledef: null,
- init: function (i, h, g) {
- this.parent(i, h);
- this.tiledef = g || ig.CollisionMap.defaultTileDef;
- for (var f in this.tiledef) {
- if (f | 0 > this.lastSlope) {
- this.lastSlope = f | 0
- }
- }
- },
- trace: function (q, m, n, k, g, f) {
- var j = {
- collision: {
- x: false,
- y: false,
- slope: false
- },
- pos: {
- x: q,
- y: m
- },
- tile: {
- x: 0,
- y: 0
- }
- };
- var o = Math.ceil(Math.max(Math.abs(n), Math.abs(k)) / this.tilesize);
- if (o > 1) {
- var p = n / o;
- var l = k / o;
- for (var h = 0; h < o && (p || l); h++) {
- this._traceStep(j, q, m, p, l, g, f, n, k, h);
- q = j.pos.x;
- m = j.pos.y;
- if (j.collision.x) {
- p = 0;
- n = 0
- }
- if (j.collision.y) {
- l = 0;
- k = 0
- }
- if (j.collision.slope) {
- break
- }
- }
- } else {
- this._traceStep(j, q, m, n, k, g, f, n, k, 0)
- }
- return j
- },
- _traceStep: function (E, l, i, u, s, w, r, A, v, h) {
- E.pos.x += u;
- E.pos.y += s;
- var q = 0;
- if (u) {
- var B = (u > 0 ? w : 0);
- var m = (u < 0 ? this.tilesize : 0);
- var f = Math.max(Math.floor(i / this.tilesize), 0);
- var C = Math.min(Math.ceil((i + r) / this.tilesize), this.height);
- var n = Math.floor((E.pos.x + B) / this.tilesize);
- var p = Math.floor((l + B) / this.tilesize);
- if (h > 0 || n == p || p < 0 || p >= this.width) {
- p = -1
- }
- if (n >= 0 && n < this.width) {
- for (var k = f; k < C; k++) {
- if (p != -1) {
- q = this.data[k][p];
- if (q > 1 && q <= this.lastSlope && this._checkTileDef(E, q, l, i, A, v, w, r, p, k)) {
- break
- }
- }
- q = this.data[k][n];
- if (q == 1 || q > this.lastSlope || (q > 1 && this._checkTileDef(E, q, l, i, A, v, w, r, n, k))) {
- if (q > 1 && q <= this.lastSlope && E.collision.slope) {
- break
- }
- E.collision.x = true;
- E.tile.x = q;
- l = E.pos.x = n * this.tilesize - B + m;
- A = 0;
- break
- }
- }
- }
- }
- if (s) {
- var z = (s > 0 ? r : 0);
- var j = (s < 0 ? this.tilesize : 0);
- var g = Math.max(Math.floor(E.pos.x / this.tilesize), 0);
- var D = Math.min(Math.ceil((E.pos.x + w) / this.tilesize), this.width);
- var k = Math.floor((E.pos.y + z) / this.tilesize);
- var o = Math.floor((i + z) / this.tilesize);
- if (h > 0 || k == o || o < 0 || o >= this.height) {
- o = -1
- }
- if (k >= 0 && k < this.height) {
- for (var n = g; n < D; n++) {
- if (o != -1) {
- q = this.data[o][n];
- if (q > 1 && q <= this.lastSlope && this._checkTileDef(E, q, l, i, A, v, w, r, n, o)) {
- break
- }
- }
- q = this.data[k][n];
- if (q == 1 || q > this.lastSlope || (q > 1 && this._checkTileDef(E, q, l, i, A, v, w, r, n, k))) {
- if (q > 1 && q <= this.lastSlope && E.collision.slope) {
- break
- }
- E.collision.y = true;
- E.tile.y = q;
- E.pos.y = k * this.tilesize - z + j;
- break
- }
- }
- }
- }
- },
- _checkTileDef: function (F, p, n, l, w, v, z, u, o, m) {
- var q = this.tiledef[p];
- if (!q) {
- return false
- }
- var h = (o + q[0]) * this.tilesize,
- g = (m + q[1]) * this.tilesize,
- k = (q[2] - q[0]) * this.tilesize,
- j = (q[3] - q[1]) * this.tilesize,
- A = q[4];
- var E = n + w + (j < 0 ? z : 0) - h,
- D = l + v + (k > 0 ? u : 0) - g;
- if (k * D - j * E > 0) {
- if (w * -j + v * k < 0) {
- return A
- }
- var f = Math.sqrt(k * k + j * j);
- var C = j / f,
- B = -k / f;
- var i = E * C + D * B;
- var s = C * i,
- r = B * i;
- if (s * s + r * r >= w * w + v * v) {
- return A || (k * (D - v) - j * (E - w) < 0.5)
- }
- F.pos.x = n + w - s;
- F.pos.y = l + v - r;
- F.collision.slope = {
- x: k,
- y: j,
- nx: C,
- ny: B
- };
- return true
- }
- return false
- }
- });
- var c = 1 / 2,
- d = 1 / 3,
- e = 2 / 3,
- a = true,
- b = false;
- ig.CollisionMap.defaultTileDef = {
- 5: [0, 1, 1, e, a],
- 6: [0, e, 1, d, a],
- 7: [0, d, 1, 0, a],
- 3: [0, 1, 1, c, a],
- 4: [0, c, 1, 0, a],
- 2: [0, 1, 1, 0, a],
- 10: [c, 1, 1, 0, a],
- 21: [0, 1, c, 0, a],
- 32: [e, 1, 1, 0, a],
- 43: [d, 1, e, 0, a],
- 54: [0, 1, d, 0, a],
- 27: [0, 0, 1, d, a],
- 28: [0, d, 1, e, a],
- 29: [0, e, 1, 1, a],
- 25: [0, 0, 1, c, a],
- 26: [0, c, 1, 1, a],
- 24: [0, 0, 1, 1, a],
- 11: [0, 0, c, 1, a],
- 22: [c, 0, 1, 1, a],
- 33: [0, 0, d, 1, a],
- 44: [d, 0, e, 1, a],
- 55: [e, 0, 1, 1, a],
- 16: [1, d, 0, 0, a],
- 17: [1, e, 0, d, a],
- 18: [1, 1, 0, e, a],
- 14: [1, c, 0, 0, a],
- 15: [1, 1, 0, c, a],
- 13: [1, 1, 0, 0, a],
- 8: [c, 1, 0, 0, a],
- 19: [1, 1, c, 0, a],
- 30: [d, 1, 0, 0, a],
- 41: [e, 1, d, 0, a],
- 52: [1, 1, e, 0, a],
- 38: [1, e, 0, 1, a],
- 39: [1, d, 0, e, a],
- 40: [1, 0, 0, d, a],
- 36: [1, c, 0, 1, a],
- 37: [1, 0, 0, c, a],
- 35: [1, 0, 0, 1, a],
- 9: [1, 0, c, 1, a],
- 20: [c, 0, 0, 1, a],
- 31: [1, 0, e, 1, a],
- 42: [e, 0, d, 1, a],
- 53: [d, 0, 0, 1, a],
- 12: [0, 0, 1, 0, b],
- 23: [1, 1, 0, 1, b],
- 34: [1, 0, 1, 1, b],
- 45: [0, 1, 0, 0, b]
- };
- ig.CollisionMap.staticNoCollision = {
- trace: function (f, i, h, g) {
- return {
- collision: {
- x: false,
- y: false,
- slope: false
- },
- pos: {
- x: f + h,
- y: i + g
- },
- tile: {
- x: 0,
- y: 0
- }
- }
- }
- }
- });
- ig.baked = true;
- ig.module("impact.background-map").requires("impact.map", "impact.image").defines(function () {
- ig.BackgroundMap = ig.Map.extend({
- tiles: null,
- scroll: {
- x: 0,
- y: 0
- },
- distance: 1,
- repeat: false,
- tilesetName: "",
- foreground: false,
- enabled: true,
- preRender: false,
- preRenderedChunks: null,
- chunkSize: 512,
- debugChunks: false,
- anims: {},
- init: function (c, a, b) {
- this.parent(c, a);
- this.setTileset(b)
- },
- setTileset: function (a) {
- this.tilesetName = a instanceof ig.Image ? a.path : a;
- this.tiles = new ig.Image(this.tilesetName);
- this.preRenderedChunks = null
- },
- setScreenPos: function (a, b) {
- this.scroll.x = a / this.distance;
- this.scroll.y = b / this.distance
- },
- preRenderMapToChunks: function () {
- var b = this.width * this.tilesize * ig.system.scale,
- e = this.height * this.tilesize * ig.system.scale;
- this.chunkSize = Math.min(Math.max(b, e), this.chunkSize);
- var d = Math.ceil(b / this.chunkSize),
- c = Math.ceil(e / this.chunkSize);
- this.preRenderedChunks = [];
- for (var h = 0; h < c; h++) {
- this.preRenderedChunks[h] = [];
- for (var a = 0; a < d; a++) {
- var f = (a == d - 1) ? b - a * this.chunkSize : this.chunkSize;
- var g = (h == c - 1) ? e - h * this.chunkSize : this.chunkSize;
- this.preRenderedChunks[h][a] = this.preRenderChunk(a, h, f, g)
- }
- }
- },
- preRenderChunk: function (c, b, p, g) {
- var i = p / this.tilesize / ig.system.scale + 1,
- a = g / this.tilesize / ig.system.scale + 1;
- var j = (c * this.chunkSize / ig.system.scale) % this.tilesize,
- f = (b * this.chunkSize / ig.system.scale) % this.tilesize;
- var e = Math.floor(c * this.chunkSize / this.tilesize / ig.system.scale),
- d = Math.floor(b * this.chunkSize / this.tilesize / ig.system.scale);
- var o = ig.$new("canvas");
- o.width = p;
- o.height = g;
- o.retinaResolutionEnabled = false;
- var k = o.getContext("2d");
- ig.System.scaleMode(o, k);
- var q = ig.system.context;
- ig.system.context = k;
- for (var n = 0; n < i; n++) {
- for (var m = 0; m < a; m++) {
- if (n + e < this.width && m + d < this.height) {
- var l = this.data[m + d][n + e];
- if (l) {
- this.tiles.drawTile(n * this.tilesize - j, m * this.tilesize - f, l - 1, this.tilesize)
- }
- }
- }
- }
- ig.system.context = q;
- return o
- },
- draw: function () {
- if (!this.tiles.loaded || !this.enabled) {
- return
- }
- if (this.preRender) {
- this.drawPreRendered()
- } else {
- this.drawTiled()
- }
- },
- drawPreRendered: function () {
- if (!this.preRenderedChunks) {
- this.preRenderMapToChunks()
- }
- var r = ig.system.getDrawPos(this.scroll.x),
- q = ig.system.getDrawPos(this.scroll.y);
- if (this.repeat) {
- var n = this.width * this.tilesize * ig.system.scale;
- r = (r % n + n) % n;
- var e = this.height * this.tilesize * ig.system.scale;
- q = (q % e + e) % e
- }
- var j = Math.max(Math.floor(r / this.chunkSize), 0),
- g = Math.max(Math.floor(q / this.chunkSize), 0),
- i = Math.ceil((r + ig.system.realWidth) / this.chunkSize),
- f = Math.ceil((q + ig.system.realHeight) / this.chunkSize),
- b = this.preRenderedChunks[0].length,
- a = this.preRenderedChunks.length;
- if (!this.repeat) {
- i = Math.min(i, b);
- f = Math.min(f, a)
- }
- var o = 0;
- for (var c = g; c < f; c++) {
- var p = 0;
- for (var d = j; d < i; d++) {
- var m = this.preRenderedChunks[c % a][d % b];
- var l = -r + d * this.chunkSize - p;
- var k = -q + c * this.chunkSize - o;
- ig.system.context.drawImage(m, l, k);
- ig.Image.drawCount++;
- if (this.debugChunks) {
- ig.system.context.strokeStyle = "#f0f";
- ig.system.context.strokeRect(l, k, this.chunkSize, this.chunkSize)
- }
- if (this.repeat && m.width < this.chunkSize && l + m.width < ig.system.realWidth) {
- p += this.chunkSize - m.width;
- i++
- }
- }
- if (this.repeat && m.height < this.chunkSize && k + m.height < ig.system.realHeight) {
- o += this.chunkSize - m.height;
- f++
- }
- }
- },
- drawTiled: function () {
- var j = 0,
- e = null,
- g = (this.scroll.x / this.tilesize).toInt(),
- f = (this.scroll.y / this.tilesize).toInt(),
- b = this.scroll.x % this.tilesize,
- p = this.scroll.y % this.tilesize,
- i = -b - this.tilesize,
- h = -p - this.tilesize,
- d = ig.system.width + this.tilesize - b,
- c = ig.system.height + this.tilesize - p;
- for (var m = -1, k = h; k < c; m++, k += this.tilesize) {
- var o = m + f;
- if (o >= this.height || o < 0) {
- if (!this.repeat) {
- continue
- }
- o = (o % this.height + this.height) % this.height
- }
- for (var n = -1, l = i; l < d; n++, l += this.tilesize) {
- var a = n + g;
- if (a >= this.width || a < 0) {
- if (!this.repeat) {
- continue
- }
- a = (a % this.width + this.width) % this.width
- }
- if ((j = this.data[o][a])) {
- if ((e = this.anims[j - 1])) {
- e.draw(l, k)
- } else {
- this.tiles.drawTile(l, k, j - 1, this.tilesize)
- }
- }
- }
- }
- }
- })
- });
- ig.baked = true;
- ig.module("impact.game").requires("impact.impact", "impact.entity", "impact.collision-map", "impact.background-map").defines(function () {
- ig.Game = ig.Class.extend({
- clearColor: "#000000",
- gravity: 0,
- screen: {
- x: 0,
- y: 0
- },
- _rscreen: {
- x: 0,
- y: 0
- },
- entities: [],
- namedEntities: {},
- collisionMap: ig.CollisionMap.staticNoCollision,
- backgroundMaps: [],
- backgroundAnims: {},
- autoSort: false,
- sortBy: null,
- cellSize: 64,
- _deferredKill: [],
- _levelToLoad: null,
- _doSortEntities: false,
- staticInstantiate: function () {
- this.sortBy = this.sortBy || ig.Game.SORT.Z_INDEX;
- ig.game = this;
- return null
- },
- loadLevel: function (e) {
- this.screen = {
- x: 0,
- y: 0
- };
- this.entities = [];
- this.namedEntities = {};
- for (var b = 0; b < e.entities.length; b++) {
- var d = e.entities[b];
- this.spawnEntity(d.type, d.x, d.y, d.settings)
- }
- this.sortEntities();
- this.collisionMap = ig.CollisionMap.staticNoCollision;
- this.backgroundMaps = [];
- for (var b = 0; b < e.layer.length; b++) {
- var c = e.layer[b];
- if (c.name == "collision") {
- this.collisionMap = new ig.CollisionMap(c.tilesize, c.data)
- } else {
- var a = new ig.BackgroundMap(c.tilesize, c.data, c.tilesetName);
- a.anims = this.backgroundAnims[c.tilesetName] || {};
- a.repeat = c.repeat;
- a.distance = c.distance;
- a.foreground = !!c.foreground;
- a.preRender = !!c.preRender;
- a.name = c.name;
- this.backgroundMaps.push(a)
- }
- }
- for (var b = 0; b < this.entities.length; b++) {
- this.entities[b].ready()
- }
- },
- loadLevelDeferred: function (a) {
- this._levelToLoad = a
- },
- getMapByName: function (a) {
- if (a == "collision") {
- return this.collisionMap
- }
- for (var b = 0; b < this.backgroundMaps.length; b++) {
- if (this.backgroundMaps[b].name == a) {
- return this.backgroundMaps[b]
- }
- }
- return null
- },
- getEntityByName: function (a) {
- return this.namedEntities[a]
- },
- getEntitiesByType: function (e) {
- var c = typeof (e) === "string" ? ig.global[e] : e;
- var b = [];
- for (var d = 0; d < this.entities.length; d++) {
- var f = this.entities[d];
- if (f instanceof c && !f._killed) {
- b.push(f)
- }
- }
- return b
- },
- spawnEntity: function (d, a, f, c) {
- var b = typeof (d) === "string" ? ig.global[d] : d;
- if (!b) {
- throw ("Can't spawn entity of type " + d)
- }
- var e = new(b)(a, f, c || {});
- this.entities.push(e);
- if (e.name) {
- this.namedEntities[e.name] = e
- }
- return e
- },
- sortEntities: function () {
- this.entities.sort(this.sortBy)
- },
- sortEntitiesDeferred: function () {
- this._doSortEntities = true
- },
- removeEntity: function (a) {
- if (a.name) {
- delete this.namedEntities[a.name]
- }
- a._killed = true;
- a.type = ig.Entity.TYPE.NONE;
- a.checkAgainst = ig.Entity.TYPE.NONE;
- a.collides = ig.Entity.COLLIDES.NEVER;
- this._deferredKill.push(a)
- },
- run: function () {
- this.update();
- this.draw()
- },
- update: function () {
- if (this._levelToLoad) {
- this.loadLevel(this._levelToLoad);
- this._levelToLoad = null
- }
- this.updateEntities();
- this.checkEntities();
- for (var d = 0; d < this._deferredKill.length; d++) {
- this._deferredKill[d].erase();
- this.entities.erase(this._deferredKill[d])
- }
- this._deferredKill = [];
- if (this._doSortEntities || this.autoSort) {
- this.sortEntities();
- this._doSortEntities = false
- }
- for (var e in this.backgroundAnims) {
- var b = this.backgroundAnims[e];
- for (var c in b) {
- b[c].update()
- }
- }
- },
- updateEntities: function () {
- for (var a = 0; a < this.entities.length; a++) {
- var b = this.entities[a];
- if (!b._killed) {
- b.update()
- }
- }
- },
- draw: function () {
- if (this.clearColor) {
- ig.system.clear(this.clearColor)
- }
- this._rscreen.x = ig.system.getDrawPos(this.screen.x) / ig.system.scale;
- this._rscreen.y = ig.system.getDrawPos(this.screen.y) / ig.system.scale;
- var a;
- for (a = 0; a < this.backgroundMaps.length; a++) {
- var b = this.backgroundMaps[a];
- if (b.foreground) {
- break
- }
- b.setScreenPos(this.screen.x, this.screen.y);
- b.draw()
- }
- this.drawEntities();
- for (a; a < this.backgroundMaps.length; a++) {
- var b = this.backgroundMaps[a];
- b.setScreenPos(this.screen.x, this.screen.y);
- b.draw()
- }
- },
- drawEntities: function () {
- for (var a = 0; a < this.entities.length; a++) {
- this.entities[a].draw()
- }
- },
- checkEntities: function () {
- var f = {};
- for (var h = 0; h < this.entities.length; h++) {
- var d = this.entities[h];
- if (d.type == ig.Entity.TYPE.NONE && d.checkAgainst == ig.Entity.TYPE.NONE && d.collides == ig.Entity.COLLIDES.NEVER) {
- continue
- }
- var l = {},
- a = Math.floor(d.pos.x / this.cellSize),
- m = Math.floor(d.pos.y / this.cellSize),
- g = Math.floor((d.pos.x + d.size.x) / this.cellSize) + 1,
- b = Math.floor((d.pos.y + d.size.y) / this.cellSize) + 1;
- for (var k = a; k < g; k++) {
- for (var j = m; j < b; j++) {
- if (!f[k]) {
- f[k] = {};
- f[k][j] = [d]
- } else {
- if (!f[k][j]) {
- f[k][j] = [d]
- } else {
- var n = f[k][j];
- for (var i = 0; i < n.length; i++) {
- if (d.touches(n[i]) && !l[n[i].id]) {
- l[n[i].id] = true;
- ig.Entity.checkPair(d, n[i])
- }
- }
- n.push(d)
- }
- }
- }
- }
- }
- }
- });
- ig.Game.SORT = {
- Z_INDEX: function (d, c) {
- return d.zIndex - c.zIndex
- },
- POS_X: function (d, c) {
- return (d.pos.x + d.size.x) - (c.pos.x + c.size.x)
- },
- POS_Y: function (d, c) {
- return (d.pos.y + d.size.y) - (c.pos.y + c.size.y)
- }
- }
- });
- ig.baked = true;
- ig.module("plugins.impact-tween.entity").requires("impact.entity").defines(function () {
- if (!Array.prototype.indexOf) {
- Array.prototype.indexOf = function (b, c) {
- var c = c || 0;
- for (var a = 0; a < this.length; ++a) {
- if (this[a] === b) {
- return a
- }
- }
- return -1
- }
- }
- ig.Entity.inject({
- tweens: [],
- update: function () {
- this.parent();
- if (this.tweens.length > 0) {
- var b = [];
- for (var a = 0; a < this.tweens.length; a++) {
- this.tweens[a].update();
- if (!this.tweens[a].complete) {
- b.push(this.tweens[a])
- }
- }
- this.tweens = b
- }
- },
- tween: function (c, d, b) {
- var a = new ig.Tween(this, c, d, b);
- this.tweens.push(a);
- return a
- },
- pauseTweens: function () {
- for (var a = 0; a < this.tweens.length; a++) {
- this.tweens[a].pause()
- }
- },
- resumeTweens: function () {
- for (var a = 0; a < this.tweens.length; a++) {
- this.tweens[a].resume()
- }
- },
- stopTweens: function (b) {
- for (var a = 0; a < this.tweens.length; a++) {
- this.tweens[a].stop(b)
- }
- }
- })
- });
- ig.baked = true;
- ig.module("plugins.impact-tween.tween").requires("plugins.impact-tween.entity").defines(function () {
- if (!Array.prototype.indexOf) {
- Array.prototype.indexOf = function (b, c) {
- var c = c || 0;
- for (var a = 0; a < this.length; ++a) {
- if (this[a] === b) {
- return a
- }
- }
- return -1
- }
- }
- ig.Tween = ig.Class.extend({
- _objects: null,
- valuesStart: [],
- valuesEnd: [],
- valuesDelta: [],
- _elapsed: 0,
- timer: false,
- started: false,
- _props: {},
- _chained: false,
- duration: 0,
- complete: false,
- paused: false,
- easing: null,
- onComplete: false,
- delay: 0,
- loop: 0,
- loopCount: -1,
- loopNum: -1,
- init: function (e, b, d, c) {
- this.easing = ig.Tween.Easing.Linear.EaseNone;
- this.duration = d;
- ig.merge(this, c);
- this.loopNum = this.loopCount;
- if (typeof b == "object" && b.constructor === (new Array).constructor) {
- this._props = b
- } else {
- this._props = [b]
- } if (typeof e == "object" && e.constructor === (new Array).constructor) {
- this._objects = e
- } else {
- this._objects = [e]
- }
- for (var a = 0; a < this._objects.length; a++) {
- this.valuesStart.push({});
- this.valuesEnd.push({});
- this.valuesDelta.push({})
- }
- },
- chain: function (a) {
- this._chained = a
- },
- initEnd: function (d, c, b) {
- if (typeof (c[d]) !== "object") {
- b[d] = c[d]
- } else {
- for (var a in c[d]) {
- if (!b[d]) {
- b[d] = {}
- }
- this.initEnd(a, c[d], b[d])
- }
- }
- },
- initStart: function (e, a, d, c) {
- if (typeof d.tweenInitStart === "function") {
- return d.tweenInitStart(e, a, c)
- }
- if (typeof (d[e]) !== "object") {
- if (typeof (a[e]) !== "undefined") {
- c[e] = d[e]
- }
- } else {
- for (var b in d[e]) {
- if (!c[e]) {
- c[e] = {}
- }
- if (typeof (a[e]) !== "undefined") {
- this.initStart(b, a[e], d[e], c[e])
- }
- }
- }
- },
- start: function () {
- this.complete = false;
- this.paused = false;
- this.loopNum = this.loopCount;
- this._elapsed = 0;
- this.started = true;
- this.timer = new ig.Timer();
- for (var a = 0; a < this._objects.length; a++) {
- if (this._objects[a].tweens.indexOf(this) == -1) {
- this._objects[a].tweens.push(this)
- }
- for (var b in this._props[a]) {
- this.initEnd(b, this._props[a], this.valuesEnd[a])
- }
- for (var b in this.valuesEnd[a]) {
- this.initStart(b, this.valuesEnd[a], this._objects[a], this.valuesStart[a]);
- this.initDelta(b, this.valuesDelta[a], this._objects[a], this.valuesEnd[a])
- }
- }
- },
- initDelta: function (e, d, c, a) {
- if (typeof c.tweenInitDelta === "function") {
- return c.tweenInitDelta(e, d, a)
- }
- if (typeof (a[e]) !== "object") {
- d[e] = a[e] - c[e]
- } else {
- for (var b in a[e]) {
- if (!d[e]) {
- d[e] = {}
- }
- this.initDelta(b, d[e], c[e], a[e])
- }
- }
- },
- propUpdate: function (f, c, e, d, b) {
- if (typeof c.tweenPropUpdate === "function") {
- return c.tweenPropUpdate(f, e, d, b)
- }
- if (typeof (e[f]) !== "object") {
- if (typeof e[f] != "undefined") {
- c[f] = e[f] + d[f] * b
- } else {
- c[f] = c[f]
- }
- } else {
- for (var a in e[f]) {
- this.propUpdate(a, c[f], e[f], d[f], b)
- }
- }
- },
- propSet: function (c, b, a) {
- if (typeof a.tweenPropSet === "function") {
- return a.tweenPropSet(c, b)
- }
- if (typeof (b[c]) !== "object") {
- a[c] = b[c]
- } else {
- for (subprop in b[c]) {
- if (!a[c]) {
- a[c] = {}
- }
- this.propSet(subprop, b[c], a[c])
- }
- }
- },
- update: function () {
- if (!this.started) {
- return false
- }
- if (this.delay) {
- if (this.timer.delta() < this.delay) {
- return
- }
- this.delay = 0;
- this.timer.reset()
- }
- if (this.paused || this.complete) {
- return false
- }
- var a = (this.timer.delta() + this._elapsed) / this.duration;
- a = a > 1 ? 1 : a;
- var g = this.easing(a);
- for (var c = 0; c < this._objects.length; c++) {
- for (var f in this.valuesDelta[c]) {
- this.propUpdate(f, this._objects[c], this.valuesStart[c], this.valuesDelta[c], g)
- }
- if (a >= 1) {
- if (this.loopNum == 0 || !this.loop) {
- this.complete = true;
- if (this.onComplete) {
- this.onComplete()
- }
- if (this._chained) {
- this._chained.start()
- }
- return false
- } else {
- if (this.loop == ig.Tween.Loop.Revert) {
- for (var f in this.valuesStart[c]) {
- this.propSet(f, this.valuesStart[c], this._objects[c])
- }
- this._elapsed = 0;
- this.timer.reset();
- if (this.loopNum != -1) {
- this.loopNum--
- }
- } else {
- if (this.loop == ig.Tween.Loop.Reverse) {
- var e = {},
- b = {},
- d = {};
- ig.merge(e, this.valuesEnd[c]);
- ig.merge(b, this.valuesStart[c]);
- ig.merge(this.valuesStart[c], e);
- ig.merge(this.valuesEnd[c], b);
- for (var f in this.valuesEnd[c]) {
- this.initDelta(f, this.valuesDelta[c], this._objects[c], this.valuesEnd[c])
- }
- this._elapsed = 0;
- this.timer.reset();
- if (this.loopNum != -1) {
- this.loopNum--
- }
- }
- }
- }
- }
- }
- },
- pause: function () {
- this.paused = true;
- this._elapsed += this.timer.delta()
- },
- resume: function () {
- this.paused = false;
- this.timer.reset()
- },
- stop: function (a) {
- if (a) {
- this.paused = false;
- this.complete = false;
- this.loop = false;
- this._elapsed += this.duration;
- this.update()
- }
- this.complete = true
- },
- rewind: function () {
- var a = this.loop;
- this.complete = false;
- this.paused = false;
- this.loopNum = -1;
- this.loop = ig.Tween.Loop.Revert;
- this.update();
- this.loop = a
- }
- });
- ig.Tween.Loop = {
- Revert: 1,
- Reverse: 2
- };
- ig.Tween.Easing = {
- Linear: {},
- Quadratic: {},
- Cubic: {},
- Quartic: {},
- Quintic: {},
- Sinusoidal: {},
- Exponential: {},
- Circular: {},
- Elastic: {},
- Back: {},
- Bounce: {}
- };
- ig.Tween.Easing.Linear.EaseNone = function (a) {
- return a
- };
- ig.Tween.Easing.Quadratic.EaseIn = function (a) {
- return a * a
- };
- ig.Tween.Easing.Quadratic.EaseOut = function (a) {
- return -a * (a - 2)
- };
- ig.Tween.Easing.Quadratic.EaseInOut = function (a) {
- if ((a *= 2) < 1) {
- return 0.5 * a * a
- }
- return -0.5 * (--a * (a - 2) - 1)
- };
- ig.Tween.Easing.Cubic.EaseIn = function (a) {
- return a * a * a
- };
- ig.Tween.Easing.Cubic.EaseOut = function (a) {
- return --a * a * a + 1
- };
- ig.Tween.Easing.Cubic.EaseInOut = function (a) {
- if ((a *= 2) < 1) {
- return 0.5 * a * a * a
- }
- return 0.5 * ((a -= 2) * a * a + 2)
- };
- ig.Tween.Easing.Quartic.EaseIn = function (a) {
- return a * a * a * a
- };
- ig.Tween.Easing.Quartic.EaseOut = function (a) {
- return -(--a * a * a * a - 1)
- };
- ig.Tween.Easing.Quartic.EaseInOut = function (a) {
- if ((a *= 2) < 1) {
- return 0.5 * a * a * a * a
- }
- return -0.5 * ((a -= 2) * a * a * a - 2)
- };
- ig.Tween.Easing.Quintic.EaseIn = function (a) {
- return a * a * a * a * a
- };
- ig.Tween.Easing.Quintic.EaseOut = function (a) {
- return (a = a - 1) * a * a * a * a + 1
- };
- ig.Tween.Easing.Quintic.EaseInOut = function (a) {
- if ((a *= 2) < 1) {
- return 0.5 * a * a * a * a * a
- }
- return 0.5 * ((a -= 2) * a * a * a * a + 2)
- };
- ig.Tween.Easing.Sinusoidal.EaseIn = function (a) {
- return -Math.cos(a * Math.PI / 2) + 1
- };
- ig.Tween.Easing.Sinusoidal.EaseOut = function (a) {
- return Math.sin(a * Math.PI / 2)
- };
- ig.Tween.Easing.Sinusoidal.EaseInOut = function (a) {
- return -0.5 * (Math.cos(Math.PI * a) - 1)
- };
- ig.Tween.Easing.Exponential.EaseIn = function (a) {
- return a == 0 ? 0 : Math.pow(2, 10 * (a - 1))
- };
- ig.Tween.Easing.Exponential.EaseOut = function (a) {
- return a == 1 ? 1 : -Math.pow(2, -10 * a) + 1
- };
- ig.Tween.Easing.Exponential.EaseInOut = function (a) {
- if (a == 0) {
- return 0
- }
- if (a == 1) {
- return 1
- }
- if ((a *= 2) < 1) {
- return 0.5 * Math.pow(2, 10 * (a - 1))
- }
- return 0.5 * (-Math.pow(2, -10 * (a - 1)) + 2)
- };
- ig.Tween.Easing.Circular.EaseIn = function (a) {
- return -(Math.sqrt(1 - a * a) - 1)
- };
- ig.Tween.Easing.Circular.EaseOut = function (a) {
- return Math.sqrt(1 - (--a) * a)
- };
- ig.Tween.Easing.Circular.EaseInOut = function (a) {
- if ((a /= 0.5) < 1) {
- return -0.5 * (Math.sqrt(1 - a * a) - 1)
- }
- return 0.5 * (Math.sqrt(1 - (a -= 2) * a) + 1)
- };
- ig.Tween.Easing.Elastic.EaseIn = function (c) {
- var d, b = 0.1,
- e = 0.4;
- if (c == 0) {
- return 0
- }
- if (c == 1) {
- return 1
- }
- if (!e) {
- e = 0.3
- }
- if (!b || b < 1) {
- b = 1;
- d = e / 4
- } else {
- d = e / (2 * Math.PI) * Math.asin(1 / b)
- }
- return -(b * Math.pow(2, 10 * (c -= 1)) * Math.sin((c - d) * (2 * Math.PI) / e))
- };
- ig.Tween.Easing.Elastic.EaseOut = function (c) {
- var d, b = 0.1,
- e = 0.4;
- if (c == 0) {
- return 0
- }
- if (c == 1) {
- return 1
- }
- if (!e) {
- e = 0.3
- }
- if (!b || b < 1) {
- b = 1;
- d = e / 4
- } else {
- d = e / (2 * Math.PI) * Math.asin(1 / b)
- }
- return (b * Math.pow(2, -10 * c) * Math.sin((c - d) * (2 * Math.PI) / e) + 1)
- };
- ig.Tween.Easing.Elastic.EaseInOut = function (c) {
- var d, b = 0.1,
- e = 0.4;
- if (c == 0) {
- return 0
- }
- if (c == 1) {
- return 1
- }
- if (!e) {
- e = 0.3
- }
- if (!b || b < 1) {
- b = 1;
- d = e / 4
- } else {
- d = e / (2 * Math.PI) * Math.asin(1 / b)
- } if ((c *= 2) < 1) {
- return -0.5 * (b * Math.pow(2, 10 * (c -= 1)) * Math.sin((c - d) * (2 * Math.PI) / e))
- }
- return b * Math.pow(2, -10 * (c -= 1)) * Math.sin((c - d) * (2 * Math.PI) / e) * 0.5 + 1
- };
- ig.Tween.Easing.Back.EaseIn = function (a) {
- var b = 1.70158;
- return a * a * ((b + 1) * a - b)
- };
- ig.Tween.Easing.Back.EaseOut = function (a) {
- var b = 1.70158;
- return (a = a - 1) * a * ((b + 1) * a + b) + 1
- };
- ig.Tween.Easing.Back.EaseInOut = function (a) {
- var b = 1.70158 * 1.525;
- if ((a *= 2) < 1) {
- return 0.5 * (a * a * ((b + 1) * a - b))
- }
- return 0.5 * ((a -= 2) * a * ((b + 1) * a + b) + 2)
- };
- ig.Tween.Easing.Bounce.EaseIn = function (a) {
- return 1 - ig.Tween.Easing.Bounce.EaseOut(1 - a)
- };
- ig.Tween.Easing.Bounce.EaseOut = function (a) {
- if ((a /= 1) < (1 / 2.75)) {
- return 7.5625 * a * a
- } else {
- if (a < (2 / 2.75)) {
- return 7.5625 * (a -= (1.5 / 2.75)) * a + 0.75
- } else {
- if (a < (2.5 / 2.75)) {
- return 7.5625 * (a -= (2.25 / 2.75)) * a + 0.9375
- } else {
- return 7.5625 * (a -= (2.625 / 2.75)) * a + 0.984375
- }
- }
- }
- };
- ig.Tween.Easing.Bounce.EaseInOut = function (a) {
- if (a < 0.5) {
- return ig.Tween.Easing.Bounce.EaseIn(a * 2) * 0.5
- }
- return ig.Tween.Easing.Bounce.EaseOut(a * 2 - 1) * 0.5 + 0.5
- }
- });
- ig.baked = true;
- ig.module("game.config").defines(function () {
- ig.CONFIG = {
- TILESIZE: 17,
- FIELD_ROWS: 19,
- FIELD_COLS: 10,
- MIN_HIGHSCORE: 0,
- // MORE_GAMES_URL: "http://www.play68.com",
- LANG: ["en", "es", "de", "fr", "it", "pt", "tr", "ru", "zh"],//langs
- CONTENTS: [{
- Start: "开始",
- Help: "排行榜",
- MoreGames: "更多游戏",
- Back: "返回"
- }, {
- Start: "Jugar",
- Help: "Ayudar",
- MoreGames: "Más Juegos",
- Back: "Volver"
- }, {
- Start: "Spielen",
- Help: "Hilfe",
- MoreGames: "Mehr Spiele",
- Back: "Zurück"
- }, {
- Start: "Jouer",
- Help: "Aider",
- MoreGames: "Plus de Jeux",
- Back: "Retour"
- }, {
- Start: "Giocare",
- Help: "Aiuto",
- MoreGames: "Altre partite",
- Back: "Indietro"
- }, {
- Start: "Jogar",
- Help: "Ajudar",
- MoreGames: "Mais jogos",
- Back: "Retroceder"
- }, {
- Start: "taşlar",
- Help: "Yardım",
- MoreGames: "Daha Fazla Oyun",
- Back: "Geri"
- }, {
- Start: "Играть",
- Help: "Помощь",
- MoreGames: "Еще игры",
- Back: "Назад"
- }, {
- Start: "开始",
- Help: "帮助",
- MoreGames: "更多游戏",
- Back: "返回"
- }]
- };
- ig.CONFIG.GEMS = {
- TILESIZE: 17,
- FIELD_ROWS: 19,
- FIELD_COLS: 10,
- SHAPES: 7,
- LOCKIN_DELAY: 0.5,
- PRESSED_DELAY: 0.25,
- REPEAT_LEFT_RIGHT_DELAY: 0.07,
- REPEAT_DOWN_DELAY: 0.05,
- CLEAN_LINES_DELAY: 0.42,
- DROP_POS_X: 68,
- DROP_POS_Y: 34,
- SPAWN_POS_X: 210,
- SPAWN_POS_Y: 88,
- SPEED_INCREASE_PER_STAGE: 0.4,
- MIN_HIGHSCORE: 10,
- SLOW_DURITION: 4.2,
- BOMB_PROBABILITY: 0.012,
- SLOW_PROBABILITY: 0.016,
- BOMB_OVER_SLOW_PROBABILITY: 0.5
- };
- ig.CONFIG.CLASSIC = {
- TILESIZE: 17,
- FIELD_ROWS: 19,
- FIELD_COLS: 10,
- SHAPES: 7,
- LOCKIN_DELAY: 0.5,
- PRESSED_DELAY: 0.25,
- REPEAT_LEFT_RIGHT_DELAY: 0.07,
- REPEAT_DOWN_DELAY: 0.05,
- CLEAN_LINES_DELAY: 0.42,
- DROP_POS_X: 68,
- DROP_POS_Y: 34,
- SPAWN_POS_X: 218,
- SPAWN_POS_Y: 78,
- SPEED_INCREASE_PER_STAGE: 0.4,
- MIN_HIGHSCORE: 10
- }
- });
- ig.baked = true;
- ig.module("game.scenes.title").requires("impact.game", "impact.entity", "plugins.impact-tween.tween", "game.config").defines(function () {
- var h = ig.CONFIG;
- var d = 0,
- a = 1,
- j = 2;
- var m = ig.Entity.extend({
- _layer: "bg",
- size: {
- x: 320,
- y: 480
- },
- animSheet: new ig.AnimationSheet("media/title-bg-empty.png", 320, 480),
- init: function (o, q, p) {
- this.parent(o, q, p);
- this.addAnim("idle", 1, [0])
- }
- });
- var g = ig.Entity.extend({
- _layer: "gui",
- enable: false,
- touched: false,
- pressed: false,
- released: false,
- animSheet: new ig.AnimationSheet("media/big-button.png", 166, 61),
- size: {
- x: 166,
- y: 61
- },
- fontSize: 24,
- content: "",
- visible: true,
- init: function (o, q, p) {
- this.parent(o, q, p);
- this.addAnim("up", 1, [0], true);
- this.addAnim("down", 1, [1], true)
- },
- update: function () {
- this.parent();
- if (this.pressed) {
- this.pressed = false
- }
- if (this.released) {
- this.released = false;
- if (this.enable) {
- this.activated()
- }
- }
- },
- draw: function () {
- if (this.visible) {
- this.parent();
- ig.system.context.save();
- 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));
- ig.system.context.fillStyle = "#f8d396";
- ig.system.context.shadowColor = "rgba(0, 0, 0, 0.8)";
- ig.system.context.shadowOffsetX = 2;
- ig.system.context.shadowOffsetX = 2;
- ig.system.context.shadowBlur = 5;
- ig.system.context.font = this.fontSize + "px Sofia";
- ig.system.context.textBaseline = "center";
- ig.system.context.textAlign = "center";
- ig.system.context.fillText(this.content, this.size.x / 2, this.size.y / 2 + 2);
- ig.system.context.restore()
- }
- },
- onTouch: function () {
- this.touched = true;
- this.pressed = true;
- this.currentAnim = this.anims.down
- },
- onRelease: function () {
- this.touched = false;
- this.released = true;
- this.currentAnim = this.anims.up
- },
- activated: function () {}
- });
- var n = g.extend({
- animSheet: new ig.AnimationSheet("media/title-word.png", 214, 197),
- size: {
- x: 214,
- y: 197
- },
- init: function (o, q, p) {
- this.parent(o, q, p);
- this.addAnim("idle", 1, [0], true)
- },
- moveIn: function () {
- this.tween({
- pos: {
- y: (ig.ua.iPad ? 4 : 16)
- }
- }, 1.6, {
- delay: 0.4,
- easing: ig.Tween.Easing.Elastic.EaseOut,
- onComplete: function () {
- this.offsetToStage = {
- x: this.pos.x,
- y: this.pos.y
- }
- }.bind(this)
- }).start()
- }
- });
- var k = g.extend({
- activated: function () {
- if (ig.game.state === d) {
- ig.gameManager.newGemsRound()
- }
- },
- moveIn: function () {
- this.content = h.CONTENTS[ig.gameManager.langIndex].Start;
- this.tween({
- pos: {
- y: (ig.ua.iPad ? 196 : 234)
- }
- }, 0.8, {
- delay: 0.25,
- easing: ig.Tween.Easing.Quartic.EaseOut,
- onComplete: function () {
- this.offsetToStage = {
- x: this.pos.x,
- y: this.pos.y
- };
- this.enable = true
- }.bind(this)
- }).start()
- }
- });
- var i = g.extend({
- activated: function () {
- if (ig.game.state === d) {
- ig.game.transToHelp()
- }
- },
- moveIn: function () {
- this.content = h.CONTENTS[ig.gameManager.langIndex].Help;
- this.tween({
- pos: {
- y: (ig.ua.iPad ? 260 : 308)
- }
- }, 0.8, {
- delay: 0.25,
- easing: ig.Tween.Easing.Quartic.EaseOut,
- onComplete: function () {
- this.offsetToStage = {
- x: this.pos.x,
- y: this.pos.y
- };
- this.enable = true
- }.bind(this)
- }).start()
- }
- });
- var b = g.extend({
- fontSize: 18,
- activated: function () {
- if (ig.game.state === d) {
- //window.open(h.MORE_GAMES_URL, "_top")
- SG.redirectToPortal();
- }
- },
- moveIn: function () {
- this.content = h.CONTENTS[ig.gameManager.langIndex].MoreGames;
- this.tween({
- pos: {
- y: (ig.ua.iPad ? 322 : 382)
- }
- }, 0.8, {
- delay: 0.3,
- easing: ig.Tween.Easing.Quartic.EaseOut,
- onComplete: function () {
- this.offsetToStage = {
- x: this.pos.x,
- y: this.pos.y
- };
- this.enable = true;
- ig.game.state = d
- }.bind(this)
- }).start()
- }
- });
- var f = g.extend({
- enable: false,
- visible: false,
- init: function (o, q, p) {
- this.parent(o, q, p);
- this.content = h.CONTENTS[ig.gameManager.langIndex].Back
- },
- activated: function () {
- if (ig.game.state === a) {
- ig.game.transToTitle()
- }
- }
- });
- var e = g.extend({
- animSheet: new ig.AnimationSheet("media/touch-tut.png", 88, 79),
- size: {
- x: 88,
- y: 79
- },
- visible: false,
- init: function (o, q, p) {
- this.parent(o, q, p);
- this.addAnim("idle", 1, [0], true);
- this.offsetToStage = {
- x: o,
- y: q
- }
- }
- });
- var c = g.extend({
- animSheet: new ig.AnimationSheet("media/keyboard-tut.png", 86, 61),
- size: {
- x: 86,
- y: 61
- },
- visible: false,
- init: function (o, q, p) {
- this.parent(o, q, p);
- this.addAnim("idle", 1, [0], true);
- this.offsetToStage = {
- x: o,
- y: q
- }
- }
- });
- var l = ig.Game.extend({
- state: 0,
- clearColor: "#fff",
- bg: null,
- stageTouched: false,
- stagePressed: false,
- stageReleased: false,
- init: function () {
- this.createLayer("bg");
- this.createLayer("gui");
- this.setLayerSort(["bg", "gui"]);
- ig.gameManager.inputManager.on("touch", this.touched.bind(this));
- ig.gameManager.inputManager.on("release", this.released.bind(this));
- this.state = j;
- this.bg = this.spawnEntity(m, 0, 0);
- this.startBtn = this.spawnEntity(k, 78, 480);
- this.startBtn.moveIn();
- this.helpBtn = this.spawnEntity(i, 78, 480);
- this.helpBtn.moveIn();
- this.moreBtn = this.spawnEntity(b, 78, 480);
- this.moreBtn.moveIn();
- this.gameTitle = this.spawnEntity(n, 56, -197);
- this.gameTitle.moveIn();
- this.helpBackBtn = this.spawnEntity(f, 78, 60);
- this.tutTouch = this.spawnEntity(e, 116, (ig.ua.iPad ? 150 : 180));
- this.tutKeyboard = this.spawnEntity(c, 116, (ig.ua.iPad ? 270 : 300))
- },
- update: function () {
- this.stagePressed = false;
- this.stageReleased = false;
- this.parent()
- },
- transToHelp: function () {
- /*this.state = a;
- this.gameTitle.visible = false;
- this.startBtn.visible = false;
- this.helpBtn.visible = false;
- this.moreBtn.visible = false;
- this.gameTitle.enable = false;
- this.startBtn.enable = false;
- this.helpBtn.enable = false;
- this.moreBtn.enable = false;*/
- // this.helpBackBtn.visible = true;
- // this.helpBackBtn.enable = true;
- // this.tutTouch.visible = true;
- // this.tutKeyboard.visible = true
- //Play68.showRanking();
- },
- transToTitle: function () {
- this.state = d;
- this.gameTitle.visible = true;
- this.startBtn.visible = true;
- this.helpBtn.visible = true;
- this.moreBtn.visible = true;
- this.gameTitle.enable = true;
- this.startBtn.enable = true;
- this.helpBtn.enable = true;
- this.moreBtn.enable = true;
- this.helpBackBtn.visible = false;
- this.helpBackBtn.enable = false;
- this.tutTouch.visible = false;
- this.tutKeyboard.visible = false
- },
- touched: function (s) {
- var t = this.getPointPos(s),
- p = this.layers.gui.items,
- r;
- for (var q = 0, o = p.length; q < o; ++q) {
- r = p[q];
- if (r.enable && r.visible && this.intersect(r, t.x, t.y)) {
- r.onTouch();
- return false
- }
- }
- this.stageTouched = true;
- this.stagePressed = true
- },
- released: function (s) {
- var t = this.getPointPos(s),
- p = this.layers.gui.items,
- r;
- for (var q = 0, o = p.length; q < o; ++q) {
- r = p[q];
- if (r.enable && r.visible && this.intersect(r, t.x, t.y)) {
- r.onRelease();
- return false
- }
- }
- this.stageTouched = false;
- this.stageReleased = true
- },
- getPointPos: function (r) {
- var p = r.gesture.center,
- q = ig.system.canvas.getBoundingClientRect();
- var o = (p.pageX - q.left) / ig.gameManager.stageScale.x,
- s = (p.pageY - q.top) / ig.gameManager.stageScale.y;
- return {
- x: o,
- y: s
- }
- },
- intersect: function (r, o, u) {
- var t = r.pos.x,
- q = r.pos.x + r.size.x,
- s = r.pos.y,
- p = r.pos.y + r.size.y;
- return !(o < t || o > q || u < s || u > p)
- }
- });
- ig.SceneTitle = l
- });
- ig.baked = true;
- ig.module("impact.entity-pool").requires("impact.game").defines(function () {
- ig.EntityPool = {
- pools: {},
- mixin: {
- staticInstantiate: function (a, c, b) {
- return ig.EntityPool.getFromPool(this.classId, a, c, b)
- },
- erase: function () {
- ig.EntityPool.putInPool(this)
- }
- },
- enableFor: function (a) {
- a.inject(this.mixin)
- },
- getFromPool: function (e, b, f, d) {
- var c = this.pools[e];
- if (!c || !c.length) {
- return null
- }
- var a = c.pop();
- a.reset(b, f, d);
- return a
- },
- putInPool: function (a) {
- if (!this.pools[a.classId]) {
- this.pools[a.classId] = [a]
- } else {
- this.pools[a.classId].push(a)
- }
- },
- drainPool: function (a) {
- delete this.pools[a]
- },
- drainAllPools: function () {
- this.pools = {}
- }
- };
- ig.Game.inject({
- loadLevel: function (a) {
- ig.EntityPool.drainAllPools();
- this.parent(a)
- }
- })
- });
- ig.baked = true;
- ig.module("plugins.layers").requires("impact.game", "impact.background-map", "impact.entity", "impact.entity-pool").defines(function () {
- var a = parseFloat(window.ig.version) || 0;
- if (!a || a < 1.23) {
- throw new Error("layers.js requires ImpactJS v1.23 or above, current version: " + a)
- }
- ig.Game.inject({
- layerOrder: [],
- onPreRun: [],
- onPostRun: [],
- layers: {},
- init: function () {
- this.createLayer("backgroundMaps", {
- clearOnLoad: true,
- mapLayer: true
- });
- this.createLayer("entities", {
- clearOnLoad: true,
- entityLayer: true,
- autoSort: this.autoSort,
- sortBy: this.sortBy,
- _doSortEntities: false
- });
- this.createLayer("foregroundMaps", {
- clearOnLoad: true,
- mapLayer: true
- })
- },
- setLayerProperties: function (b, c) {
- this._layerProperties.push([b, c]);
- return this
- },
- setLayerSort: function (b) {
- this._layerOrder = (b && b.length) ? b : null;
- return this
- },
- createLayer: function (b, d, e) {
- var c = this.layers[b] = ig.merge(this.layers[b] || {}, d);
- if (!c.items) {
- c.items = []
- }
- if (b === "entities") {
- this.entities = c.items
- }
- if (b === "backgroundMaps") {
- this.backgroundMaps = c.items
- }
- if (e) {
- return this
- }
- this.layerOrder.push(b);
- return this
- },
- _layerProperties: [],
- _layersToRemove: [],
- _itemsToRemove: [],
- _layersToPush: [],
- _layersToPop: [],
- removeLayer: function (c) {
- var b = this._layersToRemove.indexOf(c);
- if (b === -1) {
- this._layersToRemove.push(c)
- }
- return this
- },
- pushLayer: function (c) {
- var b = this._layersToPush.indexOf(c);
- if (b === -1) {
- this._layersToPush.push(c)
- }
- return this
- },
- popLayer: function (c) {
- var b = this._layersToPop.indexOf(c);
- if (b === -1) {
- this._layersToPop.push(c)
- }
- return this
- },
- clearLayer: function (b) {
- this._itemsToRemove = this._itemsToRemove.concat(this.layers[b].items);
- return this
- },
- addItem: function (d, b) {
- var c;
- b = b || d._layer;
- c = this.layers[b];
- if (!c) {
- throw new Error("Attempting to add to a layer that doesn't exist: " + b)
- }
- d._layer = b;
- c.items.push(d);
- return this
- },
- removeItem: function (b) {
- if (!b || !b._layer) {
- throw new Error("Layers: Cannot remove an item that doesn't exist or has no ._layer property")
- }
- this._itemsToRemove.push(b);
- return this
- },
- sortEntitiesDeferred: function (b) {
- b = b || "entities";
- this.layers[b]._doSortEntities = true
- },
- sortEntities: function (b) {
- b = this.layers[b || "entities"];
- if (!b) {
- return this
- }
- b.items.sort(b.sortBy);
- return this
- },
- updateEntities: function (b) {
- var e = this.layers[b || "entities"].items,
- d, c;
- for (c = 0; c < e.length; c++) {
- d = e[c];
- if (!d._killed) {
- d.update()
- }
- }
- return this
- },
- checkEntities: function (j) {
- var h = {},
- i, k, l, f, q, b, p, g, d, o, n, r, m;
- i = this.layers[j || "entities"];
- if (!i || !i.entityLayer) {
- return
- }
- j = i.items;
- k = j.length;
- for (l = 0; l < k; l++) {
- f = j[l];
- if (f.type === ig.Entity.TYPE.NONE && f.checkAgainst === ig.Entity.TYPE.NONE && f.collides === ig.Entity.COLLIDES.NEVER) {
- continue
- }
- q = {};
- b = Math.floor(f.pos.x / this.cellSize);
- p = Math.floor(f.pos.y / this.cellSize);
- g = Math.floor((f.pos.x + f.size.x) / this.cellSize) + 1;
- d = Math.floor((f.pos.y + f.size.y) / this.cellSize) + 1;
- for (o = b; o < g; o++) {
- for (n = p; n < d; n++) {
- if (!h[o]) {
- h[o] = {};
- h[o][n] = [f]
- } else {
- if (!h[o][n]) {
- h[o][n] = [f]
- } else {
- r = h[o][n];
- for (m = 0; m < r.length; m++) {
- if (f.touches(r[m]) && !q[r[m].id]) {
- q[r[m].id] = true;
- ig.Entity.checkPair(f, r[m])
- }
- }
- r.push(f)
- }
- }
- }
- }
- }
- },
- getEntitiesByType: function (g, e) {
- var c = typeof (g) === "string" ? ig.global[g] : g,
- b = [],
- d, h, j, f;
- j = this.layers[e || "entities"].items;
- f = j.length;
- for (d = 0; d < f; d++) {
- h = j[d];
- if (h instanceof c && !h._killed) {
- b.push(h)
- }
- }
- return b
- },
- getMapByName: function (d) {
- var b, f, c, e;
- if (d === "collision") {
- return this.collisionMap
- }
- for (b = 0; b < this.layerOrder.length; b++) {
- e = this.layers[this.layerOrder[b]];
- c = e.items;
- if (!e.mapLayer) {
- continue
- }
- for (f = 0; f < c.length; f++) {
- if (c[f].name === d) {
- return c[f]
- }
- }
- }
- return null
- },
- update: function () {
- var e, d, h, b, g, j, c, i, f;
- while (this._layerProperties.length) {
- d = this._layerProperties.shift();
- if (!this.layers[d[0]]) {
- continue
- }
- ig.merge(this.layers[d[0]], d[1])
- }
- while (this._layersToRemove.length) {
- e = this._layersToRemove.shift();
- d = this.layers[e];
- if (!d) {
- continue
- }
- this._itemsToRemove = this._itemsToRemove.concat(d.items);
- this.layers[e] = null
- }
- while (this._itemsToRemove.length) {
- j = this._itemsToRemove.shift();
- g = this.layers[j._layer] ? this.layers[j._layer].items : null;
- if (j._itemCleanUp) {
- j._itemCleanUp()
- }
- if (!g) {
- continue
- }
- h = g.indexOf(j);
- if (h < 0) {
- continue
- }
- g.splice(h, 1)
- }
- if (this._layerOrder) {
- this.layerOrder = this._layerOrder;
- this._layerOrder = null
- }
- if (this._layersToPush.length) {
- for (h = 0; h < this._layersToPush.length; h++) {
- this.layerOrder.push(this._layersToPush[h])
- }
- this._layersToPush = []
- }
- if (this._layersToPop.length) {
- for (h = 0; h < this._layersToPop.length; h++) {
- f = this.layerOrder.indexOf(this._layersToPop[h]);
- if (f !== -1) {
- this.layerOrder.splice(f, 1)
- }
- }
- this._layersToPop = []
- }
- if (this._levelToLoad) {
- this.loadLevel(this._levelToLoad);
- this._levelToLoad = null
- }
- for (h = 0; h < this.layerOrder.length; h++) {
- e = this.layerOrder[h];
- d = this.layers[e];
- g = d.items;
- if (d.noUpdate || d.mapLayer) {
- continue
- }
- for (b = 0; b < g.length; b++) {
- g[b].update()
- }
- if (d.entityLayer && (d._doSortEntities || d.autoSort)) {
- g.sort(d.sortBy || this.sortBy);
- d._doSortEntities = false
- }
- if (d.entityLayer) {
- this.checkEntities(e)
- }
- }
- while (this._deferredKill.length) {
- j = this._deferredKill.shift();
- g = this.layers[j._layer].items;
- h = g.indexOf(j);
- if (j.erase) {
- j.erase()
- }
- if (j._itemCleanUp) {
- j._itemCleanUp()
- }
- if (h < 0) {
- continue
- }
- g.splice(h, 1)
- }
- for (c in this.backgroundAnims) {
- i = this.backgroundAnims[c];
- for (h in i) {
- i[h].update()
- }
- }
- },
- draw: function () {
- var d, b, e, c;
- if (this.clearColor) {
- ig.system.clear(this.clearColor)
- }
- this._rscreen.x = ig.system.getDrawPos(this.screen.x) / ig.system.scale;
- this._rscreen.y = ig.system.getDrawPos(this.screen.y) / ig.system.scale;
- for (b = 0; b < this.layerOrder.length; b++) {
- d = this.layers[this.layerOrder[b]];
- c = d.items;
- if (d.noDraw) {
- continue
- }
- for (e = 0; e < c.length; e++) {
- c[e].draw()
- }
- }
- },
- spawnEntity: function (e, b, g, d) {
- var c = typeof (e) === "string" ? ig.global[e] : e,
- f;
- if (!c) {
- throw new Error("Can't spawn entity of type: " + e)
- }
- f = new(c)(b, g, d || {});
- this.addItem(f);
- if (f.name) {
- this.namedEntities[f.name] = f
- }
- return f
- },
- loadLevel: function (e) {
- var j = this.layerOrder.length,
- f, l, c, b, d, h, g, m, k;
- ig.EntityPool.drainAllPools();
- this.screen = {
- x: 0,
- y: 0
- };
- for (m = 0; m < j; m++) {
- g = this.layerOrder[m];
- h = this.layers[g];
- if (!h) {
- continue
- }
- if (h.clearOnLoad) {
- h.items.length = 0
- }
- }
- this.namedEntities = {};
- for (f = 0; f < e.entities.length; f++) {
- l = e.entities[f];
- if (this._validateEntitySettings) {
- this.spawnEntity(l.type, l.x, l.y, l.settings)
- }
- }
- this.sortEntities();
- this.collisionMap = ig.CollisionMap.staticNoCollision;
- for (f = 0; f < e.layer.length; f++) {
- c = e.layer[f];
- if (c.name === "collision") {
- this.collisionMap = new ig.CollisionMap(c.tilesize, c.data)
- } else {
- b = new ig.BackgroundMap(c.tilesize, c.data, c.tilesetName);
- b.anims = this.backgroundAnims[c.tilesetName] || {};
- b.repeat = c.repeat;
- b.distance = c.distance;
- b.foreground = !!c.foreground;
- b.preRender = !!c.preRender;
- b.name = c.name;
- if (!b._layer && b.foreground) {
- b._layer = "foregroundMaps"
- } else {
- if (!b._layer) {
- b._layer = "backgroundMaps"
- }
- }
- this.addItem(b)
- }
- }
- for (m = 0; m < j; m++) {
- g = this.layerOrder[m];
- h = this.layers[g];
- k = h.items;
- d = k.length;
- if (h.entityLayer) {
- for (f = 0; f < d; f++) {
- k[f].ready()
- }
- }
- }
- },
- drawEntities: function (b) {
- var e, d, c;
- b = b || "entities";
- e = this.layers[b].items;
- for (c = 0; c < d; c++) {
- e[c].draw()
- }
- },
- run: function () {
- var b;
- if (this._checkRotatePrompt()) {
- return
- }
- if (this.onPreRun.length) {
- for (b = 0; b < this.onPreRun.length; b++) {
- this.onPreRun[b]()
- }
- this.onPreRun.length = 0
- }
- if (!this._pauseRun) {
- this.update();
- this.draw()
- }
- if (this.onPostRun.length) {
- for (b = 0; b < this.onPostRun.length; b++) {
- this.onPostRun[b]()
- }
- this.onPostRun.length = 0
- }
- },
- _checkRotatePrompt: function () {
- ig.gameManager.checkOrientationFlag();
- if (ig.gameManager && ig.gameManager._promptPause) {
- this._pauseRun = true
- } else {
- if (ig.gameManager && !ig.gameManager._promptPause) {
- this._pauseRun = false
- }
- }
- },
- _validateEntitySettings: function () {
- return true
- }
- });
- ig.Entity.inject({
- _layer: "entities"
- });
- ig.BackgroundMap.inject({
- draw: function () {
- this.setScreenPos(ig.game.screen.x, ig.game.screen.y);
- if (!this.tiles.loaded || !this.enabled) {
- return
- }
- if (this.preRender) {
- this.drawPreRendered()
- } else {
- this.drawTiled()
- }
- }
- })
- });
- ig.baked = true;
- ig.module("game.entities.button-left").requires("impact.entity").defines(function () {
- ig.global.EntityButtonLeft = ig.Entity.extend({
- _layer: "gui",
- size: {
- x: 45,
- y: 45
- },
- animSheet: new ig.AnimationSheet("media/button-left.png", 45, 45),
- touched: false,
- pressed: false,
- released: false,
- init: function (a, d, b) {
- this.parent(a, d, b);
- var c = this.addAnim("up", 1, [0]);
- if (ig.ua.iPad) {
- c.alpha = 0.5
- }
- c = this.addAnim("down", 1, [1]);
- if (ig.ua.iPad) {
- c.alpha = 0.5
- }
- },
- update: function () {
- this.parent();
- if (this.pressed) {
- this.pressed = false
- }
- if (this.released) {
- this.released = false
- }
- },
- onTouch: function () {
- this.touched = true;
- this.pressed = true;
- this.currentAnim = this.anims.down
- },
- onRelease: function () {
- if (this.touched) {
- this.touched = false;
- this.released = true
- }
- this.currentAnim = this.anims.up
- }
- })
- });
- ig.baked = true;
- ig.module("game.entities.button-right").requires("impact.entity").defines(function () {
- ig.global.EntityButtonRight = ig.Entity.extend({
- _layer: "gui",
- size: {
- x: 45,
- y: 45
- },
- animSheet: new ig.AnimationSheet("media/button-right.png", 45, 45),
- touched: false,
- pressed: false,
- released: false,
- init: function (a, d, b) {
- this.parent(a, d, b);
- var c = this.addAnim("up", 1, [0]);
- if (ig.ua.iPad) {
- c.alpha = 0.5
- }
- c = this.addAnim("down", 1, [1]);
- if (ig.ua.iPad) {
- c.alpha = 0.5
- }
- },
- update: function () {
- this.parent();
- if (this.pressed) {
- this.pressed = false
- }
- if (this.released) {
- this.released = false
- }
- },
- onTouch: function () {
- this.touched = true;
- this.pressed = true;
- this.currentAnim = this.anims.down
- },
- onRelease: function () {
- if (this.touched) {
- this.touched = false;
- this.released = true
- }
- this.currentAnim = this.anims.up
- }
- })
- });
- ig.baked = true;
- ig.module("game.entities.button-down").requires("impact.entity").defines(function () {
- ig.global.EntityButtonDown = ig.Entity.extend({
- _layer: "gui",
- size: {
- x: 45,
- y: 45
- },
- animSheet: new ig.AnimationSheet("media/button-down.png", 45, 45),
- touched: false,
- pressed: false,
- released: false,
- init: function (a, d, b) {
- this.parent(a, d, b);
- var c = this.addAnim("up", 1, [0]);
- if (ig.ua.iPad) {
- c.alpha = 0.5
- }
- c = this.addAnim("down", 1, [1]);
- if (ig.ua.iPad) {
- c.alpha = 0.5
- }
- },
- update: function () {
- this.parent();
- if (this.pressed) {
- this.pressed = false
- }
- if (this.released) {
- this.released = false
- }
- },
- onTouch: function () {
- this.touched = true;
- this.pressed = true;
- this.currentAnim = this.anims.down
- },
- onRelease: function () {
- if (this.touched) {
- this.touched = false;
- this.released = true
- }
- this.currentAnim = this.anims.up
- }
- })
- });
- ig.baked = true;
- ig.module("game.entities.button-rotate").requires("impact.entity").defines(function () {
- ig.global.EntityButtonRotate = ig.Entity.extend({
- _layer: "gui",
- size: {
- x: 45,
- y: 45
- },
- animSheet: new ig.AnimationSheet("media/button-rotate.png", 45, 45),
- touched: false,
- pressed: false,
- released: false,
- init: function (a, d, b) {
- this.parent(a, d, b);
- var c = this.addAnim("up", 1, [0]);
- if (ig.ua.iPad) {
- c.alpha = 0.5
- }
- c = this.addAnim("down", 1, [1]);
- if (ig.ua.iPad) {
- c.alpha = 0.5
- }
- },
- update: function () {
- this.parent();
- if (this.pressed) {
- this.pressed = false
- }
- if (this.released) {
- this.released = false
- }
- },
- onTouch: function () {
- this.touched = true;
- this.pressed = true;
- this.currentAnim = this.anims.down;
- return true
- },
- onRelease: function () {
- if (this.touched) {
- this.touched = false;
- this.released = true;
- this.activated()
- }
- this.currentAnim = this.anims.up
- },
- activated: function () {
- ig.game.activeBlock.rotateRight()
- }
- })
- });
- ig.baked = true;
- ig.module("game.entities.button-menu").requires("impact.entity").defines(function () {
- ig.global.EntityButtonMenu = ig.Entity.extend({
- _layer: "gui",
- size: {
- x: 47,
- y: 47
- },
- animSheet: new ig.AnimationSheet("media/button-menu.png", 47, 47),
- touched: false,
- pressed: false,
- released: false,
- enable: false,
- init: function (a, c, b) {
- this.parent(a, c, b);
- this.addAnim("up", 1, [0]);
- this.addAnim("down", 1, [1])
- },
- update: function () {
- this.parent();
- if (this.pressed) {
- this.pressed = false
- }
- if (this.released) {
- this.released = false
- }
- },
- onTouch: function () {
- this.touched = true;
- this.pressed = true;
- this.currentAnim = this.anims.down
- },
- onRelease: function () {
- if (this.touched && this.enable) {
- this.touched = false;
- this.released = true;
- this.activate()
- }
- this.currentAnim = this.anims.up
- },
- activate: function () {
- if (ig.game.gameScene) {
- ig.game.pause();
- ig.game.playBtn.moveIn();
- ig.game.quitBtn.moveIn()
- }
- }
- })
- });
- ig.baked = true;
- ig.module("game.entities.button-play").requires("impact.entity").defines(function () {
- ig.global.EntityButtonPlay = ig.Entity.extend({
- _layer: "gui",
- size: {
- x: 45,
- y: 45
- },
- animSheet: new ig.AnimationSheet("media/button-down.png", 45, 45),
- touched: false,
- pressed: false,
- released: false,
- enable: false,
- init: function (a, c, b) {
- this.parent(a, c, b);
- this.addAnim("up", 1, [0]);
- this.addAnim("down", 1, [1])
- },
- update: function () {
- this.parent();
- if (this.pressed) {
- this.pressed = false
- }
- if (this.released) {
- this.released = false
- }
- },
- onTouch: function () {
- this.touched = true;
- this.pressed = true;
- this.currentAnim = this.anims.down
- },
- onRelease: function () {
- if (this.touched && this.enable) {
- this.touched = false;
- this.released = true;
- this.activate()
- }
- this.currentAnim = this.anims.up
- },
- activate: function () {
- this.moveOut();
- if (ig.game.quitBtn) {
- ig.game.quitBtn.moveOut()
- }
- this.enable = false
- },
- moveIn: function () {
- console.log("starting");
- this.tween({
- pos: {
- y: 120
- }
- }, 0.8, {
- easing: ig.Tween.Easing.Cubic.EaseOut,
- onComplete: function () {
- this.enable = true
- }.bind(this)
- }).start()
- console.log("started");
- },
- moveOut: function () {
- this.tween({
- pos: {
- y: -100
- }
- }, 0.6, {
- easing: ig.Tween.Easing.Cubic.EaseIn,
- onComplete: function () {
- this.enable = false;
- ig.game.unpause()
- }
- }).start()
- }
- })
- });
- ig.baked = true;
- ig.module("game.entities.button-quit").requires("impact.entity").defines(function () {
- ig.global.EntityButtonQuit = ig.Entity.extend({
- _layer: "gui",
- size: {
- x: 47,
- y: 47
- },
- animSheet: new ig.AnimationSheet("media/button-home.png", 47, 47),
- touched: false,
- pressed: false,
- released: false,
- enable: false,
- init: function (a, c, b) {
- this.parent(a, c, b);
- this.addAnim("up", 1, [0]);
- this.addAnim("down", 1, [1])
- },
- update: function () {
- this.parent();
- if (this.pressed) {
- this.pressed = false
- }
- if (this.released) {
- this.released = false
- }
- },
- onTouch: function () {
- this.touched = true;
- this.pressed = true;
- this.currentAnim = this.anims.down
- },
- onRelease: function () {
- if (this.touched && this.enable) {
- this.touched = false;
- this.released = true;
- this.activate()
- }
- this.currentAnim = this.anims.up
- },
- activate: function () {
- this.enable = false;
- ig.gameManager.switchToTitle()
- },
- moveIn: function () {
- this.tween({
- pos: {
- y: 120
- }
- }, 0.8, {
- easing: ig.Tween.Easing.Cubic.EaseOut,
- onComplete: function () {
- this.enable = true
- }.bind(this)
- }).start()
- },
- moveOut: function () {
- this.tween({
- pos: {
- y: -100
- }
- }, 0.6, {
- easing: ig.Tween.Easing.Cubic.EaseIn,
- onComplete: function () {
- this.enable = false
- }.bind(this)
- }).start()
- }
- })
- });
- ig.baked = true;
- ig.module("game.entities.button-restart").requires("impact.entity").defines(function () {
- ig.global.EntityButtonRestart = ig.Entity.extend({
- _layer: "gui",
- size: {
- x: 47,
- y: 47
- },
- animSheet: new ig.AnimationSheet("media/button-replay.png", 47, 47),
- touched: false,
- pressed: false,
- released: false,
- enable: false,
- init: function (a, c, b) {
- this.parent(a, c, b);
- this.addAnim("up", 1, [0]);
- this.addAnim("down", 1, [1])
- },
- update: function () {
- this.parent();
- if (this.pressed) {
- this.pressed = false
- }
- if (this.released) {
- this.released = false
- }
- },
- onTouch: function () {
- this.touched = true;
- this.pressed = true;
- this.currentAnim = this.anims.down
- },
- onRelease: function () {
- if (this.touched && this.enable) {
- this.touched = false;
- this.released = true;
- this.activate()
- }
- this.currentAnim = this.anims.up
- },
- activate: function () {
- this.enable = false;
- if (ig.game.quitBtn) {
- ig.game.quitBtn.enable = false
- }
- if (ig.game.gemsMode) {
- ig.gameManager.newGemsRound()
- } else {
- ig.gameManager.newClassicRound()
- }
- },
- moveIn: function () {
- this.tween({
- pos: {
- y: 120
- }
- }, 0.8, {
- easing: ig.Tween.Easing.Cubic.EaseOut,
- onComplete: function () {
- this.enable = true
- }.bind(this)
- }).start()
- },
- moveOut: function () {
- this.tween({
- pos: {
- y: -100
- }
- }, 0.6, {
- easing: ig.Tween.Easing.Cubic.EaseIn,
- onComplete: function () {
- this.enable = false
- }.bind(this)
- }).start()
- }
- })
- });
- ig.baked = true;
- ig.module("plugins.gridmovement").requires("impact.impact").defines(function () {
- var a = window.GridMovement = ig.Class.extend({
- entity: null,
- init: function (b) {
- this.entity = b
- },
- move: function (e) {
- if (this.canMove(e)) {
- var c = this.getCurrentTile();
- var d = this.getAdjacentTile(c.x, c.y, e);
- var b = this.tileToPixelPos(d.x, d.y);
- this.entity.pos.x = b.x;
- this.entity.pos.y = b.y
- }
- },
- getCurrentTile: function () {
- var d = ig.game.collisionMap.tilesize;
- var c = this.entity.pos.x / d;
- var b = this.entity.pos.y / d;
- return {
- x: c,
- y: b
- }
- },
- getAdjacentTile: function (c, b, d) {
- if (d === a.direction.UP) {
- b += -1
- } else {
- if (d === a.direction.DOWN) {
- b += 1
- } else {
- if (d === a.direction.LEFT) {
- c += -1
- } else {
- if (d === a.direction.RIGHT) {
- c += 1
- }
- }
- }
- }
- return {
- x: c,
- y: b
- }
- },
- snapToTile: function (b, d) {
- var c = ig.game.collisionMap.tilesize;
- this.entity.pos.x = b * c;
- this.entity.pos.y = d * c
- },
- canMoveFromTile: function (d, c, e) {
- var b = this.getAdjacentTile(d, c, e);
- return ig.game.collisionMap.data[Math.round(b.y)][Math.round(b.x)] === 0
- },
- canMove: function (c) {
- var b = this.getCurrentTile();
- return this.canMoveFromTile(b.x, b.y, c)
- },
- tileToPixelPos: function (c, b) {
- return {
- x: c * ig.game.collisionMap.tilesize,
- y: b * ig.game.collisionMap.tilesize
- }
- }
- });
- a.direction = {
- UP: 1,
- DOWN: 2,
- LEFT: 4,
- RIGHT: 8
- }
- });
- ig.baked = true;
- ig.module("game.entities.destruct").requires("impact.entity").defines(function () {
- ig.global.EntityDestruct = ig.Entity.extend({
- _layer: "effect",
- animSheet: new ig.AnimationSheet("media/block-destruct.png", 33, 33),
- init: function (a, c, b) {
- this.parent(a, c, b);
- this.addAnim("play", 0.06, [0, 1, 2, 3, 4, 5, 6, 7, 8], false)
- },
- update: function () {
- this.parent();
- if (this.currentAnim.loopCount > 0) {
- this.kill()
- }
- }
- })
- });
- ig.baked = true;
- ig.module("game.entities.explosion").requires("impact.entity").defines(function () {
- ig.global.EntityExplosion = ig.Entity.extend({
- _layer: "effect",
- size: {
- x: 186,
- y: 157
- },
- animSheet: new ig.AnimationSheet("media/bang.png", 186, 157),
- init: function (a, c, b) {
- this.parent(a, c, b);
- this.addAnim("play", 0.12, [0, 1, 2, 3, 4, 5, 6, 7, 8], false)
- },
- update: function () {
- this.parent();
- if (this.currentAnim.loopCount > 0) {
- this.kill()
- }
- }
- })
- });
- ig.baked = true;
- ig.module("game.entities.slowlight").requires("impact.entity").defines(function () {
- ig.global.EntitySlowlight = ig.Entity.extend({
- _layer: "effect",
- timeScale: 0.6,
- animSheet: new ig.AnimationSheet("media/slow.png", 181, 54),
- collides: ig.Entity.COLLIDES.NEVER,
- init: function (a, c, b) {
- this.parent(a, c, b);
- this.addAnim("idle", 1, [0], true)
- },
- update: function () {
- this.pos.y -= 320 * ig.system.tick;
- if (this.pos.y < -64) {
- this.kill()
- }
- }
- })
- });
- ig.baked = true;
- ig.module("game.entities.block").requires("impact.entity", "plugins.gridmovement", "game.entities.destruct", "game.entities.explosion", "game.entities.slowlight", "game.config").defines(function () {
- var a = ig.CONFIG;
- var b = ig.global.EntityBlock = ig.Entity.extend({
- _layer: "block",
- size: {
- x: a.TILESIZE,
- y: a.TILESIZE
- },
- collides: ig.Entity.COLLIDES.NEVER,
- animSheet: null,
- gridMover: null,
- destroyState: false,
- init: function (c, e, d) {
- this.parent(c, e, d);
- this.gridMover = new GridMovement(this)
- },
- setColor: function (c) {
- this.initAnim(c)
- },
- initAnim: function (c) {
- switch (c) {
- case b.color.COLOR_L:
- if (!ig.game.gemsMode) {
- this.animSheet = new ig.AnimationSheet("media/block-l.png", a.TILESIZE, a.TILESIZE)
- } else {
- this.animSheet = new ig.AnimationSheet("media/gems-01.png", a.TILESIZE, a.TILESIZE)
- }
- break;
- case b.color.COLOR_S:
- if (!ig.game.gemsMode) {
- this.animSheet = new ig.AnimationSheet("media/block-s.png", a.TILESIZE, a.TILESIZE)
- } else {
- this.animSheet = new ig.AnimationSheet("media/gems-02.png", a.TILESIZE, a.TILESIZE)
- }
- break;
- case b.color.COLOR_SQUARE:
- if (!ig.game.gemsMode) {
- this.animSheet = new ig.AnimationSheet("media/block-square.png", a.TILESIZE, a.TILESIZE)
- } else {
- this.animSheet = new ig.AnimationSheet("media/gems-03.png", a.TILESIZE, a.TILESIZE)
- }
- break;
- case b.color.COLOR_LINE:
- if (!ig.game.gemsMode) {
- this.animSheet = new ig.AnimationSheet("media/block-line.png", a.TILESIZE, a.TILESIZE)
- } else {
- this.animSheet = new ig.AnimationSheet("media/gems-04.png", a.TILESIZE, a.TILESIZE)
- }
- break;
- case b.color.COLOR_TRIANGLE:
- if (!ig.game.gemsMode) {
- this.animSheet = new ig.AnimationSheet("media/block-triangle.png", a.TILESIZE, a.TILESIZE)
- } else {
- this.animSheet = new ig.AnimationSheet("media/gems-05.png", a.TILESIZE, a.TILESIZE)
- }
- break;
- case b.color.COLOR_LR:
- if (!ig.game.gemsMode) {
- this.animSheet = new ig.AnimationSheet("media/block-lr.png", a.TILESIZE, a.TILESIZE)
- } else {
- this.animSheet = new ig.AnimationSheet("media/gems-06.png", a.TILESIZE, a.TILESIZE)
- }
- break;
- case b.color.COLOR_SR:
- if (!ig.game.gemsMode) {
- this.animSheet = new ig.AnimationSheet("media/block-sr.png", a.TILESIZE, a.TILESIZE)
- } else {
- this.animSheet = new ig.AnimationSheet("media/gems-03.png", a.TILESIZE, a.TILESIZE)
- }
- break;
- default:
- if (!ig.game.gemsMode) {
- this.animSheet = new ig.AnimationSheet("media/single-block.png", a.TILESIZE, a.TILESIZE)
- } else {
- this.animSheet = new ig.AnimationSheet("media/gems-06.png", a.TILESIZE, a.TILESIZE)
- }
- break
- }
- this.addAnim("idle", 1, [0]);
- this.addAnim("blink", 0.07, [0, 1, 2, 3, 2, 1]);
- this.anims.blink.timer = b.animationTimer
- },
- update: function () {
- if (this.destroyState) {
- if (this.currentAnim !== this.anims.blink) {
- this.currentAnim = this.anims.blink.rewind()
- }
- } else {
- if (this.currentAnim !== this.anims.idle) {
- this.currentAnim = this.anims.idle.rewind()
- }
- }
- this.parent()
- },
- check: function () {
- this.parent()
- },
- moveLeft: function () {
- this.gridMover.move(GridMovement.direction.LEFT)
- },
- moveRight: function () {
- this.gridMover.move(GridMovement.direction.RIGHT)
- },
- moveDown: function () {
- this.gridMover.move(GridMovement.direction.DOWN)
- },
- canMoveLeft: function () {
- return this.gridMover.canMove(GridMovement.direction.LEFT)
- },
- canMoveRight: function () {
- return this.gridMover.canMove(GridMovement.direction.RIGHT)
- },
- canMoveDown: function () {
- return this.gridMover.canMove(GridMovement.direction.DOWN)
- },
- lock: function () {
- var c = this.getCurrentTile();
- ig.game.collisionMap.data[c.y][c.x] = 1
- },
- freeCollisionMap: function () {
- var c = this.getCurrentTile();
- ig.game.collisionMap.data[c.y][c.x] = 0
- },
- overlapsCollisionMap: function () {
- var c = this.getCurrentTile();
- return ig.game.collisionMap.data[c.y][c.x] !== 0
- },
- getCurrentTile: function () {
- return {
- x: Math.round(this.pos.x / a.TILESIZE),
- y: Math.round(this.pos.y / a.TILESIZE)
- }
- },
- startDestruction: function () {
- this.destroyState = true;
- if (ig.game.gemsMode) {
- ig.game.spawnEntity(ig.global.EntityDestruct, this.pos.x + (this.size.x - 1) / 2 - 16, this.pos.y + (this.size.y - 1) / 2 - 16)
- }
- }
- });
- b.color = {
- COLOR_L: "1",
- COLOR_LR: "2",
- COLOR_LINE: "3",
- COLOR_S: "4",
- COLOR_SR: "5",
- COLOR_SQUARE: "6",
- COLOR_TRIANGLE: "7"
- }, b.animationTimer = new ig.Timer();
- ig.global.EntityBombBlock = b.extend({
- imBomb: true,
- setColor: function () {
- this.animSheet = new ig.AnimationSheet("media/bomb-block.png", a.TILESIZE, a.TILESIZE);
- this.addAnim("idle", 0.1, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6], false);
- this.addAnim("blink", 1, [0], false)
- },
- startDestruction: function () {
- this.destroyState = true;
- ig.game.spawnEntity(ig.global.EntityExplosion, this.pos.x + this.size.x / 2 - 93, this.pos.y + this.size.y / 2 - 78)
- }
- });
- ig.global.EntitySlowBlock = b.extend({
- setColor: function () {
- this.animSheet = new ig.AnimationSheet("media/slow-block.png", a.TILESIZE, a.TILESIZE);
- this.addAnim("idle", 0.1, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6], false);
- this.addAnim("blink", 1, [0], false)
- },
- startDestruction: function () {
- this.destroyState = true;
- ig.game.slowdown()
- }
- })
- });
- ig.baked = true;
- ig.module("game.entities.block-container").requires("impact.entity", "game.entities.block", "game.config").defines(function () {
- var c = ig.CONFIG,
- b = ig.CONFIG.GEMS;
- var a = ig.global.EntityBlockContainer = ig.Entity.extend({
- _layer: "proxy",
- size: {
- x: c.TILESIZE * 4,
- y: c.TILESIZE * 4
- },
- collides: ig.Entity.COLLIDES.NEVER,
- spawnOffset: {
- x: 0,
- y: 0
- },
- rotationState: 0,
- rotationShapes: [],
- rotationStates: 0,
- blocks: [],
- initialized: false,
- init: function (d, f, e) {
- this.parent(d, f, e);
- this.rotationStates = this.rotationShapes.length;
- this.initBlocks();
- this.initialized = true
- },
- initBlocks: function () {
- var m = this.getCurrentShape();
- for (var k = 0; k < m.length; k++) {
- for (var d = 0; d < m[k].length; d++) {
- if (m[k][d] === 1) {
- var f = ig.global.EntityBlock;
- if (ig.game.gemsMode) {
- var j = Math.random(),
- i = Math.random();
- var h = (j < b.BOMB_PROBABILITY),
- l = (i < b.SLOW_PROBABILITY);
- if (h && !l) {
- f = ig.global.EntityBombBlock
- } else {
- if (l && !h) {
- f = ig.global.EntitySlowBlock
- } else {
- if (h && l) {
- var e = Math.random();
- if (e < b.BOMB_OVER_SLOW_PROBABILITY) {
- f = ig.global.EntityBombBlock
- } else {
- f = ig.global.EntitySlowBlock
- }
- }
- }
- }
- }
- var g = ig.game.spawnEntity(f, this.pos.x + (c.TILESIZE * d), this.pos.y + (c.TILESIZE * k));
- g.setColor(this.color);
- this.blocks.push(g)
- }
- }
- }
- },
- rotateRight: function () {
- var d = this._doRotateRight()
- },
- _doRotateRight: function () {
- this.rotationState = mmod(this.rotationState + 1, this.rotationStates);
- var d = this.getCurrentShape();
- this.adjustBlockPositions(d);
- if (this.blocksHaveCollision()) {
- this._doRotateLeft();
- return false
- }
- return true
- },
- rotateLeft: function () {
- var d = this._doRotateLeft()
- },
- _doRotateLeft: function () {
- this.rotationState = mmod(this.rotationState - 1, this.rotationStates);
- var d = this.getCurrentShape();
- this.adjustBlockPositions(d);
- if (this.blocksHaveCollision()) {
- this._doRotateRight();
- return false
- }
- return true
- },
- moveLeft: function () {
- for (var d = 0; d < this.blocks.length; d++) {
- if (this.blocks[d].canMoveLeft() === false) {
- return false
- }
- }
- this.pos.x -= c.TILESIZE;
- for (var d = 0; d < this.blocks.length; d++) {
- this.blocks[d].moveLeft()
- }
- return true
- },
- moveRight: function () {
- for (var d = 0; d < this.blocks.length; d++) {
- if (this.blocks[d].canMoveRight() === false) {
- return false
- }
- }
- this.pos.x += c.TILESIZE;
- for (var d = 0; d < this.blocks.length; d++) {
- this.blocks[d].moveRight()
- }
- return true
- },
- moveDown: function () {
- for (var d = 0; d < this.blocks.length; d++) {
- if (this.blocks[d].canMoveDown() === false) {
- return false
- }
- }
- this.pos.y += c.TILESIZE;
- for (var d = 0; d < this.blocks.length; d++) {
- this.blocks[d].moveDown()
- }
- return true
- },
- canMoveDown: function () {
- for (var d = 0; d < this.blocks.length; d++) {
- if (this.blocks[d].canMoveDown() === false) {
- return false
- }
- }
- return true
- },
- teleportPos: function (e) {
- this.pos.x = e.x;
- this.pos.y = e.y;
- var d = this.getCurrentShape();
- this.adjustBlockPositions(d)
- },
- adjustBlockPositions: function (d) {
- var f = 0;
- for (var h = 0; h < d.length; h++) {
- for (var e = 0; e < d[h].length; e++) {
- if (d[h][e] === 1) {
- var g = this.blocks[f];
- g.pos.x = this.pos.x + (c.TILESIZE * e);
- g.pos.y = this.pos.y + (c.TILESIZE * h);
- f++
- }
- }
- }
- },
- blocksHaveCollision: function () {
- for (var d = 0; d < this.blocks.length; d++) {
- if (this.blocks[d].overlapsCollisionMap()) {
- return true
- }
- }
- return false
- },
- getCurrentShape: function () {
- return this.rotationShapes[this.rotationState]
- },
- lock: function () {
- this.initialized = false;
- for (var d = 0; d < this.blocks.length; d++) {
- this.blocks[d].lock()
- }
- return this.blocks
- },
- isInitialized: function () {
- return this.initialized
- }
- })
- });
- ig.baked = true;
- ig.module("game.entities.block-shape-single").requires("game.entities.block", "game.entities.block-container").defines(function () {
- var a = ig.global.EntityBlockShapeSingle = EntityBlockContainer.extend({
- rotationShapes: [
- [
- [1]
- ]
- ]
- })
- });
- ig.baked = true;
- ig.module("game.entities.block-shape-l").requires("game.entities.block", "game.entities.block-container").defines(function () {
- var a = ig.global.EntityBlockShapeL = EntityBlockContainer.extend({
- color: EntityBlock.color.COLOR_L,
- rotationShapes: [
- [
- [0, 0, 0],
- [1, 1, 1],
- [1, 0, 0]
- ],
- [
- [1, 1, 0],
- [0, 1, 0],
- [0, 1, 0]
- ],
- [
- [0, 0, 1],
- [1, 1, 1],
- [0, 0, 0]
- ],
- [
- [0, 1, 0],
- [0, 1, 0],
- [0, 1, 1]
- ]
- ]
- })
- });
- ig.baked = true;
- ig.module("game.entities.block-shape-lr").requires("game.entities.block", "game.entities.block-container").defines(function () {
- var a = ig.global.EntityBlockShapeLr = EntityBlockContainer.extend({
- color: EntityBlock.color.COLOR_LR,
- rotationShapes: [
- [
- [0, 0, 0],
- [1, 1, 1],
- [0, 0, 1]
- ],
- [
- [0, 1, 0],
- [0, 1, 0],
- [1, 1, 0]
- ],
- [
- [1, 0, 0],
- [1, 1, 1],
- [0, 0, 0]
- ],
- [
- [0, 1, 1],
- [0, 1, 0],
- [0, 1, 0]
- ]
- ]
- })
- });
- ig.baked = true;
- ig.module("game.entities.block-shape-line").requires("game.entities.block", "game.entities.block-container").defines(function () {
- var a = ig.global.EntityBlockShapeLine = EntityBlockContainer.extend({
- color: EntityBlock.color.COLOR_LINE,
- rotationShapes: [
- [
- [0, 0, 0, 0],
- [0, 0, 0, 0],
- [1, 1, 1, 1]
- ],
- [
- [0, 1, 0],
- [0, 1, 0],
- [0, 1, 0],
- [0, 1, 0]
- ]
- ]
- })
- });
- ig.baked = true;
- ig.module("game.entities.block-shape-square").requires("game.entities.block", "game.entities.block-container").defines(function () {
- var a = ig.global.EntityBlockShapeSquare = EntityBlockContainer.extend({
- color: EntityBlock.color.COLOR_SQUARE,
- rotationShapes: [
- [
- [1, 1],
- [1, 1]
- ]
- ]
- })
- });
- ig.baked = true;
- ig.module("game.entities.block-shape-s").requires("game.entities.block", "game.entities.block-container").defines(function () {
- var a = ig.global.EntityBlockShapeS = EntityBlockContainer.extend({
- color: EntityBlock.color.COLOR_S,
- rotationShapes: [
- [
- [0, 1, 1],
- [1, 1, 0]
- ],
- [
- [1, 0],
- [1, 1],
- [0, 1]
- ]
- ]
- })
- });
- ig.baked = true;
- ig.module("game.entities.block-shape-sr").requires("game.entities.block", "game.entities.block-container").defines(function () {
- var a = ig.global.EntityBlockShapeSr = EntityBlockContainer.extend({
- color: EntityBlock.color.COLOR_SR,
- rotationShapes: [
- [
- [1, 1, 0],
- [0, 1, 1]
- ],
- [
- [0, 1],
- [1, 1],
- [1, 0]
- ]
- ]
- })
- });
- ig.baked = true;
- ig.module("game.entities.block-shape-triangle").requires("game.entities.block", "game.entities.block-container").defines(function () {
- var a = ig.global.EntityBlockShapeTriangle = EntityBlockContainer.extend({
- color: EntityBlock.color.COLOR_TRIANGLE,
- rotationShapes: [
- [
- [0, 0, 0],
- [1, 1, 1],
- [0, 1, 0]
- ],
- [
- [0, 1, 0],
- [1, 1, 0],
- [0, 1, 0]
- ],
- [
- [0, 1, 0],
- [1, 1, 1],
- [0, 0, 0]
- ],
- [
- [0, 1, 0],
- [0, 1, 1],
- [0, 1, 0]
- ]
- ]
- })
- });
- ig.baked = true;
- ig.module("game.levels.main").requires("impact.image").defines(function () {
- LevelMain = {
- entities: [],
- layer: [{
- name: "collision",
- width: 22,
- height: 20,
- linkWithCollision: false,
- visible: 1,
- tilesetName: "",
- repeat: false,
- preRender: true,
- distance: 1,
- tilesize: 17,
- foreground: false,
- data: [
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
- ]
- }]
- }
- });
- ig.baked = true;
- ig.module("game.utils.field-manager").requires("game.entities.block", "game.entities.block-container", "game.config").defines(function () {
- var a = ig.CONFIG;
- var b = ig.Class.extend({
- field: [],
- init: function () {
- this.initField()
- },
- initField: function () {
- this.field = [];
- for (var d = 0; d < a.FIELD_ROWS; d++) {
- var e = [];
- for (var c = 0; c < a.FIELD_COLS; c++) {
- e.push(null)
- }
- this.field.push(e)
- }
- },
- lockBlock: function (c) {
- var f = c.lock();
- c.kill();
- for (var d = 0; d < f.length; d++) {
- var e = f[d].getCurrentTile();
- this.field[e.y][e.x - 1] = f[d]
- }
- },
- handleLineCleaning: function () {
- var c = this.checkFullLines();
- return this.cleanFullRows(c)
- },
- checkFullLines: function () {
- var d = [],
- h, c = false;
- for (var g = 0; g < a.FIELD_ROWS; g++) {
- var f = 0;
- for (var e = 0; e < a.FIELD_COLS; e++) {
- h = this.field[g][e];
- if (!h) {
- break
- }
- f++;
- if (h.imBomb) {
- c = true
- }
- h = undefined
- }
- if (f === a.FIELD_COLS) {
- if (c) {
- if (g > 0) {
- d.push(g - 1)
- }
- if (g < a.FIELD_ROWS - 2) {
- d.push(a.FIELD_ROWS - 1)
- }
- }
- d.push(g)
- }
- c = false
- }
- return d
- },
- cleanFullRows: function (d) {
- var c = d.length;
- if (c <= 0) {
- return 0
- }
- d.sort(function (j, i) {
- return j - i
- });
- for (var g = 0; g < d.length; g++) {
- var h = d[g];
- for (var e = 0; e < a.FIELD_COLS; e++) {
- var f = this.field[h][e];
- if (f) {
- f.freeCollisionMap();
- f.kill()
- }
- this.field[h][e] = null
- }
- this.moveUpperRowsDown(h, 1)
- }
- return c
- },
- moveUpperRowsDown: function (e, c) {
- for (var h = e; h >= 0; h--) {
- for (var d = 0; d < a.FIELD_COLS; d++) {
- var g = this.field[h][d];
- if (!g) {
- continue
- }
- g.freeCollisionMap();
- for (var f = 0; f < c; f++) {
- g.moveDown()
- }
- g.lock();
- this.field[h][d] = null;
- this.field[h + c][d] = g
- }
- }
- },
- startLineDestruction: function (c) {
- for (var f = 0; f < c.length; f++) {
- var g = c[f];
- for (var d = 0; d < a.FIELD_COLS; d++) {
- var e = this.field[g][d];
- if (e) {
- e.startDestruction()
- }
- }
- }
- },
- logField: function () {
- for (var e = 0; e < a.FIELD_ROWS; e++) {
- var d = "";
- for (var c = 0; c < a.FIELD_COLS; c++) {
- d += (this.field[e][c] !== null ? "1" : 0)
- }
- console.log(e + ": " + d)
- }
- }
- });
- ig.FieldManager = b
- });
- ig.baked = true;
- 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 () {
- var b = ig.CONFIG.GEMS;
- var a = ig.Entity.extend({
- _layer: "bg",
- animSheet: new ig.AnimationSheet("media/gems-bg.png", 320, 480),
- size: {
- x: 320,
- y: 480
- },
- init: function (g, i, h) {
- this.parent(g, i, h);
- this.addAnim("idle", 1, [0], true)
- }
- });
- var d = ig.Entity.extend({
- _layer: "bg",
- animSheet: new ig.AnimationSheet("media/bg-anim-top.png", 320, 98),
- size: {
- x: 320,
- y: 98
- },
- init: function (g, i, h) {
- this.parent(g, i, h);
- this.addAnim("idle", 0.16, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])
- }
- });
- var f = ig.Entity.extend({
- _layer: "bg",
- animSheet: new ig.AnimationSheet("media/bg-anim-bottom.png", 320, 113),
- size: {
- x: 320,
- y: 113
- },
- init: function (g, i, h) {
- this.parent(g, i, h);
- 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])
- }
- });
- var e = ig.Entity.extend({
- _layer: "bg",
- animSheet: new ig.AnimationSheet("media/pirate.png", 171, 149),
- size: {
- x: 171,
- y: 149
- },
- switchRange: {
- min: 4,
- max: 8
- },
- switchTimer: null,
- init: function (g, i, h) {
- this.parent(g, i, h);
- this.addAnim("idle", 0.2, [0, 1, 2, 3, 4, 5, 6, 7, 8], false);
- this.addAnim("sword", 0.1, [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22], true);
- this.switchTimer = new ig.Timer();
- this.resetTimer()
- },
- update: function () {
- this.parent();
- if (this.currentAnim === this.anims.sword) {
- if (this.currentAnim.loopCount > 0) {
- this.resetTimer();
- this.currentAnim = this.anims.idle.rewind()
- }
- } else {
- if (this.switchTimer.delta() > 0) {
- this.resetTimer()
- }
- }
- },
- resetTimer: function () {
- this.switchTimer.set(Math.random().map(0, 1, this.switchRange.min, this.switchRange.max));
- if (this.currentAnim === this.anims.idle) {
- this.currentAnim = this.anims.sword.rewind()
- } else {
- this.currentAnim = this.anims.idle.rewind()
- }
- }
- });
- var c = ig.Game.extend({
- gemsMode: true,
- gameScene: true,
- font: new ig.Font("media/bitdust2_16.font.png"),
- bFont: new ig.Font("media/bitdust2_16_bold.font.png"),
- bgOffset: {
- x: -25,
- y: -44
- },
- activeBlock: null,
- nextBlock: null,
- timerLeftRight: null,
- timerDown: null,
- timerAutoDown: null,
- timerLock: null,
- timerDestruction: null,
- lockTimerRunning: false,
- forceButtonDownRelease: false,
- stage: 1,
- fallSpeed: 1.1,
- fieldManager: null,
- currentFullRows: null,
- lineCount: 0,
- score: 0,
- ended: false,
- linesPosOnKeyDown: 0,
- isCleaningLines: false,
- timeScale: 0.6,
- slowDurition: b.SLOW_DURITION,
- leftBtn: null,
- rightBtn: null,
- downBtn: null,
- rotateBtn: null,
- stageTouched: false,
- stagePressed: false,
- stageReleased: false,
- paused: false,
- init: function () {
- this.createLayer("bg");
- this.createLayer("proxy", {
- clearOnLoad: true,
- entityLayer: true
- });
- this.createLayer("block", {
- clearOnLoad: true,
- entityLayer: true
- });
- this.createLayer("effect", {
- clearOnLoad: true,
- entityLayer: true
- });
- this.createLayer("gui", {
- clearOnLoad: true,
- entityLayer: true
- });
- this.setLayerSort(["bg", "proxy", "block", "effect", "gui"]);
- this.activeBlock = null;
- this.nextBlock = null;
- this.timerLeftRight = new ig.Timer();
- this.timerDown = new ig.Timer();
- this.timerAutoDown = new ig.Timer();
- this.timerLock = new ig.Timer();
- this.timerLock.pause();
- this.timerDestruction = new ig.Timer();
- this.timerDestruction.pause();
- this.slowTimer = new ig.Timer(this.slowDurition);
- this.slowTimer.pause();
- this.currentFullRows = [];
- this.fieldManager = new ig.FieldManager();
- ig.gameManager.inputManager.on("touch", this.touched.bind(this));
- ig.gameManager.inputManager.on("release", this.released.bind(this));
- if (ig.ua.mobile) {
- this.handleControls = this.handleControlsTouch
- } else {
- this.handleControls = this.handleControlsKeyboard;
- ig.input.bind(ig.KEY.LEFT_ARROW, "left");
- ig.input.bind(ig.KEY.RIGHT_ARROW, "right");
- ig.input.bind(ig.KEY.DOWN_ARROW, "down");
- ig.input.bind(ig.KEY.UP_ARROW, "rotateRight")
- }
- this.start()
- },
- update: function () {
- this.screen.x = this.bgOffset.x;
- this.screen.y = this.bgOffset.y;
- if (this.ended) {
- var g = this.stagePressed;
- if (g) {
- ig.gameManager.gameOver()
- }
- } else {
- if (!this.paused) {
- if (this.isCleaningLines) {
- this.cleanLines()
- } else {
- this.handleControls();
- if (this.isSlowingdown) {
- if (this.slowTimer.delta() > 0) {
- this.restoreSlowmotion()
- }
- }
- }
- }
- }
- this.stagePressed = false;
- this.stageReleased = false;
- this.parent()
- },
- draw: function () {
- this.parent();
- if (this.ended) {
- this.font.draw("GAME OVER", 126, 124, ig.Font.ALIGN.CENTER)
- }
- this.bFont.draw("Lv:", 244, 260, ig.Font.ALIGN.LEFT);
- this.bFont.draw(this.stage, 300, 260, ig.Font.ALIGN.RIGHT);
- this.font.draw("GEM:", 42, 12, ig.Font.ALIGN.LEFT);
- this.font.draw(this.score, 210, 12, ig.Font.ALIGN.RIGHT);
- this.font.draw("HI:", 42, 24, ig.Font.ALIGN.LEFT);
- this.font.draw(ig.gameManager.gemsHigh, 210, 24, ig.Font.ALIGN.RIGHT)
- },
- handleControlsKeyboard: function () {
- if (!this.activeBlock || !this.activeBlock.isInitialized()) {
- return
- }
- if (this.lockTimerRunning && this.timerLock.delta() >= b.LOCKIN_DELAY) {
- if (this.activeBlock.canMoveDown()) {
- this.timerLock.pause();
- this.lockTimerRunning = false
- } else {
- this.lockActiveBlock()
- }
- }
- if (ig.input.pressed("rotateRight")) {
- this.activeBlock.rotateRight()
- }
- var j = false;
- var k = ig.input.pressed("left"),
- h = ig.input.pressed("right");
- if (k && !h) {
- this.timerLeftRight.set(b.PRESSED_DELAY);
- this.activeBlock.moveLeft();
- j = true;
- this.forceButtonDownRelease = true
- } else {
- if (h && !k) {
- this.timerLeftRight.set(b.PRESSED_DELAY);
- this.activeBlock.moveRight();
- j = true;
- this.forceButtonDownRelease = true
- }
- } if (ig.input.state("left") && ig.input.state("right")) {
- this.timerLeftRight.set(b.PRESSED_DELAY);
- j = true
- }
- if (ig.input.released("left") || ig.input.released("right")) {
- this.forceButtonDownRelease = false
- }
- if (ig.input.state("left") && this.timerLeftRight.delta() >= 0 && !j) {
- this.timerLeftRight.set(b.REPEAT_LEFT_RIGHT_DELAY);
- this.activeBlock.moveLeft();
- this.forceButtonDownRelease = true
- }
- if (ig.input.state("right") && this.timerLeftRight.delta() >= 0 && !j) {
- this.timerLeftRight.set(b.REPEAT_LEFT_RIGHT_DELAY);
- this.activeBlock.moveRight();
- this.forceButtonDownRelease = true
- }
- if (ig.input.state("down") && this.forceButtonDownRelease === false && this.timerDown.delta() >= 0) {
- this.timerDown.set(b.REPEAT_DOWN_DELAY);
- if (this.linesPosOnKeyDown === 0) {
- this.linesPosOnKeyDown = this.activeBlock.pos.y
- }
- var g = this.activeBlock.moveDown();
- if (g === false) {
- this.lockActiveBlock(true)
- }
- } else {
- if (this.forceButtonDownRelease && ig.input.state("down") === false) {
- this.forceButtonDownRelease = false
- }
- } if (!(ig.input.state("down") && this.forceButtonDownRelease === false) && this.timerAutoDown.delta() >= (1 / this.fallSpeed)) {
- var i = this.activeBlock.moveDown();
- this.timerAutoDown.set(0);
- if (i === false && this.lockTimerRunning === false) {
- this.timerLock.set(0);
- this.timerLock.unpause();
- this.lockTimerRunning = true
- } else {
- if (i) {
- this.timerLock.pause();
- this.lockTimerRunning = false
- }
- }
- }
- if (ig.input.released("down")) {
- this.linesPosOnKeyDown = 0;
- this.timerAutoDown.set(0)
- }
- },
- handleControlsTouch: function () {
- if (!this.activeBlock || !this.activeBlock.isInitialized()) {
- return
- }
- if (this.lockTimerRunning && this.timerLock.delta() >= b.LOCKIN_DELAY) {
- if (this.activeBlock.canMoveDown()) {
- this.timerLock.pause();
- this.lockTimerRunning = false
- } else {
- this.lockActiveBlock()
- }
- }
- var h = this.stagePressed;
- if (h) {}
- var k = false;
- var l = this.leftBtn.pressed,
- i = this.rightBtn.pressed;
- if (l && !i) {
- this.timerLeftRight.set(b.PRESSED_DELAY);
- this.activeBlock.moveLeft();
- k = true;
- this.forceButtonDownRelease = true
- } else {
- if (i && !l) {
- this.timerLeftRight.set(b.PRESSED_DELAY);
- this.activeBlock.moveRight();
- k = true;
- this.forceButtonDownRelease = true
- }
- }
- l = this.leftBtn.touched;
- i = this.rightBtn.touched;
- if (l && i) {
- this.timerLeftRight.set(b.PRESSED_DELAY);
- k = true
- }
- l = !this.leftBtn.released;
- i = !this.rightBtn.released;
- if (l || i) {
- this.forceButtonDownRelease = false
- }
- l = this.leftBtn.touched;
- if (l && this.timerLeftRight.delta() >= 0 && !k) {
- this.timerLeftRight.set(b.REPEAT_LEFT_RIGHT_DELAY);
- this.activeBlock.moveLeft();
- this.forceButtonDownRelease = true
- }
- i = this.rightBtn.touched;
- if (i && this.timerLeftRight.delta() >= 0 && !k) {
- this.timerLeftRight.set(b.REPEAT_LEFT_RIGHT_DELAY);
- this.activeBlock.moveRight();
- this.forceButtonDownRelease = true
- }
- var m = this.downBtn.touched;
- if (m && this.forceButtonDownRelease === false && this.timerDown.delta() >= 0) {
- this.timerDown.set(b.REPEAT_DOWN_DELAY);
- if (this.linesPosOnKeyDown === 0) {
- this.linesPosOnKeyDown = this.activeBlock.pos.y
- }
- var g = this.activeBlock.moveDown();
- if (g === false) {
- this.lockActiveBlock(true)
- }
- } else {
- if (this.forceButtonDownRelease && !this.downBtn.touched) {
- this.forceButtonDownRelease = false
- }
- }
- m = this.downBtn.touched;
- if (!(m && this.forceButtonDownRelease === false) && this.timerAutoDown.delta() >= (1 / this.fallSpeed)) {
- var j = this.activeBlock.moveDown();
- this.timerAutoDown.set(0);
- if (j === false && this.lockTimerRunning === false) {
- this.timerLock.set(0);
- this.timerLock.unpause();
- this.lockTimerRunning = true
- } else {
- if (j) {
- this.timerLock.pause();
- this.lockTimerRunning = false
- }
- }
- }
- m = this.downBtn.released;
- if (m) {
- this.linesPosOnKeyDown = 0;
- this.timerAutoDown.set(0)
- }
- },
- cleanLines: function () {
- if (this.timerDestruction.delta() >= 0) {
- this.fieldManager.cleanFullRows(this.currentFullRows);
- this.currentFullRows.length = 0;
- this.isCleaningLines = false;
- this.timerDestruction.pause();
- this.makeNextBlockActive();
- if (!this.ended) {
- this.generateBlock()
- }
- }
- },
- makeNextBlockActive: function () {
- this.activeBlock = this.nextBlock;
- var g = {
- x: b.DROP_POS_X + this.activeBlock.spawnOffset.x,
- y: b.DROP_POS_Y + this.activeBlock.spawnOffset.y
- };
- this.activeBlock.teleportPos(g);
- this.checkSpawnFail();
- this.nextBlock = null;
- this.timerAutoDown.set(0);
- this.timerDown.set(0)
- },
- checkSpawnFail: function () {
- if (this.activeBlock.blocksHaveCollision()) {
- this.gameOver()
- }
- },
- gameOver: function () {
- this.ended = true;
- window.SG_Hooks.gameOver(this.stage, this.score);
- this.restartBtn.moveIn();
- this.quitBtn.moveIn()
- },
- generateBlock: function () {
- var h = (Math.random().map(0, 1, 1, b.SHAPES) | 0);
- var g = null;
- var i = 0,
- j = 0;
- switch (h) {
- case 1:
- j = b.TILESIZE * -2;
- g = ig.game.spawnEntity(ig.global.EntityBlockShapeLine, b.SPAWN_POS_X, b.SPAWN_POS_Y + j);
- break;
- case 2:
- i = b.TILESIZE;
- g = ig.game.spawnEntity(ig.global.EntityBlockShapeSquare, b.SPAWN_POS_X + i, b.SPAWN_POS_Y);
- break;
- case 3:
- j = b.TILESIZE * -1;
- g = ig.game.spawnEntity(ig.global.EntityBlockShapeTriangle, b.SPAWN_POS_X, b.SPAWN_POS_Y + j);
- break;
- case 4:
- j = b.TILESIZE * -1;
- g = ig.game.spawnEntity(ig.global.EntityBlockShapeL, b.SPAWN_POS_X, b.SPAWN_POS_Y + j);
- break;
- case 5:
- j = b.TILESIZE * -1;
- g = ig.game.spawnEntity(ig.global.EntityBlockShapeLr, b.SPAWN_POS_X, b.SPAWN_POS_Y + j);
- break;
- case 6:
- g = ig.game.spawnEntity(ig.global.EntityBlockShapeS, b.SPAWN_POS_X, b.SPAWN_POS_Y);
- break;
- case 7:
- g = ig.game.spawnEntity(ig.global.EntityBlockShapeSr, b.SPAWN_POS_X, b.SPAWN_POS_Y);
- break
- }
- g.spawnOffset.x = i;
- g.spawnOffset.y = j;
- this.nextBlock = g
- },
- lockActiveBlock: function () {
- this.forceButtonDownRelease = true;
- this.fieldManager.lockBlock(this.activeBlock);
- var g = this.fieldManager.checkFullLines();
- var h = g.length;
- if (h > 0) {
- this.currentFullRows = g;
- this.lineCount += h;
- this.score += this.getLineClearingScore(h);
- ig.gameManager.updateScore(this.score);
- this.isCleaningLines = true;
- this.fieldManager.startLineDestruction(g);
- this.timerDestruction.set(b.CLEAN_LINES_DELAY);
- this.timerDestruction.unpause();
- this.checkAdvanceStageCondition()
- } else {
- this.makeNextBlockActive();
- this.generateBlock()
- }
- this.lockTimerRunning = false;
- this.timerLock.pause()
- },
- checkAdvanceStageCondition: function () {
- var g = (this.lineCount + (this.startStage - 1) * 10) - this.stage * 10;
- if (g >= 0 && g < 10) {
- this.advanceStage()
- }
- },
- start: function () {
- this.loadLevel(ig.copy(ig.global.LevelMain));
- this.spawnEntity(a, this.bgOffset.x, this.bgOffset.y);
- this.spawnEntity(d, this.bgOffset.x, this.bgOffset.y);
- this.spawnEntity(f, this.bgOffset.x, this.bgOffset.y + 367);
- if (ig.ua.mobile) {
- if (!ig.ua.iPad) {
- this.leftBtn = this.spawnEntity(ig.global.EntityButtonLeft, -20, 332);
- this.rightBtn = this.spawnEntity(ig.global.EntityButtonRight, 152, 332);
- this.downBtn = this.spawnEntity(ig.global.EntityButtonDown, 37, 332);
- this.rotateBtn = this.spawnEntity(ig.global.EntityButtonRotate, 95, 332)
- } else {
- this.leftBtn = this.spawnEntity(ig.global.EntityButtonLeft, -20, 296);
- this.rightBtn = this.spawnEntity(ig.global.EntityButtonRight, 152, 296);
- this.downBtn = this.spawnEntity(ig.global.EntityButtonDown, 37, 296);
- this.rotateBtn = this.spawnEntity(ig.global.EntityButtonRotate, 95, 296)
- }
- }
- this.menuBtn = this.spawnEntity(ig.global.EntityButtonMenu, 246, -32);
- this.playBtn = this.spawnEntity(ig.global.EntityButtonPlay, 104, -100);
- this.quitBtn = this.spawnEntity(ig.global.EntityButtonQuit, 48, -100);
- this.restartBtn = this.spawnEntity(ig.global.EntityButtonRestart, 104, -100);
- this.pirate = this.spawnEntity(e, 160, 244);
- this.menuBtn.enable = true;
- this.startStage = 1;
- if (this.startStage > 1) {
- var g = this.startStage - this.stage;
- this.advanceStage(g)
- }
- this.generateBlock();
- this.makeNextBlockActive();
- this.generateBlock()
- },
- advanceStage: function (g) {
- if (g <= 0 || g === null || g === undefined) {
- g = 1
- }
- this.stage += g;
- this.fallSpeed += (b.SPEED_INCREASE_PER_STAGE * g);
- /*ig.game.pause();
- console.log("game paused");*/
- window.SG_Hooks.levelUp(this.stage, this.score/*,function(){ig.game.unpause();}*/)
- },
- getLineClearingScore: function (g) {
- var h = 0;
- var i = this.stage * this.stage;
- switch (g) {
- case 4:
- h = 2560 * i;
- break;
- case 3:
- h = 1080 * i;
- break;
- case 2:
- h = 320 * i;
- break;
- default:
- h = 40 * i;
- break
- }
- return h
- },
- slowdown: function () {
- if (!this.isSlowingdown) {
- this.fallSpeedBackup = this.fallSpeed;
- this.fallSpeed *= this.timeScale;
- this.fallSpeed.limit(0, 1.1);
- this.isSlowingdown = true;
- this.slowTimer.reset();
- ig.game.spawnEntity(ig.global.EntitySlowlight, 16, 312)
- }
- },
- restoreSlowmotion: function () {
- this.isSlowingdown = false;
- this.fallSpeed = this.fallSpeedBackup
- },
- touched: function (m) {
- var n = this.getPointPos(m),
- j = this.layers.gui.items,
- l;
- for (var k = 0, h = j.length; k < h; ++k) {
- l = j[k];
- if (this.intersect(l, n.x, n.y)) {
- var g = l.onTouch();
- if (!g) {
- return false
- }
- }
- }
- this.stageTouched = true;
- this.stagePressed = true;
- m.stopPropagation();
- m.preventDefault()
- },
- released: function (k) {
- this.getPointPos(k);
- var h = this.layers.gui.items;
- for (var j = 0, g = h.length; j < g; ++j) {
- h[j].onRelease()
- }
- if (this.stageTouched) {
- this.stageTouched = false;
- this.stageReleased = true
- }
- k.stopPropagation();
- k.preventDefault()
- },
- getPointPos: function (j) {
- var h = j.gesture.center,
- i = ig.system.canvas.getBoundingClientRect();
- var g = (h.pageX - i.left) / ig.gameManager.stageScale.x,
- k = (h.pageY - i.top) / ig.gameManager.stageScale.y;
- return {
- x: g + this.bgOffset.x,
- y: k + this.bgOffset.y
- }
- },
- intersect: function (j, g, m) {
- var l = j.pos.x,
- i = j.pos.x + j.size.x,
- k = j.pos.y,
- h = j.pos.y + j.size.y;
- return !(g < l || g > i || m < k || m > h)
- },
- pause: function () {
- this.paused = true
- },
- unpause: function () {
- this.paused = false
- }
- });
- ig.SceneGems = c
- });
- ig.baked = true;
- ig.module("plugins.storage").defines(function () {
- var a = ig.Class.extend({
- staticInstantiate: function () {
- return !ig.Storage.instance ? null : ig.Storage.instance
- },
- init: function () {
- ig.Storage.instance = this
- },
- isCapable: function () {
- var d = (typeof (window.localStorage) !== "undefined"),
- b = d;
- if (b) {
- try {
- window.localStorage.setItem("PixelPicoSean", "");
- window.localStorage.removeItem("PixelPicoSean")
- } catch (c) {
- b = false
- }
- }
- return b
- },
- isSet: function (b) {
- return (this.get(b) !== null)
- },
- initUnset: function (b, c) {
- if (this.get(b) === null) {
- this.set(b, c)
- }
- },
- get: function (b) {
- if (!this.isCapable()) {
- return null
- }
- try {
- return JSON.parse(localStorage.getItem(b))
- } catch (c) {
- return window.localStorage.getItem(b)
- }
- },
- getInt: function (b) {
- return~~ this.get(b)
- },
- getFloat: function (b) {
- return parseFloat(this.get(b))
- },
- getBool: function (b) {
- return !!this.get(b)
- },
- key: function (b) {
- return this.isCapable() ? window.localStorage.key(b) : null
- },
- set: function (b, c) {
- if (!this.isCapable()) {
- return null
- }
- try {
- window.localStorage.setItem(b, JSON.stringify(c))
- } catch (d) {
- if (d == QUOTA_EXCEEDED_ERR) {
- console.log("localStorage quota exceeded")
- }
- }
- },
- setHighest: function (b, c) {
- if (c > this.getInt(b)) {
- this.set(b, c)
- }
- },
- remove: function (b) {
- if (!this.isCapable()) {
- return null
- }
- window.localStorage.removeItem(b)
- },
- clear: function () {
- if (!this.isCapable()) {
- return null
- }
- window.localStorage.clear()
- }
- });
- ig.Storage = a
- });
- ig.baked = true;
- ig.module("plugins.hammer").defines(function () {
- var E = function (Z, Y) {
- return new E.Instance(Z, Y || {})
- };
- E.defaults = {
- stop_browser_behavior: {
- userSelect: "none",
- touchAction: "none",
- touchCallout: "none",
- contentZooming: "none",
- userDrag: "none",
- tapHighlightColor: "rgba(0,0,0,0)"
- }
- };
- E.HAS_POINTEREVENTS = window.navigator.pointerEnabled || window.navigator.msPointerEnabled;
- E.HAS_TOUCHEVENTS = ("ontouchstart" in window);
- E.MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android|silk/i;
- E.NO_MOUSEEVENTS = E.HAS_TOUCHEVENTS && window.navigator.userAgent.match(E.MOBILE_REGEX);
- E.EVENT_TYPES = {};
- E.UPDATE_VELOCITY_INTERVAL = 16;
- E.DOCUMENT = window.document;
- var A = E.DIRECTION_DOWN = "down";
- var x = E.DIRECTION_LEFT = "left";
- var T = E.DIRECTION_UP = "up";
- var G = E.DIRECTION_RIGHT = "right";
- var R = E.POINTER_MOUSE = "mouse";
- var c = E.POINTER_TOUCH = "touch";
- var r = E.POINTER_PEN = "pen";
- var p = E.EVENT_START = "start";
- var D = E.EVENT_MOVE = "move";
- var w = E.EVENT_END = "end";
- E.plugins = E.plugins || {};
- E.gestures = E.gestures || {};
- E.READY = false;
- function f() {
- if (E.READY) {
- return
- }
- L.determineEventTypes();
- M.each(E.gestures, function (Y) {
- l.register(Y)
- });
- L.onTouch(E.DOCUMENT, D, l.detect);
- L.onTouch(E.DOCUMENT, w, l.detect);
- E.READY = true
- }
- var M = E.utils = {
- extend: function j(Y, aa, ab) {
- for (var Z in aa) {
- if (Y[Z] !== undefined && ab) {
- continue
- }
- Y[Z] = aa[Z]
- }
- return Y
- },
- each: function (ab, aa, Z) {
- var Y, ac;
- if ("forEach" in ab) {
- ab.forEach(aa, Z)
- } else {
- if (ab.length !== undefined) {
- for (Y = -1;
- (ac = ab[++Y]);) {
- if (aa.call(Z, ac, Y, ab) === false) {
- return
- }
- }
- } else {
- for (Y in ab) {
- if (ab.hasOwnProperty(Y) && aa.call(Z, ab[Y], Y, ab) === false) {
- return
- }
- }
- }
- }
- },
- hasParent: function (Z, Y) {
- while (Z) {
- if (Z == Y) {
- return true
- }
- Z = Z.parentNode
- }
- return false
- },
- getCenter: function F(Z) {
- var aa = [],
- Y = [];
- M.each(Z, function (ab) {
- aa.push(typeof ab.clientX !== "undefined" ? ab.clientX : ab.pageX);
- Y.push(typeof ab.clientY !== "undefined" ? ab.clientY : ab.pageY)
- });
- return {
- pageX: (Math.min.apply(Math, aa) + Math.max.apply(Math, aa)) / 2,
- pageY: (Math.min.apply(Math, Y) + Math.max.apply(Math, Y)) / 2
- }
- },
- getVelocity: function a(Y, aa, Z) {
- return {
- x: Math.abs(aa / Y) || 0,
- y: Math.abs(Z / Y) || 0
- }
- },
- getAngle: function o(aa, Z) {
- var ab = Z.pageY - aa.pageY,
- Y = Z.pageX - aa.pageX;
- return Math.atan2(ab, Y) * 180 / Math.PI
- },
- getDirection: function k(aa, Z) {
- var Y = Math.abs(aa.pageX - Z.pageX),
- ab = Math.abs(aa.pageY - Z.pageY);
- if (Y >= ab) {
- return aa.pageX - Z.pageX > 0 ? x : G
- }
- return aa.pageY - Z.pageY > 0 ? T : A
- },
- getDistance: function n(aa, Z) {
- var Y = Z.pageX - aa.pageX,
- ab = Z.pageY - aa.pageY;
- return Math.sqrt((Y * Y) + (ab * ab))
- },
- getScale: function C(Z, Y) {
- if (Z.length >= 2 && Y.length >= 2) {
- return this.getDistance(Y[0], Y[1]) / this.getDistance(Z[0], Z[1])
- }
- return 1
- },
- getRotation: function y(Z, Y) {
- if (Z.length >= 2 && Y.length >= 2) {
- return this.getAngle(Y[1], Y[0]) - this.getAngle(Z[1], Z[0])
- }
- return 0
- },
- isVertical: function K(Y) {
- return Y == T || Y == A
- },
- toggleDefaultBehavior: function H(aa, Z, Y) {
- if (!Z || !aa || !aa.style) {
- return
- }
- M.each(["webkit", "moz", "Moz", "ms", "o", ""], function (ac) {
- M.each(Z, function (ad, ae) {
- if (ac) {
- ae = ac + ae.substring(0, 1).toUpperCase() + ae.substring(1)
- }
- if (ae in aa.style) {
- aa.style[ae] = !Y && ad
- }
- })
- });
- var ab = function () {
- return false
- };
- if (Z.userSelect == "none") {
- aa.onselectstart = !Y && ab
- }
- if (Z.userDrag == "none") {
- aa.ondragstart = !Y && ab
- }
- }
- };
- E.Instance = function (aa, Z) {
- var Y = this;
- f();
- this.element = aa;
- this.enabled = true;
- this.options = M.extend(M.extend({}, E.defaults), Z || {});
- if (this.options.stop_browser_behavior) {
- M.toggleDefaultBehavior(this.element, this.options.stop_browser_behavior, false)
- }
- this.eventStartHandler = L.onTouch(aa, p, function (ab) {
- if (Y.enabled) {
- l.startDetect(Y, ab)
- }
- });
- this.eventHandlers = [];
- return this
- };
- E.Instance.prototype = {
- on: function N(Y, Z) {
- var aa = Y.split(" ");
- M.each(aa, function (ab) {
- this.element.addEventListener(ab, Z, false);
- this.eventHandlers.push({
- gesture: ab,
- handler: Z
- })
- }, this);
- return this
- },
- off: function q(Z, aa) {
- var ac = Z.split(" "),
- Y, ab;
- M.each(ac, function (ad) {
- this.element.removeEventListener(ad, aa, false);
- for (Y = -1;
- (ab = this.eventHandlers[++Y]);) {
- if (ab.gesture === ad && ab.handler === aa) {
- this.eventHandlers.splice(Y, 1)
- }
- }
- }, this);
- return this
- },
- trigger: function S(Z, ab) {
- if (!ab) {
- ab = {}
- }
- var aa = E.DOCUMENT.createEvent("Event");
- aa.initEvent(Z, true, true);
- aa.gesture = ab;
- var Y = this.element;
- if (M.hasParent(ab.target, Y)) {
- Y = ab.target
- }
- Y.dispatchEvent(aa);
- return this
- },
- enable: function e(Y) {
- this.enabled = Y;
- return this
- },
- dispose: function z() {
- var Y, Z;
- if (this.options.stop_browser_behavior) {
- M.toggleDefaultBehavior(this.element, this.options.stop_browser_behavior, true)
- }
- for (Y = -1;
- (Z = this.eventHandlers[++Y]);) {
- this.element.removeEventListener(Z.gesture, Z.handler, false)
- }
- this.eventHandlers = [];
- L.unbindDom(this.element, E.EVENT_TYPES[p], this.eventStartHandler);
- return null
- }
- };
- var Q = null;
- var m = false;
- var i = false;
- var L = E.event = {
- bindDom: function (Z, ab, aa) {
- var Y = ab.split(" ");
- M.each(Y, function (ac) {
- Z.addEventListener(ac, aa, false)
- })
- },
- unbindDom: function (Z, ab, aa) {
- var Y = ab.split(" ");
- M.each(Y, function (ac) {
- Z.removeEventListener(ac, aa, false)
- })
- },
- onTouch: function J(aa, Z, ab) {
- var Y = this;
- var ac = function (af) {
- var ae = af.type.toLowerCase();
- if (ae.match(/mouse/) && i) {
- return
- } else {
- if (ae.match(/touch/) || ae.match(/pointerdown/) || (ae.match(/mouse/) && af.which === 1)) {
- m = true
- } else {
- if (ae.match(/mouse/) && !af.which) {
- m = false
- }
- }
- } if (ae.match(/touch|pointer/)) {
- i = true
- }
- var ad = 0;
- if (m) {
- if (E.HAS_POINTEREVENTS && Z != w) {
- ad = d.updatePointer(Z, af)
- } else {
- if (ae.match(/touch/)) {
- ad = af.touches.length
- } else {
- if (!i) {
- ad = ae.match(/up/) ? 0 : 1
- }
- }
- } if (ad > 0 && Z == w) {
- Z = D
- } else {
- if (!ad) {
- Z = w
- }
- } if (ad || Q === null) {
- Q = af
- }
- ab.call(l, Y.collectEventData(aa, Z, Y.getTouchList(Q, Z), af));
- if (E.HAS_POINTEREVENTS && Z == w) {
- ad = d.updatePointer(Z, af)
- }
- }
- if (!ad) {
- Q = null;
- m = false;
- i = false;
- d.reset()
- }
- };
- this.bindDom(aa, E.EVENT_TYPES[Z], ac);
- return ac
- },
- determineEventTypes: function P() {
- var Y;
- if (E.HAS_POINTEREVENTS) {
- Y = d.getEvents()
- } else {
- if (E.NO_MOUSEEVENTS) {
- Y = ["touchstart", "touchmove", "touchend touchcancel"]
- } else {
- Y = ["touchstart mousedown", "touchmove mousemove", "touchend touchcancel mouseup"]
- }
- }
- E.EVENT_TYPES[p] = Y[0];
- E.EVENT_TYPES[D] = Y[1];
- E.EVENT_TYPES[w] = Y[2]
- },
- getTouchList: function v(Y) {
- if (E.HAS_POINTEREVENTS) {
- return d.getTouchList()
- }
- if (Y.touches) {
- return Y.touches
- }
- Y.identifier = 1;
- return [Y]
- },
- collectEventData: function W(aa, Z, ac, ab) {
- var Y = c;
- if (ab.type.match(/mouse/) || d.matchType(R, ab)) {
- Y = R
- }
- return {
- center: M.getCenter(ac),
- timeStamp: new Date().getTime(),
- target: ab.target,
- touches: ac,
- eventType: Z,
- pointerType: Y,
- srcEvent: ab,
- preventDefault: function () {
- if (this.srcEvent.preventManipulation) {
- this.srcEvent.preventManipulation()
- }
- if (this.srcEvent.preventDefault) {
- this.srcEvent.preventDefault()
- }
- },
- stopPropagation: function () {
- this.srcEvent.stopPropagation()
- },
- stopDetect: function () {
- return l.stopDetect()
- }
- }
- }
- };
- var d = E.PointerEvent = {
- pointers: {},
- getTouchList: function () {
- var Y = [];
- M.each(this.pointers, function (Z) {
- Y.push(Z)
- });
- return Y
- },
- updatePointer: function (Z, Y) {
- if (Z == w) {
- delete this.pointers[Y.pointerId]
- } else {
- Y.identifier = Y.pointerId;
- this.pointers[Y.pointerId] = Y
- }
- return Object.keys(this.pointers).length
- },
- matchType: function (Y, aa) {
- if (!aa.pointerType) {
- return false
- }
- var ab = aa.pointerType,
- Z = {};
- Z[R] = (ab === R);
- Z[c] = (ab === c);
- Z[r] = (ab === r);
- return Z[Y]
- },
- getEvents: function () {
- return ["pointerdown MSPointerDown", "pointermove MSPointerMove", "pointerup pointercancel MSPointerUp MSPointerCancel"]
- },
- reset: function () {
- this.pointers = {}
- }
- };
- var l = E.detection = {
- gestures: [],
- current: null,
- previous: null,
- stopped: false,
- startDetect: function I(Z, Y) {
- if (this.current) {
- return
- }
- this.stopped = false;
- this.current = {
- inst: Z,
- startEvent: M.extend({}, Y),
- lastEvent: false,
- lastVelocityEvent: false,
- velocity: false,
- name: ""
- };
- this.detect(Y)
- },
- detect: function u(Y) {
- if (!this.current || this.stopped) {
- return
- }
- Y = this.extendEventData(Y);
- var Z = this.current.inst.options;
- M.each(this.gestures, function (aa) {
- if (!this.stopped && Z[aa.name] !== false) {
- if (aa.handler.call(aa, Y, this.current.inst) === false) {
- this.stopDetect();
- return false
- }
- }
- }, this);
- if (this.current) {
- this.current.lastEvent = Y
- }
- if (Y.eventType == w && !Y.touches.length - 1) {
- this.stopDetect()
- }
- return Y
- },
- stopDetect: function b() {
- this.previous = M.extend({}, this.current);
- this.current = null;
- this.stopped = true
- },
- extendEventData: function B(ad) {
- var ae = this.current,
- ag = ae.startEvent;
- if (ad.touches.length != ag.touches.length || ad.touches === ag.touches) {
- ag.touches = [];
- M.each(ad.touches, function (ai) {
- ag.touches.push(M.extend({}, ai))
- })
- }
- var ah = ad.timeStamp - ag.timeStamp,
- ab = ad.center.pageX - ag.center.pageX,
- Z = ad.center.pageY - ag.center.pageY,
- ac, af, Y = ae.lastVelocityEvent,
- aa = ae.velocity;
- if (Y && ad.timeStamp - Y.timeStamp > E.UPDATE_VELOCITY_INTERVAL) {
- aa = M.getVelocity(ad.timeStamp - Y.timeStamp, ad.center.pageX - Y.center.pageX, ad.center.pageY - Y.center.pageY);
- ae.lastVelocityEvent = ad;
- ae.velocity = aa
- } else {
- if (!ae.velocity) {
- aa = M.getVelocity(ah, ab, Z);
- ae.lastVelocityEvent = ad;
- ae.velocity = aa
- }
- } if (ad.eventType == w) {
- ac = ae.lastEvent && ae.lastEvent.interimAngle;
- af = ae.lastEvent && ae.lastEvent.interimDirection
- } else {
- ac = ae.lastEvent && M.getAngle(ae.lastEvent.center, ad.center);
- af = ae.lastEvent && M.getDirection(ae.lastEvent.center, ad.center)
- }
- M.extend(ad, {
- deltaTime: ah,
- deltaX: ab,
- deltaY: Z,
- velocityX: aa.x,
- velocityY: aa.y,
- distance: M.getDistance(ag.center, ad.center),
- angle: M.getAngle(ag.center, ad.center),
- interimAngle: ac,
- direction: M.getDirection(ag.center, ad.center),
- interimDirection: af,
- scale: M.getScale(ag.touches, ad.touches),
- rotation: M.getRotation(ag.touches, ad.touches),
- startEvent: ag
- });
- return ad
- },
- register: function g(Z) {
- var Y = Z.defaults || {};
- if (Y[Z.name] === undefined) {
- Y[Z.name] = true
- }
- M.extend(E.defaults, Y, true);
- Z.index = Z.index || 1000;
- this.gestures.push(Z);
- this.gestures.sort(function (ab, aa) {
- if (ab.index < aa.index) {
- return -1
- }
- if (ab.index > aa.index) {
- return 1
- }
- return 0
- });
- return this.gestures
- }
- };
- E.gestures.Drag = {
- name: "drag",
- index: 50,
- defaults: {
- drag_min_distance: 10,
- correct_for_drag_min_distance: true,
- drag_max_touches: 1,
- drag_block_horizontal: false,
- drag_block_vertical: false,
- drag_lock_to_axis: false,
- drag_lock_min_distance: 25
- },
- triggered: false,
- handler: function t(aa, ab) {
- if (l.current.name != this.name && this.triggered) {
- ab.trigger(this.name + "end", aa);
- this.triggered = false;
- return
- }
- if (ab.options.drag_max_touches > 0 && aa.touches.length > ab.options.drag_max_touches) {
- return
- }
- switch (aa.eventType) {
- case p:
- this.triggered = false;
- break;
- case D:
- if (aa.distance < ab.options.drag_min_distance && l.current.name != this.name) {
- return
- }
- if (l.current.name != this.name) {
- l.current.name = this.name;
- if (ab.options.correct_for_drag_min_distance && aa.distance > 0) {
- var Y = Math.abs(ab.options.drag_min_distance / aa.distance);
- l.current.startEvent.center.pageX += aa.deltaX * Y;
- l.current.startEvent.center.pageY += aa.deltaY * Y;
- aa = l.extendEventData(aa)
- }
- }
- if (l.current.lastEvent.drag_locked_to_axis || (ab.options.drag_lock_to_axis && ab.options.drag_lock_min_distance <= aa.distance)) {
- aa.drag_locked_to_axis = true
- }
- var ac = l.current.lastEvent.direction;
- if (aa.drag_locked_to_axis && ac !== aa.direction) {
- if (M.isVertical(ac)) {
- aa.direction = (aa.deltaY < 0) ? T : A
- } else {
- aa.direction = (aa.deltaX < 0) ? x : G
- }
- }
- if (!this.triggered) {
- ab.trigger(this.name + "start", aa);
- this.triggered = true
- }
- ab.trigger(this.name, aa);
- ab.trigger(this.name + aa.direction, aa);
- var Z = M.isVertical(aa.direction);
- if ((ab.options.drag_block_vertical && Z) || (ab.options.drag_block_horizontal && !Z)) {
- aa.preventDefault()
- }
- break;
- case w:
- if (this.triggered) {
- ab.trigger(this.name + "end", aa)
- }
- this.triggered = false;
- break
- }
- }
- };
- E.gestures.Hold = {
- name: "hold",
- index: 10,
- defaults: {
- hold_timeout: 500,
- hold_threshold: 1
- },
- timer: null,
- handler: function V(Y, Z) {
- switch (Y.eventType) {
- case p:
- clearTimeout(this.timer);
- l.current.name = this.name;
- this.timer = setTimeout(function () {
- if (l.current.name == "hold") {
- Z.trigger("hold", Y)
- }
- }, Z.options.hold_timeout);
- break;
- case D:
- if (Y.distance > Z.options.hold_threshold) {
- clearTimeout(this.timer)
- }
- break;
- case w:
- clearTimeout(this.timer);
- break
- }
- }
- };
- E.gestures.Release = {
- name: "release",
- index: Infinity,
- handler: function U(Y, Z) {
- if (Y.eventType == w) {
- Z.trigger(this.name, Y)
- }
- }
- };
- E.gestures.Swipe = {
- name: "swipe",
- index: 40,
- defaults: {
- swipe_min_touches: 1,
- swipe_max_touches: 1,
- swipe_velocity: 0.7
- },
- handler: function X(Y, Z) {
- if (Y.eventType == w) {
- if (Y.touches.length < Z.options.swipe_min_touches || Y.touches.length > Z.options.swipe_max_touches) {
- return
- }
- if (Y.velocityX > Z.options.swipe_velocity || Y.velocityY > Z.options.swipe_velocity) {
- Z.trigger(this.name, Y);
- Z.trigger(this.name + Y.direction, Y)
- }
- }
- }
- };
- E.gestures.Tap = {
- name: "tap",
- index: 100,
- defaults: {
- tap_max_touchtime: 250,
- tap_max_distance: 10,
- tap_always: true,
- doubletap_distance: 20,
- doubletap_interval: 300
- },
- has_moved: false,
- handler: function O(ab, ac) {
- var aa, Y, Z;
- if (ab.eventType == p) {
- this.has_moved = false
- } else {
- if (ab.eventType == D && !this.moved) {
- this.has_moved = (ab.distance > ac.options.tap_max_distance)
- } else {
- if (ab.eventType == w && ab.srcEvent.type != "touchcancel" && ab.deltaTime < ac.options.tap_max_touchtime && !this.has_moved) {
- aa = l.previous;
- Y = aa && aa.lastEvent && ab.timeStamp - aa.lastEvent.timeStamp;
- Z = false;
- if (aa && aa.name == "tap" && (Y && Y < ac.options.doubletap_interval) && ab.distance < ac.options.doubletap_distance) {
- ac.trigger("doubletap", ab);
- Z = true
- }
- if (!Z || ac.options.tap_always) {
- l.current.name = "tap";
- ac.trigger(l.current.name, ab)
- }
- }
- }
- }
- }
- };
- E.gestures.Touch = {
- name: "touch",
- index: -Infinity,
- defaults: {
- prevent_default: false,
- prevent_mouseevents: false
- },
- handler: function h(Y, Z) {
- if (Z.options.prevent_mouseevents && Y.pointerType == R) {
- Y.stopDetect();
- return
- }
- if (Z.options.prevent_default) {
- Y.preventDefault()
- }
- if (Y.eventType == p) {
- Z.trigger(this.name, Y)
- }
- }
- };
- E.gestures.Transform = {
- name: "transform",
- index: 45,
- defaults: {
- transform_min_scale: 0.01,
- transform_min_rotation: 1,
- transform_always_block: false,
- transform_within_instance: false
- },
- triggered: false,
- handler: function s(ab, ac) {
- if (l.current.name != this.name && this.triggered) {
- ac.trigger(this.name + "end", ab);
- this.triggered = false;
- return
- }
- if (ab.touches.length < 2) {
- return
- }
- if (ac.options.transform_always_block) {
- ab.preventDefault()
- }
- if (ac.options.transform_within_instance) {
- for (var Y = -1; ab.touches[++Y];) {
- if (!M.hasParent(ab.touches[Y].target, ac.element)) {
- return
- }
- }
- }
- switch (ab.eventType) {
- case p:
- this.triggered = false;
- break;
- case D:
- var aa = Math.abs(1 - ab.scale);
- var Z = Math.abs(ab.rotation);
- if (aa < ac.options.transform_min_scale && Z < ac.options.transform_min_rotation) {
- return
- }
- l.current.name = this.name;
- if (!this.triggered) {
- ac.trigger(this.name + "start", ab);
- this.triggered = true
- }
- ac.trigger(this.name, ab);
- if (Z > ac.options.transform_min_rotation) {
- ac.trigger("rotate", ab)
- }
- if (aa > ac.options.transform_min_scale) {
- ac.trigger("pinch", ab);
- ac.trigger("pinch" + (ab.scale < 1 ? "in" : "out"), ab)
- }
- break;
- case w:
- if (this.triggered) {
- ac.trigger(this.name + "end", ab)
- }
- this.triggered = false;
- break
- }
- }
- };
- ig.Hammer = E
- });
- ig.baked = true;
- ig.module("game.game-manager").requires("game.scenes.title", "game.scenes.gems", "plugins.storage", "plugins.hammer", "game.config").defines(function () {
- var a = ig.CONFIG;
- var b = ig.Class.extend({
- _promptPause: false,
- storage: null,
- inputManager: null,
- highest: 0,
- roundCounter: 0,
- langIndex: 0,
- _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)],
- screenRatio: 320 / 480,
- init: function () {
- ig.Sound.enabled = false;
- this.storage = new ig.Storage();
- if (this.storage.isCapable()) {
- if (!this.storage.isSet("gemsHigh")) {
- this.storage.initUnset("gemsHigh", a.MIN_HIGHSCORE)
- } else {
- if (this.storage.getInt("gemsHigh") < a.MIN_HIGHSCORE) {
- this.storage.set("gemsHigh", a.MIN_HIGHSCORE)
- }
- }
- this.gemsHigh = this.storage.get("gemsHigh");
- if (!this.storage.isSet("classicHigh")) {
- this.storage.initUnset("classicHigh", a.MIN_HIGHSCORE)
- } else {
- if (this.storage.getInt("classicHigh") < a.MIN_HIGHSCORE) {
- this.storage.set("classicHigh", a.MIN_HIGHSCORE)
- }
- }
- this.classicHigh = this.storage.get("classicHigh")
- } else {
- this.gemsHigh = this.classicHigh = a.MIN_HIGHSCORE
- }
- },
- ready: function () {
- window.addEventListener("resize", this.autoResize.bind(this), false);
- window.addEventListener("orientationchange", this.autoResize.bind(this), false);
- this.autoResize();
- if (ig.ua.mobile && !ig.ua.iOS71) {
- setInterval(function () {
- window.scrollTo(0, 1)
- }, 10)
- }
- this.inputManager = ig.Hammer(ig.system.canvas, {
- drag: false,
- hold: false,
- prevent_default: true,
- prevent_mouseevents: false,
- show_touches: false,
- swipe: false,
- transform: false,
- stop_browser_behavior: {
- touchAction: true,
- holdAction: true
- }
- })
- },
- firstScene: function () {
- return ig.SceneTitle
- },
- newClassicRound: function () {
- this.roundCounter++;
- this.removeInputListeners();
- ig.system.setGame(ig.SceneClassic)
- },
- newGemsRound: function () {
- this.roundCounter++;
- this.removeInputListeners();
- ig.system.setGame(ig.SceneGems)
- },
- updateScore: function (c) {
- if (this.storage.isCapable()) {
- if (ig.game.gemsMode) {
- this.storage.setHighest("gemsHigh", c);
- this.gemsHigh = this.storage.get("gemsHigh")
- } else {
- this.storage.setHighest("classicHigh", c);
- this.classicHigh = this.storage.get("classicHigh")
- }
- } else {
- if (ig.game.gemsMode) {
- this.gemsHigh = Math.max(this.gemsHigh, c)
- } else {
- this.classicHigh = Math.max(this.classicHigh, c)
- }
- }
- },
- gameOver: function () {
- console.log("game over")
- },
- switchToTitle: function () {
- ig.system.setGame(ig.SceneTitle)
- },
- autoResize: function () {
- var h = window.innerWidth,
- f = window.innerHeight;
- var g = h / 320,
- e = f / 480;
- var d = h / f;
- var c = (ig.ua.mobile) ? g : Math.min(g, e);
- if (d > this.screenRatio - 0.016 && d < this.screenRatio + 0.016) {
- ig.system.canvas.style.width = h + "px";
- ig.system.canvas.style.height = f + "px";
- this.stageScale = {
- x: h / 320,
- y: f / 480
- }
- } else {
- if (d < 1 || !ig.ua.mobile) {
- var i = 320 * c,
- j = 480 * c;
- ig.system.canvas.style.width = i + "px";
- ig.system.canvas.style.height = j + "px";
- this.stageScale = {
- x: c,
- y: c
- }
- }
- } if (ig.ua.mobile) {
- if (d > 1) {
- this.promptRotate()
- } else {
- this.recoverFromRotatePrompt()
- }
- }
- },
- checkOrientationFlag: function () {
- var c = window.innerWidth / window.innerHeight;
- if (ig.ua.mobile) {
- if (c > 1) {
- this.promptRotate()
- } else {
- this.recoverFromRotatePrompt()
- }
- }
- },
- promptRotate: function () {
- this._promptPause = true;
- var c = document.getElementById("rotate-prompt");
- c.style.width = "100%";
- c.style.height = "100%";
- c.style.visibility = "visible";
- if (ig.game && ig.game.clearColor) {
- ig.system.clear("#000")
- }
- },
- recoverFromRotatePrompt: function () {
- this._promptPause = false;
- var c = document.getElementById("rotate-prompt");
- c.style.visibility = "hidden"
- },
- removeInputListeners: function () {
- this.inputManager.off("touch", ig.game.touched.bind(ig.game));
- this.inputManager.off("release", ig.game.released.bind(ig.game))
- }
- });
- ig.GameManager = b
- });
- function mmod(a, b) {
- return ((a % b) + b) % b
- }
- //window.addEventListener("load", ); --> original load function was here
- function startGame() {
- var a = window.SG_Hooks;
- var b = SG.lang; //a.getLanguage(ig.CONFIG.LANG);
- ig.gameManager.langIndex = ig.CONFIG.LANG.indexOf(b);
- a.setOrientationHandler(function () {
- window.ig.gameManager.autoResize()
- });
- a.setResizeHandler(function () {
- window.ig.gameManager.autoResize()
- });
- //a.start() -> not here
- }
- ig.baked = true;
- ig.module("game.main").requires("game.game-manager").defines(function () {
- ig.gameManager = new ig.GameManager();
- ig.main("#canvas", ig.gameManager.firstScene(), 60, 320, 480);
- ig.gameManager.ready()
- });
|