精简代码

This commit is contained in:
MrZ626
2020-10-23 00:01:44 +08:00
parent 3cb3cf5fac
commit aa48fbfb33

View File

@@ -445,13 +445,13 @@ local function drawField(P)
end end
else--With falling animation else--With falling animation
local ENV=P.gameEnv 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 A=P.falling/ENV.fall
local h=1 local h=1
gc.push("transform")
for j=start,min(start+21,#F)do for j=start,min(start+21,#F)do
while j==P.clearingRow[h]do while j==P.clearingRow[h]do
h=h+1 h=h+1
dy=dy+stepY
gc.translate(0,-stepY) gc.translate(0,-stepY)
gc.setColor(1,1,1,A) gc.setColor(1,1,1,A)
gc.rectangle("fill",0,30-30*j,300,stepY) gc.rectangle("fill",0,30-30*j,300,stepY)
@@ -468,7 +468,7 @@ local function drawField(P)
end end
end end
end end
gc.translate(0,dy) gc.pop()
end end
end end
local function drawFXs(P) local function drawFXs(P)
@@ -955,71 +955,27 @@ local function Pdraw_demo(P)
--Camera --Camera
gc.push("transform") 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 --Frame
gc.setColor(.1,.1,.1,.8) gc.setColor(0,0,0,.6)
gc.rectangle("fill",0,0,300,600) gc.rectangle("fill",0,0,300,600)
gc.setLineWidth(2) gc.setLineWidth(2)
gc.setColor(1,1,1) gc.setColor(1,1,1)
gc.rectangle("line",-1,-1,302,602) gc.rectangle("line",-1,-1,302,602)
gc.push("transform") gc.push("transform")
gc.translate(0,600) gc.translate(0,600)
if P.falling==-1 then drawField(P)
--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
drawFXs(P) drawFXs(P)
if P.cur and P.waiting==-1 then if P.cur and P.waiting==-1 then
--Draw ghost if ENV.ghost then drawGhost(P,curColor)end
if ENV.ghost then if ENV.block then
gc.setColor(1,1,1,ENV.ghost) drawBlockOutline(P,curColor,P.lockDelay/ENV.lock)
for i=1,P.r do for j=1,P.c do drawBlock(P,curColor)
if P.cur.bk[i][j]then
drawCell(i+P.imgY-1,j+P.curX-1,curColor)
end 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 end
gc.pop() gc.pop()
@@ -1043,9 +999,7 @@ local function Pdraw_demo(P)
gc.draw(_,285,40*N-10,nil,16,nil,_:getWidth(),_:getHeight()*.5) gc.draw(_,285,40*N-10,nil,16,nil,_:getWidth(),_:getHeight()*.5)
N=N+1 N=N+1
end end
gc.pop()
gc.setColor(1,1,1)
gc.translate(-P.fieldOff.x,-P.fieldOff.y)
TEXT.draw(P.bonus) TEXT.draw(P.bonus)
gc.pop() gc.pop()
end end