PicoPicoGameEngine

Quick Links

Source Code

g=ppgraph
z=ppscreen:size()

o=ppoffscreen.new()
n=10
o:create(16*5,16*n)
for i=1,n do
b=(n-i+1)*(256)/n-1
y=(i-1)*16
c={b,0,0,255}
o:fill( 0,y,16,16,c)
c={0,b,0,255}
o:fill(16,y,16,16,c)
c={0,0,b,255}
o:fill(32,y,16,16,c)
c={0,b,b,255}
o:fill(48,y,16,16,c)
c={b,b,0,255}
o:fill(64,y,16,16,c)
end
o:hflip()
o:bind()

function map(py,dx,w,h,c)
local m=ppmap.new()
m:texture(o:texture())
m:addLayer("layer")
m:mapSize(w,h)
m:tileSize(16,16)
m:clip(0,0,w*2,h)
for y=0,h-1 do
  for x=0,w-1 do
    p=x*math.pi/(w/4)
    t=math.sin(p)/1.5
    q=y/(h/2)-0.5
    if q<t then
      t=0
    else
      t=c+y*8
    end
    m:tile(x,y,t)
  end
end
m.y=py*8-10*16
m.x=0
m.dx=dx
m.idle=function(s)
  s.x=s.x-s.dx
  if s.x<-w*16 then
    s.x=s.x+w*16
  end
end
return m
end

m={}
zz=320/16
hh=z.height/8+10
for i=0,hh,5 do
  m[#m+1]=map(
     i,0.02+i*0.02,zz,10,
     ((i/5)%5)+1)
end

function start()
  for i,n in ipairs(m) do
    n:idle()
    n:draw()
  end
end