Skip to content

Commit

Permalink
puyo也使用新的das系统
Browse files Browse the repository at this point in the history
整理代码
  • Loading branch information
MrZ626 committed Dec 29, 2023
1 parent 8adf73a commit cf37ce7
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 50 deletions.
104 changes: 69 additions & 35 deletions assets/game/mechanicLib/puyo/actions.lua
Original file line number Diff line number Diff line change
@@ -1,45 +1,79 @@
local actions={}
actions.moveLeft={
press=function(P)
P.moveDir=-1
P.moveCharge=0
if P.hand then
if P:moveLeft() then
P:playSound('move')
else
P:freshDelay('move')
P:playSound('move_failed')
local function getCharge(charge,mode,SET)
if mode=='reset' then
return 0
elseif mode=='keep' then
local base=SET.asd-SET.asp
if charge>base then
return charge-(charge-base)%SET.asp
end
elseif mode=='raw' then
return charge
elseif mode=='full' then
return SET.asd
else
error("WTF why dblMoveChrg is "..mode)
end
end
local function move(P,dir,canBuffer)
if P.hand then
if P[dir=='L' and 'moveLeft' or 'moveRight'](P) then
P:playSound('move')
else
P:freshDelay('move')
P:playSound('move_failed')
if P.settings.particles then
P:createHandEffect(1,.26,0)
end
else
P.keyBuffer.move='L'
end
end,
release=function(P)
if P.keyBuffer.move=='L' then P.keyBuffer.move=false end
if P.hand and P.deathTimer then P:moveRight() end
elseif canBuffer then
P.keyBuffer.move=dir
end
}
actions.moveRight={
press=function(P)
P.moveDir=1
end
local function pressMove(P,dir)
-- WARNING: Has early return
local d=dir=='L' and -1 or 1

local SET=P.settings
if P.keyState[dir=='L' and 'moveRight' or 'moveLeft'] then
if SET.dblMoveCover then
P.moveDir=d
end
P.moveCharge=getCharge(P.moveCharge,SET.dblMoveChrg,SET)
if not SET.dblMoveStep then return end -- [Early return]
else
P.moveDir=d
P.moveCharge=0
if P.hand then
if P:moveRight() then
P:playSound('move')
else
P:freshDelay('move')
P:playSound('move_failed')
P:createHandEffect(1,.26,0)
end
else
P.keyBuffer.move='R'
end
move(P,dir,true)
end
local function releaseMove(P,dir)
local invD=dir=='L' and 'R' or 'L'
local invDN=dir=='L' and -1 or 1

local SET=P.settings
if P.keyState[dir=='L' and 'moveRight' or 'moveLeft'] then
if P.moveDir==-invDN then -- Normal Release
P.moveCharge=getCharge(P.moveCharge,SET.dblMoveRelChrg,SET)
if SET.dblMoveRelStep then move(P,invD,false) end
else -- Inversed Release
if SET.dblMoveRelInvRedir then P.moveDir=-invDN end
P.moveCharge=getCharge(P.moveCharge,SET.dblMoveRelInvChrg,SET)
if SET.dblMoveRelInvStep then move(P,invD,true) end
end
end,
release=function(P)
if P.keyBuffer.move=='R' then P.keyBuffer.move=false end
if P.hand and P.deathTimer then P:moveLeft() end
else
if P.keyBuffer.move==dir then P.keyBuffer.move=false end
if P.hand and P.deathTimer then P[dir=='L' and 'moveLeft' or 'moveRight'](P) end
end
end

local actions={}
actions.moveLeft={
press=function(P) pressMove(P,'L') end,
release=function(P) releaseMove(P,'L') end
}
actions.moveRight={
press=function(P) pressMove(P,'R') end,
release=function(P) releaseMove(P,'R') end
}
actions.rotateCW={
press=function(P)
Expand Down
23 changes: 13 additions & 10 deletions assets/game/minoPlayer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1917,16 +1917,13 @@ local baseEnv={
allowTransform=true,

-- May be overrode with user setting
asd=162,
asp=26,
adp=12,
ash=0, -- Discharge some asd when piece spawn
hdLockA=1000, -- Harddrop lock (auto)
hdLockM=100, -- Harddrop lock (manual)
initMove='buffer',
initRotate='buffer',
initHold='buffer',
IRSpushUp=true,
asd=122, -- Auto shift delay
asp=26, -- Auto shift period
adp=26, -- Auto drop period
ash=26, -- Auto Shift Halt, discharge asd when piece spawn
stopMoveWhenSpawn=false, -- Stop moving when piece spawn
stopMoveWhenRotate=false, -- Stop moving when rotate
stopMoveWhenHold=false, -- Stop moving when hold
dblMoveCover=false, -- Use second dir (Press 2)
dblMoveChrg='reset', -- reset/keep/raw/full charge (Press 2)
dblMoveStep=true, -- Move (Press 2)
Expand All @@ -1935,6 +1932,12 @@ local baseEnv={
dblMoveRelInvChrg='reset', -- reset/keep/raw/full charge (Release 2)
dblMoveRelInvStep=true, -- Move (Release 2)
dblMoveRelInvRedir=true, -- Change direction (Release 2)
initMove='buffer', -- buffer/hold to do initial move
initRotate='buffer', -- buffer/hold to do initial rotate
initHold='buffer', -- buffer/hold to do initial hold
hdLockA=1000, -- Harddrop lock (auto)
hdLockM=100, -- Harddrop lock (manual)
IRSpushUp=true, -- Use bottom-align when IRS or suffocate
skin='mino_plastic',
particles=true,
shakeness=.26,
Expand Down
20 changes: 15 additions & 5 deletions assets/game/puyoPlayer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1245,14 +1245,24 @@ local baseEnv={
script=false,

-- May be overrode with user setting
asd=162,
asd=122,
asp=26,
adp=12,
ash=0,
hdLockA=1000,
hdLockM=100,
adp=26,
ash=26,
stopMoveWhenSpawn=false,
stopMoveWhenRotate=false,
dblMoveCover=false,
dblMoveChrg='reset',
dblMoveStep=true,
dblMoveRelChrg='raw',
dblMoveRelStep=false,
dblMoveRelInvChrg='reset',
dblMoveRelInvStep=true,
dblMoveRelInvRedir=true,
initMove='buffer',
initRotate='buffer',
hdLockA=1000,
hdLockM=100,
IRSpushUp=true,
skin='puyo_jelly',
particles=true,
Expand Down

0 comments on commit cf37ce7

Please sign in to comment.