blackhole和blockrain背景适配任意尺寸屏幕
This commit is contained in:
@@ -38,7 +38,7 @@ function back.update()
|
|||||||
local S=squares[i]
|
local S=squares[i]
|
||||||
local ang=math.atan2(S.y,S.x)
|
local ang=math.atan2(S.y,S.x)
|
||||||
local d=(S.x^2+S.y^2)^.5
|
local d=(S.x^2+S.y^2)^.5
|
||||||
d=d-2000/(d+60)
|
d=d-SCR.rad/(d+60)
|
||||||
if d>0 then
|
if d>0 then
|
||||||
S.x=d*math.cos(ang)
|
S.x=d*math.cos(ang)
|
||||||
S.y=d*math.sin(ang)
|
S.y=d*math.sin(ang)
|
||||||
|
|||||||
@@ -5,29 +5,33 @@ local ins,rem=table.insert,table.remove
|
|||||||
local back={}
|
local back={}
|
||||||
|
|
||||||
local t
|
local t
|
||||||
local cell
|
local mino
|
||||||
function back.init()
|
function back.init()
|
||||||
t=0
|
t=0
|
||||||
cell={}
|
mino={}
|
||||||
end
|
end
|
||||||
function back.update()
|
function back.update()
|
||||||
t=t+1
|
t=t+1
|
||||||
if t%10==0 then
|
if t%10==0 then
|
||||||
ins(cell,{
|
local r=rnd(29)
|
||||||
bid=rnd(29),
|
ins(mino,{
|
||||||
|
bid=r,
|
||||||
|
block=TEXTURE.miniBlock[r],
|
||||||
|
color=minoColor[SETTING.skin[r]],
|
||||||
x=SCR.w*rnd(),
|
x=SCR.w*rnd(),
|
||||||
y=-25,
|
y=SCR.h*-.05,
|
||||||
|
k=SCR.rad/100,
|
||||||
a=rnd()*6.2832,
|
a=rnd()*6.2832,
|
||||||
vy=.5+rnd()*.4,
|
vy=.5+rnd()*.4,
|
||||||
vx=rnd()*.4-.2,
|
vx=rnd()*.4-.2,
|
||||||
va=rnd()*.04-.02,
|
va=rnd()*.04-.02,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
for i=#cell,1,-1 do
|
for i=#mino,1,-1 do
|
||||||
local P=cell[i]
|
local P=mino[i]
|
||||||
P.y=P.y+P.vy
|
P.y=P.y+P.vy
|
||||||
if P.y>SCR.h+25 then
|
if P.y>SCR.h+25 then
|
||||||
rem(cell,i)
|
rem(mino,i)
|
||||||
else
|
else
|
||||||
P.x=P.x+P.vx
|
P.x=P.x+P.vx
|
||||||
P.a=P.a+P.va
|
P.a=P.a+P.va
|
||||||
@@ -39,18 +43,15 @@ function back.draw()
|
|||||||
gc.clear(.15,.15,.15)
|
gc.clear(.15,.15,.15)
|
||||||
gc.push("transform")
|
gc.push("transform")
|
||||||
gc.origin()
|
gc.origin()
|
||||||
local texture=TEXTURE.miniBlock
|
for i=1,#mino do
|
||||||
local minoColor=minoColor
|
local C=mino[i]
|
||||||
for i=1,#cell do
|
local c=C.color
|
||||||
local C=cell[i]
|
|
||||||
local tex=texture[C.bid]
|
|
||||||
local c=minoColor[SETTING.skin[C.bid]]
|
|
||||||
gc.setColor(c[1],c[2],c[3],.5)
|
gc.setColor(c[1],c[2],c[3],.5)
|
||||||
gc.draw(tex,C.x,C.y,C.a,10,10,tex:getWidth()/2,tex:getHeight()/2)
|
gc.draw(C.block,C.x,C.y,C.a,C.k,C.k,C.block:getWidth()/2,C.block:getHeight()/2)
|
||||||
end
|
end
|
||||||
gc.pop()
|
gc.pop()
|
||||||
end
|
end
|
||||||
function back.discard()
|
function back.discard()
|
||||||
cell=nil
|
mino=nil
|
||||||
end
|
end
|
||||||
return back
|
return back
|
||||||
Reference in New Issue
Block a user