From f7ece80becffe859542dbee324d8645746aae177 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 25 Mar 2021 15:28:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=A9=E5=AE=B6=E6=96=B0=E5=A2=9EgetCenterX?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E7=A7=BB=E9=99=A4SFX.fieldPlay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/sfx.lua | 3 --- parts/kickList.lua | 8 ++++---- parts/player/player.lua | 15 +++++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Zframework/sfx.lua b/Zframework/sfx.lua index 6037cdab..3ad983ad 100644 --- a/Zframework/sfx.lua +++ b/Zframework/sfx.lua @@ -25,9 +25,6 @@ function SFX.init(list) end SFX.loadOne=nil - function SFX.fieldPlay(s,v,P) - 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 local S=Sources[s]--Source list diff --git a/parts/kickList.lua b/parts/kickList.lua index 51d8b92d..99650c09 100644 --- a/parts/kickList.lua +++ b/parts/kickList.lua @@ -130,7 +130,7 @@ do 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 - if P.sound then SFX.fieldPlay("rotatekick",nil,P)end + if P.sound then SFX.play("rotatekick",nil,P:getCenterX()*.15)end local D=P.spinSeq%100*10+d P.spinSeq=D if D<100 then return end @@ -155,11 +155,11 @@ do end end else - if P.sound then SFX.fieldPlay("rotate",nil,P)end + if P.sound then SFX.play("rotate",nil,P:getCenterX()*.15)end P.spinSeq=0 end else - if P.sound then SFX.fieldPlay("rotate",nil,P)end + if P.sound then SFX.play("rotate",nil,P:getCenterX()*.15)end end end,--O { @@ -270,7 +270,7 @@ do [31]={{ 0,-1},{ 1, 0}}, },--W function(P,d) - if P.type=="human"then SFX.fieldPlay("rotate",nil,P)end + if P.type=="human"then SFX.play("rotate",nil,P:getCenterX()*.15)end local kickData=XspinList[d] for test=1,#kickData do local x,y=P.curX+kickData[test][1],P.curY+kickData[test][2] diff --git a/parts/player/player.lua b/parts/player/player.lua index 05d31d1f..83d011c3 100644 --- a/parts/player/player.lua +++ b/parts/player/player.lua @@ -315,6 +315,9 @@ function Player.pushNextList(P,L,mir)--Push some nexts to nextQueue end end +function Player.getCenterX(P) + return P.curX+P.cur.sc[2]-5.5 +end function Player.solid(P,x,y) if x<1 or x>10 or y<1 then return true end if y>#P.field then return false end @@ -579,7 +582,7 @@ function Player.spin(P,d,ifpre) kickData=kickData[P.cur.dir*10+idir] if not kickData then P:freshBlock("move") - SFX.fieldPlay(ifpre and"prerotate"or"rotate",nil,P) + SFX.play(ifpre and"prerotate"or"rotate",nil,P:getCenterX()*.15) return end local icb=BLOCKS[P.cur.id][idir] @@ -605,7 +608,7 @@ function Player.spin(P,d,ifpre) end if P.sound then - SFX.fieldPlay(ifpre and"prerotate"or P:ifoverlap(P.cur.bk,P.curX,P.curY+1)and P:ifoverlap(P.cur.bk,P.curX-1,P.curY)and P:ifoverlap(P.cur.bk,P.curX+1,P.curY)and"rotatekick"or"rotate",nil,P) + SFX.play(ifpre and"prerotate"or P:ifoverlap(P.cur.bk,P.curX,P.curY+1)and P:ifoverlap(P.cur.bk,P.curX-1,P.curY)and P:ifoverlap(P.cur.bk,P.curX+1,P.curY)and"rotatekick"or"rotate",nil,P:getCenterX()*.15) end P.stat.rotate=P.stat.rotate+1 return @@ -615,7 +618,7 @@ function Player.spin(P,d,ifpre) kickData(P,d) else P:freshBlock("move") - SFX.fieldPlay(ifpre and"prerotate"or"rotate",nil,P) + SFX.play(ifpre and"prerotate"or"rotate",nil,P:getCenterX()*.15) end end local phyHoldKickX={ @@ -1118,11 +1121,11 @@ do--Player.drop(P)--Place piece elseif ENV.fine then SFX.play("finesseError",.8) else - SFX.fieldPlay("lock",nil,P) + SFX.play("lock",nil,P:getCenterX()*.15) end end elseif P.sound then - SFX.fieldPlay("lock",nil,P) + SFX.play("lock",nil,P:getCenterX()*.15) end if finePts<=1 then @@ -1902,7 +1905,7 @@ function Player.act_hardDrop(P) P.fieldOff.vy=P.gameEnv.shakeFX*.6 end if P.sound then - SFX.fieldPlay("drop",nil,P) + SFX.play("drop",nil,P:getCenterX()*.15) VIB(1) end end