整理代码,两个远古时期的游戏相关全局变量移入GAME

This commit is contained in:
MrZ626
2020-11-20 01:03:27 +08:00
parent 0456bf515e
commit 9442da2b44
5 changed files with 17 additions and 14 deletions

View File

@@ -14,7 +14,7 @@ local ins,rem=table.insert,table.remove
-- 11~13:LL,RR,DD
local blockPos={4,4,4,4,4,5,4}
-------------------------------------------------Cold clear
local _CC=LOADLIB("CC")
local _CC=LOADLIB("CC")cc=nil
if _CC then
local CCblockID={6,5,4,3,2,1,0}
CC={

View File

@@ -409,7 +409,7 @@ end
function pauseGame()
if not SCN.swapping then
restartCount=0--Avoid strange darkness
GAME.restartCount=0--Avoid strange darkness
if not GAME.result then
GAME.pauseCount=GAME.pauseCount+1
end
@@ -435,7 +435,7 @@ function loadGame(M,ifQuickPlay)
GAME.modeEnv=GAME.curMode.env
drawableText.modeName:set(text.modes[M][1])
drawableText.levelName:set(text.modes[M][2])
needResetGameData=true
GAME.init=true
SCN.swapTo("play",ifQuickPlay and"swipeD"or"fade_togame")
SFX.play("enter")
end

View File

@@ -168,6 +168,9 @@ BAG={}--Sequence for custom game
MISSION={}--Clearing mission for custom game
GAME={--Global game data
init=false, --If need initializing game when enter scene-play
restartCount=0, --Keep +=1 if player hold restart button after game start
frame=0, --Frame count
result=false, --Game result (string)
pauseTime=0, --Time paused

View File

@@ -91,7 +91,7 @@ function Tmr.load()
gc.setLineWidth(3)
for i=1,17 do
puzzleMark[i]=C(30,30)
_=SKIN.libColor[i]
local _=SKIN.libColor[i]
gc.setColor(_[1],_[2],_[3],.6)
gc.rectangle("line",5,5,20,20)
gc.rectangle("line",10,10,10,10)

View File

@@ -26,10 +26,10 @@ end
function sceneInit.play()
love.keyboard.setKeyRepeat(false)
restartCount=0
if needResetGameData then
GAME.restartCount=0
if GAME.init then
resetGameData()
needResetGameData=nil
GAME.init=nil
end
end
@@ -197,16 +197,16 @@ function Tmr.play(dt)
P.moving=0
end
end
if restartCount>0 then restartCount=restartCount-1 end
if GAME.restartCount>0 then GAME.restartCount=GAME.restartCount-1 end
return
elseif P1.keyPressing[10]then
restartCount=restartCount+1
if restartCount>20 then
GAME.restartCount=GAME.restartCount+1
if GAME.restartCount>20 then
resetGameData()
return
end
elseif restartCount>0 then
restartCount=restartCount>2 and restartCount-2 or 0
elseif GAME.restartCount>0 then
GAME.restartCount=GAME.restartCount>2 and GAME.restartCount-2 or 0
end
--Update players
@@ -347,8 +347,8 @@ function Pnt.play()
gc.rectangle("fill",0,0,SCR.w,SCR.h)
gc.setShader()
end
if restartCount>0 then
gc.setColor(0,0,0,restartCount*.05)
if GAME.restartCount>0 then
gc.setColor(0,0,0,GAME.restartCount*.05)
gc.rectangle("fill",0,0,SCR.w,SCR.h)
end
gc.pop()