From 0028fad60af9d224ef7b261ced21bc306be5f717 Mon Sep 17 00:00:00 2001 From: MrZ_26 <1046101471@qq.com> Date: Tue, 7 Nov 2023 11:48:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9A=AE=E8=82=A4=E6=A8=A1=E5=9D=97=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=AF=AD=E6=B3=95=E6=B3=A8=E9=87=8A=20=E6=B0=94?= =?UTF-8?q?=E6=B3=A1=E5=92=8C=E5=AE=9D=E7=9F=B3=E7=9A=AE=E8=82=A4=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=9C=BA=E5=9C=B0=E7=BB=98=E5=88=B6=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=20=E6=A1=86=E6=9E=B6=E8=B7=9F=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zenitha | 2 +- assets/game/gemPlayer.lua | 7 ++++++ assets/game/puyoPlayer.lua | 9 ++++++- assets/skin/gem_template.lua | 42 +++++++++++++++----------------- assets/skin/init.lua | 46 +++++++++++++++++++++++++++++------ assets/skin/mino_interior.lua | 1 + assets/skin/mino_plastic.lua | 1 + assets/skin/mino_simp.lua | 3 ++- assets/skin/mino_template.lua | 1 + assets/skin/puyo_jelly.lua | 17 ++++++------- assets/skin/puyo_template.lua | 15 +++++------- 11 files changed, 92 insertions(+), 52 deletions(-) diff --git a/Zenitha b/Zenitha index 14f2fba4..2fa63a18 160000 --- a/Zenitha +++ b/Zenitha @@ -1 +1 @@ -Subproject commit 14f2fba4e4daae6418ff5b22b875e37425e0c1ea +Subproject commit 2fa63a1863afe4b7b7de54a5a5c04b17d4750f47 diff --git a/assets/game/gemPlayer.lua b/assets/game/gemPlayer.lua index 4f9fe570..a496ff27 100644 --- a/assets/game/gemPlayer.lua +++ b/assets/game/gemPlayer.lua @@ -809,6 +809,13 @@ function GP:render() -- Grid & Cells skin.drawFieldBackground(settings.fieldSize) + local F=self.field + for y=1,#F do for x=1,#F[1] do + local C=F[y][x] + if C then + 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 diff --git a/assets/game/puyoPlayer.lua b/assets/game/puyoPlayer.lua index a7c210e8..43c6d682 100644 --- a/assets/game/puyoPlayer.lua +++ b/assets/game/puyoPlayer.lua @@ -1091,7 +1091,14 @@ function PP:render() -- Grid & Cells skin.drawFieldBackground(settings.fieldW) - skin.drawFieldCell(self.field) + + local F=self.field + for y=1,#F do for x=1,#F[1] do + local C=F[y][x] + if C then + skin.drawFieldCell(C,F,(x-1)*40+2,-y*40+2) + end + end end self:triggerEvent('drawBelowBlock') -- From frame's bottom-left, 40px a cell diff --git a/assets/skin/gem_template.lua b/assets/skin/gem_template.lua index db27fdd6..12af7e41 100644 --- a/assets/skin/gem_template.lua +++ b/assets/skin/gem_template.lua @@ -10,6 +10,7 @@ local max,min=math.max,math.min local COLOR=COLOR +---@type Techmino.skin.gem local S={} local crossR,crossL=1,6 @@ -156,31 +157,26 @@ local function drawGem(g) gc_rectangle('line',-12,-12,24,24) end end -function S.drawFieldCell(F) +function S.drawFieldCell(G,_,x,y) gc_setLineWidth(2) - for y=1,#F do for x=1,#F[1] do - local G=F[y][x] - if G then - gc_push('transform') - if G.moveTimer then - local d=G.moveTimer/G.moveDelay - if G.fall then - d=-d*(d-2) - else - d=-math.cos(d*math.pi)/2+.5 - end - gc_translate(45*(x+d*G.dx)-22.5,-45*(y+d*G.dy)+22.5) - else - gc_translate(45*x-22.5,-45*y+22.5) - end - if G.clearTimer and not G.generate then - local i=G.clearTimer/G.clearDelay - gc_scale(-2*i^2+3*i) - end - drawGem(G) - gc_pop() + gc_push('transform') + if G.moveTimer then + local d=G.moveTimer/G.moveDelay + if G.fall then + d=-d*(d-2) + else + d=-math.cos(d*math.pi)/2+.5 end - end end + gc_translate(45*(x+d*G.dx)-22.5,-45*(y+d*G.dy)+22.5) + else + gc_translate(45*x-22.5,-45*y+22.5) + end + if G.clearTimer and not G.generate then + local t=G.clearTimer/G.clearDelay + gc_scale(-2*t^2+3*t) + end + drawGem(G) + gc_pop() end function S.drawGarbageBuffer(garbageBuffer) diff --git a/assets/skin/init.lua b/assets/skin/init.lua index 57468062..004658a4 100644 --- a/assets/skin/init.lua +++ b/assets/skin/init.lua @@ -5,18 +5,50 @@ local SKIN={} SKIN.time=0 local function _getTime() return SKIN.time end -function SKIN.add(name,data) +---@class Techmino.skin +---@field base string +---@field getTime function +---@field drawFieldBackground fun(fieldW:number) +---@field drawFieldBorder fun() +---@field drawFieldCell fun(C:Techmino.Cell, F:Techmino.RectField, x:number, y:number) +---@field drawFloatHold fun(n:number|string, B:table, handX:number, handY:number, unavailable:boolean) +---@field drawHeightLines fun(fieldW:number, maxSpawnH:number, spawnH,lockoutH:number, deathH:number, voidH:number) +---@field drawDasIndicator fun(dir:number , charge:number, dasMax:number, arrMax:number, dasHalt:number) +---@field drawDelayIndicator fun(color:Zenitha.Color, value:number) +---@field drawGarbageBuffer fun(garbageBuffer:table) +---@field drawLockDelayIndicator fun(freshCondition:string, freshChance:number) +---@field drawGhost fun(B:table, handX:number, ghostY:number) +---@field drawHand fun(B:table, handX:number, handY:number) +---@field drawNextBorder fun(slot:number) +---@field drawNext fun(n:number, B:table, unavailable:boolean) +---@field drawHoldBorder fun(mode:string, slot:number) +---@field drawHold fun(n:number, B:table, unavailable:boolean) +---@field drawTime fun(time:number) +---@field drawInfoPanel fun(x:number, y:number, w:number, h:number) +---@field drawStartingCounter fun(readyDelay:number) + +---@class Techmino.skin.mino: Techmino.skin + +---@class Techmino.skin.puyo: Techmino.skin + +---@class Techmino.skin.gem: Techmino.skin +---@field drawSwapCursor fun(cx:number, cy:number, lock:boolean) +---@field drawTwistCursor fun(sx:number, sy:number) + +---@param name string +---@param skin Techmino.skin +function SKIN.add(name,skin) assert(type(name)=='string',"Skin name must be string") assert(not SKIN[name],"Skin "..name.." already exists") - assert(type(data)=='table',"Skin must be table") - assert(getmetatable(data)==nil,"Skin table must not have metatable") + assert(type(skin)=='table',"Skin must be table") + assert(getmetatable(skin)==nil,"Skin table must not have metatable") - assert(not data.getTime,"Skin mustn't define 'getTime'") - data.getTime=_getTime + assert(not skin.getTime,"Skin mustn't define 'getTime'") + skin.getTime=_getTime - setmetatable(data,{__index=data.base and assert(skinLib[data.base],"no base skin named "..tostring(data.base))}) + setmetatable(skin,{__index=skin.base and assert(skinLib[skin.base],"no base skin named "..tostring(skin.base))}) - skinLib[name]=data + skinLib[name]=skin end function SKIN.get(name) diff --git a/assets/skin/mino_interior.lua b/assets/skin/mino_interior.lua index 2d4b0b04..84e6b64d 100644 --- a/assets/skin/mino_interior.lua +++ b/assets/skin/mino_interior.lua @@ -10,6 +10,7 @@ local gc_printf=gc.printf local COLOR=COLOR +---@type Techmino.skin.mino local S={} S.base='mino_simp' diff --git a/assets/skin/mino_plastic.lua b/assets/skin/mino_plastic.lua index 2f6759d0..754c9b50 100644 --- a/assets/skin/mino_plastic.lua +++ b/assets/skin/mino_plastic.lua @@ -12,6 +12,7 @@ local min=math.min local COLOR=COLOR +---@type Techmino.skin.mino local S={} S.base='mino_template' diff --git a/assets/skin/mino_simp.lua b/assets/skin/mino_simp.lua index 1e49696e..6121a719 100644 --- a/assets/skin/mino_simp.lua +++ b/assets/skin/mino_simp.lua @@ -6,10 +6,11 @@ ]] local gc=love.graphics local gc_setColor,gc_setLineWidth=gc.setColor,gc.setLineWidth -local gc_line,gc_rectangle=gc.line,gc.rectangle +local gc_line=gc.line local COLOR=COLOR +---@type Techmino.skin.mino local S={} S.base='mino_template' diff --git a/assets/skin/mino_template.lua b/assets/skin/mino_template.lua index 83aeb237..d82a9ca0 100644 --- a/assets/skin/mino_template.lua +++ b/assets/skin/mino_template.lua @@ -15,6 +15,7 @@ local max,min=math.max,math.min local COLOR=COLOR +---@type Techmino.skin.mino local S={} local crossR,crossL=1,6 diff --git a/assets/skin/puyo_jelly.lua b/assets/skin/puyo_jelly.lua index 467d522f..748ee2d8 100644 --- a/assets/skin/puyo_jelly.lua +++ b/assets/skin/puyo_jelly.lua @@ -4,6 +4,7 @@ local gc_translate=gc.translate local gc_setColor=gc.setColor local gc_rectangle=gc.rectangle +---@type Techmino.skin.puyo local S={} S.base='puyo_template' @@ -16,17 +17,13 @@ local function drawSide(B,x,y,bx,by) if B[y+1] then t=B[y+1][x ] if t and t.connClear and t.color==c then gc_rectangle('fill',bx+8, by, 24, 5) end end end -function S.drawFieldCell(F) - F=F._matrix +function S.drawFieldCell(C,F,x,y) local flashing=S.getTime()%100<=50 - for y=1,#F do for x=1,#F[1] do - local C=F[y][x] - if C and (not C.clearing or flashing) then - gc_setColor(ColorTable[C.color]) - gc_rectangle('fill',(x-1)*40+2,-y*40+2,36,36,15) - drawSide(F,x,y,(x-1)*40,-y*40) - end - end end + if C and (not C.clearing or flashing) then + gc_setColor(ColorTable[C.color]) + gc_rectangle('fill',(x-1)*40+2,-y*40+2,36,36,15) + drawSide(F,x,y,(x-1)*40,-y*40) + end end function S.drawHand(B,handX,handY) diff --git a/assets/skin/puyo_template.lua b/assets/skin/puyo_template.lua index e1999d1c..a370d5c2 100644 --- a/assets/skin/puyo_template.lua +++ b/assets/skin/puyo_template.lua @@ -5,6 +5,7 @@ local gc_setColor=gc.setColor local gc_rectangle=gc.rectangle local gc_setLineWidth=gc.setLineWidth +---@type Techmino.skin.puyo local S={} S.base='mino_template' @@ -13,16 +14,12 @@ function S.drawFieldBackground(fieldW) gc_rectangle('fill',0,0,40*fieldW,-80*fieldW) end -function S.drawFieldCell(F) - F=F._matrix +function S.drawFieldCell(C,_,x,y) local flashing=S.getTime()%100<=50 - for y=1,#F do for x=1,#F[1] do - local C=F[y][x] - if C and (not C.clearing or flashing) then - gc_setColor(ColorTable[C.color]) - gc_rectangle('fill',(x-1)*40+2,-y*40+2,36,36,15) - end - end end + if C and (not C.clearing or flashing) then + gc_setColor(ColorTable[C.color]) + gc_rectangle('fill',x,y,36,36,15) + end end function S.drawGhost(B,handX,ghostY)