play场景改名game,整理代码,重构GAME.frame相关内容,修复联网录像播放不正确
This commit is contained in:
@@ -426,12 +426,12 @@ local function drawMission(P)
|
||||
end
|
||||
local function drawStartCounter(P)
|
||||
gc_setColor(1,1,1)
|
||||
if GAME.frame<180 then
|
||||
if GAME.frame==0 then
|
||||
if P.frameRun<180 then
|
||||
if P.frameRun==0 then
|
||||
setFont(70)
|
||||
mStr(P.ready and text.beReady or text.notReady,305,220)
|
||||
else
|
||||
local count=179-GAME.frame
|
||||
local count=179-P.frameRun
|
||||
gc_push("transform")
|
||||
gc_translate(305,220)
|
||||
setFont(95)
|
||||
|
||||
@@ -43,7 +43,7 @@ local function pressKey(P,keyID)
|
||||
P.keyPressing[keyID]=true
|
||||
P.actList[keyID](P)
|
||||
if P.control then
|
||||
ins(P.keyTime,1,GAME.frame)
|
||||
ins(P.keyTime,1,P.frameRun)
|
||||
P.keyTime[11]=nil
|
||||
end
|
||||
P.stat.key=P.stat.key+1
|
||||
@@ -55,12 +55,12 @@ end
|
||||
local function pressKey_Rec(P,keyID)
|
||||
if P.keyAvailable[keyID]and P.alive then
|
||||
local L=GAME.rep
|
||||
ins(L,GAME.frame)
|
||||
ins(L,P.frameRun)
|
||||
ins(L,keyID)
|
||||
P.keyPressing[keyID]=true
|
||||
P.actList[keyID](P)
|
||||
if P.control then
|
||||
ins(P.keyTime,1,GAME.frame)
|
||||
ins(P.keyTime,1,P.frameRun)
|
||||
P.keyTime[11]=nil
|
||||
end
|
||||
P.stat.key=P.stat.key+1
|
||||
@@ -68,7 +68,7 @@ local function pressKey_Rec(P,keyID)
|
||||
end
|
||||
local function releaseKey_Rec(P,keyID)
|
||||
local L=GAME.rep
|
||||
ins(L,GAME.frame)
|
||||
ins(L,P.frameRun)
|
||||
ins(L,32+keyID)
|
||||
P.keyPressing[keyID]=false
|
||||
end
|
||||
@@ -114,6 +114,7 @@ local function newEmptyPlayer(id,mini)
|
||||
|
||||
P.randGen=love.math.newRandomGenerator(GAME.seed)
|
||||
|
||||
P.frameRun=GAME.frameStart
|
||||
P.alive=true
|
||||
P.control=false
|
||||
P.timing=false
|
||||
@@ -354,6 +355,7 @@ function PLY.newDemoPlayer(id)
|
||||
P.sound=true
|
||||
P.demo=true
|
||||
|
||||
P.frameRun=180
|
||||
P.draw=PLY.draw.demo
|
||||
P.control=true
|
||||
GAME.modeEnv=DemoEnv
|
||||
|
||||
@@ -339,7 +339,7 @@ function Player:attack(R,send,time,line,fromStream)
|
||||
local atkFX=self.gameEnv.atkFX
|
||||
if GAME.net then
|
||||
if self.type=="human"then--Local player attack others
|
||||
ins(GAME.rep,GAME.frame)
|
||||
ins(GAME.rep,self.frameRun)
|
||||
ins(GAME.rep,
|
||||
R.sid+
|
||||
send*0x100+
|
||||
@@ -352,7 +352,7 @@ function Player:attack(R,send,time,line,fromStream)
|
||||
end
|
||||
end
|
||||
if fromStream and R.type=="human"then--Local player receiving lines
|
||||
ins(GAME.rep,GAME.frame)
|
||||
ins(GAME.rep,self.frameRun)
|
||||
ins(GAME.rep,
|
||||
self.sid+
|
||||
send*0x100+
|
||||
@@ -960,7 +960,7 @@ do--Player.drop(self)--Place piece
|
||||
function Player:drop()
|
||||
local _
|
||||
local CHN=VOC.getFreeChannel()
|
||||
self.dropTime[11]=ins(self.dropTime,1,GAME.frame)--Update speed dial
|
||||
self.dropTime[11]=ins(self.dropTime,1,self.frameRun)--Update speed dial
|
||||
local ENV=self.gameEnv
|
||||
local Stat=self.stat
|
||||
local piece=self.lastPiece
|
||||
@@ -1609,7 +1609,7 @@ function tick_autoPause()
|
||||
while true do
|
||||
yield()
|
||||
time=time+1
|
||||
if SCN.cur~="play"or GAME.frame<180 then
|
||||
if SCN.cur~="game"or PLAYERS[1].frameRun<180 then
|
||||
return
|
||||
elseif time==120 then
|
||||
pauseGame()
|
||||
@@ -1697,7 +1697,7 @@ function Player:die()--Called both when win/lose!
|
||||
end
|
||||
if GAME.net then
|
||||
if self.id==1 then
|
||||
ins(GAME.rep,GAME.frame)
|
||||
ins(GAME.rep,self.frameRun)
|
||||
ins(GAME.rep,0)
|
||||
else
|
||||
if self.lastRecv and self.lastRecv.id==1 then
|
||||
|
||||
@@ -114,8 +114,29 @@ local update={
|
||||
}
|
||||
function update.alive(P,dt)
|
||||
local ENV=P.gameEnv
|
||||
local S=P.stat
|
||||
|
||||
P.frameRun=P.frameRun+1
|
||||
if P.frameRun<=180 then
|
||||
if P.frameRun==180 then
|
||||
if P.id==1 then SFX.play("start")end
|
||||
P.control=true
|
||||
P.timing=true
|
||||
P:popNext()
|
||||
elseif P.frameRun==60 or P.frameRun==120 then
|
||||
if P.id==1 then SFX.play("ready")end
|
||||
end
|
||||
if P.movDir~=0 then
|
||||
if P.moving<P.gameEnv.das then
|
||||
P.moving=P.moving+1
|
||||
end
|
||||
else
|
||||
P.moving=0
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
if P.timing then
|
||||
local S=P.stat
|
||||
S.time=S.time+dt
|
||||
S.frame=S.frame+1
|
||||
end
|
||||
@@ -123,10 +144,10 @@ function update.alive(P,dt)
|
||||
--Calculate key speed
|
||||
do
|
||||
local v=0
|
||||
for i=2,10 do v=v+i*(i-1)*72/(GAME.frame-P.keyTime[i]+1)end
|
||||
for i=2,10 do v=v+i*(i-1)*72/(P.frameRun-P.keyTime[i]+1)end
|
||||
P.keySpeed=P.keySpeed*.99+v*.01
|
||||
v=0
|
||||
for i=2,10 do v=v+i*(i-1)*72/(GAME.frame-P.dropTime[i])end
|
||||
for i=2,10 do v=v+i*(i-1)*72/(P.frameRun-P.dropTime[i])end
|
||||
P.dropSpeed=P.dropSpeed*.99+v*.01
|
||||
end
|
||||
|
||||
@@ -372,17 +393,17 @@ function update.dead(P,dt)
|
||||
updateTasks(P)
|
||||
end
|
||||
function update.remote_alive(P,dt)
|
||||
local frmStep=GAME.frame-P.stat.frame
|
||||
local frmDelta=PLAYERS[1].frameRun-P.frameRun
|
||||
for _=1,
|
||||
frmStep<20 and 1 or
|
||||
frmStep<45 and rnd(2)or
|
||||
frmStep<90 and 2 or
|
||||
frmStep<180 and rnd(2,3) or
|
||||
frmDelta<20 and 1 or
|
||||
frmDelta<45 and rnd(2)or
|
||||
frmDelta<90 and 2 or
|
||||
frmDelta<180 and rnd(2,3) or
|
||||
3
|
||||
do
|
||||
local eventTime=P.stream[P.streamProgress]
|
||||
if eventTime then--Normal state, event forward
|
||||
if P.stat.frame==eventTime then--Event time, execute action, read next so don't update immediately
|
||||
if P.frameRun==eventTime then--Event time, execute action, read next so don't update immediately
|
||||
local event=P.stream[P.streamProgress+1]
|
||||
if event==0 then--Just wait
|
||||
elseif event<=32 then--Press key
|
||||
|
||||
Reference in New Issue
Block a user