From e71bf616f2ac81f07dd63c2becc7daeca5a2d4a5 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Mon, 1 Mar 2021 21:05:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=8B=E8=BD=AC=E4=B8=AD=E5=BF=83=E5=92=8C?= =?UTF-8?q?=E6=9C=9D=E5=90=91=E4=BF=A1=E6=81=AF=E6=94=BE=E5=85=A5=E6=96=B9?= =?UTF-8?q?=E5=9D=97=E5=AF=B9=E8=B1=A1=E4=B8=AD=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?+=E4=BF=AE=E6=94=B9=E5=87=BA=E5=9D=97=E9=AB=98=E5=BA=A6?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=97=A0=E9=99=90=E4=B8=8A=E8=B8=A2?= =?UTF-8?q?bug=EF=BC=8C=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/sfx.lua | 2 +- parts/ai.lua | 2 +- parts/kickList.lua | 6 ++-- parts/player/draw.lua | 21 ++++++------ parts/player/init.lua | 12 +++++-- parts/player/player.lua | 73 ++++++++++++++++++++++++----------------- 6 files changed, 69 insertions(+), 47 deletions(-) diff --git a/Zframework/sfx.lua b/Zframework/sfx.lua index e52e5a77..a1c49dcd 100644 --- a/Zframework/sfx.lua +++ b/Zframework/sfx.lua @@ -27,7 +27,7 @@ function SFX.init(list) SFX.loadOne=nil function SFX.fieldPlay(s,v,P) - SFX.play(s,v,(P.curX+P.sc[2]-5.5)*.15) + SFX.play(s,v,(P.curX+P.cur.sc[2]-5.5)*.15) end function SFX.play(s,vol,pos) if SETTING.sfx==0 or vol==0 then return end diff --git a/parts/ai.lua b/parts/ai.lua index 866ab9cb..4f5eff1e 100644 --- a/parts/ai.lua +++ b/parts/ai.lua @@ -79,7 +79,7 @@ if _CC then P.holdTime=P.gameEnv.holdCount P.cur=rem(P.nextQueue,1) - P.sc,P.dir=spinCenters[P.cur.id][0],0 + P.cur.sc,P.cur.dir=spinCenters[P.cur.id][0],0--TODO P.curX,P.curY=blockPos[P.cur.id],21+ceil(P.fieldBeneath/30)-#P.cur.bk+min(int(#P.field*.2),2) P:newNext() diff --git a/parts/kickList.lua b/parts/kickList.lua index be5d38e2..f61688e9 100644 --- a/parts/kickList.lua +++ b/parts/kickList.lua @@ -121,7 +121,9 @@ do [31]={{ 0,-1},{ 0, 1},{-1, 0},{ 0,-2},{ 0, 2}}, },--T function(P,d) - P:freshBlock("fresh") + if P.gameEnv.easyFresh then + P:freshBlock("fresh") + end if P.gameEnv.ospin then local x,y=P.curX,P.curY if y==P.ghoY and((P:solid(x-1,y)or P:solid(x-1,y+1)))and(P:solid(x+2,y)or P:solid(x+2,y+1))then @@ -140,7 +142,7 @@ do C.id=id C.bk=bk P.curX,P.curY=x,y - P.dir,P.sc=dir,spinCenters[id][dir] + P.cur.dir,P.cur.sc=dir,spinCenters[id][dir] P.spinLast=2 P.stat.rotate=P.stat.rotate+1 P:freshBlock("move") diff --git a/parts/player/draw.lua b/parts/player/draw.lua index 790aa3c2..abed2a26 100644 --- a/parts/player/draw.lua +++ b/parts/player/draw.lua @@ -4,7 +4,7 @@ local gc_draw,gc_print,gc_line,gc_rectangle,gc_circle=gc.draw,gc.print,gc.line,g local gc_setColor,gc_setLineWidth=gc.setColor,gc.setLineWidth local TIME=TIME local int,ceil,rnd=math.floor,math.ceil,math.random -local max,min,sin=math.max,math.min,math.sin +local max,min,sin,modf=math.max,math.min,math.sin,math.modf local SCR=SCR local setFont,mStr=setFont,mStr @@ -212,8 +212,9 @@ local function drawBlock(P,clr) end local function drawNextPreview(P,B) gc_setColor(1,1,1,.8) + local y=int(21-modf(B.sc[1]))+ceil(P.fieldBeneath/30) + B=B.bk local x=int(6-#B[1]*.5) - local y=21+ceil(P.fieldBeneath/30) for i=1,#B do for j=1,#B[1]do if B[i][j]then gc_draw(puzzleMark[-1],30*(x+j-2),30*(1-y-i)) @@ -591,13 +592,13 @@ function draw.norm(P) local curColor=P.cur.color local trans=P.lockDelay/ENV.lock - local centerX=30*(P.curX+P.sc[2])-15 + 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.sc[1])+15,nil,nil,nil,4,4) + gc_draw(IMG.spinCenter,centerX,-30*(P.ghoY+P.cur.sc[1])+15,nil,nil,nil,4,4) end local dy=ENV.smooth and P.ghoY~=P.curY and(P.dropDelay/ENV.drop-1)*30 or 0 @@ -608,7 +609,7 @@ function draw.norm(P) drawBlock(P,curColor) if ENV.center then gc_setColor(1,1,1,ENV.center) - gc_draw(IMG.spinCenter,centerX,-30*(P.curY+P.sc[1])+15,nil,nil,nil,4,4) + gc_draw(IMG.spinCenter,centerX,-30*(P.curY+P.cur.sc[1])+15,nil,nil,nil,4,4) end end gc_translate(0,dy) @@ -616,7 +617,7 @@ function draw.norm(P) --Draw next preview if ENV.nextPos and P.nextQueue[1]then - drawNextPreview(P,P.nextQueue[1].bk) + drawNextPreview(P,P.nextQueue[1]) end gc.setScissor() @@ -748,13 +749,13 @@ function draw.norm_remote(P) local curColor=P.cur.color local trans=P.lockDelay/ENV.lock - local centerX=30*(P.curX+P.sc[2])-15 + 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.sc[1])+15,nil,nil,nil,4,4) + gc_draw(IMG.spinCenter,centerX,-30*(P.ghoY+P.cur.sc[1])+15,nil,nil,nil,4,4) end local dy=ENV.smooth and P.ghoY~=P.curY and(P.dropDelay/ENV.drop-1)*30 or 0 @@ -765,7 +766,7 @@ function draw.norm_remote(P) drawBlock(P,curColor) if ENV.center then gc_setColor(1,1,1,ENV.center) - gc_draw(IMG.spinCenter,centerX,-30*(P.curY+P.sc[1])+15,nil,nil,nil,4,4) + gc_draw(IMG.spinCenter,centerX,-30*(P.curY+P.cur.sc[1])+15,nil,nil,nil,4,4) end end gc_translate(0,dy) @@ -773,7 +774,7 @@ function draw.norm_remote(P) --Draw next preview if ENV.nextPos and P.nextQueue[1]then - drawNextPreview(P,P.nextQueue[1].bk) + drawNextPreview(P,P.nextQueue[1]) end gc.setScissor() diff --git a/parts/player/init.lua b/parts/player/init.lua index 52abf5ba..5755cb18 100644 --- a/parts/player/init.lua +++ b/parts/player/init.lua @@ -128,8 +128,16 @@ local function newEmptyPlayer(id,mini) P.showTime=false P.keepVisible=true - --P.cur={bk=matrix[2], id=shapeID, color=colorID, name=nameID} - --P.sc,P.dir={0,0},0--SpinCenterCoord, direction + --[[ + P.cur={ + id=shapeID, + bk=matrix[2], + sc=table[2], + dir=direction, + name=nameID + color=colorID, + } + ]] -- P.curX,P.curY,P.ghoY,P.minY=0,0,0,0--x,y,ghostY P.holdQueue={} P.holdTime=0 diff --git a/parts/player/player.lua b/parts/player/player.lua index 52c5f15a..8a96a18d 100644 --- a/parts/player/player.lua +++ b/parts/player/player.lua @@ -5,7 +5,7 @@ local Player={}--Player class local int,ceil,rnd=math.floor,math.ceil,math.random -local max,min=math.max,math.min +local max,min,modf=math.max,math.min,math.modf local ins,rem=table.insert,table.remove local ct=coroutine @@ -102,7 +102,7 @@ end function Player.createBeam(P,R,send,color) local x1,y1,x2,y2 if P.mini then x1,y1=P.centerX,P.centerY - else x1,y1=P.x+(30*(P.curX+P.sc[2])-30+15+150)*P.size,P.y+(600-30*(P.curY+P.sc[1])+15)*P.size + else x1,y1=P.x+(30*(P.curX+P.cur.sc[2])-30+15+150)*P.size,P.y+(600-30*(P.curY+P.cur.sc[1])+15)*P.size end if R.small then x2,y2=R.centerX,R.centerY else x2,y2=R.x+308*R.size,R.y+450*R.size @@ -437,7 +437,7 @@ end function Player.freshBlock(P,mode)--string mode: push/move/fresh/newBlock local ENV=P.gameEnv --Fresh ghost - if(mode=="push"or mode=="move"or mode=="newBlock")and P.cur then + if(mode=="move"or mode=="newBlock"or mode=="push")and P.cur then local CB=P.cur.bk P.ghoY=min(#P.field+1,P.curY) if P._20G or ENV.sdarr==0 and P.keyPressing[7]and P.downing>ENV.sddas then @@ -471,7 +471,7 @@ function Player.freshBlock(P,mode)--string mode: push/move/fresh/newBlock end --Fresh delays - if mode=="move"or mode=="fresh"or mode=="newBlock"then + if mode=="move"or mode=="newBlock"or P.gameEnv.easyFresh and mode=="fresh"then local d0,l0=ENV.drop,ENV.lock if ENV.easyFresh then if P.lockDelay0 then @@ -531,15 +531,12 @@ end local spawnSFX_name={}for i=1,7 do spawnSFX_name[i]="spawn_"..i end function Player.resetBlock(P) local B=P.cur.bk + local sc=P.cur.sc local id=P.cur.id - local face=P.gameEnv.face[id] - local sc=scs[id][face] - P.sc=sc --Spin center - P.dir=face --Block direction P.curX=int(6-#B[1]*.5) - local y=21+ceil(P.fieldBeneath/30) + local y=int(21-modf(sc[1]))+ceil(P.fieldBeneath/30) P.curY=y - P.minY=y+sc[2] + P.minY=y+sc[1] local _=P.keyPressing --IMS @@ -581,18 +578,11 @@ end function Player.spin(P,d,ifpre) local iki=P.RS[P.cur.id] if type(iki)=="table"then - local idir=(P.dir+d)%4 + local idir=(P.cur.dir+d)%4 local icb=BLOCKS[P.cur.id][idir] local isc=scs[P.cur.id][idir] - local ix,iy=P.curX+P.sc[2]-isc[2],P.curY+P.sc[1]-isc[1] - iki=iki[P.dir*10+idir] - if not iki then - if P.gameEnv.easyFresh then - P:freshBlock("move") - end - SFX.fieldPlay(ifpre and"prerotate"or"rotate",nil,P) - return - end + local ix,iy=P.curX+P.cur.sc[2]-isc[2],P.curY+P.cur.sc[1]-isc[1] + iki=iki[P.cur.dir*10+idir] for test=1,#iki do local x,y=ix+iki[test][1],iy+iki[test][2] if not P:ifoverlap(icb,x,y)and(P.freshTime>=0 or iki[test][2]<0)then @@ -600,13 +590,13 @@ function Player.spin(P,d,ifpre) if P.gameEnv.moveFX and P.gameEnv.block then P:createMoveFX() end - P.curX,P.curY,P.dir=ix,iy,idir - P.sc,P.cur.bk=scs[P.cur.id][idir],icb + P.curX,P.curY,P.cur.dir=ix,iy,idir + P.cur.sc,P.cur.bk=isc,icb P.spinLast=test==2 and 0 or 1 if not ifpre then P:freshBlock("move") end - if iki[test][2]>0 and not P.gameEnv.easyFresh then + if iki[test][2]>0 and P.curY~=P.imgY then P.freshTime=P.freshTime-1 end @@ -619,14 +609,15 @@ function Player.spin(P,d,ifpre) end elseif iki then iki(P,d) + else + P:freshBlock("move") + SFX.fieldPlay(ifpre and"prerotate"or"rotate",nil,P) end end function Player.hold(P,ifpre) if P.holdTime>0 and(ifpre or P.waiting==-1)then if #P.holdQueue