Skip to content

Commit

Permalink
添加方块锁定特效
Browse files Browse the repository at this point in the history
修马拉松进去就爆炸
整理代码
  • Loading branch information
MrZ626 committed May 20, 2024
1 parent b2db028 commit 8c43920
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 23 deletions.
48 changes: 34 additions & 14 deletions assets/game/brikPlayer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ function BP:createRotateCornerEffect(cx,cy)
end
end
end
function BP:createHandEffect(r,g,b,a)
function BP:createHandErrorEffect(r,g,b,a)
local CB,bx,by=self.hand.matrix,self.handX,self.handY
local dx,dy=self:getSmoothPos()
local p=self.particles.tiltRect
local p=self.particles.rectTilt
p:setColors(r,g,b,a or 1,r,g,b,0)
for y=1,#CB do for x=1,#CB[1] do
local c=CB[y][x]
Expand Down Expand Up @@ -166,21 +166,36 @@ function BP:createHoldEffect(ifInit)
local p=self.particles.spinArrow
p:new((cx-.5)*40,-(cy-.5)*40,ifInit)
end
function BP:createFrenzyEffect(amount)
local p=self.particles.star
p:setEmissionArea('uniform',200,400,0,true)
p:setParticleLifetime(.626,1.6)
p:setPosition(200,-400)
p:emit(amount)
end
function BP:createLockEffect()
function BP:createPieceDropEffect()
local p=self.particles.trail
p:setPosition(
(self.handX+#self.hand.matrix[1]/2-1)*40,
-(self.handY+#self.hand.matrix/2-1)*40
)
p:emit(1)
end
function BP:createHandLockEffect() -- Basically the same as createHandErrorEffect
local CB,bx,by=self.hand.matrix,self.handX,self.handY
local dx,dy=self:getSmoothPos()
local p=self.particles.rectScale
for y=1,#CB do for x=1,#CB[1] do
local c=CB[y][x]
if c then
p:setPosition(
(bx+x-1.5)*40+dx,
-(by+y-1.5)*40+dy
)
p:emit(1)
end
end end
end
function BP:createFrenzyEffect(amount)
local p=self.particles.star
p:setEmissionArea('uniform',200,400,0,true)
p:setParticleLifetime(.626,1.6)
p:setPosition(200,-400)
p:emit(amount)
end
function BP:createSuffocateEffect()
end
function BP:createDesuffocateEffect()
Expand Down Expand Up @@ -325,7 +340,7 @@ function BP:moveHand(action,A,B,C,D)
self:shakeBoard(C=='L' and '-ccw' or C=='R' and '-cw' or '-180')
self:playSound('rotate_locked')
if SET.particles then
self:createHandEffect(.942,1,1)
self:createHandErrorEffect(.942,1,1)
end
end
if SET.spin_corners then
Expand Down Expand Up @@ -963,7 +978,7 @@ function BP:rotate(dir,ifInit)
if not ifInit then self:freshDelay('rotate') end
self:playSound('rotate_failed')
if self.settings.particles then
self:createHandEffect(1,.26,.26)
self:createHandErrorEffect(1,.26,.26)
end
else
error("WTF why no state in brikData")
Expand Down Expand Up @@ -1078,7 +1093,8 @@ function BP:brikDropped() -- Drop & lock brik, and trigger a lot of things
if not self.hand or self.finished then return end

if SET.particles then
self:createLockEffect()
self:createPieceDropEffect()
self:createHandLockEffect()
end

-- Lock to field
Expand Down Expand Up @@ -1106,6 +1122,9 @@ function BP:brikDropped() -- Drop & lock brik, and trigger a lot of things
self.lastMovement.clear=fullLines
self.lastMovement.combo=self.combo
self:doClear(fullLines)
if SET.clearRule=='line' then
self:createHandLockEffect(1,1,1,1)
end
else
self.combo=0
end
Expand Down Expand Up @@ -1659,7 +1678,8 @@ function BP:render()

gc_setColor(1,1,1)
gc_draw(self.particles.rectShade)
gc_draw(self.particles.tiltRect)
gc_draw(self.particles.rectTilt)
gc_draw(self.particles.rectScale)

if self.hand then
local CB=self.hand.matrix
Expand Down
8 changes: 4 additions & 4 deletions assets/game/gelaPlayer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ function GP:createMoveEffect(x1,y1,x2,y2)
p:emit(1)
end end
end
function GP:createHandEffect(r,g,b,a)
function GP:createHandErrorEffect(r,g,b,a)
local CB,bx,by=self.hand.matrix,self.handX,self.handY
local dx,dy=self:getSmoothPos()
local p=self.particles.tiltRect
local p=self.particles.rectTilt
p:setColors(r,g,b,a or 1,r,g,b,0)
for y=1,#CB do for x=1,#CB[1] do
local c=CB[y][x]
Expand All @@ -91,7 +91,7 @@ function GP:createHandEffect(r,g,b,a)
end
function GP:createTuckEffect()
end
function GP:createLockEffect()
function GP:createPieceDropEffect()
local p=self.particles.trail
p:setPosition(
(self.handX+#self.hand.matrix[1]/2-1)*40,
Expand Down Expand Up @@ -647,7 +647,7 @@ function GP:gelaDropped() -- Drop & lock gela, and trigger a lot of things
self:playSound('drop')
end
if self.settings.particles then
self:createLockEffect()
self:createPieceDropEffect()
end

self:triggerEvent('afterDrop')
Expand Down
2 changes: 1 addition & 1 deletion assets/game/mechanicLib/brik/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ local function move(P,dir,canBuffer)
end
P:playSound('move_failed')
if P.settings.particles then
P:createHandEffect(1,.26,0)
P:createHandErrorEffect(1,.26,0)
end
end
else
Expand Down
2 changes: 1 addition & 1 deletion assets/game/mechanicLib/gela/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ local function move(P,dir,canBuffer)
end
P:playSound('move_failed')
if P.settings.particles then
P:createHandEffect(1,.26,0)
P:createHandErrorEffect(1,.26,0)
end
end
else
Expand Down
2 changes: 1 addition & 1 deletion assets/game/mode/brik/exterior/marathon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ return {
event={
playerInit={
mechLib.brik.marathon.event_playerInit_auto,
"P:setAction('func1',mechLib.stack.switch_auto)",
"P:setAction('func1',mechLib.brik.stack.switch_auto)",
},
afterClear={
mechLib.brik.music.marathon_afterClear,
Expand Down
12 changes: 11 additions & 1 deletion assets/game/particleSystemTemplate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ do -- Piece controlling effect
p:setRotation(-.26,.26)
p:setSpin(-2.6,2.6)
p:setParticleLifetime(.26)
ps.tiltRect=p
ps.rectTilt=p
end

do -- Harddrop light
Expand Down Expand Up @@ -164,6 +164,16 @@ do -- Harddrop light
ps.trail=p
end

do -- Piece lock effect
local p=love.graphics.newParticleSystem(GC.load{1,1,
{'clear',1,1,1},
},26)
p:setSizes(40,40)
p:setColors(.926,.926,.926,.42,1,1,1,0)
p:setParticleLifetime(.16)
ps.rectScale=p
end

do -- Background light of brik map
local p=love.graphics.newParticleSystem(GC.load{10,10,
{'setCL',1,1,1,.5},
Expand Down
3 changes: 2 additions & 1 deletion assets/game/pubClass.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@

---@class Techmino.ParticleSystems
---@field rectShade love.ParticleSystem
---@field rectTilt love.ParticleSystem
---@field rectScale love.ParticleSystem
---@field spinArrow table
---@field star love.ParticleSystem
---@field boardSmoke love.ParticleSystem
---@field line love.ParticleSystem
---@field hitSparkle love.ParticleSystem
---@field cornerCheck love.ParticleSystem
---@field tiltRect love.ParticleSystem
---@field trail love.ParticleSystem
---@field brikMapBack love.ParticleSystem

Expand Down

0 comments on commit 8c43920

Please sign in to comment.