Skip to content

Commit

Permalink
框架跟进
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZ626 committed May 1, 2024
1 parent 1ea9207 commit 0972bdf
Show file tree
Hide file tree
Showing 17 changed files with 109 additions and 106 deletions.
2 changes: 1 addition & 1 deletion Zenitha
Submodule Zenitha updated 5 files
+1 −1 image.lua
+13 −2 init.lua
+1 −1 mathExtend.lua
+6 −13 tableExtend.lua
+33 −3 tween.lua
3 changes: 1 addition & 2 deletions assets/fmod20221/constants.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
local bit=require("bit")
local ffi=require("ffi")
local path=(...):gsub("[^%.]*$", "")
local r=require; local function require(m) return r(path..m) end
local require=simpRequire(((...):gsub("[^%.]*$", "")))

---@class FMOD.master
local M=require("master")
Expand Down
3 changes: 1 addition & 2 deletions assets/fmod20221/enums.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local path=(...):gsub("[^%.]*$", "")
local r=require; local function require(m) return r(path..m) end
local require=simpRequire(((...):gsub("[^%.]*$", "")))

---@class FMOD.master
local M=require("master")
Expand Down
3 changes: 1 addition & 2 deletions assets/fmod20221/errors.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local path=(...):gsub("[^%.]*$", "")
local r=require; local function require(m) return r(path..m) end
local require=simpRequire(((...):gsub("[^%.]*$", "")))

---@class FMOD.master
local M=require("master")
Expand Down
15 changes: 7 additions & 8 deletions assets/fmod20221/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
local ffi=require("ffi")
local path=(...):gsub(".init$","").."."
local r=require; local function require(m) return r(path..m) end
local require=simpRequire(((...):gsub(".init$","").."."))

require("cdef")

Expand Down Expand Up @@ -65,7 +64,7 @@ function M.loadBank(bankPath,flag)
return bank
end

---@type table<any,FMOD.Studio.EventDescription>
---@type Map<FMOD.Studio.EventDescription>
local musicLib={}
function M.registerMusic(map)
if not studio then return end
Expand All @@ -76,7 +75,7 @@ function M.registerMusic(map)
end
end

---@type table<any,FMOD.Studio.EventDescription>
---@type Map<FMOD.Studio.EventDescription>
local effectLib={}
function M.registerEffect(map)
if not studio then return end
Expand Down Expand Up @@ -108,7 +107,7 @@ end

--------------------------

---@type table|fun(name:string, args?:{instant?:boolean, volume?:number, pitch?:number, tune?:number, fine?:number, pos?:table<number,number>, param?:table}):FMOD.Studio.EventInstance?
---@type table|fun(name:string, args?:{instant?:boolean, volume?:number, pitch?:number, tune?:number, fine?:number, pos?:number[], param?:table}):FMOD.Studio.EventInstance?
M.music={}

---@param v number
Expand All @@ -123,7 +122,7 @@ end
local playing=nil

---@param name string
---@param args? {instant?:boolean, volume?:number, pitch?:number, tune?:number, fine?:number, pos?:table<number,number>, param?:table}
---@param args? {instant?:boolean, volume?:number, pitch?:number, tune?:number, fine?:number, pos?:number[], param?:table}
---@return FMOD.Studio.EventInstance?
function M.music.play(name,args)
FMOD.music.stop()
Expand Down Expand Up @@ -227,7 +226,7 @@ setmetatable(M.music,{__call=function(_,...) return playMusic(...) end})

--------------------------

---@type table|fun(name:string, args?:{instant?:boolean, volume?:number, pitch?:number, tune?:number, fine?:number, pos?:table<number,number>, param?:table}):FMOD.Studio.EventInstance?
---@type table|fun(name:string, args?:{instant?:boolean, volume?:number, pitch?:number, tune?:number, fine?:number, pos?:number[], param?:table}):FMOD.Studio.EventInstance?
M.effect={}

---@param v number
Expand All @@ -244,7 +243,7 @@ end
---
---param:{'paramName', 0, true?}
---@param name string
---@param args? {volume?:number, pitch?:number, tune?:number, fine?:number, pos?:table<number,number>, param?:table}
---@param args? {volume?:number, pitch?:number, tune?:number, fine?:number, pos?:number[], param?:table}
---@return FMOD.Studio.EventInstance?
function M.effect.play(name,args)
local desc=effectLib[name]
Expand Down
3 changes: 1 addition & 2 deletions assets/fmod20221/wrap.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
local ffi=require("ffi")
local path=(...):gsub("[^%.]*$", "")
local r=require; local function require(m) return r(path..m) end
local require=simpRequire(((...):gsub("[^%.]*$", "")))

---@alias FMOD.GUID FMOD.GUID
---@alias FMOD.Result FMOD.Result
Expand Down
2 changes: 1 addition & 1 deletion assets/game/basePlayer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function P:triggerEvent(name,...)
end
end
end
---@param E Techmino.Event|function|string|table<number, Techmino.Event>|any
---@param E Techmino.Event|Map<Techmino.Event>|function|string|any
function P:addEvent(name,E)
local L=self.event[name]
assert(L,"Wrong event key: '"..tostring(name).."'")
Expand Down
14 changes: 7 additions & 7 deletions assets/game/classes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
---@field trail love.ParticleSystem
---@field minoMapBack love.ParticleSystem

---@alias Techmino.Mino.Shape table<number, table<number, boolean>>
---@alias Techmino.Mino.Shape Map<Map<boolean>>
---@alias Techmino.Mino.Name 'Z'|'S'|'J'|'L'|'T'|'O'|'I'|'Z5'|'S5'|'P'|'Q'|'F'|'E'|'T5'|'U'|'V'|'W'|'X'|'J5'|'L5'|'R'|'Y'|'N'|'H'|'I5'|'I3'|'C'|'I2'|'O1'|string
---@alias Techmino.Mino.ID 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|integer
---@alias Techmino.Event {[1]:number, [2]:function}
Expand Down Expand Up @@ -116,13 +116,13 @@
---@field name string Mode name, for debug use

---@class Techmino.Mode.Setting.Mino
---@field event table<Techmino.mode.event.basic|Techmino.mode.event.mino, string|table|function|table<number, string|table|function>>
---@field event table<Techmino.mode.event.basic|Techmino.mode.event.mino, string|table|function|Map<string|table|function>>

---@class Techmino.Mode.Setting.Puyo
---@field event table<Techmino.mode.event.basic|Techmino.mode.event.puyo, string|table|function|table<number, string|table|function>>
---@field event table<Techmino.mode.event.basic|Techmino.mode.event.puyo, string|table|function|Map<string|table|function>>

---@class Techmino.Mode.Setting.Gem
---@field event table<Techmino.mode.event.basic|Techmino.mode.event.gem, string|table|function|table<number, string|table|function>>
---@field event table<Techmino.mode.event.basic|Techmino.mode.event.gem, string|table|function|Map<string|table|function>>

---@class Techmino.mino.clearRule
---@field getDelay fun(P:Techmino.Player.mino, lines:number[]): number?
Expand All @@ -132,8 +132,8 @@

---@class Techmino.Game
---@field playing boolean
---@field playerList table<number, Techmino.Player>|false
---@field playerMap table<number, Techmino.Player>|false
---@field playerList Techmino.Player[]|false
---@field playerMap Techmino.Player[]|false
---@field camera Zenitha.Camera
---@field hitWaves table
---@field seed number|false
Expand Down Expand Up @@ -169,7 +169,7 @@
---@field hand table|false Piece object
---@field handX number
---@field handY number
---@field event table<string, table<number, Techmino.Event>>
---@field event table<string, Techmino.Event[]>
---@field soundEvent table
---@field _actions table<string, {press:fun(P:Techmino.Player), release:fun(P:Techmino.Player)}>
---
Expand Down
8 changes: 5 additions & 3 deletions assets/game/gemPlayer.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local require=simpRequire('assets.game.')

local gc=love.graphics
local gc_push,gc_pop=gc.push,gc.pop
local gc_translate,gc_scale,gc_rotate=gc.translate,gc.scale,gc.rotate
Expand All @@ -11,7 +13,7 @@ local ins,rem=table.insert,table.remove

---@class Techmino.Player.gem: Techmino.Player
---@field field any[][]
local GP=setmetatable({},{__index=require'assets.game.basePlayer',__metatable=true})
local GP=setmetatable({},{__index=require'basePlayer',__metatable=true})

--[[ Gem tags:
int color <1~7>
Expand Down Expand Up @@ -859,7 +861,7 @@ local soundEventMeta={
__metatable=true,
}
function GP.new()
local self=setmetatable(require'assets.game.basePlayer'.new(),{__index=GP,__metatable=true})
local self=setmetatable(require'basePlayer'.new(),{__index=GP,__metatable=true})
self.settings=TABLE.copy(baseEnv)
self.event={
-- Press & Release
Expand Down Expand Up @@ -892,7 +894,7 @@ function GP.new()
return self
end
function GP:initialize()
require'assets.game.basePlayer'.initialize(self)
require'basePlayer'.initialize(self)

self.field={}
for y=1,self.settings.fieldSize do
Expand Down
17 changes: 9 additions & 8 deletions assets/game/init.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
Mino=require'assets.game.minoes'
ColorTable=require'assets.game.colorTable'
local require=simpRequire('assets.game.')
Mino=require'minoes'
ColorTable=require'colorTable'
defaultMinoColor=setmetatable({
2,22,42,6,52,12,32,
2,22,62,26,38,4,52,16,32,56,12,42,6,38,4,60,28,12,
36,52,4,24,
},{__index=function() return math.random(64) end})
defaultPuyoColor=setmetatable({2,12,42,22,52},{__index=function() return math.random(64) end})
---@type Techmino.Mech
mechLib=TABLE.newResourceTable(require'assets.game.mechanicLib',function(path) return FILE.load(path,'-lua') end)
mechLib=TABLE.newResourceTable(require'mechanicLib',function(path) return FILE.load(path,'-lua') end)
regFuncLib(mechLib,"mechLib")
require'assets.game.rotsys_mino'
require'rotsys_mino'

local gc=love.graphics

Expand Down Expand Up @@ -172,7 +173,7 @@ GAME.camera.moveSpeed=12
function GAME.getMode(name)
if love.keyboard.isDown('f5') then
modeLib[name]=nil
mechLib=TABLE.newResourceTable(require'assets.game.mechanicLib',function(path) return FILE.load(path,'-lua') end)
mechLib=TABLE.newResourceTable(require'mechanicLib',function(path) return FILE.load(path,'-lua') end)
regFuncLib(mechLib,"mechLib")
end
if modeLib[name] then
Expand Down Expand Up @@ -261,11 +262,11 @@ function GAME.newPlayer(id,pType)

local P
if pType=='mino' then
P=require'assets.game.minoPlayer'.new(GAME.mode)
P=require'minoPlayer'.new(GAME.mode)
elseif pType=='puyo' then
P=require'assets.game.puyoPlayer'.new(GAME.mode)
P=require'puyoPlayer'.new(GAME.mode)
elseif pType=='gem' then
P=require'assets.game.gemPlayer'.new(GAME.mode)
P=require'gemPlayer'.new(GAME.mode)
else
MSG.new('error',"invalid player type :'"..tostring(pType).."'")
return
Expand Down
61 changes: 30 additions & 31 deletions assets/game/mechanicLib/init.lua
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
-- Fake require function, make both human and language server happy
-- Those files will be loaded in another way, not require
local function require(path) return path:gsub('%.','/')..'.lua' end
-- Fake require function, only do string manipulation, real require when needed
local require=simpRequire(function(path) return 'assets/game/mechanicLib/'..path..'.lua' end)

---@class Techmino.Mech
local mechLib={
common={
timer=require'assets.game.mechanicLib.common.timer',
finish=require'assets.game.mechanicLib.common.finish',
timer=require'common/timer',
finish=require'common/finish',
},
mino={
-- Basic
actions=require'assets.game.mechanicLib.mino.actions',
statistics=require'assets.game.mechanicLib.mino.statistics',
sequence=require'assets.game.mechanicLib.mino.sequence',
clearRule=require'assets.game.mechanicLib.mino.clearRule',
attackSys=require'assets.game.mechanicLib.mino.attackSys',
misc=require'assets.game.mechanicLib.mino.misc',
actions=require'mino/actions',
statistics=require'mino/statistics',
sequence=require'mino/sequence',
clearRule=require'mino/clearRule',
attackSys=require'mino/attackSys',
misc=require'mino/misc',

-- Mode
sprint=require'assets.game.mechanicLib.mino.sprint',
dig=require'assets.game.mechanicLib.mino.dig',
survivor=require'assets.game.mechanicLib.mino.survivor',
backfire=require'assets.game.mechanicLib.mino.backfire',
marathon=require'assets.game.mechanicLib.mino.marathon',
hypersonic=require'assets.game.mechanicLib.mino.hypersonic',
comboPractice=require'assets.game.mechanicLib.mino.comboPractice',
tsdChallenge=require'assets.game.mechanicLib.mino.tsdChallenge',
techrashChallenge=require'assets.game.mechanicLib.mino.techrashChallenge',
acGenerator=require'assets.game.mechanicLib.mino.acGenerator',
sprint=require'mino/sprint',
dig=require'mino/dig',
survivor=require'mino/survivor',
backfire=require'mino/backfire',
marathon=require'mino/marathon',
hypersonic=require'mino/hypersonic',
comboPractice=require'mino/comboPractice',
tsdChallenge=require'mino/tsdChallenge',
techrashChallenge=require'mino/techrashChallenge',
acGenerator=require'mino/acGenerator',

-- Special
stack=require'assets.game.mechanicLib.mino.stack',
squeeze=require'assets.game.mechanicLib.mino.squeeze',
progress=require'assets.game.mechanicLib.mino.progress',
music=require'assets.game.mechanicLib.mino.music',
stack=require'mino/stack',
squeeze=require'mino/squeeze',
progress=require'mino/progress',
music=require'mino/music',
},
puyo={
-- Basic
actions=require'assets.game.mechanicLib.puyo.actions',
statistics=require'assets.game.mechanicLib.puyo.statistics',
sequence=require'assets.game.mechanicLib.puyo.sequence',
attackSys=require'assets.game.mechanicLib.puyo.attackSys',
misc=require'assets.game.mechanicLib.puyo.misc',
actions=require'puyo/actions',
statistics=require'puyo/statistics',
sequence=require'puyo/sequence',
attackSys=require'puyo/attackSys',
misc=require'puyo/misc',
},
gem={
-- Basic
actions=require'assets.game.mechanicLib.gem.actions',
actions=require'gem/actions',
},
}
return mechLib
14 changes: 8 additions & 6 deletions assets/game/minoPlayer.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local require=simpRequire('assets.game.')

local gc=love.graphics
local gc_push,gc_pop=gc.push,gc.pop
local gc_translate,gc_scale,gc_rotate=gc.translate,gc.scale,gc.rotate
Expand All @@ -12,7 +14,7 @@ local clamp,expApproach=MATH.clamp,MATH.expApproach

---@class Techmino.Player.mino: Techmino.Player
---@field field Techmino.RectField
local MP=setmetatable({},{__index=require'assets.game.basePlayer',__metatable=true})
local MP=setmetatable({},{__index=require'basePlayer',__metatable=true})

--------------------------------------------------------------
-- Function tables
Expand Down Expand Up @@ -1253,7 +1255,7 @@ end
{4,6,6,3,0,0,2,2,5,5},
{4,4,3,3,0,0,0,2,2,5},
}]]
---@param arg {color:'template'|'absolute'|nil, resetHand?:boolean, sudden?:boolean, number:table<number, number>}
---@param arg {color:'template'|'absolute'|nil, resetHand?:boolean, sudden?:boolean, [number]:number[]}
function MP:setField(arg)
local F=self.field
local w=self.settings.fieldW
Expand Down Expand Up @@ -1976,7 +1978,7 @@ local soundEventMeta={
__metatable=true,
}
function MP.new()
local self=setmetatable(require'assets.game.basePlayer'.new(),{__index=MP,__metatable=true})
local self=setmetatable(require'basePlayer'.new(),{__index=MP,__metatable=true})
self.settings=TABLE.copy(baseEnv)
self.event={
-- Press & Release
Expand Down Expand Up @@ -2024,9 +2026,9 @@ function MP.new()
return self
end
function MP:initialize()
require'assets.game.basePlayer'.initialize(self)
require'basePlayer'.initialize(self)

self.field=require'assets.game.rectField'.new(self.settings.fieldW)
self.field=require'rectField'.new(self.settings.fieldW)
self.fieldDived=0
self.fieldRisingSpeed=0

Expand Down Expand Up @@ -2099,7 +2101,7 @@ end
function MP:unserialize_custom()
-- Recover field object
local f=self.field
self.field=require'assets.game.rectField'.new(self.settings.fieldW)
self.field=require'rectField'.new(self.settings.fieldW)
self.field._width=f._width
self.field._matrix=f._matrix

Expand Down
2 changes: 1 addition & 1 deletion assets/game/minoes.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local Mino={}


---@type table<any, Techmino.Mino>
---@type Map<Techmino.Mino>
local minoes={}

function Mino.registerMino(name,id,shape)
Expand Down
Loading

0 comments on commit 0972bdf

Please sign in to comment.