From b06d07bd47365d6f29d52754a85ea5476e46cc04 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 14 Feb 2021 03:15:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=95=E5=83=8F(=E6=B5=81)?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E5=B8=A7=E8=AF=AF=E5=B7=AE=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E7=A7=BB=E9=99=A4=E7=8E=A9=E5=AE=B6keyRec=E5=B1=9E?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/player/init.lua | 17 ++++++--------- parts/player/update.lua | 44 +++++++++++++++++++-------------------- parts/scenes/net_game.lua | 25 +++++++++++----------- parts/scenes/play.lua | 20 ++++++++---------- 4 files changed, 49 insertions(+), 57 deletions(-) diff --git a/parts/player/init.lua b/parts/player/init.lua index 9c55ce7e..4299fb9f 100644 --- a/parts/player/init.lua +++ b/parts/player/init.lua @@ -36,10 +36,8 @@ local function pressKey(P,keyID) P.keyPressing[keyID]=true P.actList[keyID](P) if P.control then - if P.keyRec then - ins(P.keyTime,1,GAME.frame) - P.keyTime[11]=nil - end + ins(P.keyTime,1,GAME.frame) + P.keyTime[11]=nil end P.stat.key=P.stat.key+1 end @@ -50,22 +48,20 @@ end local function pressKey_Rec(P,keyID) if P.keyAvailable[keyID]and P.alive then local L=GAME.rep - ins(L,GAME.frame+1) + ins(L,GAME.frame) ins(L,keyID) P.keyPressing[keyID]=true P.actList[keyID](P) if P.control then - if P.keyRec then - ins(P.keyTime,1,GAME.frame) - P.keyTime[11]=nil - end + ins(P.keyTime,1,GAME.frame) + P.keyTime[11]=nil end P.stat.key=P.stat.key+1 end end local function releaseKey_Rec(P,keyID) local L=GAME.rep - ins(L,GAME.frame+1) + ins(L,GAME.frame) ins(L,32+keyID) P.keyPressing[keyID]=false end @@ -102,7 +98,6 @@ local function newEmptyPlayer(id,mini) P.frameWait=rnd(30,120) P.draw=PLY.draw.small else - P.keyRec=true--If calculate keySpeed P.draw=PLY.draw.norm end P.randGen=love.math.newRandomGenerator(GAME.seed) diff --git a/parts/player/update.lua b/parts/player/update.lua index 8eaf0766..c2f2a2f3 100644 --- a/parts/player/update.lua +++ b/parts/player/update.lua @@ -118,26 +118,25 @@ function update.alive(P,dt) S.time=S.time+dt S.frame=S.frame+1 end - if P.keyRec then--Update speeds - local frame=GAME.frame + --Calculate key speed + do local v=0 - for i=2,10 do v=v+i*(i-1)*7.2/(frame-P.keyTime[i]+1)end + for i=2,10 do v=v+i*(i-1)*7.2/(GAME.frame-P.keyTime[i]+1)end P.keySpeed=P.keySpeed*.99+v*.1 - v=0 - for i=2,10 do v=v+i*(i-1)*7.2/(frame-P.dropTime[i])end + for i=2,10 do v=v+i*(i-1)*7.2/(GAME.frame-P.dropTime[i])end P.dropSpeed=P.dropSpeed*.99+v*.1 + end - if GAME.modeEnv.royaleMode then - v=P.swappingAtkMode - if P.keyPressing[9]then - P.swappingAtkMode=min(v+2,30) - else - local tar=#P.field>15 and 4 or 8 - if v~=tar then - P.swappingAtkMode=v+(v15 and 4 or 8 + if v~=tar then + P.swappingAtkMode=v+(v=0 then P.falling=P.falling-1 if P.falling<0 then diff --git a/parts/scenes/net_game.lua b/parts/scenes/net_game.lua index c9843c84..b6ffbfa2 100644 --- a/parts/scenes/net_game.lua +++ b/parts/scenes/net_game.lua @@ -270,30 +270,29 @@ function scene.update(dt) touchMoveLastFrame=false updateVirtualkey() - GAME.frame=GAME.frame+1 + + --Counting, include pre-das + if checkStart()then return end + + --Update players + for p=1,#PLAYERS do PLAYERS[p]:update(dt)end + + --Warning check + checkWarning() + + --Upload stream if GAME.frame-lastUpstreamTime>8 then local stream stream,upstreamProgress=dumpRecording(GAME.rep,upstreamProgress) if #stream>0 then wsWrite("S"..data.encode("string","base64",stream)) else - ins(GAME.rep,GAME.frame+1) + ins(GAME.rep,GAME.frame) ins(GAME.rep,0) end lastUpstreamTime=PLAYERS[1].alive and GAME.frame or 1e99 end - - --Counting, include pre-das - if checkStart()then return end - - --Update players - for p=1,#PLAYERS do - PLAYERS[p]:update(dt) - end - - --Warning check - checkWarning() end function scene.draw() diff --git a/parts/scenes/play.lua b/parts/scenes/play.lua index dea62500..d942fe9f 100644 --- a/parts/scenes/play.lua +++ b/parts/scenes/play.lua @@ -125,16 +125,12 @@ end function scene.update(dt) local _ - local P1=PLAYERS[1] local GAME=GAME - touchMoveLastFrame=false - updateVirtualkey() - GAME.frame=GAME.frame+1 - --Replay if GAME.replaying then _=GAME.replaying + local P1=PLAYERS[1] local L=GAME.rep while GAME.frame==L[_]do local key=L[_+1] @@ -151,21 +147,23 @@ function scene.update(dt) GAME.replaying=_ end + touchMoveLastFrame=false + updateVirtualkey() + GAME.frame=GAME.frame+1 + --Counting, include pre-das if checkStart()then return end --Update players - for p=1,#PLAYERS do - PLAYERS[p]:update(dt) - end + for p=1,#PLAYERS do PLAYERS[p]:update(dt)end + + --Warning check + checkWarning() --Fresh royale target if GAME.modeEnv.royaleMode and GAME.frame%120==0 then freshMostDangerous() end - - --Warning check - checkWarning() end local function drawAtkPointer(x,y)