PicoPicoGameEngine

Quick Links

Source Code

g=ppgraph
B=ppscreen:size()

tex=pptex:load("map.png")

m=ppmap.new()
m:texture(tex)
m:addLayer("l",10,40)
m:clip(0,-40,10,40)
m:fill(0,0,10,40,3)
for i=1,20 do
local x,y
x=math.random(0,9)
y=math.random(12,38)
m:fill(x,y,1,1,9)
end
for i=1,20 do
local x,y
x=math.random(0,9)
y=math.random(12,38)
m:fill(x,y,1,1,10)
end
m:fill(5,0,1,40,5)
m:fill(0,20,10,1,6)
m:fill(0,33,10,1,6)
m:fill(5,30,5,1,5)
m:fill(0,13,5,1,5)
m:fill(0,0,10,10,4)

p=ppsprite.new(tex)
p:tile(2)
l=g:layout(p,true,true,B)
p:pos(l)
p:move(0,96)

t={}
for i=1,3 do
local r
r=ppsprite.new(tex)
r:hide()
r.idle=function(s)
if s:isVisible() then
s:move(0,-16)
s:loopAnime(1.0/30,{7,8})
s:draw()
if s.y<-32 then
s:hide()
end
end
end
t[i]=r
end

function set(o)
for i=1,3 do
if not t[i]:isVisible() then
 t[i]:pos(o)
 t[i]:show()
 break
end
end
end

st=0

function start()
p:drag(pptouch())
m:draw()
m.y=m.y+1
if m.y>40*32 then
m.y=0
end
st=st+1
if st>2 then
 st=0
 set(p)
end
p:draw()
for i=1,3 do
t[i]:idle()
end
end