0,]']±>Sï}WÿÍu§ðp8·d%qy)6o;]ÉA¦ösï÷ôôô”°ÂVl†3 136 then leaf.y = -8 leaf.x = math.random(0, 240) end if leaf.x > 240 then leaf.x = 0 end if leaf.x < 0 then leaf.x = 240 end spr(254, leaf.x, leaf.y, 0) end end -- map pose m = {x = 0, y = 0} crntlvl=1 lvls = { [1] = {mapx=000, mapy=0, sx=070, sy=030, bg=09}, [2] = {mapx=030, mapy=0, sx=020, sy=090, bg=16}, [3] = {mapx=060, mapy=0, sx=010, sy=005, bg=03}, [4] = {mapx=090, mapy=0, sx=020, sy=100, bg=14}, [5] = {mapx=120, mapy=0, sx=134, sy=015, bg=13} } function ldlvl(lvl) crntlvl = lvl local l = lvls[lvl] m.x = l.mapx m.y = l.mapy p.x = l.sx p.y = l.sy p.dx= 0 p.dy= 0 end function rspwn() local l = lvls[crntlvl] p.x = l.sx p.y = l.sy p.dx= 0 p.dy= 0 end win = false function issld(px, py) local tx = (px // 8) + m.x local ty = (py // 8) + m.y local tid= mget(tx, ty) return fget(tid, 0) end function istrns(px, py) local tx = (px // 8) + m.x local ty = (py // 8) + m.y local tid = mget(tx, ty) return fget(tid, 7) end -- player movment function pmov() -- accelaration if btn(2) then -- left p.dx = max(p.dx - p.acc , -p.mspd) p.flp= 1 elseif btn(3) then -- right p.dx = min(p.dx + p.acc, p.mspd) p.flp= 0 else -- friction if p.dx > 0 then p.dx = max(0, p.dx - p.fric) elseif p.dx < 0 then p.dx = min(0, p.dx + p.fric) end end -- check ground collision local fy = p.y + 8 p.isgrnd = (issld(p.x + 2, fy) or issld(p.x + 5, fy)) and 1 or 0 -- coyote time if p.isgrnd == 1 then p.cyt = p.mcyt elseif p.cyt > 0 then p.cyt = p.cyt - 1 end -- jumping if btnp(4) then p.bjmp = p.bmjmp elseif p.bjmp > 0 then p.bjmp = p.bjmp - 1 end if p.cyt > 0 and p.bjmp > 0 then p.dy = p.jmp p.isgrnd = 0 p.bjmp = 0 p.cyt = 0 sfx(0) end -- variable jump if p.dy < 0 and not btn(4) then p.dy = p.dy * 0.5 end -- gravity p.dy = p.dy + p.grvty -- check collision if p.dx ~= 0 then local nx = p.x + p.dx -- new local cx = p.dx > 0 and (nx + 5) or (nx + 2) -- check if not issld(cx, p.y) and not issld(cx, p.y+7) then p.x = nx else if p.dx > 0 then p.x = (cx//8)*8-6 else p.x = (cx//8+1)*8-2 end p.dx = 0 end end if p.dy ~= 0 then local ny = p.y + p.dy -- new local cy = p.dy > 0 and (ny + 7) or ny -- check if not issld(p.x+2, cy) and not issld(p.x+5, cy) then p.y = ny else if p.dy > 0 then p.y = (cy//8)*8-8 elseif p.dy < 0 then p.y = (cy // 8 + 1) * 8 end p.dy = 0 end end end function pdrw() local cid = p.id if p.isgrnd == 0 then cid = p.id + 1 elseif abs(p.dx) > 0.1 then cid = p.id + math.floor((time()/150)%2) end spr(cid, p.x, p.y, 0, 1, p.flp, 0, 1, 1) end ldlvl(1) function updt() pmov() -- dying if p.y > 136 then rspwn() end -- next lvl if istrns(p.x + 4, p.y + 4) then local nxt = crntlvl + 1 if lvls[nxt] then ldlvl(nxt) else win = true end end end function drwin() -- draw win cls(5) local txt1 = "THANK YOU FOR PLAYING!" local txt2 = "PRESS Z/JUMP TO RESTART" local x1 = (240 - #txt1 * 6) // 2 local x2 = (240 - #txt2 * 6) // 2 print(txt1, x1, 50, 12) print(txt2, x2, 70, 15) mleaf() if btnp(4) then ldlvl(1) win = false end end function draw() local bgc = lvls[crntlvl].bg or 9 cls(bgc) map(m.x,m.y, 240, 136, 0, 0, 0, 1) pdrw() mleaf() -- its work here end function TIC() if win == false then updt() draw() else drwin() end end