From 32403078bc42e5aa0ba498902d0404248beeacdf Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 2 May 2021 20:24:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=80=E7=82=B9=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/init.lua | 32 +++++----- parts/player/draw.lua | 145 ++++++++++++++++++++---------------------- 2 files changed, 86 insertions(+), 91 deletions(-) diff --git a/Zframework/init.lua b/Zframework/init.lua index 88a620b8..d629e587 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -54,11 +54,12 @@ local setFont=setFont local int,rnd,abs=math.floor,math.random,math.abs local min,sin=math.min,math.sin local ins,rem=table.insert,table.remove -local SCR=SCR + +local WIDGET,SCR,SCN=WIDGET,SCR,SCN +local xOy=SCR.xOy local mx,my,mouseShow=-20,-20,false local touching--First touching ID(userdata) -local xOy=SCR.xOy joysticks={} local devMode @@ -457,16 +458,15 @@ love.draw,love.update=nil--remove default draw/update function love.run() local love=love - local SCN,WIDGET=SCN,WIDGET local VOC,BG,SYSFX=VOC,BG,SYSFX local TASK,LOG,TEXT=TASK,LOG,TEXT - local SETTING=SETTING - local TIME=TIME + local TEXTURE,TIME=TEXTURE,TIME + local SETTING,VERSION=SETTING,VERSION + local destroyPlayers=destroyPlayers local STEP,WAIT=love.timer.step,love.timer.sleep - local FPS=love.timer.getFPS - local MINI=love.window.isMinimized + local FPS,MINI=love.timer.getFPS,love.window.isMinimized local PUMP,POLL=love.event.pump,love.event.poll local frameTimeList={} @@ -485,9 +485,9 @@ function love.run() return function() local _ - local t=TIME() - local dt=t-lastFrame - lastFrame=t + local time=TIME() + local dt=time-lastFrame + lastFrame=time --EVENT PUMP() @@ -533,11 +533,11 @@ function love.run() --Draw cursor if mouseShow then - local R=int((t+1)/2)%7+1 + local R=int((time+1)/2)%7+1 _=minoColor[SETTING.skin[R]] - gc_setColor(_[1],_[2],_[3],min(abs(1-t%2),.3)) + gc_setColor(_[1],_[2],_[3],min(abs(1-time%2),.3)) _=SCS[R][0] - gc_draw(TEXTURE.miniBlock[R],mx,my,t%3.14159265359*4,16,16,_[2]+.5,#BLOCKS[R][0]-_[1]-.5) + gc_draw(TEXTURE.miniBlock[R],mx,my,time%3.14159265359*4,16,16,_[2]+.5,#BLOCKS[R][0]-_[1]-.5) gc_setColor(1,1,1) gc_draw(TEXTURE[ms.isDown(1)and'cursor_hold'or'cursor'],mx,my,nil,nil,nil,8,8) end @@ -594,7 +594,7 @@ function love.run() gc_setColor(1,1,1) gc_draw(TEXTURE.ws_dead,-20,20*i-20) elseif status=='connecting'then - gc_setColor(1,1,1,.5+.3*sin(t*6.26)) + gc_setColor(1,1,1,.5+.3*sin(time*6.26)) gc_draw(TEXTURE.ws_connecting,-20,20*i-20) elseif status=='running'then gc_setColor(1,1,1) @@ -622,10 +622,10 @@ function love.run() end --Fresh power info. - if t-lastFreshPow>2.6 then + if time-lastFreshPow>2.6 then if SETTING.powerInfo and LOADED then updatePowerInfo() - lastFreshPow=t + lastFreshPow=time end if gc.getWidth()~=SCR.w then love.resize(gc.getWidth(),gc.getHeight()) diff --git a/parts/player/draw.lua b/parts/player/draw.lua index f152ea96..279e88df 100644 --- a/parts/player/draw.lua +++ b/parts/player/draw.lua @@ -9,32 +9,13 @@ local gc_stencil,gc_setStencilTest=gc.stencil,gc.setStencilTest local int,ceil,rnd=math.floor,math.ceil,math.random local max,min,sin,modf=math.max,math.min,math.sin,math.modf -local setFont,mDraw,mStr=setFont,mDraw,mStr -local TIME=TIME +local setFont,mDraw,mStr,mText=setFont,mDraw,mStr,mText +local SKIN,TEXTURE,IMG=SKIN,TEXTURE,IMG +local TEXT,COLOR,GAME,TIME=TEXT,COLOR,GAME,TIME +local shader_alpha,shader_lighter=SHADER.alpha,SHADER.lighter +local drawableText,missionEnum,minoColor=drawableText,missionEnum,minoColor -local frameColorList={ - [0]=COLOR.Z, - COLOR.lG, - COLOR.lB, - COLOR.lV, - COLOR.lO, -} ---local function drawCell(y,x,id)gc_draw(SKIN.curText[id],30*x-30,-30*y)end -local function stencilBoard()gc_rectangle('fill',0,-10,300,610)end -local function drawGrid(P) - local d=P.fieldBeneath+P.fieldUp - gc_setLineWidth(1) - gc_setColor(1,1,1,P.gameEnv.grid) - for x=1,9 do - gc_line(30*x,-10,30*x,600) - end - gc_push('transform') - gc_translate(0,d-30*int(d/30)) - for y=0,19 do - gc_line(0,30*y,300,30*y) - end - gc_pop() -end +local frameColorList={[0]=COLOR.Z,COLOR.lG,COLOR.lB,COLOR.lV,COLOR.lO} local function boardTransform(mode) if mode then if mode=="U-D"then @@ -49,15 +30,35 @@ local function boardTransform(mode) end end end +local function applyFieldOffset(P,notNorm) + if not notNorm then gc_translate(150,0)end + local O=P.fieldOff + gc_translate(O.x+150,O.y+300) + gc_rotate(O.a) + gc_translate(-150,-300) +end +local function stencilBoard()gc_rectangle('fill',0,-10,300,610)end + +local function drawGrid(P) + gc_setLineWidth(1) + + gc_setColor(1,1,1,P.gameEnv.grid) + for x=1,9 do gc_line(30*x,-10,30*x,600)end + + local dx=P.fieldBeneath+P.fieldUp + dx=dx-30*int(dx/30) + gc_translate(0,dx) + for y=0,19 do gc_line(0,30*y,300,30*y)end + gc_translate(0,-dx) +end local function drawRow(h,V,L,showInvis) local texture=SKIN.curText local t=TIME()*4 for i=1,10 do if L[i]>0 then if V[i]>0 then - local a=V[i]*.05 - gc_setColor(1,1,1,a) - gc_draw(texture[L[i]],30*i-30,-30*h)-- drawCell(j,i,L[i]) + gc_setColor(1,1,1,V[i]*.05) + gc_draw(texture[L[i]],30*i-30,-30*h) elseif showInvis then gc_setColor(1,1,1,.3+.08*sin(.5*(h-i)+t)) gc_rectangle('fill',30*i-30,-30*h,30,30) @@ -72,7 +73,7 @@ local function drawField(P) if P.falling==-1 then--Blocks only if ENV.upEdge then - gc_setShader(SHADER.lighter) + gc_setShader(shader_lighter) gc_translate(0,-4) -- for j=start,min(start+21,#F)do drawRow(j,V[j],F[j])end @@ -90,7 +91,7 @@ local function drawField(P) local h=1 if ENV.upEdge then gc_push('transform') - gc_setShader(SHADER.lighter) + gc_setShader(shader_lighter) gc_translate(0,-4) -- for j=start,min(start+21,#F)do @@ -149,7 +150,7 @@ local function drawFXs(P) for i=1,#P.moveFX do local S=P.moveFX[i] gc_setColor(1,1,1,.6-S[4]*.6) - gc_draw(texture[S[1]],30*S[2]-30,-30*S[3])-- drawCell(S[3],S[2],S[1]) + gc_draw(texture[S[1]],30*S[2]-30,-30*S[3]) end --ClearFX @@ -168,13 +169,13 @@ local function drawGhost(P,clr) local CB=P.cur.bk for i=1,#CB do for j=1,#CB[1]do if CB[i][j]then - gc_draw(texture[clr],30*(j+P.curX-1)-30,-30*(i+P.ghoY-1))-- drawCell(i+P.ghoY-1,j+P.curX-1,clr) + gc_draw(texture[clr],30*(j+P.curX-1)-30,-30*(i+P.ghoY-1)) end end end end local function drawBlockOutline(P,texture,trans) - SHADER.alpha:send("a",trans) - gc_setShader(SHADER.alpha) + shader_alpha:send("a",trans) + gc_setShader(shader_alpha) local CB=P.cur.bk for i=1,#CB do for j=1,#CB[1]do if CB[i][j]then @@ -190,11 +191,11 @@ local function drawBlockOutline(P,texture,trans) end local function drawBlock(P,clr) gc_setColor(1,1,1) - local texture=SKIN.curText + local texture=SKIN.curText[clr] local CB=P.cur.bk for i=1,#CB do for j=1,#CB[1]do if CB[i][j]then - gc_draw(texture[clr],30*(j+P.curX-1)-30,-30*(i+P.curY-1))-- drawCell(i+P.curY-1,j+P.curX-1,clr) + gc_draw(texture,30*(j+P.curX-1)-30,-30*(i+P.curY-1)) end end end end @@ -287,8 +288,8 @@ local function drawHold(P) local ENV=P.gameEnv if ENV.holdCount==0 then return end + local holdQueue=P.holdQueue local N=ENV.holdCount*72 - local texture=SKIN.curText gc_push('transform') gc_translate(-140,36) gc_setColor(0,0,0,.4)gc_rectangle('fill',0,0,124,N+8) @@ -297,21 +298,22 @@ local function drawHold(P) mText(drawableText.hold,62,-51) gc_setColor(1,1,1) - if #P.holdQueue2 and 2.2/#bk or 1 gc_scale(k) for i=1,#bk do for j=1,#bk[1]do if bk[i][j]then - gc_draw(texture[clr],30*(j-#bk[1]*.5)-30,-30*(i-#bk*.5))-- drawCell(i+1.36-#B*.5,j+2.06-#B[1]*.5,clr) + gc_draw(texture,30*(j-#bk[1]*.5)-30,-30*(i-#bk*.5)) end end end gc_scale(1/k) @@ -343,25 +345,25 @@ end local function drawFinesseCombo_norm(P) if P.finesseCombo>2 then local S=P.stat - local _=P.finesseComboTime + local t=P.finesseComboTime local str=P.finesseCombo.."x" if S.finesseRate==5*S.piece then - gc_setColor(.9,.9,.3,_*.2) + gc_setColor(.9,.9,.3,t*.2) gc_print(str,20,570) - gc_setColor(.9,.9,.3,1.2-_*.1) + gc_setColor(.9,.9,.3,1.2-t*.1) elseif S.maxFinesseCombo==S.piece then - gc_setColor(.7,.7,1,_*.2) + gc_setColor(.7,.7,1,t*.2) gc_print(str,20,570) - gc_setColor(.7,.7,1,1.2-_*.1) + gc_setColor(.7,.7,1,1.2-t*.1) else - gc_setColor(1,1,1,_*.2) + gc_setColor(1,1,1,t*.2) gc_print(str,20,570) - gc_setColor(1,1,1,1.2-_*.1) + gc_setColor(1,1,1,1.2-t*.1) end - if _>0 then + if t>0 then gc_push('transform') gc_translate(20,600) - gc_scale(1+_*.08) + gc_scale(1+t*.08) gc_print(str,0,-30) gc_pop() else @@ -399,7 +401,6 @@ local function drawLife(life) end local function drawMission(P) if not P.curMission then return end - local missionEnum=missionEnum local L=P.gameEnv.mission local cur=P.curMission @@ -456,7 +457,7 @@ function draw.drawNext_norm(P) gc_scale(k) for i=1,#bk do for j=1,#bk[1]do if bk[i][j]then - gc_draw(texture[clr],30*(j-#bk[1]*.5)-30,-30*(i-#bk*.5))-- drawCell(i-#bk*.5,j-#bk[1]*.5,clr) + gc_draw(texture[clr],30*(j-#bk[1]*.5)-30,-30*(i-#bk*.5)) end end end gc_scale(1/k) @@ -494,7 +495,7 @@ function draw.drawNext_hidden(P) gc_scale(k) for i=1,#bk do for j=1,#bk[1]do if bk[i][j]then - gc_draw(texture[clr],30*(j-#bk[1]*.5)-30,-30*(i-#bk*.5))-- drawCell(i-#bk*.5,j-#bk[1]*.5,clr) + gc_draw(texture[clr],30*(j-#bk[1]*.5)-30,-30*(i-#bk*.5)) end end end gc_scale(1/k) @@ -514,21 +515,14 @@ function draw.drawNext_hidden(P) end gc_pop() end +draw.applyFieldOffset=applyFieldOffset -function draw.applyFieldOffset(P,notNorm) - if not notNorm then gc_translate(150,0)end - local O=P.fieldOff - gc_translate(O.x,O.y) - gc_translate(150,300) - gc_rotate(O.a) - gc_translate(-150,-300) -end function draw.drawTargetLine(P,r) if r<21+(P.fieldBeneath+P.fieldUp)/30 and r>0 then gc_setLineWidth(4) gc_setColor(1,r>10 and 0 or rnd(),.5) gc_push('transform') - draw.applyFieldOffset(P) + applyFieldOffset(P) gc_line(0,600-30*r,300,600-30*r) gc_pop() end @@ -543,7 +537,7 @@ function draw.norm(P) --Field-related things gc_push('transform') - draw.applyFieldOffset(P) + applyFieldOffset(P) --Fill field gc_setColor(0,0,0,.6) @@ -585,10 +579,12 @@ function draw.norm(P) local centerX=30*(P.curX+P.cur.sc[2])-15 --Draw ghost & rotation center - if ENV.ghost then drawGhost(P,curColor)end - if ENV.center and ENV.ghost then - gc_setColor(1,1,1,trans*ENV.center) - gc_draw(IMG.spinCenter,centerX,-30*(P.ghoY+P.cur.sc[1])+15,nil,nil,nil,4,4) + if ENV.ghost then + drawGhost(P,curColor) + if ENV.center then + gc_setColor(1,1,1,trans*ENV.center) + gc_draw(IMG.spinCenter,centerX,-30*(P.ghoY+P.cur.sc[1])+15,nil,nil,nil,4,4) + end end local dy=ENV.smooth and P.ghoY~=P.curY and(P.dropDelay/ENV.drop-1)*30 or 0 @@ -697,7 +693,7 @@ function draw.norm_remote(P) --Field-related things gc_push('transform') - draw.applyFieldOffset(P) + applyFieldOffset(P) --Draw username setFont(30) @@ -816,12 +812,12 @@ function draw.norm_remote(P) --Score & Time setFont(25) - local tm=int(P.stat.time*100)*.01 + local time=int(P.stat.time*100)*.01 gc_setColor(0,0,0,.3) gc_print(P.score1,18,509) - gc_print(tm,18,539) + gc_print(time,18,539) gc_setColor(COLOR.lY)gc_print(P.score1,20,510) - gc_setColor(COLOR.N)gc_print(tm,20,540) + gc_setColor(COLOR.N)gc_print(time,20,540) drawFinesseCombo_remote(P) drawLife(P.life) @@ -894,7 +890,7 @@ function draw.demo(P) gc_translate(P.x,P.y) gc_scale(P.size) gc_push('transform') - draw.applyFieldOffset(P,true) + applyFieldOffset(P,true) --Frame gc_setColor(0,0,0,.6) @@ -920,13 +916,12 @@ function draw.demo(P) gc_pop() local blockImg=TEXTURE.miniBlock - local libColor=minoColor local skinSet=ENV.skin --Draw hold local N=1 while P.holdQueue[N]do local id=P.holdQueue[N].id - _=libColor[skinSet[id]] + _=minoColor[skinSet[id]] gc_setColor(_[1],_[2],_[3],.3) _=blockImg[id] gc_draw(_,15,40*N-10,nil,16,nil,0,_:getHeight()*.5) @@ -937,7 +932,7 @@ function draw.demo(P) N=1 while N<=ENV.nextCount and P.nextQueue[N]do local id=P.nextQueue[N].id - _=libColor[skinSet[id]] + _=minoColor[skinSet[id]] gc_setColor(_[1],_[2],_[3],.3) _=blockImg[id] gc_draw(_,285,40*N-10,nil,16,nil,_:getWidth(),_:getHeight()*.5)