Hello so im working on something its a game that is similar to a game code: function _init() cartdata("heratrog_dkd_1") stt,flk,fri,sclst,ckr1,ckr0,mnulr,opstg,oplvl=unspl"0,0,0,0,-23131,23130,0,1,1" btp=spp"1=56|2=57|3=58|4=59|50=16|51=17|52=27|53=22|54=32|55=33|56=34|57=93|58=94|90=18|91=19|92=92" seq={split"1,4",split"1,3,4",split"1,2,3,4",split"1,2,1,3,4",split"1,2,1,3,1,4"} ?"@56000003!5680  \0\0\0  \0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0 \0\0\0 \0\0\0 \0\0\0\0\0\0\0 \0 \0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0 \n\t\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0 \0\0\0\0\0\0\0\n\0\0\0\0\0\0  \0\0\0  \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\t\t\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\t\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\n\0\0\0\0\0\0\n\n\0\0\0\n\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" poke(0x5f58,0x81) --custom font poke(0x5f5c,-1) --btnp once ?"!5f11😐☉웃░\t\n◆ \r" rstshk() mnuflk() sfx"1" sfx"9" music"24" end function start() --todo:test height -- mds=spp"gon=1|lvl=5|stp=5|ntr=0|tmr=500|sco=0|sca=0|ctr=0|fem=0|liv=2" -- mds.lvl=5 mds=spp"gon=1|lvl=1|stp=0|ntr=1|tmr=500|sco=0|sca=0|ctr=0|fem=0|liv=2" mds.lvl=oplvl mds.fem=dget(11) if opstg>1 then mds.stp,mds.ntr=1,0 respawn(opstg) else nextstage() end --xlp=50--todo:test end function respawn(stg) mds.ctr=0 xlp,xtc=0 --#sts then --lvl advance mds.lvl+=1 mds.stp=1 end sts=seq[min(5,mds.lvl)] respawn(sts[mds.stp]) end end function _update60() fri=(fri+1)%80--60 if dget(10)&1==0 then flk=fri%2==0 and 0 or 1 else flk=0 end -- if(edt)upd_editor() return if mds then ------- fri%60==0 if not ison"ctr" and fri==79 and not cstg.hht then mds.tmr-=1 if(mds.tmr==10)stgmusic() end if(mds.tmr<0)hit() mds.tmr=0 if ison"gon" then --if(mds.tmr<1) return gameover() if cstg.hht then boom(cstg.hht) if(not alv())cstg.hr:upd() elseif ison"ctr" then endstage() else cstg:upd() end if pts then pts.tmr-=1 if(pts.tmr<0)pts=nil end if mds.sca>0 then mds.sco+=1 mds.sca-=1 if(mds.sco==70)xtralife() --if(mds.sco%3000==0)xtralife() end if xtc then xtc+=.05 if(xtc>12)xtc=nil end else mds.ctr+=1 updgmvr() end else --intro -- if(t()==3) if btnp(🅾️) then if mnulr==0 then start() else mnulr=0 end end -- if btnp(❎) then -- if not edt then -- init_editor() -- mnulr=0 -- end -- end if(btnp(⬅️)) mnulr-=1 if(btnp(➡️)) mnulr+=1 if btnp(⬆️) then if(mnulr>0) oplvl+=1 if(mnulr<0) opstg+=1 elseif btnp(⬇️) then if(mnulr>0) oplvl-=1 if(mnulr<0) opstg-=1 if(mnulr==0) sfx"1" dset(11,dget(11)^^1) end mnulr=mid(-1,mnulr,1) oplvl=mid(1,oplvl,8) opstg=mid(1,opstg,4) end end function sco(n) mds.sca+=n end function ptsco(n,ob,ox,oy) ox=ox or 0 oy=oy or 0 sco(n) pts=spp("x=,|y=,|n=,|tmr=70",ob.x+ox,ob.y+oy,n) sfx"8" end function _draw() cls() pal(12,flk>0 and 11 or 12,1) -- if(edt)drw_editor() return local sco=sclst if(shk>0) scrshk() if mds then drwbonus(90,0) cstg:drw() if(pts)mnsco(pts,pts.n) sco=smod"sco" -- if(ison"liv")?"\*"..xn(mds.liv)..aastr";",12,1,7 if(xtc and flr(xtc)%2==0) ?(flk==0 and "b0" or "")..aastr"extra life",36,116,7 if not ison"gon" and ison"ctr" then drwgmvr() end ?aastr"1up",0,0,8 --todo: -- if(flk>0)rectfill(18,0,53,5,0) if(flk>0)cmds"rectfill_18_0_53_5_0" ?num0(sco),18,0,7 -- ?num0(12345),12,0,7 ?aastr("l="..(mds.lvl<10 and "0" or ""))..mds.lvl,72,0,1 for i=0,mds.liv-1 do spr(dget(11)&1==1 and 119 or 55,i*6,6) end -- if(edt)drw_editor() else titlescr() ?aastr"1up",24,1,8 ?num0(sco),12,7,7 ?aastr"high score",62,1,8 ?num0(dget(0)),74,7,7 local fem=dget(11)&1==1 if mnulr==0 then ?aastr" push button",14,110,flk==0 and 7 or 14 ?"⬅️b \-h 8🅾️e 9➡️",2,110,10 -- ?"⬅️s 9➡️\^jhq\-3 8🅾️",0,110,10 ?aastr"by heracleum}trog",14,122,flk==0 and 1 or 2 mntxt("st"..opstg,0,116,10) mntxt("lv"..oplvl,119,116,9) mntxt("starring:",36,74,7) ?"⬇️\n\n\n\n"..aastr(fem and "smalline" or "minio"),26,74,12 spr(fem and 70 or 68,36,80,2,2) if btn(⬇️) then cmds"spr_139_74_70_5_4_1\nspr_128_91_102_2_1_1" else cmds"spr_139_66_70_5_4\nspr_128_73_102_2_1" end --sspr_119_92_9_3_73_10_9_3_true]] -- spr(139,65,70,5,4) -- sspr(119,92,9,3,73,102,9,3,1) elseif mnulr<0 then local st=opstg.." - "..({"barrels","factory","elevators","rivets"})[opstg] ?aastr"starting stage \n"..aastr(st),20,110,10 ?"⬆️\n⬇️s ➡️",0,110 elseif mnulr>0 then ?aastr"difficulty\nlevel "..aastr(tostr(oplvl)),20,110,9 ?"⬆️\n⬇️s ⬅️",0,110 end end end function updgmvr() local ct=mds.ctr if ct==200 then mds,nws,tsc=nil --game reset music"24" -- ?"!5f11\t\n \r" elseif ct==10 then if mds.sco > dget"0" then dset(0,mds.sco) nws=true end sclst=mds.sco end end function mnuflk() menuitem(2,"flicker: "..(dget"10"&1==1 and"off" or"on"),function() dset(10,dget"10"^^1) mnuflk() return true end) end function xtralife() mds.liv+=1 sfx"31" xtc=0 end function alv() if(not cstg.hr)return true --todo:just for intro, avoid it? return cstg.hr.ded==0 end function hit(l) if alv() then local hr=cstg.hr hr.ded=l or 250--180 hr.ani=0--1 cstg.hht=hr sfx"1" end end function iscutscene() return ison"ctr" and alv() end function gameover() mds.gon,mds.ctr=0,1 end function newlife() mds.liv-=1 if mds.liv<0 then gameover() else return true end end -->8 --stages function setstage(n) cstg=newstge(n) stgmusic() end function newstge(n) cmds"pal_9_9_1" --fix after stg4 mds.tmr=40+min(40,mds.lvl*10) if n==0 then -- local s0="\0Xd!ャ\"d+ャ\"dF\r2\r" local s0="d!ャ\"d+ャ\"dF\r2\r\0x" local ob=spp"stg=0|x=0|acs=|bls=|cpx=51|cpy=5" ob.kg=spp"x=61|y=13|w=16|h=16|spr=238|tmr=30|inc=.2|brt=40|wld=0" ob.upd=function(ob) -- mds.ctr=1 end ob.drw=drwstg0 impadd(s0,ob.bls) return ob elseif n==1 then local s1="3\0\r4$4`Z\0X\0{HXh21(08/H.X-h,x+\0>?@(A8BHCXDhEXW(V8UHTXShRxQ\0def(g8hHiXjhkHzXyhxxwd!ャ\"d+ャ\"dABd-gdg\rdgE\rdgk\rd]-d2\rdX\rd7Ud!@d'0d0dF\r2\rf,n\nf I\n f\\7\nf/$\n" local ob=spp"stg=1|x=0|acs=|bls=|cpx=51|cpy=5" ob.kg=spp"x=16|y=13|w=16|h=16|spr=238|tmr=30|inc=.2|brt=40|wld=0" -- ob.hr=newhero(68,32) ob.hr=newhero(18,115) add(ob.acs,ob.hr) ob.upd=updstg1 ob.drw=drwstg1 ob.oil=newblok(unspl"50,8,114,9,9") ob.oil.cnt=0 impadd(s1,ob.bls) -- impadd("f,n\nf I\n f\\7\n f/$\n",ob.bls) --BROKEN LADDERS -- music(0,2000) -- music"5" return ob elseif n==2 then local s2="\\6>dG\rd!ワ&d,ワ&\0{█e~_M%M1ME5Bヲ5B~d\r5d\red,5d,edK5dKedl5dled$MdOMddq8pD 7$E6Bs4 <4;T3\rf\"\n fp\"\n " local ob=spp"stg=2|x=0|acs=|bls=|cys=|lds=|ldc=6|bnc=3|cpx=51|cpy=5" ob.kg=spp"x=16|y=13|w=16|h=16|spr=238|tmr=0|inc=.2|brt=40|wld=0" ob.hr=newhero(26,115) add(ob.acs,ob.hr) ob.upd=updstg2 ob.drw=drwstg2 impadd(s2,ob.bls) ob.oil=newblok(unspl"50,59,53,9,9") -- ob.oil.cnt=0 ob.oil.cnt,ob.oil.flm,ob.oil.tmr=0,1,60 --typ4 to conveyors local id,tmp=1,true for bl in all(ob.bls) do if bl.typ==4 then bl.cvy=spp("cnt=400|id=,",id) bl.cvy.lft=tmp tmp=not tmp id+=1 add(ob.cys,bl) end end --moving ladders add(ob.lds,spp"typ=101|x=7|y=37|w=10|h=10") add(ob.lds,spp"typ=101|x=112|y=37|w=10|h=10") -- music(0,2000) return ob elseif n==3 then local s3="\0{█\0`\0009\r\0q\r\0Z\rd9!dZ7 T q 9d!9,7. 7L 7j \"ed,9,3\rMG ZK gO tS g<ds&I4\rDq\rUm bh odZ/ g* t& dYdf<dsSdG\rdL46s7(]81 d!ワ&d,ワ&Z [x Z7 [7x " local ob=spp"stg=3|x=0|acs=|bls=|cpx=51|cpy=5" ob.kg=spp"x=16|y=13|w=16|h=16|spr=238|tmr=0|inc=.2|brt=40|wld=0" ob.hr=newhero(4,105) add(ob.acs,ob.hr) add(ob.acs,newfire(40,40,3)) add(ob.acs,newfire(120,30,3)) add(ob.acs,newspng(-40,20,1)) add(ob.acs,newspng(-100,20,2)) ob.upd=updstg3 ob.drw=drwstg3 impadd(s3,ob.bls) return ob elseif n==4 then -- local s4="H #@ 9@ O@\0{█5_\"d# 5_8d95_NdO5_dde e@di#dm9dqOduedX#4<)dTOd;9d;ed #d$O#  9Oed#d 9dOde4?5\"585N5d8 6Js7q]" local s4=" @$#8$98$O8\0{█5[\"`#5[8`95[N`O5[d`e$e8di#dm9dqOduedT#4<)dPOd;9d;ed$#d(O# 9Oed#d 9dOde4?5\"585N5d8 6Js7q]" local ob=spp"stg=4|x=0|acs=|bls=|cpx=60|cpy=6|cpf=1|spw=|ldc=9|bnc=1|rvt=8"--8 ob.kg=spp"x=56|y=19|w=16|h=16|spr=238|tmr=0|inc=.2|brt=40|wld=0" ob.hr=newhero(24,115) add(ob.acs,ob.hr) ob.upd=updstg4 ob.drw=drwstg4 impadd(s4,ob.bls) --firefoxes spawn doors impadd("g\0Gg◜]gョsgsg~]g|Gg1gx1",ob.spw) ob.spw.tmr,ob.spw.cnt=200,0 return ob end end function updstg1(ob) local hr=ob.hr citr8(ob.acs,"upd") --todo:proper spawn -- if rnd()<.005 then -- add(ob.acs,newbarl(24,0,rnd({1,1,1,1,1,2}))) -- end -- ob.kg=spp"x=0|y=0|spr=238| --tmr=0|inc=.2|brt=10|wld=0" local kg,trw=ob.kg kg.tmr+=kg.inc if kg.tmr\1==kg.brt-4 and (#ob.acs==1 or rnd()<.01+mds.lvl/1000) then --/1000 trw=true end if kg.tmr>=kg.brt or trw then local brl=newbarl(kg.x+18,kg.y+8,kg.wld<1 and 2 or 1) if trw then --thrown brl.x,brl.y,brl.lft=kg.x+4,kg.y+12,true local tdir=mds.lvl==1 and 0 or .48 if(brl.typ==1)tdir=(ob.hr.x-20)/150 -- if(brl.typ==1)tdir=(ob.hr.x+100-ob.hr.y)/150 brl.jmp=spp("dx=,|dy=.4|grv=.03|fll=1",tdir) end add(ob.acs,brl) if kg.wld<1 then kg.wld=7 else kg.wld-=1 end --todo:temp. fix rate by lvl kg.tmr=min(30,rnd"30"\1) --todo:this kg.tmr=rnd(10+mds.lvl)\1 end local oil=ob.oil if oil.flm then oil.flm-=.05 if(oil.flm<=0)oil.flm+=1 end if(hr.y<6)music"7" endstage() end function updstg2(ob) local hr=ob.hr for bl in all(ob.cys) do local cvy,ikg=bl.cvy,bl.y<40 --id=4 cvy.cnt-=1 if cvy.cnt<=0 then cvy.cnt=400+(ikg and 0 or rnd"200"\1) cvy.lft=not cvy.lft end local tmp=bl.cvy.lft and -.2 or .2 if ikg then ob.kg.x+=tmp else if cvy.id>1 then --2,3 local ld=ob.lds[cvy.id-1] ld.y=mid(34,ld.y+tmp,43) if hr.y>21 and hr.y<37 and tmp>0 then --bring hero down with ladder if(hr.x==ld.x+1) hr.y=max(ld.y-9,hr.y) end end if cvy.cnt%150==0 and rnd()<.5 then local pie=newcpie(cvy.lft and bl.x+bl.w+2 or bl.x-8,bl.y-6,bl) if(pie.x<10 or pie.x>110)add(cstg.acs,pie) end end end citr8(ob.acs,"upd") local oil=ob.oil oil.tmr-=1 if oil.tmr<=0 then --spawn fire local wfr=newfire(oil.x,oil.y-3,3) wfr.jmp=spp("dx=,|dy=-1|grv=.04",rnd()<.5 and -.25 or .25) if oil.cnt<5 then --4+mds.lvl add(cstg.acs,wfr) oil.cnt+=1 end oil.flm=4 oil.tmr=oil.cnt*80+rnd"100"\1 elseif oil.tmr%100==0 then oil.flm=3 end if oil.flm then oil.flm-=.05 if(oil.flm<=0)oil.flm+=1 end if(hr.y<22)music"7" endstage() end function updstg3(ob) local hr=ob.hr citr8(ob.acs,"upd") local lf=newbox(unspl"21,32,2,90") for _,bl in ipairs(cstg.bls) do if cllbox(bl,lf) and bl.w==9 and bl.typ==1 then bl.y-=.3 if(bl.ylf.y+lf.h)bl.y=lf.y end end if(hr.y<6)music"7" endstage() if(hr.y>114)hit() end function updstg4(ob) local hr=ob.hr citr8(ob.acs,"upd") local spw,tmp=ob.spw,99 spw.tmr-=1 if spw.tmr<=0 then spw.tmr=200 tmp=rnd(4)\1 --0-3 end for s in all(spw) do --hero wall jump local hj,sl=hr.jmp,s.x<64 if(hj and hj.dx!=0 and cllbox(hr.hb,s))wallbnc(hr,sl) if (sl and hr.x>=64) or (not sl and hr.x<64) then if tmp==0 then --spawn fire local wfr=newfire(s.x+(sl and 5 or -10),s.y,4) --wfr.jmp=spp"dx=.25|dy=-1|grv=.04" if spw.cnt<5 then --min(8,4+mds.lvl) add(cstg.acs,wfr) spw.cnt+=1 end tmp=4 else tmp-=1 end end end --rivets check if hr.jmp and not hr.rvt then local hb=newobox(hr,"3,7,2,7") for bl in all(ob.bls) do if(bl.typ==53 and cllbox(hb,bl))bl.lft=hr.lft hr.rvt=bl end end --test: -- if ob.rvt<7 then if ob.rvt<1 then sfx(8,-2) music"13" endstage() end end function stgmusic() if(not alv()) return local stg=cstg.stg if smod"tmr"<=10 then music"9" else --if stg!=3 then music(split"5,23,-1,22"[stg]) -- elseif stg==1 then -- music"5" end end function endstage() local hr,kg=cstg.hr,cstg.kg if not ison"ctr" and hr then --stg 1-3 cstg.acs={hr} --remove other sprites cstg.hrt=newblok(unspl"57,61,1,8,8") add(cstg.acs,cstg.hrt) if(cstg.stg<4)hr.spr,hr.lft=35,true end mds.ctr+=1 local ctr=mds.ctr if cstg.stg==0 then if ctr==2 then kg.clb=-93 elseif ctr<300 then if(kg.clb<-18 and ctr%10==0)kg.clb+=3 elseif ctr<360 then kg.y-=(340-ctr)/40 elseif ctr==360 then kg.tmr,kg.y,kg.clb=0,13 elseif ctr==362 then cstg.bls[5].w=88 elseif ctr>382 and ctr<537 then kg.x-=.28 kg.y=13-abs(sin(kg.x/18))*3+.7 elseif ctr==801 then music"4" elseif ctr>=1000 then nextstage(true) end if(ctr>30 and ctr<800 and btnp()>0)mds.ctr=800 elseif cstg.stg<4 then if ctr<60 then kg.x,kg.tmr=21,0 elseif ctr<61 then kg.x,kg.clb=34,0 elseif ctr==320 then sco(mds.tmr) --bonus elseif ctr==400 then nextstage() else if(ctr%20==0)kg.clb+=3 if(kg.clb==12)cstg.hrt.typ=58 --cstg.acs[#cstg.acs].typ=58 end else --rivets ending if ctr==280 then music(mds.lvl%2==0 and 19 or 16) -- elseif ctr==280 then sfx"1" elseif ctr==440 then sco(mds.tmr) --bonus elseif ctr==720 then nextstage() end end end --...=x,y,w,h function newblok(typ,...) local ob=newbox(...) --spp"w=8|h=8|spr=36|ded=0|ani=1|vni=11|vnh=-1|atk=-1" ob.typ=typ if typ>=100 and typ<=101 then ob.clmb=true end -- ob.upd=updblok ob.drw=drwblok return ob end -->8 --actors function walk(ob,a) if not ob.jmp then ob.ani=(ob.ani+.2)%4 --+abs(a) ob.spr=(split"35,36,35,37")[flr(ob.ani+1)] ob.x+=a ob.lft=(a<0) -- if(ob.x%6<1)sfx(60,3,ob.x%20,8) -- if(ob.x%3<1) -- sfx(60,3,ob.ani*4,4) if(ob.x%4<1) sfx(7,3,(ob.x\4*4)%20,4) end end function climb(ob,a) local ld,isblk=ob.ldr if ld then ob.y-=a --.5 -- local hb=newbox(ob.x,ob.y+7,8,4) local hb=newobox(ob,"0,7,8,4") if a>0 then for bl in all(cstg.bls) do if(bl.typ==102 and cllbox(bl,hb)) isblk=true break end end if isblk and cstg.lds then--moving ladders -- if ob.x<64 then if(cllbox(cstg.lds[ob.x<64 and 1 or 2],hb)) isblk=false -- else -- if(cllbox(cstg.lds[2],hb)) isblk=false -- end end if isblk then ob.y+=a --step back else if(ob.y%8<1) sfx(7,3,(ob.y\4*4)%16,4) -- if(ob.y%8<1)sfx(60,3,0,8)--ob.ani*2,4) if ob.y>=ld.y-3 then ob.ani=(ob.ani+a/2)%2 ob.spr=38 ob.lft=ob.ani<1 if(ob.y>ld.y+ld.h-8)ob.y,ob.spr,ob.ldr=ld.y+ld.h-8,41 --bl.x+5 then ob:walk(-.4) --ease else ob.ldr=bl -- ob.x=bl.x -- ob.ani=up and 0 or 5 -- return end elseif bl.typ==102 and not up and ob.ldr and cllbox(bl,ob.ldr) then ob.ldr=nil --no down on broken end end if ob.ldr then ob.x=ob.ldr.x ob.ani=up and 0 or 5 end end function injump() local hr=cstg.hr if(hr.jmp) return hr.jmp=spp"dx=.25|dy=-.8|grv=.04" -- hr.jmp=spp"dx=.5|dy=-.75|grv=.04" if (hr.lft) hr.jmp.dx*=-1 if(btn()&3==0) hr.jmp.dx=0 --up if no dir hr.spr=31 sfx"9" end function newhero(x,y) local ob=spp"w=8|h=8|spr=35|ded=0|ani=11|pvy=128" ob.x,ob.y=x,y ob.upd=updhero ob.drw=drwhero ob.cll=cllhero ob.walk=walk return ob end function cllhero(ob,bl) if bl.typ==52 and not ob.hrm then ob.hmr=spp"w=8|h=7|spr=27|ded=500|ani=0" music"6" del(cstg.bls,bl) elseif not ob.jmp and has(split"54,55,56",bl.typ) then ptsco((split"3,5,8")[min(mds.lvl,3)],bl) --ptsco(5,bl) del(cstg.bls,bl) end end function updhero(ob) local stg=cstg.stg -- local hb=newbox(ob.x+3,ob.y+6,2,2) -- local hg=newbox(ob.x+3,ob.y+8,2,2) --hero move local hr=ob -- ob.hb=newobox(ob,"2,0,4,8") ob.hb=newobox(ob,ob.jmp and "2,0,4,7" or "2,0,4,8") if alv() then if ob.inj then ob.inj-=1 if(ob.inj<0)ob.inj=nil end if(btnp(🅾️))ob.inj=10 if ob.lnd then ob.spr=51 elseif ob.spr==51 then ob.spr=35 end if hr.ldr then local ld=ob.ldr if btn(⬆️) or (ob.inj and ob.y0 then --ease exit if l/r if(ob.y>ld.y+ld.h-10)climb(hr,-.2) if(ob.yob.pvy+1) jp.dx=0 --fall straight down -- if(ob.y>ob.pvy+1.5) jp.dx=0 --fall straight down if (ob.x<-3 or ob.x>123)wallbnc(hr,ob.x<-3) --jp.dx*=-1 ob.lft=not ob.lft --temp if(ob.y>116)ob.y,land=116,true if(hr.hmr) ob.hmr.x,ob.hmr.y=ob.x+1,ob.y-7 --jump apogee pts check if not jp.apg and jp.dy<0 and jp.dy>-.1 then --todo:optim make local jp.apg=newobox(ob,"-4,9,16,6") local cnt=0 for ac in all(cstg.acs) do if(cllbox(ac,jp.apg))cnt+=1 end --jump scoring if(cnt>0) ptsco((split"1,3,5,8")[min(cnt,4)],jp.apg,3,7) end else ob.x=mid(-2,ob.x,122) if(ob.pvy-ob.y<-11) hit() return --fall from height ob.pvy=ob.y end if ob.rvt and ((ob.xob.rvt.x+1 and not ob.rvt.lft)) then del(cstg.bls,ob.rvt) ptsco(1,ob.rvt,-2,8) ob.rvt=nil cstg.rvt-=1 end if(cllbox(cstg.kg,ob))hit() else ob.ded-=1 if(ob.ded==220) music"11" if ob.ded>100 and ob.ded<210 then ob.ani=(ob.ani+.15)%4 ob.spr=52+ob.ani%2 elseif ob.ded<=100 then ob.spr=54 end if alv() then if newlife() then mds.stp-=1 nextstage() else ob.ded=1 --todo:useless? end end end end function wallbnc(hr,sl) local hj=hr.jmp if hj then hj.dx=sl and .25 or -.25 hr.lft=not sl hj.dy=hj.dy<0 and hj.dy or -hj.dy end end function objonblks(ob,hb,hg) hb=hb or newobox(ob,"3,"..ob.h-2 ..",2,2") --+6 hg=hg or newobox(ob,"3,"..ob.h..",2,2") --+8 if ob.lnd then --just landed ob.lnd-=1 if(ob.lnd<=0) ob.lnd=nil end -- if ob.ild then --just on ladder -- ob.ild-=1 -- if(ob.ild<=0) ob.lft,ob.ild=not ob.lft -- end if ob.jmp then -- local land=false local jp,land=ob.jmp jp.dy+=1*jp.grv ob.x+=jp.dx ob.y+=min(2,jp.dy) if jp.dy>0 then for k,bl in ipairs(cstg.bls) do if (bl.typ<50 or bl.typ==53) and hb.y105 then jp.dx,jp.dy,jp.fll=-.3,1.1 else jp.dy=.2 -- -=.2 --slight bounce falling if ob.typ==1 then --wild change if (jp.dx>0 and cstg.hr.x=ob.x) then jp.dx*=-1 end end end end if not jp.fll then land=true ob.y=bl.y-ob.h ob.lnd=3 end break elseif ob.cll and cllbox(bl,hb) then ob:cll(bl) end end end -- if land then if jp.dy>1 then if ob==cstg.hr then --if(jp.dy>1.5)ob.ded=100 ob.jmp=nil else jp.dy=-.4 -- -.5 --barrels end else ob.jmp=nil end end elseif not ob.ldr then --check ground -- if(ob.spr==51)ob.spr=35 --end landing spr local grnd=false for k,bl in ipairs(cstg.bls) do if (bl.typ<50 or bl.typ==53) and hb.y=lh then --todo:-3 check offset ob.ani=(ob.ani+a/2)%2 if ob.y>lh+ld.h then ob.y,ob.ldr=lh+ld.h --ld.y+ld.h-ob.h --bl.x+5 then ---- ob.x-=ob.spd or .6 --ease else ob.ldr=bl ob.x=bl.x --ob.lft=not ob.lft ob.prvdir=(ob.lft and 0 or 1) end end end end end function boom(ob) if ob==cstg.hr then if ob.ded==210 then --remove all sprites cstg.acs={ob} end return end --ob.ded-=1 ob.spr=(split"23,24,23,24,23,24,23,23,24,24,25,25,26")[min(13,flr(ob.ani+1))] ob.ani+=.175--.125 if ob.ani>13 then ptsco(ob.typ>1 and rnd({3,5,8}) or 3,ob) del(cstg.acs,ob) cstg.hht=nil if(ob.typ==3) cstg.oil.cnt-=1 if(ob.typ==4) cstg.spw.cnt-=1 end end function herohit(ob,hb) local hrhb=cstg.hr.hb if(not hrhb)return if(cllbox(hrhb,newobox(ob,hb)))hit() end function hammerhit(ob) -- if not cstg.hht and cstg.hr.hmr and cllbox(ob,cstg.hr.hmr) then if not cstg.hht and cstg.hr.hmr and cllcirc(ob,cstg.hr.hmr) then sfx"61" ob.ded,ob.ani=1,0 cstg.hht=ob end end function newbarl(x,y,typ) local ob=spp"w=8|h=7|spr=1|ded=0|ani=1" ob.x,ob.y,ob.typ=x,y,typ ob.upd=updbarl ob.drw=drwbarl -- ob.walk=walk return ob end function updbarl(ob) -- local wzldr=ob.ldr local a=ob.lft and -.6 or .6 if ob.ded>0 then boom(ob) else hammerhit(ob) ob.ani=(ob.ani+a/4)%4 --ob.lft=(a<0) objonblks(ob) --sides if ob.jmp then if (ob.x\1==-4 or ob.x\1==124 and (ob.typ>1 or ob.y1 or (rnd()<.6 and ob.y105 then -- ob.jmp.fll=nil -- else ob.spr=(split"3,5,3,5")[flr(ob.ani+1)] -- end else ob.spr=1 end elseif ob.ldr then objonladder(ob,.6) ob.spr=(split"3,5,3,5")[flr(ob.ani+1)] else --roll ob.x+=a ob.spr=1 if((#cstg.acs<4 or rnd()<.15) and ob.y127 then del(cstg.acs,ob) end local hb,oil=newobox(ob,"8,3,2,4"), cstg.oil if cllbox(oil,hb) then del(cstg.acs,ob) if ob.typ==2 then --spawn fire local wfr=newfire(oil.x,oil.y-3,3) wfr.jmp=spp"dx=.25|dy=-1|grv=.04" if oil.cnt<4+mds.lvl then add(cstg.acs,wfr) oil.cnt+=1 end oil.flm=4 end end herohit(ob,"3,4,2,1") --3,4,2,1 end end function newfire(x,y,typ) local ob=spp"w=8|h=8|spr=9|ded=0|ani=1|tmr=100|dir=1|sty=1" ob.x,ob.y,ob.typ=x,y,typ ob.spd=min(.55,.2+rnd(mds.lvl/30)) -- .1-- ob.upd=updfire ob.drw=drwfire -- ob.walk=walk return ob end function updfire(ob) local a=ob.lft and -ob.spd or ob.spd if ob.ded>0 then boom(ob) else hammerhit(ob) herohit(ob,"3,3,2,3") ob.ani=(ob.ani+a/4)%2 objonblks(ob) --checks if ob.jmp then if (ob.jmp.jst)ob.jmp.dx*=-1 ob.lft=not ob.lft ob.x+=ob.lft and -1 or 1 ob.tmr=20 ----- if (ob.x\1==-4 or ob.x\1==124 or ob.jmp.jst)ob.jmp.dx*=-1 ob.lft=not ob.lft ob.x+=ob.lft and -1 or 1 --todo:fix falling off -- if (ob.jmp.jst) ob.dir=ob.jmp.dx<0 and 1 or 0 ob.jmp.jst=nil --dx*4 avoid falling off edges -- if (ob.jmp.jst)ob.x+=ob.jmp.dx*2 ob.jmp.jst=nil --dx*4 avoid falling off edges elseif ob.ldr then --if(ob.dir>1) objonladder(ob,ob.dir==2 and -ob.spd or ob.spd) ob.spr=9+flr(ob.ani) if(ob.y<16)ob.dir=3 else --move ob.tmr-=1 if ob.tmr<=0 then local hrblw=ob.y1)objonladder(ob,ob.dir==2 and -ob.spd or ob.spd) end -- if ob.x<-1 or ob.x>121 then -- ob.lft=not ob.lft -- end end end function newcpie(x,y,cvy) local ob=spp"w=11|h=6|spr=20|ded=0|ani=1|typ=5" ob.x,ob.y,ob.cvy=x,y,cvy ob.upd,ob.drw=updcpie,drwcpie return ob end function updcpie(ob) ob.lft=ob.cvy.cvy.lft local a=ob.lft and -.2 or .2 if ob.ded>0 then boom(ob) else hammerhit(ob) -- objonblks(ob) ob.x+=a if ob.xob.cvy.x+ob.cvy.w+3 then del(cstg.acs,ob) end -- if(cllbox(cstg.hr,newobox(ob,"2,3,3,3")))hit() herohit(ob,"1,3,5,3") end end function newspng(x,y,id) local ob=spp"w=7|h=7|spr=7|ded=0|ani=1|typ=6" ob.x,ob.y,ob.id=x,y,id ob.upd,ob.drw=updspng,drwspng return ob end function updspng(ob) ob.ani=(ob.ani+.05)%2 ob.spr=7+ob.ani\1 if ob.x<-8 then ob.x+=.25 elseif ob.y<26 then if not ob.jmp or ob.lnd then ob.jmp=spp"dx=1|dy=-1.8|grv=.16" if(ob.id==1)sfx"58" end objonblks(ob) else if(ob.id==1 and ob.y\1==27)sfx"59" ob.y+=2 if(ob.y>150)ob.x,ob.y,ob.jmp=-8+rnd(min(6,1+mds.lvl)),20 --8 --render function titlescr() cmds[[cls pal_9_9_1 camera_-16_-16 map_0_0_0_-8_9_4 map_3_4_22_0_8_3 map_10_4_75_0_2_3 clip_102_16_16_13 map_11_7_84_0_2_2 clip map_9_1_71_0_2_2 camera_-25_-44 map_0_7_0_0_6_3 map_0_10_-2_0_12_3 map_0_13_-4_0_12_3 camera]] slashn(54,17) slashn(69,45) end function slashn(x,y) clip(0,y-1,127,24) for i=0,14 do line(x,y+i-6,x+9,y+i+12,i<7 and 10 or 9) end clip() end function drwbonus() if(cstg.stg==0)return local rd=cstg.bnc or 8 pal(8,rd==8 and flk==1 and 14 or rd) pal(12,cstg.ldc or 12) rectfill(98-flk,0,126+flk,14,12) cmds[[ rectfill_97_1_127_13_12 rectfill_98_1_126_13_0 rectfill_99_0_125_1_0 rect_99_6_125_12_8 spr_197_100_0_3.2_1 pal_8_8]] local tm=smod"tmr" ?num0(tm,1),tm<10 and 107 or 101,7,tm<10 and 8 or 12 pal(12,12) end function mnsco(o,n) -- local osx,ox=scx(o)-5,o.x-5 local ox,oy=o.x-2,o.y-3 for i=6,11 do --6,15 clip(ox+i,oy,1,5) ?num0(n,0),ox-i+6,oy,7 clip() ?aastr(tostr(n)),ox+1,oy end end function mntxt(t,x,y,c) for i=0,#t*3 do clip(x+i,y,1,5) ?aastr(t),x-i,y,c clip() end end function drwstg1(ob) citr8(ob.bls,"drw") citr8(ob.acs,"drw") local kg=ob.kg local krt=kg.brt -- local krt,ksp,kox=kg.brt,kg.spr,0 if kg.tmr>krt-3 then -- ksp,kox=235,-4 spr(kg.wld<1 and 2 or 1,kg.x+17,kg.y+8) spr(235,kg.x-1,kg.y,3,2) elseif kg.tmr>krt-6 then spr(206,kg.x,kg.y,2,2) spr(kg.wld<1 and 6 or 5,kg.x+4,kg.y+7) elseif kg.tmr>krt-9 then spr(kg.wld<1 and 2 or 1,kg.x-6,kg.y+9) spr(235,kg.x-7,kg.y,3,2,true) else --spr(238,kg.x,kg.y,2,2) drwkong(kg) end --barrel pile sprectfill(btp[51],unspl"6,13,14,29") drwcptv() drwoildrum(ob) -- ?"hr:"..ob.hr.x..","..ob.hr.spr,0,100,10 -- ?"objs:"..#ob.acs.."\nblks"..#ob.bls,0,100,10 -- ?mds.ctr,0,100,10 end function drwstg2(ob) -- pal(6,flk>0 and 7 or 6,1) citr8(ob.bls,"drw") drwconveyors() citr8(ob.acs,"drw") drwoildrum(ob) drwkong(ob.kg) drwcptv() --?(cstg.hr.x\4*4)%20,2,90,7 end function drwstg3(ob) cmds[[ line_21_32_21_120_2 line_59_32_59_120_2]] citr8(ob.bls,"drw") drwkong(ob.kg) drwcptv() citr8(ob.acs,"drw") end function drwstg4(ob) --pal(12,flk>0 and 3 or 12) cmds"pal_12_12_1" pal(9,flk>0 and 10 or 9,1) color(flk>0 and 6 or 12) cmds[[line_42_19_42_34 line_85_19_85_34]] citr8(ob.bls,"drw") if iscutscene() then local ctr,hr=mds.ctr,ob.hr cmds"rectfill_32_35_95_122_0" sprectfill(unspl"58,36,107,92,123") if ctr>280 then local lft=hr.x<64 ob.cpy,hr.y=27,27 if(ctr>320)hr.x=lft and 40 or 82 hr.lft=not lft if(ctr>360)ob.hrt.y,ob.hrt.x=20,lft and 50 or 71 cmds"rectfill_32_14_95_34_0" sprectfill(unspl"58,32,35,96,40") spr(113,56,106,2,1,ctr%16<8) else ob.hrt.y=-10 end end citr8(ob.acs,"drw") drwkong(ob.kg) drwcptv() -- ?mds.ctr,0,100,10 end function drwconveyors() for bl in all(cstg.cys) do local cvy=bl.cvy ------ ?cvy.id,bl.x,bl.y-6,8 for i=72,88,16 do -- if bl.x>0 and bl.x+bl.w<125 then local tmp=abs(cvy.cnt\10%4+(cvy.lft and 0 or -3)) spr(i+tmp,bl.x+(i==72 and -1 or bl.w-7),bl.y-1) -- end end end drwblok(cstg.lds[1]) drwblok(cstg.lds[2]) end function drwoildrum(ob) --oil drum local oil=ob.oil drwblok(oil) if oil.flm then local tmp=oil.flm\1+(oil.flm%1<.5 and 1 or 0) spr(13+mid(0,tmp,2),oil.x+1,oil.y-8) end end function drwgmvr() local ct,gmv,spd=mds.ctr,"game over"..(nws and "\n\nnew best!" or ""),nws and 4 or 10 if ct>64 then --todo:horiz lines -- fillp(flk==0 and ▒ or 0b1010010110100101.1) fillp(flk==0 and 0b1111000011110000.1 or ▤) rectfill(0,63-ct+64,127,63+ct-64,0) -- 3-ct/70) fillp() end -- if(ct>195) cls(3) if(ct>30) ?aastr(sub(gmv,1,(ct-30)\spd)),36,60,7 end --render actors function drwhero(ob) local fem,flp,flpv=ison"fem" and 64 or 0,fliprot(ob) if(alv() or ob.ded>210) flp,flpv=ob.lft --0) end spr(ob.spr+ob.typ-1,ob.x,hy,w,h,fliprot(ob)) pal(5,5) palt(5,false) else spr(ob.spr,ob.x,hy) end end function drwfire(ob) local w,h,hy=1,1,ob.y+sin(ob.tmr/25)*1.05 if ob.ded==0 then local hmr=cstg.hr.hmr if(hmr)cmds"pal_2_1\npal_8_13\npal_9_12\npal_10_6\npal_7_8" local sp=ob.typ==4 and 2 or 0 spr(ob.spr+sp,ob.x,hy,w,h,ob.lft) if(hmr)cmds"pal_2_2\npal_8_8\npal_9_9\npal_10_10\npal_7_7" else spr(ob.spr,ob.x,hy) end end function drwcpie(ob) local w,h,hy=1.4,.8,ob.y if ob.ded==0 then spr(ob.spr,ob.x-2,hy,w,h) else spr(ob.spr,ob.x,hy) end end function drwspng(ob) spr(ob.spr,ob.x,ob.y) end --render blocks function drwblok(ob) -- rect(ob.x,ob.y,ob.x+ob.w-1,ob.y+ob.h-1,10) local typ=ob.typ if typ<100 then --if(ob.typ==1 and flk>0)pal(2,14) local sp=btp[typ] if(typ>=54 and typ<=56 and ison"fem")sp+=16 sprectfill(sp,ob.x,ob.y,ob.x+ob.w,ob.y+ob.h) --pal(2,2) elseif typ<=101 then --ladders local gap=typ==100 and 5 or 0 -- local gap=5 clip(ob.x,ob.y+gap,ob.w,ob.h-gap) for i=0,ob.h\3+1 do -- rect(i-10+ob.x+1,(ob.y\3+i)*3-2,ob.x+ob.w-2,(ob.y\3+i),12) local sy=typ==100 and (ob.y\3+i)*3 or ob.y+i*3-1 --+1 rect(ob.x+1,sy-1, ob.x+ob.w-2,sy+2,cstg.ldc or 12) end -- for i=-1,ob.h\3 do -- rect(ob.x+1,ob.y+i*3+2,ob.x+ob.w-2,ob.y+i*3+5,12) -- end clip() elseif typ==102 then --broken ladders rectfill(ob.x,ob.y,ob.x+ob.w-1,ob.y+ob.h-1,0) end --editor if(ob.sel)rect(ob.x,ob.y,ob.x+ob.w-1,ob.y+ob.h-1,6) ?ob.x..","..ob.y..","..ob.w..","..ob.h,ob.x,ob.y-5 end function drwstg0(ob) local kg,ctr=ob.kg,mds.ctr if ctr>1 and ctr<800 then citr8(ob.bls,"drw") -- citr8(ob.acs,"drw") for j=24,130,38 do local by,cy,dm=0,-7,ctr>420 and 1.9 or 2.5 local dwb=mid(0,(ctr-j*2-300)/15,1) local dwc=mid(0,(ctr-j*dm-340)/15,1) for i=-8,104,16 do if(by+j>29)drwblok(newblok(1,i,by+j,16,8)) by+=dwb end for i=120,8,-16 do local w=16 if(j>80 and i==8)i,w=0,24 drwblok(newblok(1,i,min(122,cy+j+26),w,8)) cy+=dwc end end if kg.clb then local ldy=min(90,(abs(kg.clb)+14)\3*3) for i=61,71,9 do rectfill(i+1,34,i+6,28+ldy,0) drwblok(newblok(100,i,29,8,ldy)) end -- ?kg.clb,0,90,11 drwkong(kg) drwcptv() else drwcptv() drwkong(kg) end if ctr>570 then --kong grrr fillp(0b1010010110100101) rectfill(kg.x+5,kg.y+5,kg.x+10,kg.y+6,7) fillp() end else local stp,mh=mds.stp+1,28 local sts=seq[min(5,mds.lvl)] if(stp>#sts)stp=1 if(not cstg.cam)cstg.cam=0 local tpy,tmp=117-stp*mh,(900-ctr)/100 if ctr<900 and tpy<0 then -- cstg.cam=easeioq(tmp) cstg.cam=(tpy-10)*easeioq(1-tmp) end camera(0,cstg.cam+.5) for i=1,stp do ?aastr((i<4 and " " or "")..i*25 .." {"),6,139-i*mh,7 sspr(0,100,33,28,48,117-i*mh) end camera() ?aastr"how high can you get?",0,122,7 end end function drwkong(kg) local krt,sp,w,x,y,flph=t()%6,238,2,kg.x,kg.y if iscutscene() then krt,sp,w=0,235,3 local ctr=mds.ctr if cstg.stg==0 then sp=238 elseif cstg.stg==4 then w=2 if ctr==180 then kg.y+=8 elseif ctr>280 then sp,flph=233,ctr%12<6 elseif ctr>180 then sp=233 kg.y+=.66 elseif ctr>48 and ctr<155 then krt=4.6+ctr%15/15 else sp=238 end end end local clb=kg.clb if clb then sp,y=(clb%6==0 and 0 or 2),y-8-clb local grb=cstg.stg==0 and true or clb>8 spr(213+sp,x,y,grb and 2 or 1,3) -- else -- spr(213+sp,x,y,1,3) if(not grb)spr(215-sp,x+8,y,1,3,true) -- end else circfill(x+8,y+7,5,0) --todo:optim if krt>=5 and krt<=5.5 then sp,w,x=203,3,x-4 elseif krt>4.5 then sp,w,x,flph=203,3,x-4,true end spr(sp,x,y,w,2,flph) end end function drwcptv() local krt,kg,x,y=t()%6,cstg.kg,cstg.cpx,cstg.cpy local fem,flp,ani=ison"fem" and 0 or 64,false,krt>4.5 and krt%.3<.15 and 37 or 35 if ison"ctr" then ani,krt=36,0 if kg.clb and (kg.clb>6 or cstg.stg==0) then --kong climbing if(ison"fem") spr(180,kg.x+11,kg.y+4-kg.clb) return end end if(cstg.cpf)flp=cstg.hr.x<64 spr(fem+ani,x,y,1,1,flp) if krt>4.5 then pal(12,cstg.ldc or 12) if flp then spr(123,x-18,y,2.2,1) else spr(126,x+9,y,2,1) ?aastr">",x+23,y+1,12 end pal(12,12) end end -->8 --utils function unspl(...) return unpack(split(...)) end function spp(s,...) local r={} if(...) s=pstr(s,...) foreach(split(s,"|",false), function(s) local k,v=unspl(s,"=") --converts some strings to numbers, unlike first split if v then --key=value pair r[k]=v=="" and {} or v else --no equal sign, ordinary entry add(r,k) end end) return r end function pstr(st,...) local s="" for i,p in inext,split(st) do s..=({"",...})[i]..p end return s end function cmds(cs,...) if(...) cs=pstr(cs,...) foreach(split(cs,"\n"),function(s) local ps=split(s,"_") _ENV[deli(ps,1)](unpack(ps)) end) end function obj_copy(o) local c=o if type(o)=="table" then c={} for k,v in pairs(o) do c[k]=obj_copy(v) end -- else c=o end return c end function ison(k,t) return (t or mds)[k]>0 end function smod(k,v) if(v) mds[k]=v return mds[k] end function has(t,el) if(type(t)=="string")t=split(t) for v in all(t) do if(v==el) return true end end function cllbox(a,b) return a.y0 then local as="" for i=1,#s do local c=s[i] local o=ord(c) if o>=48then as..=chr(o-32) else as..=c end end return as end return s end function dlytxt(ct,d,txt,sp,...) if(ct>d) ?aastr(sub(txt,1,(ct-d)\sp)),... end function num0(n,f) f=f or 6 local tz,s=n>0 and "00" or "0","" local sn=n..tz if(f-#sn>0)s="\*"..max(1,f-#sn)..aastr"0" s..=aastr(sn) return s end function xn(n) return n<10 and n or chr(87+n) end function acbyid(id) for k,ac in ipairs(cstg.acs) do if (ac.id==id) return ac end end function fliprot(ob) return (ob.ani+1)&2==2,ob.ani>=2 end function sprectfill(idx,x0,y0,x1,y1) for y=y0,y1,8 do local sh = min(y1,y+8)-y for x=x0,x1,8 do spr(idx, x,y, (min(x1,x+8)-x)/8, sh/8) end end end function citr8(tab,fnc,cbk) -- for _,ac in ipairs(tab) do for ac in all(tab) do ac[fnc](ac) if(cbk)cbk(ac) end end function impadd(str,ob,unesc) if(unesc)str=unescbin(str) local args={} for i=1,#str do add(args,ord(str[i])) if #args==5 then --todo:exceptions? local nb=newblok(unpack(args)) if(nb.x>150)nb.x-=256 if(nb.y>150)nb.y-=256 add(ob,nb) args={} end end end function easeioq(t) if t<.5 then return 8*t*t*t*t else t-=1 return (1-8*t*t*t*t) end end