B,]']Б>Sя}WџЭu…№p4‰]%qy)6o;]ЩAІіsяїєєє”АТVl†3 >`ffffffff`ffffffff`ffffffffffffffffffffffffffffffffffffff`ffffffffffffff`ffffffffffffff`ffffffffffffff`ffffffffffffff`ffffffffffffff`ffffffffffffff`ffffffffffffff`ffffffffffffff`ffffffffffffff`ffffffffffffff`ffffffffffffff`ffffffffffffffffffffffffffffffffffffffffffffffffff`ffffffff`ffffffff`ffffffff""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""џџџ№№џ№№џџџџ№џ№џ№џџџџ№џџџџ№џџџџџџџџџ№џџ№џ№џ№џ№№џ№џџџџџџџџ№џџ№№џ№џџ№џџџџџџџ№џџџџ№џџџџџџ№џџџ№џџ№џџ№џџџ№џ№џџџ№џ№џ№џ№џџ№џ№№џџ№џџџџџ№џ№џџџџџџџџџ№џ№џџџџџџ№џ№џџџџџ№№№џџ№џџ№џџџџ№џ№џџ№џ№џ№џџџ№№џ’ -- title: Forest of Doom -- author: Katie Martin -- desc: The Forest is alive. -- script: lua -- cover: enthusiasticGeek t=0 -- Global tick variable (for timing, mostly) GameStarted=false Debug=true VStr="0.0.0" GStr="Forest of Doom" JUMP_DY={-3,-3,-3,-3,-2,-2,-2,-2,1,1,0,0,0,0,0} -- PLR is shorthand for PLAYER -- SWD is shorthand for SWORD -- NS is shorthand for No Sword -- YS is shorthand for Yes Sword -- WLK is shorthand for walk. There are two walking sprites. PLR_NS_STILL=256 PLR_NS_WLK1=257 PLR_NS_WLK2=258 PLR_YS_STILL=272 PLR_YS_WLK1=274 PLR_YS_WLK2=275 PLR_YS_ATK=260 SWD_STILL=273 SWD_ATK=261 Player={ x=0,y=0, -- Current position gnd=false, -- If the player is on the ground jmp=0, health=100, -- Player health hasSword=false,-- If the player has the sword. attack=1, -- Attack multiplier armor=1, -- Armor multiplier ... } Game={ scrNo=0, -- Current screen. Used for saving. ... } COLS = 29 ROWS = 16 SCRW = 240 SCRH = 136 function RenderMap() PointX=Player.x/COLS PointY=MapY()*(ROWS+1) --map(PointX,PointY,COLS+1,ROWS+1) map(0,0,COLS+1,ROWS+1) return PointX, PointY end function MapY() Y=Player.y while(Y%SCRH~=0) do Y=Y-1 end return Y/SCRH end W=1 function RenderPlayer(walk,dir) if(walk)then spr(PLR_NS_STILL+W, 112, Player.y) if(t%30==0)then if(W==1)then W=2 else W=1 end end else --spr(PLR_NS_STILL, 112, Player.y) spr(PLR_NS_STILL,Player.x-4,Player.y-4) end end function TickPlayer() --RenderPlayer(false, false) UpdateCPos() RenderPlayer(false, false) return Player.x, Player.y end function UpdateCPos() local PData=CEntData(Player.x,Player.y,8,8) Player.gnd = not CanMove(Player.x,Player.y+1,PData) if(not Player.gnd)then Player.y=Player.y+1 end local dx=btn(2) and -1 or (btn(3) and 1 or 0) local dy=0 if(Player.gnd)then Player.jmp=0 end if(btn(0) and Player.gnd)then Player.jmp=1 end if(Player.jmp>0)then dy=dy+JUMP_DY[Player.jmp] if(Player.jmp<13)then Player.jmp=Player.jmp+1 else Player.jmp=0 end end TryMoveBy(dx,dy,PData) return false, true end function TryMoveBy(dx,dy,PData) if CanMove(Player.x+dx, Player.y+dy, PData) then Player.x=Player.x+dx Player.y=Player.y+dy return true end return false end function CEntData(xi,yi,wi,hi) return {x=xi,y=yi,w=wi,h=hi} end function CanMove(x,y,ent) local x1=x+ent.x local y1=y+ent.y local x2=x1+ent.w-1 local y2=y1+ent.h-1 local sC=x1//16 local eC=x2//16 local sR=y1//16 local eR=y2//16 for c=sC,eC do for r=sR,eR do if TileSolid(mget(c,r)) then return false end end end return true end function TileSolid(t) if(t<80)then return true end return false end function TIC() cls(0) if(not GameStarted) then spr(80+t%60//30*2,96,24,14,3,0,0,2,2) print("Press X to Start!",74,84) end if(btn(5))then GameStarted = true end -- Persistent memory check here -- Always new game for now. -- Check if started if (GameStarted) then DScrnX,DScrnY=RenderMap() DPlyrX,DPlyrY=TickPlayer() if(Debug) then print(" Debug Mode!",0,0,2) print(" Screen X: "..DScrnX,0,8) print(" Screen Y: "..DScrnY,0,16) print(" Player X: "..DPlyrX,0,24) print(" Player Y: "..DPlyrY,0,32) print(" On Ground: "..tostring(Player.gnd),0,40) print(" Jump: "..tostring(Player.jmp),0,48) end end print(" "..GStr.." "..VStr,0,128) --print(" Shhh... let's not leak our hard work!",0,120) t=t+1 end