From caf99c26058c7a6e479947a1aec18fd0b5eeb53b Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Fri, 1 Jan 2021 16:31:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E7=8E=A9=E5=AE=B6=E7=9A=84r?= =?UTF-8?q?=E5=92=8Cc=E5=B1=9E=E6=80=A7=EF=BC=8C=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=AE=9E=E6=97=B6=E6=96=B9=E5=9D=97=E5=B0=BA?= =?UTF-8?q?=E5=AF=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/ai.lua | 3 +- parts/kickList.lua | 1 - parts/player/draw.lua | 17 +++--- parts/player/init.lua | 1 - parts/player/player.lua | 127 ++++++++++++++++++++-------------------- 5 files changed, 74 insertions(+), 75 deletions(-) diff --git a/parts/ai.lua b/parts/ai.lua index 6f3de429..b2a31ad8 100644 --- a/parts/ai.lua +++ b/parts/ai.lua @@ -75,8 +75,7 @@ if _CC then P.cur=rem(P.nextQueue,1) P.sc,P.dir=spinCenters[P.cur.id][0],0 - P.r,P.c=#P.cur.bk,#P.cur.bk[1] - P.curX,P.curY=blockPos[P.cur.id],21+ceil(P.fieldBeneath/30)-P.r+min(int(#P.field*.2),2) + P.curX,P.curY=blockPos[P.cur.id],21+ceil(P.fieldBeneath/30)-#P.cur.bk+min(int(#P.field*.2),2) P:newNext() local id=CCblockID[P.nextQueue[P.AIdata.next].id] diff --git a/parts/kickList.lua b/parts/kickList.lua index 094ae707..2e56020e 100644 --- a/parts/kickList.lua +++ b/parts/kickList.lua @@ -142,7 +142,6 @@ do C.id=id C.bk=bk P.curX,P.curY=x,y - P.r,P.c=#bk,#bk[1] P.dir,P.sc=dir,spinCenters[id][dir] P.spinLast=2 P.stat.rotate=P.stat.rotate+1 diff --git a/parts/player/draw.lua b/parts/player/draw.lua index c669d625..40111cf2 100644 --- a/parts/player/draw.lua +++ b/parts/player/draw.lua @@ -121,8 +121,9 @@ end local function drawGhost(P,clr) gc_setColor(1,1,1,P.gameEnv.ghost) local texture=SKIN.curText - for i=1,P.r do for j=1,P.c do - if P.cur.bk[i][j]then + 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) end end end @@ -130,9 +131,9 @@ end local function drawBlockOutline(P,texture,trans) SHADER.alpha:send("a",trans) gc.setShader(SHADER.alpha) - local B=P.cur.bk - for i=1,P.r do for j=1,P.c do - if B[i][j]then + local CB=P.cur.bk + for i=1,#CB do for j=1,#CB[1]do + if CB[i][j]then local x=30*(j+P.curX)-60-3 local y=30-30*(i+P.curY)-3 gc_draw(texture,x,y) @@ -146,9 +147,9 @@ end local function drawBlock(P,clr) gc_setColor(1,1,1) local texture=SKIN.curText - local B=P.cur.bk - for i=1,P.r do for j=1,P.c do - if B[i][j]then + 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) end end end diff --git a/parts/player/init.lua b/parts/player/init.lua index 2fa6aa68..6481629b 100644 --- a/parts/player/init.lua +++ b/parts/player/init.lua @@ -131,7 +131,6 @@ local function newEmptyPlayer(id,mini) --P.cur={bk=matrix[2], id=shapeID, color=colorID, name=nameID} --P.sc,P.dir={0,0},0--SpinCenterCoord, direction - --P.r,P.c=0,0--row, col -- 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 c8bb14eb..f9f3a102 100644 --- a/parts/player/player.lua +++ b/parts/player/player.lua @@ -22,18 +22,18 @@ function Player.showTextF(P,text,dx,dy,font,style,spd,stop) ins(P.bonus,TEXT.getText(text,150+dx,300+dy,font*P.size,style,spd,stop)) end function Player.createLockFX(P) - local BK=P.cur.bk + local CB=P.cur.bk local t=12-P.gameEnv.lockFX*2 - for i=1,P.r do + for i=1,#CB do local y=P.curY+i-1 local L=P.clearedRow for j=1,#L do if L[j]==y then goto continue end end y=-30*y - for j=1,P.c do - if BK[i][j]then + for j=1,#CB[1]do + if CB[i][j]then ins(P.lockFX,{30*(P.curX+j-2),y,0,t}) end end @@ -46,31 +46,32 @@ end function Player.createMoveFX(P,dir) local T=10-1.5*P.gameEnv.moveFX local C=P.cur.color + local CB=P.cur.bk local x=P.curX-1 local y=P.gameEnv.smooth and P.curY+P.dropDelay/P.gameEnv.drop-2 or P.curY-1 if dir=="left"then - for i=1,P.r do for j=P.c,1,-1 do + for i=1,#CB do for j=#CB[1],1,-1 do if P.cur.bk[i][j]then ins(P.moveFX,{C,x+j,y+i,0,T}) break end end end elseif dir=="right"then - for i=1,P.r do for j=1,P.c do + for i=1,#CB do for j=1,#CB[1]do if P.cur.bk[i][j]then ins(P.moveFX,{C,x+j,y+i,0,T}) break end end end elseif dir=="down"then - for j=1,P.c do for i=P.r,1,-1 do + for j=1,#CB[1]do for i=#CB,1,-1 do if P.cur.bk[i][j]then ins(P.moveFX,{C,x+j,y+i,0,T}) break end end end else - for i=1,P.r do for j=1,P.c do + for i=1,#CB do for j=1,#CB[1]do if P.cur.bk[i][j]then ins(P.moveFX,{C,x+j,y+i,0,T}) end @@ -405,7 +406,7 @@ function Player.changeAtk(P,R) end function Player.freshBlock(P,mode)--string mode: push/move/fresh/newBlock local ENV=P.gameEnv - + local CB=P.cur.bk --Fresh ghost if(mode=="push"or mode=="move"or mode=="newBlock")and P.cur then P.ghoY=min(#P.field+1,P.curY) @@ -413,7 +414,7 @@ function Player.freshBlock(P,mode)--string mode: push/move/fresh/newBlock local _=P.ghoY --Move ghost to bottom - while not P:ifoverlap(P.cur.bk,P.curX,P.ghoY-1)do + while not P:ifoverlap(CB,P.curX,P.ghoY-1)do P.ghoY=P.ghoY-1 end @@ -424,8 +425,8 @@ function Player.freshBlock(P,mode)--string mode: push/move/fresh/newBlock --Create FX if dropped if P.curY>P.ghoY then - if ENV.dropFX and ENV.block and P.curY-P.ghoY-P.r>-1 then - P:createDropFX(P.curX,P.curY-1,P.c,P.curY-P.ghoY-P.r+1) + if ENV.dropFX and ENV.block and P.curY-P.ghoY-#CB>-1 then + P:createDropFX(P.curX,P.curY-1,#CB[1],P.curY-P.ghoY-#CB+1) end if ENV.shakeFX then P.fieldOff.vy=ENV.shakeFX*.5 @@ -433,7 +434,7 @@ function Player.freshBlock(P,mode)--string mode: push/move/fresh/newBlock P.curY=P.ghoY end else - while not P:ifoverlap(P.cur.bk,P.curX,P.ghoY-1)do + while not P:ifoverlap(CB,P.curX,P.ghoY-1)do P.ghoY=P.ghoY-1 end end @@ -470,25 +471,24 @@ end function Player.lock(P) local dest=P.AI_dest local has_dest=dest~=nil - for i=1,P.r do + local CB=P.cur.bk + for i=1,#CB do local y=P.curY+i-1 if not P.field[y]then P.field[y],P.visTime[y]=FREEROW.get(0),FREEROW.get(0)end - for j=1,P.c do - if P.cur.bk[i][j]then + for j=1,#CB[1]do + if CB[i][j]then P.field[y][P.curX+j-1]=P.cur.color P.visTime[y][P.curX+j-1]=P.showTime local x=P.curX+j-1 if dest then - local original_length=#dest - for k=1,original_length do + for k=1,#dest do if x==dest[k][1]and y==dest[k][2]then - rem(dest, k) - break + rem(dest,k) + goto success end end - if #dest~=original_length-1 then - dest=nil - end + dest=nil + ::success:: end end end @@ -500,14 +500,13 @@ end local spawnSFX_name={}for i=1,7 do spawnSFX_name[i]="spawn_"..i end function Player.resetBlock(P) - local C=P.cur - local id=C.id + local B=P.cur.bk + 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.r,P.c=#C.bk,#C.bk[1] --Row/column - P.curX=int(6-P.c*.5) + P.curX=int(6-#B[1]*.5) local y=21+ceil(P.fieldBeneath/30) P.curY=y P.minY=y+sc[2] @@ -516,7 +515,7 @@ function Player.resetBlock(P) --IMS if P.gameEnv.ims and(_[1]and P.movDir==-1 or _[2]and P.movDir==1)and P.moving>=P.gameEnv.das then local x=P.curX+P.movDir - if not P:ifoverlap(C.bk,x,y)then + if not P:ifoverlap(B,x,y)then P.curX=x end end @@ -555,7 +554,6 @@ function Player.spin(P,d,ifpre) local idir=(P.dir+d)%4 local icb=BLOCKS[P.cur.id][idir] local isc=scs[P.cur.id][idir] - local ir,ic=#icb,#icb[1] 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 @@ -574,7 +572,6 @@ function Player.spin(P,d,ifpre) end P.curX,P.curY,P.dir=ix,iy,idir P.sc,P.cur.bk=scs[P.cur.id][idir],icb - P.r,P.c=ir,ic P.spinLast=test==2 and 0 or 1 if not ifpre then P:freshBlock("move") @@ -869,7 +866,7 @@ do--Player.drop(P)--Place piece local finish local cmb=P.combo - local CB,CX,CY=P.cur,P.curX,P.curY + local C,CB,CX,CY=P.cur,P.cur.bk,P.curX,P.curY local clear--If clear with no line fall local cc,gbcc=0,0--Row/garbage-row cleared,full-part local atk,exblock=0,0--Attack & extra defense @@ -877,12 +874,12 @@ do--Player.drop(P)--Place piece local cscore,sendTime=10,0--Score & send Time local dospin,mini=0 - piece.id,piece.name=CB.id,CB.name + piece.id,piece.name=C.id,C.name P.waiting=ENV.wait --Tri-corner spin check if P.spinLast then - if CB.id<6 then + if C.id<6 then local x,y=CX+P.sc[2],CY+P.sc[1] local c=0 if P:solid(x-1,y+1)then c=c+1 end @@ -895,7 +892,7 @@ do--Player.drop(P)--Place piece ::NTC:: end --Immovable spin check - if P:ifoverlap(CB.bk,CX,CY+1)and P:ifoverlap(CB.bk,CX-1,CY)and P:ifoverlap(CB.bk,CX+1,CY)then + if P:ifoverlap(CB,CX,CY+1)and P:ifoverlap(CB,CX-1,CY)and P:ifoverlap(CB,CX+1,CY)then dospin=dospin+2 end @@ -906,13 +903,14 @@ do--Player.drop(P)--Place piece if P.clearedRow[1]then P.clearedRow={}end --Check line clear - for i=1,P.r do + for i=1,#CB do + print("i"..i) local h=CY+i-2 --Bomb trigger if h>0 and P.field[h]and P.clearedRow[cc]~=h then - for x=1,P.c do - if CB.bk[i][x]and P.field[h][CX+x-1]==19 then + for x=1,#CB[1]do + if CB[i][x]and P.field[h][CX+x-1]==19 then cc=cc+1 P.clearingRow[cc]=h-cc+1 P.clearedRow[cc]=h @@ -924,6 +922,7 @@ do--Player.drop(P)--Place piece h=h+1 --Row filled for x=1,10 do + print("x="..x) if P.field[h][x]<=0 then goto notFull end @@ -965,7 +964,7 @@ do--Player.drop(P)--Place piece if cc>0 then dospin=dospin+(P.spinLast or 0) if dospin<3 then - mini=CB.id<6 and cc