0,]']±>Sï}WÿÍu§ðp8·d%qy)6o;]ÉA¦ösï÷ôôô”°ÂVl†30 then return 1 else return 0 end end function initLevel(pX,pY,hX,hY,eX,eY,camX,camY,dP,dH,dE) if start==false then c.radius=c.minRad indx=1 p.x=pX p.y=pY p.lv=true p.w=false h.x=hX h.y=hY h.lv=true h.w=false e.x=eX e.y=eY cam.x=camX cam.y=camY p.p=true h.p=true e.p=true irisZ=true start=true finis=false end if dP then drawPlayer() end if dH then drawHero() end if dE then drawMonster() end if c.radius==c.maxRad then p.p=false h.p=false e.p=false end end function level(l) map(cam.x,cam.y) --title screen if l==0 then print("The Greedy\n\n Hero",32,13,2,false,3) print("The Greedy\n\n Hero",32,12,4,false,3) print("START",204,101,12) spr(496,234,100) initLevel(32,96,0,0,0,0,30,0,true,false,false) --gameplay elseif l==1 then initLevel(112,40,112,104,0,0,0,17,true,true,false) elseif l==2 then initLevel(112,56,112,104,0,0,60,17,true,true,false) elseif l==3 then initLevel(112,56,112,104,0,0,30,17,true,true,false) elseif l==4 then drawPress() drawDoor(152,56) drawDoor(152,64) initLevel(128,56,16,56,0,0,90,17,true,true,false) elseif l==5 then drawPress() drawDoor(112,48) drawDoor(120,48) drawDoor(104,56) drawDoor(104,64) drawDoor(112,72) drawDoor(120,72) drawDoor(128,56) drawDoor(128,64) initLevel(112,56,16,56,0,0,120,17,true,true,false) elseif l==6 then drawPress() drawDoor(96,56) drawDoor(96,64) drawDoor(136,56) drawDoor(136,64) initLevel(112,56,112,104,0,0,150,17,true,true,false) elseif l==7 then initLevel(160,40,160,104,24,64,180,17,true,true,true) elseif l==8 then initLevel(16,8,16,104,200,56,210,17,true,true,true) elseif l==9 then drawPress() drawDoor(88,16) initLevel(40,8,40,104,104,48,0,34,true,true,true) elseif l==10 then print("The End",84,16,4,false,2) print("Thanks For Playing",72,40,12,false,1) print("Game by MFauzan",80,56,12,false,1) initLevel(32,96,0,0,0,0,30,34,true,false,false) end end function initNextLvl(l,m) if finis==false then music(m,0,0,false) c.radius=c.maxRad irisZ=false finis=true end p.p=true h.p=true e.p=true if c.radius==c.minRad then lvl=l start=false for i,pa in pairs(path) do path[i]=nil end ready=false finis=false p.p=false h.p=false e.p=false end end function nextLevel() level(lvl) if lvl==0 and p.x==200 then initNextLvl(1,2) elseif lvl==1 and h.w then initNextLvl(1,1) elseif lvl==1 and p.w then initNextLvl(2,0) elseif lvl==2 and h.w then initNextLvl(2,1) elseif lvl==2 and p.w then initNextLvl(3,0) elseif lvl==3 and h.w then initNextLvl(3,1) elseif lvl==3 and p.w then initNextLvl(4,0) elseif lvl==4 and h.w then initNextLvl(4,1) elseif lvl==4 and p.w then initNextLvl(5,0) elseif lvl==5 and h.w then initNextLvl(5,1) elseif lvl==5 and p.w then initNextLvl(6,0) elseif lvl==6 and h.w then initNextLvl(6,1) elseif lvl==6 and p.w then initNextLvl(7,0) elseif lvl==7 and h.w then initNextLvl(7,1) elseif lvl==7 and p.w then initNextLvl(8,0) elseif lvl==8 and h.w then initNextLvl(8,1) elseif lvl==8 and p.w then initNextLvl(9,0) elseif lvl==9 and h.w then initNextLvl(9,1) elseif lvl==9 and p.w then initNextLvl(10,0) end end -- check tiles function tileAt(x,y) local mapX=cam.x*cell local mapY=cam.y*cell return mget((x+mapX)//8,(y+mapY)//8)<96 end function tileDead(x,y) local mapX=cam.x*cell local mapY=cam.y*cell return mget((x+mapX)//8,(y+mapY)//8)==224 end function tilePress(x,y) local mapX=cam.x*cell local mapY=cam.y*cell return mget((x+mapX)//8,(y+mapY)//8)==210 end function tileDoor(x,y) local mapX=cam.x*cell local mapY=cam.y*cell if mget((x+mapX)//8,(y+mapY)//8)==212 and not press then return true end end function drawPress() -- collision local pu=p.y+7 local hu=h.y+7 local pd=p.y+16 local hd=h.y+16 local pl=p.x local hl=h.x local pr=p.x+8 local hr=h.x+16 if tilePress(pl,pu) or tilePress(pl,pd) or tilePress(pr,pu) or tilePress(pr,pd) or tilePress(hl,hu) or tilePress(hl,hd) or tilePress(hr,hu) or tilePress(hr,hd) then press=true else press=false end end function drawDoor(x,y) local c=212 if press then c=213 else c=212 end spr(c,x,y) end function needle(myX,myY) local anim=t.nd%180//90 t.nd=t.nd+1 spr(at.ndlOn+anim,myX,myY) end -- player function animPlayer() p.c=262 t.ap=0 end function drawPlayer() if ready==false then playerPath(p.x,p.y) ready=true end -- collision local u=p.y+7 local d=p.y+17 local l=p.x-1 local r=p.x+17 -- move player if p.p==false then if btnp(0,20,20) and not tileAt(l+1,u) and not tileAt(r-2,u) and not tileDoor(l+1,u) and not tileDoor(r-2,u) then sfx(0,'D-3',15) p.y=p.y-p.sp animPlayer() playerPath(p.x,p.y) end if btnp(1,20,20) and not tileAt(l+1,d) and not tileAt(r-2,d) and not tileDoor(l+1,d) and not tileDoor(r-2,d) then sfx(0,'D-3',15) p.y=p.y+p.sp animPlayer() playerPath(p.x,p.y) end if btnp(2,20,20) and not tileAt(l,u+1) and not tileAt(l,d-2) and not tileDoor(l,u+1) and not tileDoor(l,d-2) then sfx(0,'D-3',15) p.x=p.x-p.sp animPlayer() playerPath(p.x,p.y) end if btnp(3,20,20) and not tileAt(r,u+1) and not tileAt(r,d-2) and not tileDoor(r,u+1) and not tileDoor(r,d-2) then sfx(0,'D-3',15) p.x=p.x+p.sp animPlayer() playerPath(p.x,p.y) end --draw player else if h.w then p.c=258 else if p.a then p.c=264+t.ap%8//4*2 else p.c=256 end end end t.ap=t.ap+1 if t.ap==10 then p.c=256 end spr(p.c,p.x,p.y,0,1,0,0,2,2) end --emotion effect function effect(tipe) local x=h.x local y=h.y local c=302 if tipe==1 then c=302 elseif tipe==2 then c=303 elseif tipe==3 then c=318 end spr(c,x,y,0) end -- hero anim=t.ah%30//15*2 function drawHero() local u=h.y+8 local d=h.y+16 local l=h.x+1 local r=h.x+15 t.ah=t.ah+1 if h.p==false then --follow chest local pa=path[indx] h.vx=rOne(pa.x,h.x)*h.sp h.vy=rOne(pa.y,h.y)*h.sp if h.y==pa.y and h.x==pa.x then --table.remove(path,indx) indx=indx+1 end --update position if not tileDoor(l,u) and not tileDoor(l,d) and not tileDoor(r,u) and not tileDoor(r,d) then h.x=h.x+h.vx h.y=h.y+h.vy end --change sprite if h.vy<0 then h.c=292 h.f=0 anim=t.ah%30//15*2 elseif h.vy>0 then h.c=288 h.f=0 anim=t.ah%30//15*2 elseif h.vx<0 then h.c=296 h.f=0 anim=t.ah%30//15*2 elseif h.vx>0 then h.c=296 h.f=1 anim=t.ah%30//15*2 end else if h.lv then h.c=288 h.f=0 anim=0 else if h.w then h.c=288 else h.c=300 end h.f=0 anim=0 end end --draw hero spr(h.c+anim,h.x,h.y,0,1,h.f,0,2,2) --damage if tileDead(h.x+8,h.y+15) then p.w=true winLose(3) end --hero win if h.x==p.x and h.y==p.y then h.w=true winLose(2) end end -- is it win or lose? function winLose(e) p.p=true h.p=true h.lv=false effect(e) end -- monster function drawMonster() t.ae=t.ae+1 --collision local u=e.y+7 local d=e.y+15 local l=e.x+2 local r=e.x+14 if tileAt(l,u) and tileAt(l,d) then e.sp=-1*e.sp e.f=1 elseif tileAt(r,u) and tileAt(r,d) then e.sp=-1*e.sp e.f=0 end --attack if p.x+8>l and p.x+8u and p.y+8l and h.x+8u and h.y+1=c.radius then return true end end function irisShot() for y=0,screen.h do for x=0,screen.w do if creatCircle(x,y) then pix(x,y,0) end end end end function drawIrisShot(z) c.x=p.x+8 c.y=p.y+8 if z then p.a=false c.radius=c.radius+5 else p.a=true c.radius=c.radius-5 end if c.radius>c.minRad and c.radius