play场景改名game,整理代码,重构GAME.frame相关内容,修复联网录像播放不正确

This commit is contained in:
MrZ626
2021-04-17 01:39:18 +08:00
parent 444c5e571e
commit 287d5a805d
24 changed files with 81 additions and 98 deletions

View File

@@ -14,14 +14,14 @@ function scene.update(dt)
timer=timer-dt*.8
if timer<0 then
SFX.play("click")
SCN.swapTo("play","none")
SCN.swapTo("game","none")
end
end
function scene.draw()
--Game scene
if timer*1.26<1 then
SCN.scenes.play.draw()
SCN.scenes.game.draw()
end
--Grey screen cover

View File

@@ -27,7 +27,7 @@ end
scene.mouseDown=NULL
local function restart()
resetGameData(GAME.frame<240 and"q")
resetGameData(PLAYERS[1].frameRun<240 and"q")
noKey=GAME.replaying
noTouch=noKey
end
@@ -133,7 +133,7 @@ function scene.update(dt)
_=GAME.replaying
local P1=PLAYERS[1]
local L=GAME.rep
while GAME.frame==L[_]do
while P1.frameRun==L[_]do
local key=L[_+1]
if key==0 then--Just wait
elseif key<=32 then--Press key
@@ -150,10 +150,6 @@ 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
@@ -162,7 +158,7 @@ function scene.update(dt)
checkWarning()
--Fresh royale target
if GAME.modeEnv.royaleMode and GAME.frame%120==0 then
if GAME.modeEnv.royaleMode and PLAYERS[1].frameRun%120==0 then
freshMostDangerous()
end
end

View File

@@ -37,7 +37,6 @@ function scene.sceneInit()
--Create demo player
destroyPlayers()
GAME.modeEnv=NONE
GAME.frame=0
GAME.seed=math.random(2e6)
PLY.newDemoPlayer(1)
PLAYERS[1]:setPosition(520,140,.8)
@@ -127,7 +126,6 @@ function scene.keyDown(key)
end
function scene.update(dt)
GAME.frame=GAME.frame+1
PLAYERS[1]:update(dt)
scrollX=scrollX-2.6
if scrollX<-tip:getWidth()then

View File

@@ -173,7 +173,7 @@ function scene.update()
end
local _=SCN.stat.tar
mapCam.zoomMethod=_=="play"and 1 or _=="mode"and 2
mapCam.zoomMethod=_=="game"and 1 or _=="mode"and 2
if mapCam.zoomMethod==1 then
_=mapCam.zoomK
if _<.8 then _=_*1.05 end

View File

@@ -199,15 +199,11 @@ function scene.update(dt)
if NET.checkPlayDisconn()then SCN.back()end
if not playing then return end
local _
local P1=PLAYERS[1]
local GAME=GAME
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
@@ -216,16 +212,16 @@ function scene.update(dt)
checkWarning()
--Upload stream
if GAME.frame-lastUpstreamTime>8 then
if P1.frameRun-lastUpstreamTime>8 then
local stream
stream,upstreamProgress=dumpRecording(GAME.rep,upstreamProgress)
if #stream>0 then
NET.uploadRecStream(stream)
else
ins(GAME.rep,GAME.frame)
ins(GAME.rep,P1.frameRun)
ins(GAME.rep,0)
end
lastUpstreamTime=PLAYERS[1].alive and GAME.frame or 1e99
lastUpstreamTime=PLAYERS[1].alive and P1.frameRun or 1e99
end
end

View File

@@ -34,7 +34,7 @@ function scene.sceneInit(org)
local P=PLAYERS[1]
local S=P.stat
timer=org=="play"and 0 or 50
timer=org=="game"and 0 or 50
local frameLostRate=(S.frame/S.time/60-1)*100
form={
@@ -113,14 +113,14 @@ function scene.sceneInit(org)
else
rank,trophy=nil
end
if org~="play"and GAME.prevBG then
if org~="game"and GAME.prevBG then
BG.set(GAME.prevBG)
end
end
function scene.sceneBack()
love.keyboard.setKeyRepeat(true)
STAT.todayTime=STAT.todayTime+PLAYERS[1].stat.time
if not GAME.replaying and(GAME.frame>400 or GAME.result)and not GAME.result then
if not GAME.replaying and(PLAYERS[1].frameRun>400 or GAME.result)and not GAME.result then
mergeStat(STAT,PLAYERS[1].stat)
FILE.save(STAT,"conf/data")
end
@@ -130,17 +130,17 @@ function scene.keyDown(key)
if key=="q"then
SCN.back()
elseif key=="escape"then
SCN.swapTo(GAME.result and"play"or"depause","none")
SCN.swapTo(GAME.result and"game"or"depause","none")
elseif key=="s"then
GAME.prevBG=BG.cur
SCN.go("setting_sound")
elseif key=="r"then
resetGameData()
SCN.swapTo("play","none")
SCN.swapTo("game","none")
elseif key=="p"then
if(GAME.result or GAME.replaying)and #PLAYERS==1 then
resetGameData("r")
SCN.swapTo("play","none")
SCN.swapTo("game","none")
end
elseif key=="o"then
if(GAME.result or GAME.replaying)and #PLAYERS==1 and not GAME.saved and saveRecording()then
@@ -166,7 +166,7 @@ local textPos={90,131,-90,131,-200,-25,-90,-181,90,-181,200,-25}
local dataPos={90,143,-90,143,-200,-13,-90,-169,90,-169,200,-13}
function scene.draw()
local T=timer*.02
if T<1 or GAME.result then SCN.scenes.play.draw()end
if T<1 or GAME.result then SCN.scenes.game.draw()end
--Dark BG
local _=T
@@ -194,7 +194,7 @@ function scene.draw()
gc.draw(drawableText.modeName,40,240)
--Infos
if GAME.frame>180 then
if PLAYERS[1].frameRun>180 then
gc.setLineWidth(2)
--Finesse rank & trophy
if rank then
@@ -264,7 +264,7 @@ function scene.draw()
end
--Radar Chart
if T>.5 and GAME.frame>180 then
if T>.5 and PLAYERS[1].frameRun>180 then
T=T*2-1
gc.setLineWidth(2)
gc.push("transform")