Skip to content

Commit

Permalink
气泡添加配色方案设置,添加几套默认支持到8个的配色方案(随机配色wip)
Browse files Browse the repository at this point in the history
整理代码
  • Loading branch information
MrZ626 committed May 6, 2024
1 parent cc54e04 commit b361001
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 55 deletions.
12 changes: 12 additions & 0 deletions assets/game/basePlayer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ local P={}

--------------------------------------------------------------
-- Tools

function P:drawInfoPanel(x,y,w,h)
return SKIN.get(self.settings.skin).drawInfoPanel(x,y,w,h)
end

--------------------------------------------------------------
-- Effects

function P:shakeBoard(args,v)
local shake=self.settings.shakeness
local pos=self.pos
Expand Down Expand Up @@ -116,11 +119,15 @@ function P:say(arg)
a=arg.c and arg.c[4] or 1,
}
end

--------------------------------------------------------------
-- Game methods

---Random Int
function P:random(a,b)
return self.RND:random(a,b)
end
---Random Float
function P:rand(a,b)
return a+self.RND:random()*(b-a)
end
Expand Down Expand Up @@ -240,8 +247,10 @@ function P:finish(reason)
self:playSound(reason=='AC' and 'win' or 'fail')
end
end

--------------------------------------------------------------
-- Press & Release & Update & Render

function P:pressKey(act)
if self.settings.inputDelay<=0 then
self:press(act)
Expand Down Expand Up @@ -434,8 +443,10 @@ function P:update(dt)
for _,v in next,self.particles do v:update(dt) end
self.texts:update(dt)
end

--------------------------------------------------------------
-- Builder

function P:addSoundEvent(name,F)
assert(self.soundEvent[name],"Wrong soundEvent key: '"..tostring(name).."'")
assert(type(F)=='function',"soundEvent must be function")
Expand Down Expand Up @@ -827,6 +838,7 @@ end
function P:unserialize_custom()
-- Flandre kawaii
end

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

return P
14 changes: 7 additions & 7 deletions assets/game/classes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
---|'drawOnPlayer'

---@alias Techmino.Mech.basic table<string, table|fun(P:Techmino.Player|any):any>
---@alias Techmino.Mech.mino table<string, table|fun(P:Techmino.Player.mino|any):any, any>
---@alias Techmino.Mech.puyo table<string, table|fun(P:Techmino.Player.puyo|any):any, any>
---@alias Techmino.Mech.gem table<string, table|fun(P:Techmino.Player.gem|any):any, any>
---@alias Techmino.Mech.mino table<string, table|fun(P:Techmino.Player.Mino|any):any, any>
---@alias Techmino.Mech.puyo table<string, table|fun(P:Techmino.Player.Puyo|any):any, any>
---@alias Techmino.Mech.gem table<string, table|fun(P:Techmino.Player.Gem|any):any, any>

---@class Techmino.ParticleSystems
---@field rectShade love.ParticleSystem
Expand Down Expand Up @@ -125,10 +125,10 @@
---@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?
---@field isFill fun(P:Techmino.Player.mino, y:number): boolean
---@field getFill fun(P:Techmino.Player.mino): number[]?
---@field clear fun(P:Techmino.Player.mino, lines:number[])
---@field getDelay fun(P:Techmino.Player.Mino, lines:number[]): number?
---@field isFill fun(P:Techmino.Player.Mino, y:number): boolean
---@field getFill fun(P:Techmino.Player.Mino): number[]?
---@field clear fun(P:Techmino.Player.Mino, lines:number[])

---@class Techmino.Game
---@field playing boolean
Expand Down
16 changes: 14 additions & 2 deletions assets/game/gemPlayer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local max,min=math.max,math.min
local floor=math.floor
local ins,rem=table.insert,table.remove

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

Expand Down Expand Up @@ -47,6 +47,7 @@ local GP=setmetatable({},{__index=require'basePlayer',__metatable=true})

--------------------------------------------------------------
-- Function tables

local defaultSoundFunc={
countDown= countDownSound,
move= function() FMOD.effect('move') end,
Expand All @@ -71,17 +72,22 @@ local defaultSoundFunc={
win= function() FMOD.effect('win') end,
fail= function() FMOD.effect('fail') end,
}
---@type Map<fun(P:Techmino.Player.gem):any>
---@type Map<fun(P:Techmino.Player.Gem):any>
GP.scriptCmd={
}

--------------------------------------------------------------
-- Actions

GP._actions={}
for k,v in next,mechLib.mino.actions do GP._actions[k]=GP:_getActionObj(v) end

--------------------------------------------------------------
-- Effects

--------------------------------------------------------------
-- Game methods

function GP:printField() -- For debugging
local F=self.field
print('----------')
Expand Down Expand Up @@ -473,8 +479,10 @@ function GP:getScriptValue(arg)
arg.d=='field_size' and self.settings.fieldSize or
arg.d=='cell' and (self.field[arg.y][arg.x] and 1 or 0)
end

--------------------------------------------------------------
-- Press & Release & Update & Render

function GP:getMousePos(x,y)
local pos=self.pos
x,y=((x-pos.x)/pos.k/360+1)/2,((pos.y-y)/pos.k/360+1)/2
Expand Down Expand Up @@ -813,17 +821,21 @@ function GP:render()

gc_pop()
end

--------------------------------------------------------------
-- Other

function GP:decodeScript(line,errMsg)
-- TODO
-- error(errMsg.."No string command '"..cmd.."'")
end
function GP:checkScriptSyntax(cmd,arg,errMsg)
-- TODO
end

--------------------------------------------------------------
-- Builder

---@class Techmino.Mode.Setting.Gem
local baseEnv={
-- Size
Expand Down
1 change: 1 addition & 0 deletions assets/game/mechanicLib/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ local mechLib={
actions=require'puyo/actions',
statistics=require'puyo/statistics',
sequence=require'puyo/sequence',
colorSet=require'puyo/colorSet',
attackSys=require'puyo/attackSys',
misc=require'puyo/misc',
},
Expand Down
2 changes: 1 addition & 1 deletion assets/game/mechanicLib/mino/sequence.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end
---@type Techmino.Mech.mino
local sequence={}

---@param P Techmino.Player.mino
---@param P Techmino.Player.Mino
---@param d table cached data of generator
---@param init boolean true if this is the first initializating call
---@diagnostic disable-next-line
Expand Down
28 changes: 28 additions & 0 deletions assets/game/mechanicLib/puyo/colorSet.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---@type Techmino.Mech.puyo
local colorSet={}

-- R Y B G P C O M
colorSet.light={955,994,469,696,759,699,974,969}
colorSet.classic={933,882,249,484,539,489,952,849}
colorSet.black={400,440,014,141,204,144,420,414}

colorSet.grey={111,333,555,999,888,666,444,222}

function colorSet.getRandom(P)
P:random()
end

setmetatable(colorSet,{
__index=function(_,k)
assertf(k=='random','Invalid color set key : %s',k)
if 1 then
local l={}
-- TODO
return l
else
error('Not color set : '..k)
end
end
})

return colorSet
2 changes: 1 addition & 1 deletion assets/game/mechanicLib/puyo/sequence.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end
---@type Techmino.Mech.puyo
local sequence={}

---@param P Techmino.Player.puyo
---@param P Techmino.Player.Puyo
---@param d table cached data of generator
---@param init boolean true if this is the first initializating call
---@diagnostic disable-next-line
Expand Down
17 changes: 15 additions & 2 deletions assets/game/minoPlayer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ local ins,rem=table.insert,table.remove

local clamp,expApproach=MATH.clamp,MATH.expApproach

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

--------------------------------------------------------------
-- Function tables

local defaultSoundFunc={
countDown= countDownSound,
move= function() FMOD.effect('move') end,
Expand Down Expand Up @@ -66,20 +67,24 @@ local defaultSoundFunc={
win= function() FMOD.effect('win') end,
fail= function() FMOD.effect('fail') end,
}
---@type Map<fun(P:Techmino.Player.mino):any>
---@type Map<fun(P:Techmino.Player.Mino):any>
MP.scriptCmd={
clearHold=function(P) P:clearHold() end,
clearNext=function(P) P:clearNext() end,
pushNext=function(P,arg) P:pushNext(arg) end,
setField=function(P,arg) P:setField(arg) end,
switchAction=function(P,arg) P:switchAction(arg) end,
}

--------------------------------------------------------------
-- Actions

MP._actions={}
for k,v in next,mechLib.mino.actions do MP._actions[k]=MP:_getActionObj(v) end

--------------------------------------------------------------
-- Effects

function MP:createMoveEffect(x1,y1,x2,y2)
local p=self.particles.rectShade
local dx,dy=self:getSmoothPos()
Expand Down Expand Up @@ -214,8 +219,10 @@ function MP:getSmoothPos()
self.ghostY and self.handY>self.ghostY and 40*(max(1-self.dropTimer/self.settings.dropDelay*2.6,0))^2.6 or 0
end
end

--------------------------------------------------------------
-- Game methods

---@param action 'moveX'|'moveY'|'drop'|'rotate'|'reset'
function MP:moveHand(action,A,B,C,D)
--[[
Expand Down Expand Up @@ -1365,8 +1372,10 @@ function MP:getScriptValue(arg)
arg.d=='field_height' and self.field:getHeight() or
arg.d=='cell' and (self.field:getCell(arg.x,arg.y) and 1 or 0)
end

--------------------------------------------------------------
-- Press & Release & Update & Render

function MP:updateFrame()
local SET=self.settings

Expand Down Expand Up @@ -1843,8 +1852,10 @@ function MP:render()

gc_pop()
end

--------------------------------------------------------------
-- Other

function MP:decodeScript(line,errMsg)
if line.cmd=='setField' then
elseif line.cmd=='switchAction' then
Expand Down Expand Up @@ -1881,8 +1892,10 @@ function MP:checkScriptSyntax(cmd,arg,errMsg)
end
end
end

--------------------------------------------------------------
-- Builder

---@class Techmino.Mode.Setting.Mino
local baseEnv={
-- Size
Expand Down
Loading

0 comments on commit b361001

Please sign in to comment.