0 0;HSԘJ 2TvͫgE#2Tv2Tv`fff!TvwV4dv!Ce dwwwwywwwwFwwwffffffw ADADADDA4CA33A33A4CDDDDDD31431433D31311113311DDDA"""$"""$"""$"""$"""$"""$"""DDDD""""""""""""""""""""""""""""DDD""""""B"""B"""B"""B"""B"""BADDADDDDDDADAD33A33DD3DDDDDDD31313111311111333$"""$"""$"""$"""$"""$"""$"""$""""""""""""""""""""""""""""""""""""""B"""B"""B"""B"""B"""B"""B"""BA33D33433433433433333333333131313331113331111$"""$"""$"""$"""$"""$"""A"""DDD""""""""""""""""""""""""""""DDDD"""B"""B"""B"""B"""B"""B"""DDD3332DADADADADA113333333333333333333333333333333333003333333333330000033333333333300000000000000000000000DD4343DDAD333311DD4343DDDDCCDD3C331131AA00000003333333300000003333000000003333333333333333333333333333000033333333333333333333000033333333131333111313133""""""""""""""""""""""""""""""""3333333333333333333333333333000033333333000000000000000000DD$"43$"43$"DD$""$BD33332""#2""#DD$"43$"43DDDDCC"$DD3C332"232"BB00000003333333300000003333000000003333333333333333333333333333000033333333333333333333000033333333"""""""""""#""2#""3#"23#"33#""""""""""""2"""2#""23""23#"233"""""DD44DD3333133DD44DD3333133DD44DD33""""!232323""""!2!""#""2#""3#""33""33#"""""""2""C""2""""""""""!!!!!!!13331111131333333133331133111111""""23332"""2"""2"""2"""2""32""#""""3333""""""""""""""""3""32""#""""333#"""#"""#"""#"""#3""#2""#""""233#2""#2""#2""#2""#2""#2""#333333133133133133133333#3333333333333333333333333333"""33#"33#"333"333"333"33""3333!!!!""!""!""!33"!11311111311333311331111111112""#2""32"""2"""2"""2"""2""32""#2""#3""3""""""""""""""""3""32""#2""#3""#"""#"""#"""#"""#3""#2""#2""#2""#2""#2""#2""#2""#2""#2""#ADDADDDDDDADDDDDAADDDDDDDDADDDDAADDADADAA133133133133133133333233333333333333333333333333C33CD3DDD33333333333333333D43DDD3DDD4DDDD3""""!"#"3"3"3!3!!32!113111113331333333133331111111332""#2""32"""2"""2"""2"""2333""""2""#3""3""""""""""""""""3333""""2""#3""#"""#"""#"""#"""#333#""""2""#2""#2""#2""#2""#2""#233#""""23"3"2"3"2#32"$#"43!43CCCCCDDDDDDDCDDD333D3"2C3"DD3DDDDDD4DDDDDDDDDDD3D3C343"2D3$2DDD4DDDD32!#""!#"#!3"#!3##!C#!C#!4#!133311111333333333333333331331111133""""23332"""2"""2"""2"""2333""""""""3333""""""""""""""""3333""""""""333#"""#"""#"""#"""#333#""""""""233#2""#2""#2""#2""#233#""""1CC111!!!DDD3DCDCDCD3DC4CC3D3CC3DC4D3343DDCDDD3DDD3D4D3D4D3D33C4C44CC3C4C4!4!4!4!4!$!#!#!"!"!"!""""""""""""""""""33D33334333DC43CCD33CD33CDD3""""D4C333D#4CD#DD4"DD3233#C33CD"""""!"!#!!4"!4""!4""!D""!""""ADDDADDDDDDDDDDDDDDDDDDDDDDADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDADDDADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDADDDDDDDDADDDADDDDDDDDDDDDDDDDDDDDDDDDDDDDDADDDDDADDDDDDDDDADDDDDDDDDDDDDDDDDDDDDDDDDDDADDDDDDDDDADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDADDDDADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDADDDDDDDDDDDDDDDDDDDDDDDADDDDADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDADDDDDDDDDDDDDDDDDDDDDDADDDDADDDADDDDDDDDDDDDDADDDDDDDDDDDDDDADDDDDDDDDDDDDDDDDDADDDDDDDDDDDDDDADDDDDDDDDDDDDDDDDD 33033DD44DD3333033DD44DD33@@33033DD44DD33D33033DD44DD3333033DD44DD3333033DD44D@@333@@D@DD@@@@@DD44DD33DD44DD33@@DD44DD33D@@@@@@@@@@@@@@@@D@@@@@D@@@@@""2#"2#"B$B$B$B$"2#"2#""""B$"B$"2#2#2#2#"B$"B$"""""22!!1!@@@ $BD ""B DB"BB$B $BD""" $B$ $  $ D $""" "   " """"""" "" " """" 3333C44CC3D3344CC4CC3333333CC344C444C344343303"" ""DD$$D@@"""""BBBBBBBBBB""""BBBBB"" ""BD $""""BD $ DDD@"""$DB$$$B$$BB"$D"$@"""DDDDDDD""""$D"$$DB"$$B"$B"$""""DDDDD"$BDB$BBB"DDDD@3334DC444C44CC34D34@333DDDDDDD33334D344DC344C34C343333DDDDD34CDC4CCC3D "" DB $   $ "$$""$"" B$ B" ""DB  DD@""B$"$"$BB"$BD"$BB"$BB"@""BDD@33C43434CC34CD34CC34CC3DD@""B$B$"$BB"$B$"$BB"$B$"@""BDD@33C4C434CC34C434CC34C43 DB ""$"BB$ "" BD"DD@33CDDDD@33CDDzBBBBBBBBBBBBBBBBBBBBBBBL@N@N@N@MBBBBBBBBBBBL@N@ML@@NQBBBL@@@@@@@@@ML@@@@ML@@@@@@@@@@@ML@@@MBBBBBBBL@@@@@@MR@@@@@@@ML@@@@ML@@N@@@@NMBBBBBBBBBR@@QBBBBBBBBBBBL@@@@@@@ML@@@ML@@@N@@@@N@ML@@@@@@ML@@@@@@@@@@@MR@@@@@@ML@@@@@@MLN@@N@@@ML@@@@N@ML@@@@@@@ML@@@@@@@@@ML@@@@@@@ML@@@@@@@@ML@@@N@MLN@@NMFEEEETTU@@ML@@@@ML@@@@@@ML@@@@@@@@DGL@@@@@@@ML@@@@@@@@@@@MFH@@@@@@ML@@@@@@ML@@@@ML@@@@@@ML@@@@@@@ML@@@@@@@@@@ML@@@@ML@@@@@@@@@@MFEEEEEEEGFEEH@@DEEGFEEEEEGL@@N@@@ML@@@MFEEEEEEEEEEGL@@@ML@@@@@NML@@@ML@@@@@@@MFEH@@@@NML@@@@@@ML@@@@@@@@@@ML@N@MFEEEEEEEGFEEEEEGLN@@@@@MFEEEEEEEEEEEGFEEEGFEEEEEEEGBBBBBBBBBBBBBBBBBBBBBBL@@@@@@@@MBBBBBBBBBBL@@N@@ML@@N@@@MLN@@@@@@N@ML@@@@@MR@@NMRN@@@@QBBBBBBBBBL@@@@@@ML@@DEEEH@@MBBBBBBBBBR@@@QBBBBBBBBBBBBR@@@@@@QR@@@@@@@QLN@NML@@@@@@@ML@@ML@MLN@@@SN@@ML@@@@@N@@@MLN@@@NMBBRN@@@@@ML@@@@@@ML@@@@@@@ML@@@@@@@QBBL@QBBBR@@MBBBBL@@@@@P@@QL@@@@@@@@@@ML@@@@@ML@@@@@@@@ML@@@@@@ML@@@@@ML@@@@@@@@@@ML@@@@@@@@@MR@@P@@QL@@@@@@@@@@ML@@@@@@@@@ML@@@@@@MLN@@@@@@@@ML@@@@@ML@@@@@@ML@@@@@@@QBL@@@@@@@@@s@@@@@@@ML@@@@@@@@MFH@@@@@DEEGL@@@@@@MhU@@@@@@@@ViL@@@@@@QLN@@@@@@NML@N@@@@@@@@@@ML@@@@@@N@s@@@@N@ML@@@@@@N@@ML@@@@@DEEGL@@@@@@ML@@@@@@@@@@@ML@@@@@@@ML@@@@@@MFEH@@@@@@@@ML@@@@@@KH@@@@@DGL@@@I@@@@ML@@@@@ML@@@@@ML@@@@@@@@@@@@MFH@@@@@@@@NML@N@@NML@@@@@@@@@@ML@@@@N@@@MFH@@@DGL@@@S@@@@@ML@N@N@MLN@@@NMFEH@@@@@@@@DEGFH@@@@@NDGL@@@@@@@MFEEH@@@@@@ML@@@@@@@@@MFH@DGFH@@@@S@@@@DGFEEEEEGFEEEEEEEGFHN@@@@DGL@@@@@@DGLN@NML@NN@@@@ML@@@@@@@@@MFEGFEEEEWEEEEGFEEEEEEEGFEEEEEEGFEEEEEEEEEGFEEEEEEEEGFEEEEEEEEEG  '((((((((((()BBBL@`@M'(((((()L`@`ML@`@MFEEEG PPPPPPPPPP____________________```````````ooooooooooooooooooo@@@@ABCDEFGHJKMNOOOOOOOOOOOOOOzxstuz|~1 ;<>__@@ !CE') MN//OO//OO//PPPPPPPPPPPPPPPPPPPPPPPPQSTV[_PPPPPPPPP_____________________www w 7776655 4 4 3 3 2 2 2 2 2 2 2 2 2 3 3 3 4 4 4 5 566:   p p ''''`'`'`'`'`'`'`'`'`(`)`)`)`*`+`+`,`,`-`-`.`/`/`/`/`/`/` w``[[Y\^\^W[[^\^\WYU^aYYUY\Y\\YWWUWW[[Y\^\W^[[^\^YU^aYYUY\Y\\aYaWaWaWU^aZaU^aZaWaYa^a\a^a^aYa^a\a^a^aBbBBBbbbbBBbBBbbbbbbbBbB"BbBbBBBbBBbBbBBBBbBBBbbbbBBbBBbbbbbbbBbB"BbBbBBBbbBBB""""B"""""B"BBBBBBBBBBBBBB"B"BbBBbBbBBBBBbbbBBBBbBBBBB'Hhh(Hh(Hh(H'Hhh(Hh(Hh(HhHhh(Hh(Hh(H'Hhh(Hh(Hh(H'Hhh(Hh'H(H'Hhh(Hh'H(H'Hhh(Hh'H(H'Hhh(Hh'H(H'Hhh(Hh(Hh(H'Hhh(Hh(Hh(H'Hhh(Hh(Hh(H'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" BBBBBBBBBB""BBBbBBBBB""BBBBBBBBbbbbbBBBBbbbBBBBBbBbBBBBBBbbbbBBBfjmoeoeoejehehfemioifjmoeoeoehhmlheheb    k     v'HvHv'Hvv'v'HvHv'vvv'FHHHHHHHHZUXWXWX_lVUVUU]l\l]l\l]l_lU_l_lUVXZ_lX\U]l\l]l\l]l_lUl_l_l_m_m_m_mBBBbBbBBBB""BBBBBBv'HHvH{'Hvqv'HHvHv'vvv'v'HHHvHHH{'xHvqv'HHHvxHxv'Hvvqv'Hf'@HV'pHvqv'D'F'F'q0B844q4A8ˣ0ˣ8llllqUqqUqVmnVmn$$%%&  ?"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""BD$DD""D$D$DD"""BD$D$D$"""""""""""""""""""""""""""""""""""""""""""""""""""""DD$DD$"D$D$DD$""DD$D$D$""""""""""""""""""""""""""""""""""""""""""""""""""""BDD$DDD"D$D$DDD"BDD$D$D$""""""""""""""""""""""""""""""""""""""""""""""""""""DD$"DDD$D$D$DDD$DD$"D$D$""""""""""""""""""""""""""""""""""""""""""""""""""""DD""D$D$D$D$D$D$DD""D$D$""""""""""""""""""""""""""""""""""""""""""""""""""""D$""D$B$D$D$D$D$D$""D$D$""""""""""""""""""""""""""""""""""""""""""""""""""""D$""D$D$D$D$D$D$D$""DDD$""""""""""""""""""""""""""""""""""""""""""""""""""""D$""DDD$D$D$D$D$D$""DDD$""""""""""""""""""""""""""""""""""""""""""""""""""""D$""DDD"D$D$D$D$D$""DDD$""""""""""""""""""""""""""""""""""""""""""""""""""""D$""DD$"D$D$D$D$D$""D$D$""""""""""""""""""""""""""""""""""""""""""""""""""""DD""DD$"D$D$D$D$DD""D$D$""""""""""""""""""""""""""""""""""""""""""""""""""""DD$"DDD"DDD$D$D$DD$"D$D$""""""""""""""""""""""""""""""""""""""""""""""""""""BDD$DDD$DDD$D$D$BDD$D$D$"""""""""""""""""""""""""""""""""""""""""""""""""""""DD$D$D$BDD"D$D$"DD$D$D$"""""""""""""""""""""""""""""""""""""""""""""""""""""BD$D$D$"D$"D$D$"BD$D$D$""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""DDDDDD""""BDDDD""""DDDDD$""DDDDD$"""""""""""""""""""""""""""""""""""""""""""DDDDDD$"""DDDDD$""BDDDDD$"BDDDDD$"""""""""""""""""""""""""""""""""""""""""""DDDDDDD""BDDDDDD""DDDDDD$"DDDDDD$"""""""""""""""""""""""""""""""""""""""""""DDD""DD$"DDD$"DD$"DDDD$"""DDDD$"""""""""""""""""""""""""""""""""""""""""""""DDD""BD$"DDD""BD$"DDDD""""DDDD""""""""""""""""""""""""""""""""""""""""""""""DDD""DD$"DDD"""D$"DDDD$"""DDDD$"""""""""""""""""""""""""""""""""""""""""""""DDDDDDD""DDD"""D$"BDDDD"""BDDDD"""""""""""""""""""""""""""""""""""""""""""""DDDDDD$""DDD"""D$""DDDD$"""DDDD$""""""""""""""""""""""""""""""""""""""""""""DDDDDDD""DDD"""D$""BDDDD"""BDDDD""""""""""""""""""""""""""""""""""""""""""""DDD""DD$"DDD"""D$"""DDDD$"""DDDD$"""""""""""""""""""""""""""""""""""""""""""DDD""BD$"DDD""BD$"""BDDD$"""BDDD$"""""""""""""""""""""""""""""""""""""""""""DDD""DD$"DDD$"DD$"""DDDD$"""DDDD$"""""""""""""""""""""""""""""""""""""""""""DDDDDDD""BDDDDDD""DDDDDD$"DDDDDD$"""""""""""""""""""""""""""""""""""""""""""DDDDDD$"""DDDDD$""DDDDDD""DDDDDD""""""""""""""""""""""""""""""""""""""""""""DDDDDD""""BDDDD"""DDDDD$""DDDDD$""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""333333333333333333133333333133333333133333333DDDDDDDDDDDDDDDDDDD43D43D43D43D43D43DDDDDDDDDDDDDDDDDD333333333333333333333333DDDDDDAAADDDAAADAAADD!"!!!!!!!!!!!!!!!!!!!!"!!!!!!!!!!!"!!"!"!!!"!!,0 0; P[ԘJ! 23 233 233"333"333"33323332333333333333333333333333333333333333 " 2"3 23"3332333333333333333333333333333""" 2 2 23 23333333333333333333333333333333333333333333333333333333333333333333333333333333333333333" 23#2333333"33"3333333333333333333333333 23 23 23"3"3 2 2 233333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333#333"3333"3#BD3"D#BD"DBDD""" 33333333333323332333"333233323333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333#333"33#B33"D3#BD3"D#BD"D BD"D BD" BD"DDBDDDDDDDDDDD 2 """3"33233333332333233333333333333333333333333333333333333333333333333333333333333333333333333333333333333"3333"333 233"33 23"3 "33#B33"D3#BD3"D#BD"D BD"D BD B" "DBDDDDDDDDDDDDDDDBDDD"DDD BDD"DD"DD BDDDDDDDDDDDDDDDDDDDD"33 233 233"333"333"333"333"333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333 " B"D BD"D BD"DBD"DBD"D BD"D B"DDDDDDDDDDDDDDDDDDDDDDDDD BD"D B"DDDDDD"DD DDDDDDDDDDDDDDDDDDDDBDDD"DDD BDD"D BDDD"333"333 233 233"3"333333333333333333333333 233 23333333333333333333333333333333333333333333333333333333333333333333333333333333 " B"D BD"D BD"DBD"D BD B B"D"D BD DDBDD DDDDDDDDDDDDDDDDDDDDDDDD$DDD BDD B B BD"D DDDDDDDDDDDDDDDDDDDDDDDBDDD"DD BD"D 2 2"" 333333333333333323332333"333"33333333333333333333333333333333333333333333333333333333333333#333" B"D3 BD3"D#BD"D BD"D BD"D BD"DD BDD"DDBDDDDDDDD"DD BD"D B" DDDDDDDDDDDDDDDDDDDBDD"DD B "" 2 2 2"323332333333333333333333333333333333333333333333333333333333#333"33#B33"D3#BD3"D#BD"DBDDD"D BD"DD"DD BDD BDD BDD"DDDD D"DD BDD$DDDDDDDDDDDDDBDDDDDDDD"3 23 23 23"3 2""333333333333333333333333333#333"33#B33"D3#BD3"D#BD"D BD DD BD"DD BDD"DDDBDDDBDDD"DDD BD"D BD"D DDDDDDDDDDDDDDDDDDDDDDDBDDD"DDD BDD"DDDDDDDDDDDDDDDD 23#B"3"D BD"D BD BDD"DD BD"D B" DDDDDDDDDDDDDDDDDDDDDDDBDDD"DDD BD"D BD"DDDDDDDDDDD BDD"DD"DD"DD BDD"DDBDD"DDDDD B$6  0 !"#$%&'()*+,0123456789:;<@ABCDEFGHIJKLPQRSTUVWXYZ[\`abcdefghijklpqrstuvwxyz{|Ts-- title: Crunch Boss -- author: jf1x -- desc: Be the villain and get those devs back to work. -- script: lua -- saveid: gbjam9 VERSION='1.0.2' FULL_W,FULL_H=240,136 MAP_X,MAP_Y=0,0 MAP_W,MAP_H=19,17 SCREEN_W,SCREEN_H=240,136 VIEW_W,VIEW_H=152,136 XO=(SCREEN_W-VIEW_W)//2 SCREEN_MIDW=SCREEN_W//2 SCREEN_MIDH=SCREEN_H//2 TS=8 BGSCRL=false CHECKERB={S=64,E=64,O=32} LEVELS={ -- mapx, mapy, maxturns, tutorialy -- Tutorial / easy {0,0,1,29}, -- [1] yell to move devs {30,0,1,8}, -- [2] yells in 4 directions {60,0,2,19}, -- [3] movement {90,0,2,19}, -- [4] restart level -- Medium {150,0,3,0}, -- [5] TP1 {120,0,5,0}, -- [6] CB1 {30,17,9,0}, -- [7] BD11 -- Hard {180,0,9,0}, -- [8] BD13 {210,0,7,0}, -- [9] CB2 {0,17,7,0}, --[10] CB3 -- Diag level interstitial -- Hard {60,17,4,0}, -- [11] CB4 {150,17,7,0},-- [12] CB5 {120,17,9,0},-- [13] CB6 -- Extreme {90,17,5,0}, -- [14] CB7 {180,17,6,0},-- [15] BD20/CB8 {210,17,6,0} -- [16] CB9 } LEVELDATA={} level=1 LEVELFINISHDELAY=3500 MEM_ATTEMPTS=1 SAVEDLEVEL=1 SAVEDYELLS=0 CONTINUING=false turnOver=true turnsUsed=0 turnTime=time() turnsMax=20 turnEndTime=time() TURNDELAY=1 YMODES={UDLR=0,DIAG=1} yellMode=YMODES.UDLR yellChange=time() YMODEMINLEV=11 YELLLINET=500 YELLCD=500 lastYellType=1 timesYelled=0 timesYelledThisLevel=0 maxYells=0 -- ENTITIES ETYPE={ PLAYER=0, DEV=1 } EID=0 DIR={U=0,D=1,L=2,R=3,NE=4,SE=5,SW=6,NW=7} DIRB={U=1,R=2,D=4,L=8} MOVESPD = {[ETYPE.PLAYER]=1,[ETYPE.DEV]=1} -- MAP/TILES TFLG={ SOLID=1, CUBICLE=2, PC=3 } FSPR={ [0]=187,[1]=171,[2]=184,[3]=168, [4]=139,[5]=155,[6]=136,[7]=152, [8]=186,[9]=170,[10]=185,[11]=169, [12]=138,[13]=154,[14]=137,[15]=153 } PCSPR=78 ATPCSPR=79 -- ANIMATIONS -- LR default. Add 16 for down. Add 32 for up. ATYPE={ IDLE=1,RUN=2,JUMP=3,FALL=4,YELL=5 } ANIMS={ [ETYPE.PLAYER]={ -- LR default. {256,256,256,256,261,261,261,261}, -- Idle LR {257,258}, -- Run LR {259}, -- Jump LR {260}, -- Fall LR {263}, -- Yell LR }, [ETYPE.DEV]={ {272},{272,273,274} } } -- Pause menu SKIPS=0 function PFUNC_resume() PMENU.open=false;PMENU.sidx=1 end function PFUNC_mute() music(tIf(MUS,-1,2)) MUS=not MUS end function PFUNC_skip() PFUNC_resume() SKIPS=SKIPS+1 LEVELS[level][5]=true -- mark as skipped timesYelled=timesYelled+LEVELS[level][3]+1 timesYelledThisLevel=0 setGameState(GSTATES.SKIPPED) end PMENU={ open=false, sidx=1, items={ {t='Resume',fn=PFUNC_resume}, {t='Toggle music',fn=PFUNC_mute}, {t='Skip level',fn=PFUNC_skip}, } } -- Collections Plr=nil Ents={} Devs={} SoundWaves={} particle_systems={} LEVEL_X,LEVEL_Y=0,0 SCENES={JF1X=0,TITLE=1,INTRO=2,GAME=3,THEEND=4,UPGRADE=5} SCENE=SCENES.JF1X GSTATES={INTRO=0,PLAY=1,GAMEOVER=2,WON=3,OUTRO=4} GSTATE=GSTATES.PLAY GSTATETIME=time() TMENUS={START=0,CONTINUE=1} TMENU=TMENUS.START tMenuTime=time() INIT=false MUS=true music(2) TIMER=0 UIX,UIY,UIC,UIO=48,120,4,2 FLAST=false CELEBRATETIME=time() function OVR() if SCENE==SCENES.INTRO then map(210,119,13,7,XO+24,10) spr(256,XO+29,26,0,4) print("EMPLOYEE ID",XO+46,13,4) print("Nick Baird",XO+66,30,4,false,1,true) print("MANAGER",XO+66,37,4,false,1,true) print("X-Ploit Studios",XO+66,45,3,false,1,true) oprint('The devs are slacking off',0,80,4,2,false,false,1,true) oprint('and launch approaches!',0,90,4,2,false,false,1,true) oprint("IT'S TIME!",0,110,4,2,false,false,1,true) oprint("CRUNCH ",0,107,3,2,true,false,2,true) oprint('Press any button to start',0,128,4,2,true,true,1,true) elseif SCENE==SCENES.UPGRADE then -- elseif SCENE==SCENES.GAME then spr(448,148,1,0,1,0,0,3,1) print('Options',168,2,2,false,1,true) local btnO=time()%2000<1000 if GSTATE==GSTATES.WON then bprint("ALL DEVS ARE CRUNCHING!","The game launched on time.",8,UIC,2) elseif GSTATE==GSTATES.SKIPPED then bprint('LEVEL SKIPPED!',"Upper management will hear about this.",8,UIC,3) elseif GSTATE==GSTATES.GAMEOVER then bprint(#Devs..' DEV'..tIf(#Devs==1,' ISN\'T','S AREN\'T')..' CRUNCHING!',"Launch delayed!",8,UIC,3) elseif GSTATE==GSTATES.PLAY then local tuty=LEVELS[level][4] if level==1 then oprint('Press to YELL',0,tuty,UIC,UIO,true,false,1,true) spr(480+tIf(btnO,0,2),113,tuty-3,0,1,0,0,2,2) oprint('Herd lazy devs to their PCs!',0,tuty+10,UIC,UIO,true,false,1,true) elseif level==2 then oprint('Yells travel in',0,tuty,UIC,UIO,true,false,1,true) oprint('all 4 directions',0,tuty+10,UIC,UIO,true,false,1,true) elseif level==3 then oprint('Move with ',0,tuty,UIC,UIO,true,false,1,true) spr(432+tIf(btnO,0,1),133,tuty-2,0,1,0,0) oprint('Yells are limited, use wisely',0,tuty+10,UIC,UIO,true,false,1,true) elseif level==4 then if GSTATE~=GSTATES.WON then oprint(' restarts level',0,tuty,UIC,UIO,true,false,1,true) oprint("Don't miss launch! Good luck",0,tuty+10,UIC,UIO,true,false,1,true) spr(464+tIf(btnO,0,3),82,tuty-tIf(btnO,3,2),0,1,0,0,3,1) end end if level >= YMODEMINLEV then local tsy=time()-yellChange if isTurnReady() and tsy>800 then local sid=tIf(yellMode==YMODES.UDLR,373,389)+(tsy%800)//100 local pxo,pyo=XO+Plr.x-LEVEL_X*TS,Plr.y-LEVEL_Y*TS if yellMode==YMODES.UDLR then spr(sid,pxo+8,pyo,0) spr(sid,pxo-8,pyo,0,1,1) spr(sid,pxo,pyo-8,0,1,0,3) spr(sid,pxo,pyo+8,0,1,0,1) else spr(sid,pxo+6,pyo-6,0) spr(sid,pxo-6,pyo-6,0,1,1) spr(sid,pxo-6,pyo+6,0,1,0,2) spr(sid,pxo+6,pyo+6,0,1,0,1) end end end end local turnsLeft=turnsMax-turnsUsed oprint('LEVEL',UIX,UIY+7,UIC,UIO,false,false,1) local t1=oprint(level,UIX,UIY-6,UIC,UIO,false,false,2) oprint('/' ..#LEVELS,UIX+t1+1,UIY-1,UIC,UIO,true,false,1) if level > 2 then local t2=oprint('YELLS',0,-100,UIC,UIO,false,true,1) oprint('YELLS',XO+VIEW_W-t2-1,UIY+7,UIC,UIO,false,true,1) t2=oprint(turnsLeft,0,-100,UIC,UIO,false,true,2) t2=t2+1+oprint('/' ..turnsMax,0,-100,UIC,UIO,true,false,1) t2=XO+VIEW_W-t2-1 t2=t2+oprint(turnsLeft,t2+1,UIY-6,UIC,UIO,false,true,2) t2=t2+oprint('/' ..turnsMax,t2+1,UIY-1,UIC,UIO,true,false,1) end if level >= YMODEMINLEV then local t2=oprint('MODE',0,UIY+7,UIC,UIO,false,true,1,true) if yellMode==YMODES.UDLR then spr(444+tIf(btnO,2,0),114,UIY-7,0,1,0,0,2,2) else spr(476+tIf(btnO,2,0),115,UIY-6,0,1,0,0,2,2) end end if PMENU.open then map(227,120,12,10,72,28) cprint('MENU',36,4,false,1,false) for mi=1,#PMENU.items,1 do cprint(menuCursor(PMENU.items[mi].t,mi==PMENU.sidx),45+mi*10,4,false,1,true) end cprint('Score: '..timesYelled,94,2,false,1,true) end elseif SCENE==SCENES.THEEND then if SKIPS>9 then oprint('YOU... WIN?',0,SCREEN_MIDH-56,4,0,false,true,2,true) oprint('You think you can just skip',0,SCREEN_MIDH-34,4,2,true,true,1,true) oprint('over half the levels?',0,SCREEN_MIDH-24,4,2,true,true,1,true) oprint('Demoted to Developer! Get to your PC!',0,SCREEN_MIDH-14,3,2,true,true,1,true) else oprint('YOU WIN!',0,SCREEN_MIDH-56,4,0,false,true,2,true) oprint('Your games shipped on time with',0,SCREEN_MIDH-34,4,2,true,true,1,true) oprint('minimal loss of developer life!',0,SCREEN_MIDH-24,4,2,true,true,1,true) oprint('Profits are up 2.3%!',0,SCREEN_MIDH-14,3,2,true,true,1,true) end bprint('Score: '..timesYelled..' yells',SKIPSTR,SCREEN_MIDH+6,4,2) oprint('Thanks for playing!',0,SCREEN_MIDH+35,4,2,true,true,1,true) oprint('Press any button to restart',0,128,4,2,true,true,1,true) end -- Draw screen borders to maintain GB res at all times rect(0,0,XO,SCREEN_H,0) rect(240-XO,0,XO,SCREEN_H,0) end function TIC() if SCENE==SCENES.JF1X and not INIT then INIT=true sync(39,1,false) --sync(39,0,false) --loadLevel(false) local slevel = pmem(0) local syells = pmem(10) if slevel > 1 and slevel < #LEVELS then SAVEDLEVEL=slevel SAVEDYELLS=syells end end input() update() draw() end function input() if SCENE==SCENES.JF1X then if btnp(4) or time()-TIMER>2500 then sync(39,0,false) SCENE=SCENES.TITLE TMENU=TMENUS.START end elseif SCENE==SCENES.TITLE then if (btnp(0) or btnp(1)) and SAVEDLEVEL > 1 then TMENU=TMENUS.CONTINUE-TMENU tMenuTime=time() sfx(52,"C-7",15,3) elseif btnp(4) or btnp(6) then CONTINUING=TMENU==TMENUS.CONTINUE and SAVEDLEVEL > 1 if CONTINUING then level=SAVEDLEVEL timesYelled=SAVEDYELLS else pmem(0, 0) pmem(10, 0) level=1 end pmem(1, 0) SCENE=SCENES.INTRO sfx(53,"B-5",15,3) end elseif SCENE==SCENES.INTRO then if anybtnp() then loadLevel(false) SCENE=SCENES.GAME end elseif SCENE==SCENES.UPGRADE then if anybtnp() then level=level+1 loadLevel(false) setGameState(GSTATES.PLAY) SCENE=SCENES.GAME end elseif SCENE==SCENES.GAME then if btnp(6) then if PMENU.open then PFUNC_resume() elseif isTurnReady() and GSTATE==GSTATES.PLAY then PMENU.open=true;sfx(53,"B-5",15,3) end end if PMENU.open then if btnp(0) then PMENU.sidx=PMENU.sidx-1 if PMENU.sidx<1 then PMENU.sidx=#PMENU.items end sfx(52,"C-7",15,3) elseif btnp(1) then PMENU.sidx=PMENU.sidx+1 if PMENU.sidx>#PMENU.items then PMENU.sidx=1 end sfx(52,"C-7",15,3) elseif btnp(4) then PMENU.items[PMENU.sidx].fn() sfx(53,"B-5",15,3) elseif btnp(7) then resetLevel() sfx(53,"B-5",15,3) end else if GSTATE==GSTATES.WON then if btnp(5) or btnp(4) then GSTATETIME=0 end elseif GSTATE==GSTATES.SKIPPED then if btnp(5) or btnp(4) then GSTATETIME=0 end elseif GSTATE==GSTATES.GAMEOVER then if btnp(5) or btnp(4) then resetLevel() end elseif GSTATE==GSTATES.PLAY then if isTurnReady() and time()-Plr.yellTime>YELLCD then if btnp(7) then resetLevel() return elseif btn(0) then if not solid(Plr.tx,Plr.ty-1) then Plr.ty=Plr.ty-1; consumeTurn(0) end elseif btn(1) then if not solid(Plr.tx,Plr.ty+1) then Plr.ty=Plr.ty+1; consumeTurn(0) end elseif btn(2) then Plr.facing=DIR.L if not solid(Plr.tx-1,Plr.ty) then Plr.tx=Plr.tx-1; consumeTurn(0) end elseif btn(3) then Plr.facing=DIR.R if not solid(Plr.tx+1,Plr.ty) then Plr.tx=Plr.tx+1; consumeTurn(0) end elseif btnp(4) then yell(); consumeTurn(1) elseif btnp(5) and level >= YMODEMINLEV then yellMode=1-yellMode yellChange=time()-800 sfx(52,"C-6",15,3) end end end end elseif SCENE==SCENES.THEEND then if btnp(4) then reset() end end end function anybtnp() return btnp(0) or btnp(1) or btnp(2) or btnp(3) or btnp(4) or btnp(5) or btnp(6) or btnp(7) end function update() if SCENE==SCENES.UPGRADE then update_psystems() local newP=time()-CELEBRATETIME>250 if (newP) then CELEBRATETIME=time() make_pc_ps(frnd(132)+XO+10,70) end elseif SCENE==SCENES.GAME then update_psystems() local movement=false for i,e in ipairs(Ents) do if updateEntity(e) then movement=true end end if not movement and not isTurnReady() then -- At PC devs for i,c in ipairs(Devs) do if c.atPC then local tt=mget(c.tx,c.ty) mset(c.tx,c.ty,tt+1) end end ArrayRemove(Devs, function (t,i,j) return not t[i].atPC end) ArrayRemove(Ents, function (t,i,j) return not t[i].atPC end) if not turnOver then endTurn() end end if (#SoundWaves>0) then updateSoundWaves() end if GSTATE==GSTATES.WON or GSTATE==GSTATES.SKIPPED then if time()-GSTATETIME>LEVELFINISHDELAY then if level ~= YMODEMINLEV-1 then level=level+1 loadLevel(false) setGameState(GSTATES.PLAY) else LEVEL_X,LEVEL_Y=0,0 SCENE=SCENES.UPGRADE end end elseif GSTATE==GSTATES.PLAY then if #Devs==0 then winLevel() elseif turnOver and turnsUsed==turnsMax then loseLevel() end end end end function draw() if SCENE==SCENES.JF1X then cls(1) map(0,0,30,17,-4,0,0) cprint('jf1x.com',129,2,false,1,true) elseif SCENE==SCENES.TITLE then cls(1) rect(XO,20,VIEW_W,37,2) map(180,119,6,2,XO+52,22,1) map(180,121,9,2,XO+44,40,1) spr(256,XO+64,66,0,3,0,0) cprint(menuCursor('Start',TMENU==TMENUS.START),102,4,false,1,true) if SAVEDLEVEL > 1 then cprint(menuCursor('Continue from Level '..SAVEDLEVEL,TMENU==TMENUS.CONTINUE),111,4,false,1,true) end cprint('(c) 2021 jf1x',129,2,false,1,true) elseif SCENE==SCENES.INTRO then cls(1) elseif SCENE==SCENES.UPGRADE then cls(1) local prFl=time()%1000<500 map(210,119,13,7,XO+24,7) spr(256,XO+29,23,0,4) print("EMPLOYEE ID",XO+46,10,4) print("Nick Baird",XO+66,27,4,false,1,true) print("MANAGER",XO+92,34,4,false,1,true) print("SENIOR",XO+66,34,tIf(prFl,4,3),false,1,true) print("X-Ploit Studios",XO+66,42,3,false,1,true) oprint("PROMOTION!",0,70,3,2,false,false,2,true) oprint("Diagonal yells unlocked!",0,85,4,2,false,false,1,true) local dx,dy=SCREEN_MIDW-43,SCREEN_MIDH+36 map(211,126,5,5,dx-16,dy-16,0) local sid=389+(time()%800)//100 spr(tIf(sid<393,263,256),dx,dy,0) spr(sid,dx+6,dy-6,0) spr(sid,dx-6,dy-6,0,1,1) spr(sid,dx-6,dy+6,0,1,0,2) spr(sid,dx+6,dy+6,0,1,0,1) spr(480,100,dy-6,0,1,0,0,2,2) spr(484,100,dy+6,0,1,0,0,2,2) oprint('Yell',114,dy-4,4,2,true,false,1) oprint('Change direction',114,dy+8,4,2,true,false,1) oprint('Press any button to continue',0,128,4,2,true,false,1,true) draw_psystems() elseif SCENE==SCENES.GAME then cls(1) --local t=tIf(BGSCRL,mod(time()/1000*24,48),0) --map(180,85,45,250,-t,-t,0) map(LEVELS[level][1],LEVELS[level][2],MAP_W,MAP_H,XO,0,0) for i,e in ipairs(Ents) do drawEntity(e) end for i,s in ipairs(SoundWaves) do drawSoundWave(s) end draw_psystems() elseif SCENE==SCENES.THEEND then cls(1) end -- Draw screen borders to maintain GB res at all times rect(0,0,XO,SCREEN_H,0) rect(240-XO,0,XO,SCREEN_H,0) end function menuCursor(str,active) local cursor=active and (time()-tMenuTime)%1000<500 return tIf(cursor,'> '..str..' <',str) end -- Entities function createEntity(type,tx,ty,facing) local e={ id=EID, type=type, anim=1,animS=time()+frnd(2000),frame=1, sprite=nil,facing=facing, tx=tx,x=tx*TS, ty=ty,y=ty*TS, } EID=EID+1 e.sprite=ANIMS[e.type][e.anim][e.frame] if type==ETYPE.PLAYER then e.yellTime=-YELLLINET elseif type==ETYPE.DEV then e.atPC=false e.travelDist=-1 e.vx=0;e.vy=0 end table.insert(Ents,e) return e end function updateEntity(e) local anim=ANIMS[e.type][e.anim] e.sprite=anim[1+((time()-e.animS)//64)%#anim] local wasMoving=e.isMoving e.isMoving=e.x~=e.tx*TS or e.y~=e.ty*TS if e.isMoving then setEntityAnim(e,ATYPE.RUN) else if e.type==ETYPE.DEV and e.anim==ATYPE.RUN and e.atPC then make_pc_ps(e.x+XO+4,e.y+4) sfx(49,'C-5',10,3) end setEntityAnim(e,ATYPE.IDLE,false,e.type==ETYPE.DEV) if e.type==ETYPE.PLAYER and wasMoving then yellChange=time()-400 end end if e.type==ETYPE.PLAYER and time()-Plr.yellTimee.flipTime and not e.isMoving then e.facing=tIf(e.facing==DIR.L,DIR.R,DIR.L) e.flipTime=time()+frnd(2500)+2500 end end if e.xe.tx*TS then e.x=e.x-MOVESPD[e.type] end if e.ye.ty*TS then e.y=e.y-MOVESPD[e.type] end return e.isMoving end function setEntityAnim(e,anim,resetA,rand) resetA = resetA or false rand = rand or false if e.anim == anim and not resetA then return end e.anim = anim e.frame = 1 e.sprite=ANIMS[e.type][e.anim][e.frame] e.animS = time()+tIf(rand,frnd(2000),0) end function drawEntity(e) spr(e.sprite,e.x-LEVEL_X*TS+XO,e.y-LEVEL_Y*TS,0,1,tIf(e.facing==DIR.L,1,0)) end -- /Entities -- Soundwaves function updateSoundWaves() for i,s in ipairs(SoundWaves) do updateSoundWave(s) end ArrayRemove(SoundWaves, function (t,i,j) return not t[i].dead end) end function updateSoundWave(s) s.x = s.x + s.vx * 1.5 s.y = s.y + s.vy * 1.5 if mget((s.x+4)//TS,(s.y+4)//TS)==0 then s.dead=true end end function drawSoundWave(s) spr(tIf(s.mode==YMODES.UDLR,265,266),s.x-LEVEL_X*TS+XO,s.y-LEVEL_Y*TS,0,1,0,s.rot) end -- /Soundwaves -- Turns function isTurnReady() --trace(turnOver) --trace(time()-turnEndTime) return turnOver and time()-turnEndTime > TURNDELAY end function consumeTurn(turns) turnOver=false turnsUsed=turnsUsed+turns turnTime=time() end function endTurn() turnOver=true turnEndTime=time() end -- /Turns -- Yelling function yell() Plr.yellTime=time() sfx(50,"A-3",15,3) timesYelledThisLevel=timesYelledThisLevel+1 lastYellType=yellMode -- Create soundwaves startSoundWaves(Plr.x,Plr.y,yellMode) -- get Devs in line from Boz local lineDevs={} if yellMode==YMODES.UDLR then lineDevs={[DIR.U]={},[DIR.D]={},[DIR.L]={},[DIR.R]={}} for i,c in ipairs(Devs) do if c.tx==Plr.tx and c.tyPlr.ty then tIns(lineDevs[DIR.D],c) elseif c.txPlr.tx and c.ty==Plr.ty then tIns(lineDevs[DIR.R],c) end end else lineDevs={[DIR.NE]={},[DIR.SE]={},[DIR.SW]={},[DIR.NW]={}} for i,c in ipairs(Devs) do if isDiag(Plr.tx,Plr.ty,c.tx,c.ty,DIR.NE) then tIns(lineDevs[DIR.NE],c) elseif isDiag(Plr.tx,Plr.ty,c.tx,c.ty,DIR.SE) then tIns(lineDevs[DIR.SE],c) elseif isDiag(Plr.tx,Plr.ty,c.tx,c.ty,DIR.SW) then tIns(lineDevs[DIR.SW],c) elseif isDiag(Plr.tx,Plr.ty,c.tx,c.ty,DIR.NW) then tIns(lineDevs[DIR.NW],c) end end end -- slide devs, starting from furthest away for k,l in pairs(lineDevs) do px,py,sortFn=getPushDeets(k,yellMode) table.sort(l,sortFn) for i,c in ipairs(l) do slideDev(c,px,py,yellMode) end end end function getPushDeets(dir, mode) if mode==YMODES.UDLR then if dir==DIR.U then return 0,-1,function (a,b) return a.y < b.y end elseif dir==DIR.D then return 0,1,function (a,b) return a.y > b.y end elseif dir==DIR.L then return -1,0,function (a,b) return a.x < b.x end elseif dir==DIR.R then return 1,0,function (a,b) return a.x > b.x end end else if dir==DIR.NE then return 1,-1,function (a,b) return a.y < b.y end elseif dir==DIR.SE then return 1,1,function (a,b) return a.y > b.y end elseif dir==DIR.SW then return -1,1,function (a,b) return a.y > b.y end elseif dir==DIR.NW then return -1,-1,function (a,b) return a.y < b.y end end end end function isDiag(px,py,cx,cy,dir) local dx,dy=cx-px,cy-py if abs(dx)~=abs(dy) then return false end if dx>0 then return dir==tIf(dy>0,DIR.SE,DIR.NE) else return dir==tIf(dy>0,DIR.SW,DIR.NW) end end function slideDev(c,x,y) if x==-1 then c.facing=DIR.L elseif x==1 then c.facing=DIR.R end local lx,ly=c.tx+x,c.ty+y local isSolid,isDev,isPlr=solid(lx,ly) local isHole=fmget(lx,ly,TFLG.PC) while not isSolid and not isHole and not isPlr do lx=lx+x;ly=ly+y isSolid,isDev,isPlr=solid(lx,ly) isHole=fmget(lx,ly,TFLG.PC) end c.tx=lx;c.ty=ly if not isHole or isDev then c.tx=c.tx-x;c.ty=c.ty-y end if fmget(c.tx,c.ty,TFLG.PC) then c.atPC=true end end function startSoundWaves(x,y,mode) if mode==YMODES.UDLR then createSoundWave(x,y,0,-1,mode) createSoundWave(x,y,0,1,mode) createSoundWave(x,y,-1,0,mode) createSoundWave(x,y,1,0,mode) else createSoundWave(x,y,1,-1,mode) createSoundWave(x,y,1,1,mode) createSoundWave(x,y,-1,1,mode) createSoundWave(x,y,-1,-1,mode) end end function createSoundWave(x,y,vx,vy,mode) local sw={x=x,y=y,vx=vx,vy=vy,dead=false,px=Plr.tx,py=Plr.ty,mode=mode} if mode==YMODES.UDLR then if vx==1 then sw.rot=1 elseif vx==-1 then sw.rot=3 elseif vy==-1 then sw.rot=0 else sw.rot=2 end else if vx==1 and vy==-1 then sw.rot=0 elseif vx==1 and vy==1 then sw.rot=1 elseif vx==-1 and vy==1 then sw.rot=2 else sw.rot=3 end end tIns(SoundWaves,sw) end -- /Yelling -- Level function setGameState(gs) GSTATE=gs GSTATETIME=time() end function winLevel() timesYelled=timesYelled+timesYelledThisLevel timesYelledThisLevel=0 setGameState(GSTATES.WON) end function loseLevel() sfx(51,"A-2",30,3) timesYelledThisLevel=0 setGameState(GSTATES.GAMEOVER) end function resetLevel() timesYelledThisLevel=0 Plr.yellTime=time() yellMode=YMODES.UDLR loadLevel(true) setGameState(GSTATES.PLAY) end function solid(x,y) if isDevAt(x,y) then return true,true,false elseif fmget(x,y,TFLG.SOLID) then return true,false,false end return false,false,x==Plr.tx and y==Plr.ty end function isDevAt(x,y) for i,v in ipairs(Devs) do if x==v.tx and y==v.ty and v.vx==0 and v.vy==0 then return true end end return false end function surCubicle(x,y) local val=0 if fmget(x,y-1,TFLG.CUBICLE) then val=val+DIRB.U end if fmget(x,y+1,TFLG.CUBICLE) then val=val+DIRB.D end if fmget(x-1,y,TFLG.CUBICLE) then val=val+DIRB.L end if fmget(x+1,y,TFLG.CUBICLE) then val=val+DIRB.R end return val end function loadLevel(isReset) Player=nil;Devs={};Ents={};SoundWaves={} turnsUsed=0;turnOver=true;turnTime=time();turnEndTime=time() if LEVELS[level]==nil then SKIPSTR='You completed every level!' if SKIPS>9 then SKIPSTR=SKIPS..' level'..tIf(SKIPS==1,'','s')..' skipped.' elseif SKIPS>0 then SKIPSTR='' for sl=1,#LEVELS,1 do if LEVELS[sl][5] then SKIPSTR=SKIPSTR..tIf(SKIPSTR=='','',',')..sl end end SKIPSTR=SKIPS..' level'..tIf(SKIPS==1,'','s')..' skipped: '..SKIPSTR end SCENE=SCENES.THEEND return end if isReset then MEM_ATTEMPTS = MEM_ATTEMPTS + 1 if MEM_ATTEMPTS == 10 then MEM_ATTEMPTS = 1 end pmem(1, MEM_ATTEMPTS) else pmem(0, level) pmem(1, 1) pmem(10, timesYelled) end turnsMax=LEVELS[level][3] if LEVELDATA[level] == nil then loadMap() end Plr=createEntity(ETYPE.PLAYER,LEVELDATA[level].px,LEVELDATA[level].py,DIR.R) for i,d in ipairs(LEVELDATA[level].devs) do local dev=createEntity(ETYPE.DEV,d.x,d.y,tIf(frnd(100)<50,DIR.R,DIR.L)) dev.flipTime=time()+frnd(2500)+2500 tIns(Devs,dev) end for i,h in ipairs(LEVELDATA[level].PCs) do mset(h.x,h.y,PCSPR+tIf(h.co,32,0)) end LEVEL_X,LEVEL_Y=LEVELS[level][1],LEVELS[level][2] end function loadMap() local mx,my = LEVELS[level][1],LEVELS[level][2] maxYells=maxYells+LEVELS[level][3] LEVELDATA[level]={devs={},PCs={}} for y=my,my+MAP_H-1,1 do local yo=y%2 for x=mx,mx+MAP_W-1,1 do local tt=mget(x,y) local co=(x+yo)%2==0 if fget(tt,TFLG.CUBICLE) then mset(x,y,FSPR[surCubicle(x,y)]+tIf(co,4,0)) elseif tt==129 then mset(x,y,64+tIf(co,CHECKERB.O,0)); LEVELDATA[level].px=x; LEVELDATA[level].py=y; elseif tt==128 then mset(x,y,64+tIf(co,CHECKERB.O,0)); tIns(LEVELDATA[level].devs, {x=x,y=y}) elseif tt==PCSPR then tIns(LEVELDATA[level].PCs, {x=x,y=y,co=co}) end if tt>=CHECKERB.S and tt<=CHECKERB.E and co then mset(x,y,tt+CHECKERB.O) end end end end function fmget(x,y,t) return fget(mget(x,y),t) end -- /Level -- Text function oprint(t,x,y,c,oc,sf,fw,sc,centre) local w=print(t,0,-40,c,fw,sc,sf)+2 local cx=tIf(centre,XO+2+(VIEW_W-w)/2,x) if oc>0 then for tx=cx-1,cx+1,1 do for ty=y-1,y+1,1 do if tx~=0 and ty~=0 then print(t,tx,ty,oc,fw,sc,sf) end end end end --local w=print(t,0,-40,c,fw,sc,sf)+1 --rect(x-os-1,y-1,w,7*sc,12) return print(t,cx,y,c,fw,sc,sf)+2 end function bprint(t,t2,y,tc,rc,sc) sc=sc or 1 local w=print(t,0,-40,1,false,sc) local w2=print(t2,0,-40,1,false,sc,true) rect(0,y-6,SCREEN_W,20+sc*5,4) rect(0,y-5,SCREEN_W,18+sc*5,rc) print(t,SCREEN_MIDW-w//2,y,tc,false,sc) print(t2,SCREEN_MIDW-w2//2,y+8,tc,false,sc,true) end function cprint(text,y,col,fix,sc,sml) local w=print(text,0,-100,col,fix,sc,sml) print(text,XO+(VIEW_W-w)/2,y,col,fix,sc,sml) end -- /Text -- Math floor=math.floor ceil=math.ceil max=math.max min=math.min rand=math.random abs=math.abs fmod=math.fmod function mod(a,b) a=floor(a);return a-((a//b)*b) end function frnd(max) return rand()*max end function lerp(a,b,t)return (1-t)*a+t*b end -- /Math -- Tables function tIns(t,a) table.insert(t,a) end function ArrayRemove(t, fnKeep) -- thanks https://stackoverflow.com/a/53038524 local j, n = 1, #t; for i=1,n do if (fnKeep(t, i, j)) then if (i ~= j) then t[j] = t[i]; t[i] = nil; end j = j + 1; else t[i] = nil; end end return t; end -- /Tables -- List stuff function any(list, func) for i,v in ipairs(list) do if func(v) then return true end end return false end -- /List -- Things that should be in lua function tIf(c,t,f) return c and t or f end -- /Things --=== -- PARTICLES --=== function make_psystem(minlife, maxlife, minstartsize, maxstartsize, minendsize, maxendsize) local ps = { autoremove = true, minlife = minlife, maxlife = maxlife, minstartsize = minstartsize, maxstartsize = maxstartsize, minendsize = minendsize, maxendsize = maxendsize, particles = {}, emittimers = {}, emitters = {}, drawfuncs = {}, affectors = {}, } table.insert(particle_systems, ps) return ps end function update_psystems() local timenow = time() for key,ps in pairs(particle_systems) do update_ps(ps, timenow) end end function update_ps(ps, timenow) for key,et in pairs(ps.emittimers) do local keep = et.timerfunc(ps, et.params) if (keep==false) then table.remove(ps.emittimers, key) end end for key,p in pairs(ps.particles) do p.phase = (timenow-p.starttime)/(p.deathtime-p.starttime) for key,a in pairs(ps.affectors) do a.affectfunc(p, a.params) end p.x = p.x + p.vx p.y = p.y + p.vy local dead = false if (p.x-LEVEL_X*TS<0 or p.x-LEVEL_X*TS>SCREEN_W or p.y-LEVEL_Y*TS<0 or p.y-LEVEL_Y*TS>SCREEN_H) then dead = true end if (timenow>=p.deathtime) then dead = true end if (dead==true) then table.remove(ps.particles, key) end end if (ps.autoremove==true and #ps.particles<=0) then local psidx = -1 for pskey,pps in pairs(particle_systems) do if pps==ps then table.remove(particle_systems, pskey) return end end end end function draw_ps(ps, params) for key,df in pairs(ps.drawfuncs) do df.drawfunc(ps, df.params) end end function draw_psystems() for key,ps in pairs(particle_systems) do draw_ps(ps) end end function emit_particle(psystem) local p = {} local ecount = nil local e = psystem.emitters[math.random(#psystem.emitters)] e.emitfunc(p, e.params) p.phase = 0 p.starttime = time() p.deathtime = time()+frnd(psystem.maxlife-psystem.minlife)+psystem.minlife p.startsize = frnd(psystem.maxstartsize-psystem.minstartsize)+psystem.minstartsize p.endsize = frnd(psystem.maxendsize-psystem.minendsize)+psystem.minendsize table.insert(psystem.particles, p) end function frnd(max) return math.random()*max end -- EMIT TIMERS function emittimer_burst(ps, params) for i=1,params.num do emit_particle(ps) end return false end -- EMITTERS function emitter_point(p, params) p.x = params.x p.y = params.y p.vx = frnd(params.maxstartvx-params.minstartvx)+params.minstartvx p.vy = frnd(params.maxstartvy-params.minstartvy)+params.minstartvy end -- AFFECTORS function affect_force(p, params) p.vx = p.vx + params.fx p.vy = p.vy + params.fy end -- DRAW function draw_ps_fillcirc(ps, params) for key,p in pairs(ps.particles) do c = math.floor(p.phase*#params.colors)+1 r = (1-p.phase)*p.startsize+p.phase*p.endsize if r >= 1 then circ(p.x-LEVEL_X*TS,p.y-LEVEL_Y*TS,r,params.colors[c]) else pix(p.x-LEVEL_X*TS,p.y-LEVEL_Y*TS,params.colors[c]) end end end -- SYSTEMS function make_pc_ps(ex,ey) local ps = make_psystem(300,700,0.5,0.5,0.5,1) local minvx,maxvx = -0.6,0.6 table.insert(ps.emittimers, { timerfunc = emittimer_burst, params = { num = 15 } } ) table.insert(ps.emitters, { emitfunc = emitter_point, params = { x = ex, y = ey, minstartvx = minvx, maxstartvx = maxvx, minstartvy = -0.7, maxstartvy=-0.2 } } ) table.insert(ps.drawfuncs, { drawfunc = draw_ps_fillcirc, params = { colors = {3,3,4} } } ) table.insert(ps.affectors, { affectfunc = affect_force, params = { fx = 0, fy = 0 } } ) end