场地晃动改名swing

添加场地抖动特效(跟场地晃动使用同一个设置值)
This commit is contained in:
MrZ626
2021-11-08 20:02:40 +08:00
parent e6a9a4f4be
commit a1030906c7
3 changed files with 36 additions and 18 deletions

View File

@@ -119,8 +119,15 @@ local function _stencilBoard()gc_rectangle('fill',0,-10,300,610)end
local function _applyField(P)
gc_push('transform')
--Apply fieldOffset
local O=P.fieldOff
--Apply shaking
if P.shakeTimer>0 then
local dx=int(P.shakeTimer/2)
local dy=int(P.shakeTimer/3)
gc_translate(dx^1.6*(dx%2*2-1)*(P.gameEnv.shakeFX+1)/30,dy^1.4*(dy%2*2-1)*(P.gameEnv.shakeFX+1)/30)
end
--Apply swingOffset
local O=P.swingOffset
if P.gameEnv.shakeFX then
local k=P.gameEnv.shakeFX
gc_translate(O.x*k+150+150,O.y*k+300)

View File

@@ -102,11 +102,12 @@ local function _newEmptyPlayer(id,mini)
end
--Field position
P.fieldOff={--Shake FX
P.swingOffset={--Shake FX
x=0,y=0,
vx=0,vy=0,
a=0,va=0,
}
P.shakeTimer=0
P.x,P.y,P.size=0,0,1
P.frameColor=COLOR.Z

View File

@@ -33,12 +33,17 @@ end
function Player:_rotateField(dir)
if self.gameEnv.shakeFX then
if dir==1 or dir==3 then
self.fieldOff.va=self.fieldOff.va+(2-dir)*6e-3
self.swingOffset.va=self.swingOffset.va+(2-dir)*6e-3
else
self.fieldOff.va=self.fieldOff.va+self:getCenterX()*3e-3
self.swingOffset.va=self.swingOffset.va+self:getCenterX()*3e-3
end
end
end
function Player:shakeField(strength)--Range: 1~10
if self.gameEnv.shakeFX then
self.shakeTimer=max(self.shakeTimer,3*self.gameEnv.shakeFX+int(4*min(max(strength,1),10)))
end
end
function Player:checkTouchSound()
if self.sound and self.curY==self.ghoY then
SFX.play('touch')
@@ -153,7 +158,7 @@ function Player:createSplashFX(h)
if self.gameEnv.splashFX then
local L=self.field[h]
local size=self.size
local y=self.fieldY+size*(self.fieldOff.y+self.fieldBeneath+self.fieldUp+615)-30*h*size
local y=self.fieldY+size*(self.swingOffset.y+self.fieldBeneath+self.fieldUp+615)-30*h*size
for x=1,10 do
local c=L[x]
if c>0 then
@@ -577,7 +582,7 @@ function Player:freshBlock(mode)--string mode: push/move/fresh/newBlock
if self.curY>self.ghoY then
self:createDropFX()
if ENV.shakeFX then
self.fieldOff.vy=.5
self.swingOffset.vy=.5
end
self.curY=self.ghoY
end
@@ -810,7 +815,7 @@ function Player:spin(d,ifpre)
self.freshTime=self.freshTime-1
end
--Sound & Field shaking
--Sound & Field swinging
local sfx
if ifpre then
sfx='prerotate'
@@ -1853,9 +1858,9 @@ local function _updateMisc(P)
end
end
--Field shaking
--Field swinging
if P.gameEnv.shakeFX then
local O=P.fieldOff
local O=P.swingOffset
O.vx=O.vx*.6-abs(O.x)^1.3*(O.x>0 and .1 or -.1)
O.x=O.x+O.vx
@@ -1869,6 +1874,11 @@ local function _updateMisc(P)
end
end
--Field Shaking
if P.shakeTimer>0 then
P.shakeTimer=P.shakeTimer-1
end
--Update texts
if P.bonus then
TEXT.update(1/60,P.bonus)
@@ -2001,7 +2011,7 @@ local function update_alive(P)
end
end
if mov>=das and ENV.shakeFX and P.cur and P:ifoverlap(P.cur.bk,P.curX+1,P.curY)then
P.fieldOff.vx=.5
P.swingOffset.vx=.5
end
else
P.movDir=0
@@ -2026,7 +2036,7 @@ local function update_alive(P)
end
end
if mov>=das and ENV.shakeFX and P.cur and P:ifoverlap(P.cur.bk,P.curX-1,P.curY)then
P.fieldOff.vx=-.5
P.swingOffset.vx=-.5
end
else
P.movDir=0
@@ -2057,7 +2067,7 @@ local function update_alive(P)
P:act_insDown()
end
if ENV.shakeFX then
P.fieldOff.vy=.2
P.swingOffset.vy=.2
end
end
else
@@ -2511,8 +2521,8 @@ function Player:act_hardDrop()
end
end
if ENV.shakeFX then
self.fieldOff.vy=.6
self.fieldOff.va=self.fieldOff.va+self:getCenterX()*6e-4
self.swingOffset.vy=.6
self.swingOffset.va=self.swingOffset.va+self:getCenterX()*6e-4
end
self.lockDelay=-1
self:drop()
@@ -2574,7 +2584,7 @@ function Player:act_insLeft(auto)
self.spinLast=false
end
if self.gameEnv.shakeFX then
self.fieldOff.vx=-1.5
self.swingOffset.vx=-1.5
end
if auto then
if self.ctrlCount==0 then
@@ -2598,7 +2608,7 @@ function Player:act_insRight(auto)
self.spinLast=false
end
if self.gameEnv.shakeFX then
self.fieldOff.vx=1.5
self.swingOffset.vx=1.5
end
if auto then
if self.ctrlCount==0 then
@@ -2613,7 +2623,7 @@ function Player:act_insDown()
local ENV=self.gameEnv
self:createDropFX()
if ENV.shakeFX then
self.fieldOff.vy=.5
self.swingOffset.vy=.5
end
self.curY=self.ghoY
self.lockDelay=ENV.lock