修改玩家绘制流程,修复镜头平移和遮罩的一些冲突

This commit is contained in:
MrZ626
2021-08-10 19:54:51 +08:00
parent 7c326ce0d7
commit d6d2d394bc
8 changed files with 106 additions and 108 deletions

View File

@@ -21,8 +21,7 @@ return{
PLY.draw.applyField(P) PLY.draw.applyField(P)
gc.setColor(1,1,1,.1) gc.setColor(1,1,1,.1)
gc.draw(IMG.electric,0,106,0,2.6) gc.draw(IMG.electric,0,106,0,2.6)
gc.setStencilTest() PLY.draw.cancelField(P)
gc.pop()
end, end,
score=function(P)return{min(P.stat.row,200),P.stat.time}end, score=function(P)return{min(P.stat.row,200),P.stat.time}end,
scoreDisp=function(D)return D[1].." Lines "..STRING.time(D[2])end, scoreDisp=function(D)return D[1].." Lines "..STRING.time(D[2])end,

View File

@@ -22,8 +22,7 @@ return{
PLY.draw.applyField(P) PLY.draw.applyField(P)
gc.setColor(1,1,1,.1) gc.setColor(1,1,1,.1)
gc.draw(IMG.electric,0,106,0,2.6) gc.draw(IMG.electric,0,106,0,2.6)
gc.setStencilTest() PLY.draw.cancelField(P)
gc.pop()
end, end,
score=function(P)return{min(P.stat.row,200),P.stat.time}end, score=function(P)return{min(P.stat.row,200),P.stat.time}end,
scoreDisp=function(D)return D[1].." Lines "..STRING.time(D[2])end, scoreDisp=function(D)return D[1].." Lines "..STRING.time(D[2])end,

View File

@@ -18,8 +18,7 @@ return{
PLY.draw.applyField(P) PLY.draw.applyField(P)
gc.setColor(1,1,1,.1) gc.setColor(1,1,1,.1)
gc.draw(IMG.electric,0,106,0,2.6) gc.draw(IMG.electric,0,106,0,2.6)
gc.setStencilTest() PLY.draw.cancelField(P)
gc.pop()
end, end,
score=function(P)return{min(P.stat.row,200),P.stat.time}end, score=function(P)return{min(P.stat.row,200),P.stat.time}end,
scoreDisp=function(D)return D[1].." Lines "..STRING.time(D[2])end, scoreDisp=function(D)return D[1].." Lines "..STRING.time(D[2])end,

View File

@@ -21,8 +21,7 @@ return{
PLY.draw.applyField(P) PLY.draw.applyField(P)
gc.setColor(1,1,1,.1) gc.setColor(1,1,1,.1)
gc.draw(IMG.electric,0,106,0,2.6) gc.draw(IMG.electric,0,106,0,2.6)
gc.setStencilTest() PLY.draw.cancelField(P)
gc.pop()
end, end,
score=function(P)return{min(P.stat.row,100),P.stat.time}end, score=function(P)return{min(P.stat.row,100),P.stat.time}end,
scoreDisp=function(D)return D[1].." Lines "..STRING.time(D[2])end, scoreDisp=function(D)return D[1].." Lines "..STRING.time(D[2])end,

View File

@@ -63,7 +63,6 @@ return{
end end
end end end end
end end
gc.setStencilTest() PLY.draw.cancelField(P)
gc.pop()
end, end,
} }

View File

@@ -37,8 +37,7 @@ return{
PLY.draw.applyField(P) PLY.draw.applyField(P)
gc.setColor(1,.5,.5,.2) gc.setColor(1,.5,.5,.2)
gc.rectangle('fill',30*L[1]-30,0,30,600) gc.rectangle('fill',30*L[1]-30,0,30,600)
gc.setStencilTest() PLY.draw.cancelField(P)
gc.pop()
end end
end, end,
score=function(P)return{P.modeData.tsd,P.stat.time}end, score=function(P)return{P.modeData.tsd,P.stat.time}end,

View File

@@ -37,8 +37,7 @@ return{
gc.setColor(1,.5,.5,.3-i*.05) gc.setColor(1,.5,.5,.3-i*.05)
gc.rectangle('fill',30*L[i]-30,0,30,600) gc.rectangle('fill',30*L[i]-30,0,30,600)
end end
gc.setStencilTest() PLY.draw.cancelField(P)
gc.pop()
end, end,
score=function(P)return{P.modeData.tsd,P.stat.time}end, score=function(P)return{P.modeData.tsd,P.stat.time}end,
scoreDisp=function(D)return D[1].."TSD "..STRING.time(D[2])end, scoreDisp=function(D)return D[1].."TSD "..STRING.time(D[2])end,

View File

@@ -85,14 +85,25 @@ local function stencilBoard()gc_rectangle('fill',0,-10,300,610)end
local function applyField(P) local function applyField(P)
gc_push('transform') gc_push('transform')
--Apply fieldOffset
local O=P.fieldOff local O=P.fieldOff
gc_translate(O.x+150+150,O.y+300) gc_translate(O.x+150+150,O.y+300)
gc_rotate(O.a) gc_rotate(O.a)
gc_translate(-150,-300) gc_translate(-150,-300)
gc_translate(0,P.fieldBeneath+P.fieldUp)
--Apply stencil
gc_stencil(stencilBoard) gc_stencil(stencilBoard)
gc_setStencilTest('equal',1) gc_setStencilTest('equal',1)
--Move camera
gc_push('transform')
boardTransform(P.gameEnv.flipBoard)
gc_translate(0,P.fieldBeneath+P.fieldUp)
end
local function cancelField()
gc_setStencilTest()
gc_pop()
gc_pop()
end end
local function drawRow(texture,h,V,L,showInvis) local function drawRow(texture,h,V,L,showInvis)
@@ -531,6 +542,7 @@ end
local draw={} local draw={}
draw.drawGhost=drawGhost draw.drawGhost=drawGhost
draw.applyField=applyField draw.applyField=applyField
draw.cancelField=cancelField
function draw.drawNext_norm(P) function draw.drawNext_norm(P)
local ENV=P.gameEnv local ENV=P.gameEnv
local texture=P.skinLib local texture=P.skinLib
@@ -606,15 +618,13 @@ function draw.drawNext_hidden(P)
gc_translate(-476,-20) gc_translate(-476,-20)
end end
function draw.drawTargetLine(P,r) function draw.drawTargetLine(P,r)
local d=P.fieldBeneath+P.fieldUp if r<=20+(P.fieldBeneath+P.fieldUp+10)/30 and r>0 then
if r<21+d/30 and r>0 then
gc_setLineWidth(3) gc_setLineWidth(3)
gc_setColor(1,r>10 and 0 or .2+.8*rnd(),.5) gc_setColor(1,r>10 and 0 or .2+.8*rnd(),.5)
applyField(P) applyField(P)
r=600-30*(r)+d r=600-30*r
gc_line(0,r,300,r) gc_line(0,r,300,r)
gc_setStencilTest() cancelField()
gc_pop()
end end
end end
function draw.drawProgress(s1,s2) function draw.drawProgress(s1,s2)
@@ -643,6 +653,7 @@ end
function draw.norm(P) function draw.norm(P)
local ENV=P.gameEnv local ENV=P.gameEnv
local FBN,FUP=P.fieldBeneath,P.fieldUp local FBN,FUP=P.fieldBeneath,P.fieldUp
local camDY=FBN+FUP
local t=TIME() local t=TIME()
local replaying=GAME.replaying local replaying=GAME.replaying
gc_push('transform') gc_push('transform')
@@ -654,32 +665,26 @@ function draw.norm(P)
gc_setColor(.97,.97,.975) gc_setColor(.97,.97,.975)
mStr(P.username,300,-60) mStr(P.username,300,-60)
--Field-related things --Field-related things
applyField(P) applyField(P)
--Fill field --Fill field
gc_setColor(0,0,0,.6) gc_setColor(0,0,0,.6)
gc_rectangle('fill',0,-10,300,610) gc_rectangle('fill',0,-10-camDY,300,610)
--Stenciled in-field things
gc_stencil(stencilBoard)
gc_setStencilTest('equal',1)
gc_push('transform')
boardTransform(ENV.flipBoard)
--Draw grid --Draw grid
if ENV.grid then if ENV.grid then
gc_setColor(1,1,1,ENV.grid) gc_setColor(1,1,1,ENV.grid)
gc_draw(gridLines,0,(FBN+FUP+10)%30-50) gc_draw(gridLines,0,-40-(camDY-camDY%30))
end end
--Move camera gc_translate(0,600)
gc_translate(0,600+FBN+FUP)
local fieldTop=-ENV.fieldH*30 local fieldTop=-ENV.fieldH*30
--Draw dangerous area --Draw dangerous area
gc_setColor(1,0,0,.3) gc_setColor(1,0,0,.3)
gc_rectangle('fill',0,fieldTop,300,-FUP-FBN-fieldTop-620) gc_rectangle('fill',0,fieldTop,300,-10-camDY)
--Draw field --Draw field
drawField(P,replaying) drawField(P,replaying)
@@ -745,16 +750,6 @@ function draw.norm(P)
gc_draw(texture,30*L[i],-30*L[i+1]-30) gc_draw(texture,30*L[i],-30*L[i+1]-30)
end end
end end
gc_pop()
gc_setStencilTest()
drawBuffer(P)
drawB2Bbar(P)
drawLDI(P,ENV)
--Draw boarders
gc_setColor(P.frameColor)
gc_draw(playerBoarder,-17,-12)
--Draw target selecting pad --Draw target selecting pad
if GAME.modeEnv.royaleMode then if GAME.modeEnv.royaleMode then
@@ -787,8 +782,16 @@ function draw.norm(P)
gc_setColor(COLOR.rainbow_gray(t*.626+i*.1,alpha)) gc_setColor(COLOR.rainbow_gray(t*.626+i*.1,alpha))
gc_line(20*i-190,-2,20*i+10,602) gc_line(20*i-190,-2,20*i+10,602)
end end
gc_setStencilTest()
end end
gc_translate(0,-600)
gc_setStencilTest()
gc_pop()
--Draw Frame
gc_setColor(P.frameColor)
gc_draw(playerBoarder,-17,-12)
drawBuffer(P)
drawB2Bbar(P)
drawLDI(P,ENV)
--Spike --Spike
local sp,spt=P.spike,P.spikeTime local sp,spt=P.spike,P.spikeTime
@@ -814,6 +817,7 @@ function draw.norm(P)
-- gc_line(0,600-P.garbageBeneath*30,300,600-P.garbageBeneath*30) -- gc_line(0,600-P.garbageBeneath*30,300,600-P.garbageBeneath*30)
gc_pop() gc_pop()
--Draw HUD
P:drawNext() P:drawNext()
drawHold(P) drawHold(P)
@@ -919,7 +923,7 @@ function draw.demo(P)
gc_rectangle('fill',0,0,300,600,3) gc_rectangle('fill',0,0,300,600,3)
gc_push('transform') gc_push('transform')
gc_translate(0,600) gc_translate(0,600)
drawField(P,GAME.replaying) drawField(P)
drawFXs(P) drawFXs(P)
if P.cur and P.waiting==-1 then if P.cur and P.waiting==-1 then
if ENV.ghost then drawGhost[ENV.ghostType](P,curColor,ENV.ghost)end if ENV.ghost then drawGhost[ENV.ghostType](P,curColor,ENV.ghost)end
@@ -963,6 +967,7 @@ function draw.demo(P)
gc_setColor(COLOR.Z) gc_setColor(COLOR.Z)
gc_rectangle('line',-1,-1,302,602,3) gc_rectangle('line',-1,-1,302,602,3)
gc_pop() gc_pop()
gc_pop()
gc_translate(150,0) gc_translate(150,0)
TEXT.draw(P.bonus) TEXT.draw(P.bonus)
gc_pop() gc_pop()