Skip to content

Commit

Permalink
重构方块和气泡的皮肤系统,皮肤不再能完整地控制一块的绘制
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZ626 committed Apr 23, 2024
1 parent ac14567 commit 672a3c1
Show file tree
Hide file tree
Showing 10 changed files with 277 additions and 382 deletions.
2 changes: 2 additions & 0 deletions assets/game/classes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
---@field visStep? number
---@field visMax? number

---@alias Techmino.RectPiece (Techmino.Cell|false)[][]

---@class Techmino.RectField
---@field _width number
---@field _matrix (Techmino.Cell|false)[][]
Expand Down
25 changes: 1 addition & 24 deletions assets/game/gemPlayer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,7 @@ local GP=setmetatable({},{__index=require'assets.game.basePlayer',__metatable=tr
--------------------------------------------------------------
-- Function tables
local defaultSoundFunc={
countDown=function(num)
if num==0 then -- 6, 3+6+6
playSample('sine',{'A3',.8})
playSample('square',{'A4',.9},{'E5',.9},{'A5',.9})
elseif num==1 then -- 5, 3+7
playSample('sine',{'G3',.9})
playSample('square',{'B4',.9},{'E5',.9})
elseif num==2 then -- 4, 6+2
playSample('sine',{'F3'})
playSample('square',{'A4',.8},{'D5',.8})
elseif num==3 then -- 6+6
playSample('sine',{'A3',.9},{'E4',.9})
playSample('square',{'A4',.8})
elseif num==4 then -- 5+7, 5
playSample('sine',{'G3',.9},{'B3',.9})
playSample('square',{'G4',.6})
elseif num==5 then -- 4+6, 4
playSample('sine',{'F3',.8},{'A3',.8})
playSample('square',{'F4',.3})
elseif num<=10 then
playSample('sine',{'A2',2.2-num/5},{'E3',2.2-num/5})
end
end,
countDown= countDownSound,
move= function() FMOD.effect('move') end,
move_failed= function() FMOD.effect('move_failed') end,
swap= function() FMOD.effect('rotate') end,
Expand Down Expand Up @@ -790,7 +768,6 @@ function GP:render()
skin.drawFieldCell(C,F,(x-1)*40+2,-y*40+2)
end
end end
skin.drawFieldCell(self.field)

self:triggerEvent('drawInField') -- From frame's bottom-left, 40px a cell

Expand Down
148 changes: 76 additions & 72 deletions assets/game/minoPlayer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,7 @@ local MP=setmetatable({},{__index=require'assets.game.basePlayer',__metatable=tr
--------------------------------------------------------------
-- Function tables
local defaultSoundFunc={
countDown=function(num)
if num==0 then -- 6, 3+6+6
playSample('sine',{'A3',.8})
playSample('square',{'A4',.9},{'E5',.9},{'A5',.9})
elseif num==1 then -- 5, 3+7
playSample('sine',{'G3',.9})
playSample('square',{'B4',.9},{'E5',.9})
elseif num==2 then -- 4, 6+2
playSample('sine',{'F3'})
playSample('square',{'A4',.8},{'D5',.8})
elseif num==3 then -- 6+6
playSample('sine',{'A3',.9},{'E4',.9})
playSample('square',{'A4',.8})
elseif num==4 then -- 5+7, 5
playSample('sine',{'G3',.9},{'B3',.9})
playSample('square',{'G4',.6})
elseif num==5 then -- 4+6, 4
playSample('sine',{'F3',.8},{'A3',.8})
playSample('square',{'F4',.3})
elseif num<=10 then
playSample('sine',{'A2',2.2-num/5},{'E3',2.2-num/5})
end
end,
countDown= countDownSound,
move= function() FMOD.effect('move') end,
move_down= function() FMOD.effect('move_down') end,
move_failed= function() FMOD.effect('move_failed') end,
Expand Down Expand Up @@ -75,39 +53,7 @@ local defaultSoundFunc={
else FMOD.effect('spin_mega')
end
end,
combo=setmetatable({
function() playSample('sine',{'A2',.70,420}) end, -- 1
function() playSample('sine',{'C3',.75,410}) end, -- 2
function() playSample('sine',{'D3',.80,400}) end, -- 3
function() playSample('sine',{'E3',.85,390}) end, -- 4
function() playSample('sine',{'G3',.90,380}) end, -- 5
function() playSample('sine',{'A3',.90,370},'square',{'A2',.20,420,620}) end, -- 6
function() playSample('sine',{'C4',.75,360},'square',{'C3',.40,400,620}) end, -- 7
function() playSample('sine',{'D4',.60,350},'square',{'D3',.60,380,620}) end, -- 8
function() playSample('sine',{'E4',.40,340},'square',{'E3',.75,360,620}) end, -- 9
function() playSample('sine',{'G4',.20,330},'square',{'G3',.90,340,620}) end, -- 10
function() playSample('sine',{'A4',.20,320},'square',{'A3',.85,320,620}) end, -- 11
function() playSample('sine',{'A4',.40,310},'square',{'C4',.80,300,620}) end, -- 12
function() playSample('sine',{'A4',.60,300},'square',{'D4',.75,280,620}) end, -- 13
function() playSample('sine',{'A4',.75,290},'square',{'E4',.70,270,620}) end, -- 14
function() playSample('sine',{'A4',.90,280},'square',{'G4',.65,260,640}) end, -- 15
function() playSample('sine',{'A4',.90,270},{'E5',.70},'square',{'A4',1,250,660}) end, -- 16
function() playSample('sine',{'A4',.85,260},{'E5',.75},'square',{'C5',1,240,680}) end, -- 17
function() playSample('sine',{'A4',.80,250},{'E5',.80},'square',{'D5',1,230,700}) end, -- 18
function() playSample('sine',{'A4',.75,240},{'E5',.85},'square',{'E5',1,220,720}) end, -- 19
function() playSample('sine',{'A4',.70,230},{'E5',.90},'square',{'G5',1,210,740}) end, -- 20
},{__call=function(self,combo)
if self[combo] then
self[combo]()
else
playSample('sine',{'A4',.626-.01*combo,430-10*combo})
local phase=(combo-21)%12
playSample('square',{40+phase,1-((11-phase)/12)^2,400-10*combo,700+20*combo}) -- E4+
playSample('square',{45+phase,1-((11-phase)/12)^2,400-10*combo,700+20*combo}) -- A4+
playSample('square',{52+phase,1-(phase/12)^2,400-10*combo,700+20*combo}) -- E5+
playSample('square',{57+phase,1-(phase/12)^2,400-10*combo,700+20*combo}) -- A5+
end
end,__metatable=true}),
combo= comboSound,
frenzy= function() FMOD.effect('frenzy') end,
allClear= function() FMOD.effect('clear_all') end,
halfClear= function() FMOD.effect('clear_half') end,
Expand Down Expand Up @@ -1678,9 +1624,10 @@ function MP:render()
local C=matrix[y][x]
if C then
if C.bias then
gc_translate(C.bias.x,C.bias.y)
local dx,dy=C.bias.x,C.bias.y
gc_translate(dx,dy)
skin.drawFieldCell(C,matrix,x,y)
gc_translate(-C.bias.x,-C.bias.y)
gc_translate(-dx,-dy)
else
skin.drawFieldCell(C,matrix,x,y)
end
Expand All @@ -1703,7 +1650,14 @@ function MP:render()

-- Ghost
if not self.deathTimer and self.ghostY then
skin.drawGhost(CB,self.handX,self.ghostY)
for y=1,#CB do for x=1,#CB[1] do
if CB[y][x] then
local dx,dy=(self.handX+x-2)*40,-(self.ghostY+y-1)*40
gc_translate(dx,dy)
skin.drawGhostCell(CB[y][x],CB,x,y)
gc_translate(-dx,-dy)
end
end end
end

-- Hand
Expand All @@ -1712,8 +1666,22 @@ function MP:render()
local dx,dy=self:getSmoothPos()
gc_translate(dx,dy)

skin.drawHandStroke(CB,self.handX,self.handY)
skin.drawHand(CB,self.handX,self.handY)
for y=1,#CB do for x=1,#CB[1] do
if CB[y][x] then
local dx_,dy_=(self.handX+x-2)*40,-(self.handY+y-1)*40
gc_translate(dx_,dy_)
skin.drawHandCellStroke(CB[y][x],CB,x,y)
gc_translate(-dx_,-dy_)
end
end end
for y=1,#CB do for x=1,#CB[1] do
if CB[y][x] then
local dx_,dy_=(self.handX+x-2)*40,-(self.handY+y-1)*40
gc_translate(dx_,dy_)
skin.drawHandCell(CB[y][x],CB,x,y)
gc_translate(-dx_,-dy_)
end
end end

local RS=minoRotSys[SET.rotSys]
local minoData=RS[self.hand.shape]
Expand All @@ -1734,7 +1702,19 @@ function MP:render()
if #self.floatHolds>0 then
for n=1,#self.floatHolds do
local H=self.floatHolds[n]
skin.drawFloatHold(n,H.hand.matrix,H.handX,H.handY,SET.holdMode=='float' and not SET.infHold and n<=self.holdTime)
local unavailable=SET.holdMode=='float' and not SET.infHold and n<=self.holdTime
for y=1,#H do for x=1,#H[1] do
if H[y][x] then
local dx,dy=(self.handX+x-2)*40,-(self.handY+y-1)*40
gc_translate(dx,dy)
skin.drawFloatHoldCell(H[y][x],unavailable,H,x,y)
gc_translate(-dx,-dy)
end
end end
local dx,dy=(self.handX-1+#H[1]/2)*40,-(self.handY+#H/2)*40+5
gc_translate(dx,dy)
skin.drawFloatHoldMark(n,unavailable)
gc_translate(-dx,-dy)
end
end

Expand Down Expand Up @@ -1793,22 +1773,46 @@ function MP:render()

-- Next (Almost same as drawing hold(s), don't forget to change both)
gc_push('transform')
gc_translate(200,-400)
skin.drawNextBorder(SET.nextSlot)
for n=1,min(#self.nextQueue,SET.nextSlot) do
skin.drawNext(n,self.nextQueue[n].matrix,SET.holdMode=='swap' and not SET.infHold and n<=self.holdTime)
end
gc_translate(200,-400)
skin.drawNextBorder(SET.nextSlot)
for n=1,min(#self.nextQueue,SET.nextSlot) do
local unavailable=SET.holdMode=='swap' and not SET.infHold and n<=self.holdTime
local B=self.nextQueue[n].matrix
gc_push('transform')
gc_translate(100,100*n-50)
gc_scale(min(2.3/#B,3/#B[1],.86))
for y=1,#B do for x=1,#B[1] do
if B[y][x] then
local dx,dy=(x-#B[1]/2-1)*40,(y-#B/2)*-40
gc_translate(dx,dy)
skin.drawNextCell(B[y][x],unavailable,B,x,y)
gc_translate(-dx,-dy)
end
end end
gc_pop()
end
gc_pop()

-- Hold (Almost same as drawing next(s), don't forget to change both)
gc_push('transform')
gc_translate(-200,-400)
skin.drawHoldBorder(SET.holdMode,SET.holdSlot)
if #self.holdQueue>0 then
gc_translate(-200,-400)
skin.drawHoldBorder(SET.holdMode,SET.holdSlot)
for n=1,#self.holdQueue do
skin.drawHold(n,self.holdQueue[n].matrix,SET.holdMode=='hold' and not SET.infHold and n<=self.holdTime)
local unavailable=SET.holdMode=='hold' and not SET.infHold and n<=self.holdTime
local B=self.holdQueue[n].matrix
gc_push('transform')
gc_translate(-100,100*n-50)
gc_scale(min(2.3/#B,3/#B[1],.86))
for y=1,#B do for x=1,#B[1] do
if B[y][x] then
local dx,dy=(x-#B[1]/2-1)*40,(y-#B/2)*-40
gc_translate(dx,dy)
skin.drawHoldCell(B[y][x],unavailable,B,x,y)
gc_translate(-dx,-dy)
end
end end
gc_pop()
end
end
gc_pop()

-- Timer
Expand Down
Loading

0 comments on commit 672a3c1

Please sign in to comment.