PicoPicoGameEngine

Quick Links

Source Code

g=ppgraph
floor=math.floor
B=ppscreen:size()
Bw=B.width
Bh=B.height

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

function obj(x,y)
local r
r=pprect()
r.t=1
r.n={}
r.x=x
r.y=y
r.s=0.1
r.idle=function(s)
end
r.draw=function(s)
 s.t=s.t+s.s
 if s.t>=#s.n+1 then
   s.t=1
 end
 g:put(s.x,s.y,
       s.n[floor(s.t)],tex)
end
r.copy=function(s,x,y)
 local t
 t=obj(x,y)
 t.n=s.n
 t.s=s.s
 t.idle=s.idle
 return t
end
return r
end

function drawbg()
 g:fill(B,g.cyan)
 g:fill(0,200,Bw,Bh-200,g.green)
end

man=obj(160-16,240)
man.n={2,3}

cloud1=obj(60,80)
cloud1.n={4,5}
cloud1.s=0.025
cloud1.idle=function(s)
 s:move(1,0)
 if s.x>Bw then
   s.x=-32
 end
end

cloud2=cloud1:copy(160,50)

cloud3=cloud1:copy(240,60)

cloud4=cloud1:copy(280,40)

function start()
 drawbg()
 man:idle()
 man:draw()
 cloud1:idle()
 cloud1:draw()
 cloud2:idle()
 cloud2:draw()
 cloud3:idle()
 cloud3:draw()
 cloud4:idle()
 cloud4:draw()
end