PicoPicoGameEngine

Quick Links

ピコピココード

g=ppgraph
B=ppscreen:size()
pi=math.pi
sin=math.sin
cos=math.cos
rand=math.random

function obj(x,y)
local t=pprect(x,y,32,32)
t.d=pppoint()
t.r=0
t.u=0
t.draw=function(s)
g:circle(s+s.d,8,s.c)
end
return t
end

t={}

sx=1
sy=1
rx=100
ry=100
function change()
sx=rand(1,5)
sy=rand(1,5)
rx=rand(50,120)
ry=rand(50,120)
end

for i=1,100 do
o=obj(160,160)
o.u=pi*2*i/100
o.c=g.red
o.idle=function(s)
 s.r=s.r+0.01
 s.d.x=sin((s.r+s.u)*sx)*rx
 s.d.y=cos((s.r+s.u)*sy)*ry
end
t[#t+1]=o
end

o=obj(160,160)
o.c=g.cyan
o.idle=function(s)
end
t[#t+1]=o

bt=ppbutton("CHANGE")
p=g:layout(bt,true,true,B)
bt:pos(p)
bt:move(0,100)

function start()
for i,o in ipairs(t) do
 o:idle()
 o:draw()
end
bt:draw()
if bt:idle(pptouch()) then
for i,o in ipairs(t) do
 change()
end
end
end