精简代码
This commit is contained in:
@@ -445,13 +445,13 @@ local function drawField(P)
|
||||
end
|
||||
else--With falling animation
|
||||
local ENV=P.gameEnv
|
||||
local dy,stepY=0,ENV.smooth and(P.falling/(ENV.fall+1))^2.5*30 or 30
|
||||
local stepY=ENV.smooth and(P.falling/(ENV.fall+1))^2.5*30 or 30
|
||||
local A=P.falling/ENV.fall
|
||||
local h=1
|
||||
gc.push("transform")
|
||||
for j=start,min(start+21,#F)do
|
||||
while j==P.clearingRow[h]do
|
||||
h=h+1
|
||||
dy=dy+stepY
|
||||
gc.translate(0,-stepY)
|
||||
gc.setColor(1,1,1,A)
|
||||
gc.rectangle("fill",0,30-30*j,300,stepY)
|
||||
@@ -468,7 +468,7 @@ local function drawField(P)
|
||||
end
|
||||
end
|
||||
end
|
||||
gc.translate(0,dy)
|
||||
gc.pop()
|
||||
end
|
||||
end
|
||||
local function drawFXs(P)
|
||||
@@ -955,71 +955,27 @@ local function Pdraw_demo(P)
|
||||
|
||||
--Camera
|
||||
gc.push("transform")
|
||||
gc.translate(P.x,P.y)gc.scale(P.size)gc.translate(P.fieldOff.x,P.fieldOff.y)
|
||||
gc.translate(P.x,P.y)gc.scale(P.size)
|
||||
gc.push("transform")
|
||||
gc.translate(P.fieldOff.x,P.fieldOff.y)
|
||||
|
||||
--Frame
|
||||
gc.setColor(.1,.1,.1,.8)
|
||||
gc.setColor(0,0,0,.6)
|
||||
gc.rectangle("fill",0,0,300,600)
|
||||
|
||||
gc.setLineWidth(2)
|
||||
gc.setColor(1,1,1)
|
||||
gc.rectangle("line",-1,-1,302,602)
|
||||
|
||||
gc.push("transform")
|
||||
gc.translate(0,600)
|
||||
if P.falling==-1 then
|
||||
--Field block only
|
||||
for j=int(P.fieldBeneath/30+1),#P.field do
|
||||
for i=1,10 do
|
||||
if P.field[j][i]>0 then
|
||||
gc.setColor(1,1,1,min(P.visTime[j][i]*.05,1))
|
||||
drawCell(j,i,P.field[j][i])
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
--Field with falling animation
|
||||
local dy,stepY=0,ENV.smooth and(P.falling/(ENV.fall+1))^2.5*30 or 30
|
||||
local A=P.falling/ENV.fall
|
||||
local h,H=1,#P.field
|
||||
for j=int(P.fieldBeneath/30+1),H do
|
||||
while j==P.clearingRow[h]do
|
||||
h=h+1
|
||||
dy=dy+stepY
|
||||
gc.translate(0,-stepY)
|
||||
gc.setColor(1,1,1,A)
|
||||
gc.rectangle("fill",0,630-30*j,300,stepY)
|
||||
end
|
||||
for i=1,10 do
|
||||
if P.field[j][i]>0 then
|
||||
gc.setColor(1,1,1,min(P.visTime[j][i]*.05,1))
|
||||
drawCell(j,i,P.field[j][i])
|
||||
end
|
||||
end
|
||||
end
|
||||
gc.translate(0,dy)
|
||||
end
|
||||
|
||||
drawField(P)
|
||||
drawFXs(P)
|
||||
|
||||
if P.cur and P.waiting==-1 then
|
||||
--Draw ghost
|
||||
if ENV.ghost then
|
||||
gc.setColor(1,1,1,ENV.ghost)
|
||||
for i=1,P.r do for j=1,P.c do
|
||||
if P.cur.bk[i][j]then
|
||||
drawCell(i+P.imgY-1,j+P.curX-1,curColor)
|
||||
if ENV.ghost then drawGhost(P,curColor)end
|
||||
if ENV.block then
|
||||
drawBlockOutline(P,curColor,P.lockDelay/ENV.lock)
|
||||
drawBlock(P,curColor)
|
||||
end
|
||||
end end
|
||||
end
|
||||
|
||||
--Draw block
|
||||
gc.setColor(1,1,1)
|
||||
for i=1,P.r do for j=1,P.c do
|
||||
if P.cur.bk[i][j]then
|
||||
drawCell(i+P.curY-1,j+P.curX-1,curColor)
|
||||
end
|
||||
end end
|
||||
end
|
||||
gc.pop()
|
||||
|
||||
@@ -1043,9 +999,7 @@ local function Pdraw_demo(P)
|
||||
gc.draw(_,285,40*N-10,nil,16,nil,_:getWidth(),_:getHeight()*.5)
|
||||
N=N+1
|
||||
end
|
||||
|
||||
gc.setColor(1,1,1)
|
||||
gc.translate(-P.fieldOff.x,-P.fieldOff.y)
|
||||
gc.pop()
|
||||
TEXT.draw(P.bonus)
|
||||
gc.pop()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user