PicoPicoGameEngine

Quick Links

Source Code

g=ppgraph
s=ppscreen
B=s:size()
floor=math.floor

o=ppoffscreen.new()
t={
  wrap_s="repeat",
  wrap_t="repeat"
}
o:create(256,512,t)
o:fill(0,0,128,256,
  {115,197,115})
o:fill(128,0,128,256,
  {163,247,163})
o:fill(0,256,128,256,
  {131,214,131})
o:fill(128,256,128,256,
  {147,230,147})
o:bind()

function checkbg(w,h)
  local r=pprect(0,0,w,h)

  r.drawline=
  function(s,x,y,oy,z)
    local yy
    yy=s.d.y/s.cz
    zn=floor((z-yy)*14/2)
    zn=zn%2
    z=z*256*2
    g:tileInfo({
      size={z*2,1},
      offset={
       x-z+zn*128,0}
    })
    g:pivot(0,y+oy)
    local sc
    sc=(s.width/2)/z
    g:scale(sc,1)
    g:put(
      s.x/sc,oy,1+zn*300)
  end

  r.d=pppoint()
  r.checksize=100
  r.cz=480
  r.hpos=0

  r.draw=function(s)
    local x
    local zn
    zn=10
    x=r.d.x-64

    local pv
    pv=g:pivot()
    local by
    local bh
    local oy
    local cz
    cz=s.cz
    oy=s.y
    by=s.height
    bh=0
    local ch=16
    local cs
    cs=r.checksize
    local ww
    ww=by+cs+ch-bh-1
    for i=cs+ch,ww do
      local z,h
      z=i*zn/(cs-i)
      local t
      t=(by+cs+ch-bh-i)
      h=t*(cz-r.hpos)/cz
      s:drawline(x,i,
        oy+by-h,(z+zn)/2)
    end
    g:scale(1)
    g:pivot(pv)
  end

  return r
end

pptex:default(
o:texture())

p=ppsprite.new()
p.x=160
p.y=B.height/2

bg=checkbg(B.width,B.height)
bg.cz=B.height
bg:pos(0,0)

function start()
  g:fill(s:size(),
    {189,139,247})

  bg.d.x=bg.d.x+(p.x-160)/10
  bg.d.y=bg.d.y+8
  bg.hpos=p.y
  bg:draw()

  p:drag(pptouch(),B)
end