重构背景系统(每个背景使用独立文件),全局变量名整理

This commit is contained in:
MrZ626
2020-11-04 00:08:50 +08:00
parent c688fef3f6
commit a485a71dfc
149 changed files with 1087 additions and 1046 deletions

View File

@@ -8,11 +8,15 @@
optimization is welcomed if you also love tetromino game
]]--
local fs=love.filesystem
--?
NULL=function()end
DBP=print--use this if need debugging print
SYSTEM=love.system.getOS()
MOBILE=SYSTEM=="Android"or SYSTEM=="iOS"
SAVEDIR=fs.getSaveDirectory()
MARKING=true
LOADED=false
NOGAME=false
@@ -103,10 +107,10 @@ GAME={
}--Global game data
PLAYERS={alive={}}--Players data
CURMODE=nil--Current mode object
--blockSkin,blockSkinMini={},{}--Redefined in SKIN.change
--Load modules
require("Zframework")--Load Zframework
require("parts/list")
@@ -115,30 +119,38 @@ require("parts/gametoolfunc")
FIELD[1]=newBoard()--Initialize field[1]
blocks= require("parts/mino")
AITemplate= require("parts/AITemplate")
freeRow= require("parts/freeRow")
BLOCKS= require("parts/mino")
AIBUILDER= require("parts/AITemplate")
FREEROW= require("parts/freeRow")
TEXTURE=require("parts/texture")
SKIN= require("parts/skin")
PLY= require("parts/player")
AIfunc= require("parts/ai")
Modes= require("parts/modes")
AIFUNC= require("parts/ai")
MODES= require("parts/modes")
TICK= require("parts/tick")
--Load Scenes files from SOURCE ONLY
local fs=love.filesystem
local saveDir=fs.getSaveDirectory()
--Load Scene files from SOURCE ONLY
for _,v in next,fs.getDirectoryItems("parts/scenes")do
if fs.getRealDirectory("parts/scenes/"..v)~=saveDir then
if fs.getRealDirectory("parts/scenes/"..v)~=SAVEDIR then
require("parts/scenes/"..v:sub(1,-5))
else
LOG.print("Dangerous file : %SAVE%/parts/scenes/"..v)
end
end
--Load Background files from SOURCE ONLY
for _,v in next,love.filesystem.getDirectoryItems("parts/backgrounds")do
if love.filesystem.getRealDirectory("parts/backgrounds/"..v)~=SAVEDIR then
local name=v:sub(1,-5)
BG.list[name]=require("parts/backgrounds/"..name)
else
LOG.print("Dangerous file : %SAVE%/parts/backgrounds/"..v)
end
end
--Load files & settings
modeRanks={sprint_10=0}
RANKS={sprint_10=0}
if fs.getInfo("keymap.dat")then fs.remove("keymap.dat")end
if fs.getInfo("setting.dat")then fs.remove("setting.dat")end
@@ -170,7 +182,7 @@ if fs.getInfo("tech_ultimate+.dat")then fs.remove("tech_ultimate+.dat")end
--Update data
do
local R=modeRanks
local R=RANKS
R.sprint_10=R.sprint_10 or 0
for k,_ in next,R do
if type(k)=="number"then
@@ -213,13 +225,13 @@ do
if S.version~=gameVersion then
S.version=gameVersion
newVersionLaunch=true
for name,rank in next,modeRanks do
for name,rank in next,RANKS do
if rank and rank>0 then
for i=1,#Modes do
if Modes[i].name==name and Modes[i].unlock then
for _,unlockName in next,Modes[i].unlock do
if not modeRanks[unlockName]then
modeRanks[unlockName]=0
for i=1,#MODES do
if MODES[i].name==name and MODES[i].unlock then
for _,unlockName in next,MODES[i].unlock do
if not RANKS[unlockName]then
RANKS[unlockName]=0
end
end
end
@@ -230,7 +242,7 @@ do
FILE.saveSetting()
end
if MOBILE and not SETTING.fullscreen then
LOG.print("如果手机上方状态栏不消失,请到设置界面开启全屏",300,color.yellow)
LOG.print("Switch fullscreen on if titleBar don't disappear",300,color.yellow)
LOG.print("如果手机上方状态栏不消失,请到设置界面开启全屏",300,COLOR.yellow)
LOG.print("Switch fullscreen on if titleBar don't disappear",300,COLOR.yellow)
end
end