237 lines
6.1 KiB
Lua
237 lines
6.1 KiB
Lua
--[[
|
|
______ __ _
|
|
/_ __/___ _____ / /_ ____ ___ (_)____ ____
|
|
/ / / _ \ / ___// __ \ / __ `__ \ / // __ \ / __ \
|
|
/ / / __// /__ / / / // / / / / // // / / // /_/ /
|
|
/_/ \___/ \___//_/ /_//_/ /_/ /_//_//_/ /_/ \____/
|
|
Techmino is my first "huge project"
|
|
optimization is welcomed if you also love tetromino game
|
|
]]--
|
|
|
|
local fs=love.filesystem
|
|
|
|
--?
|
|
NONE={}function NULL()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
|
|
LOGIN=false
|
|
EDITING=""
|
|
|
|
--Global Setting & Vars
|
|
math.randomseed(os.time()*626)
|
|
love.keyboard.setKeyRepeat(true)
|
|
love.keyboard.setTextInput(false)
|
|
love.mouse.setVisible(false)
|
|
|
|
--Load modules
|
|
require"Zframework"
|
|
|
|
require"parts/list"
|
|
require"parts/globalTables"
|
|
require"parts/gametoolfunc"
|
|
|
|
SCR.setSize(1280,720)--Initialize Screen size
|
|
FIELD[1]=newBoard()--Initialize field[1]
|
|
|
|
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"
|
|
TICK= require"parts/tick"
|
|
|
|
SFX.set{
|
|
"welcome_sfx",
|
|
"click","enter",
|
|
"finesseError","finesseError_long",
|
|
--Stereo sfxs(cannot set position)
|
|
|
|
"virtualKey",
|
|
"button","swipe",
|
|
"ready","start","win","fail","collect",
|
|
"spawn_1","spawn_2","spawn_3","spawn_4","spawn_5","spawn_6","spawn_7",
|
|
"move","rotate","rotatekick","hold",
|
|
"prerotate","prehold",
|
|
"lock","drop","fall",
|
|
"reach",
|
|
"ren_1","ren_2","ren_3","ren_4","ren_5","ren_6","ren_7","ren_8","ren_9","ren_10","ren_11","ren_mega",
|
|
"clear_1","clear_2","clear_3","clear_4",
|
|
"spin_0","spin_1","spin_2","spin_3",
|
|
"emit","blip_1","blip_2",
|
|
"clear",
|
|
|
|
"error",
|
|
--Mono sfxs
|
|
}
|
|
BGM.set{
|
|
"blank",--menu
|
|
"race",--sprint, solo
|
|
"infinite",--infinite norm/dig, ultra, zen, tech-finesse
|
|
"push",--marathon, round, tsd, blind-5/6
|
|
"way",--dig sprint
|
|
"reason",--drought, blind-1/2/3/4
|
|
|
|
"secret8th",--master-1, survivor-2
|
|
"secret7th",--master-2, survivor-3
|
|
"waterfall",--sprint Penta/MPH
|
|
"new era",--bigbang, survivor-1, tech-normal
|
|
"oxygen",--c4w/pc train
|
|
"truth",--pc challenge
|
|
"sugar fairy",--classic2
|
|
|
|
"distortion",--master-3
|
|
"far",--GM
|
|
"shining terminal",--attacker
|
|
"storm",--defender, survivor-4/5
|
|
"down",--dig, tech-hard/lunatic
|
|
|
|
"rockblock",--classic, 49/99
|
|
"cruelty","final","8-bit happiness","end","how feeling",--49/99
|
|
}
|
|
VOC.set{
|
|
"zspin","sspin","lspin","jspin","tspin","ospin","ispin",
|
|
"single","double","triple","techrash",
|
|
"mini","b2b","b3b",
|
|
"perfect_clear","half_clear",
|
|
"win","lose","bye",
|
|
"test","happy","doubt","sad","egg",
|
|
"welcome_voc",
|
|
}
|
|
|
|
--Load shader files from SOURCE ONLY
|
|
SHADER={}
|
|
for _,v in next,love.filesystem.getDirectoryItems("parts/shaders")do
|
|
if love.filesystem.getRealDirectory("parts/shaders/"..v)~=SAVEDIR then
|
|
local name=v:sub(1,-6)
|
|
SHADER[name]=love.graphics.newShader("parts/shaders/"..name..".glsl")
|
|
else
|
|
LOG.print("Dangerous file : %SAVE%/parts/shaders/"..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.add(name,require("parts/backgrounds/"..name))
|
|
else
|
|
LOG.print("Dangerous file : %SAVE%/parts/backgrounds/"..v)
|
|
end
|
|
end
|
|
|
|
--Load scene files from SOURCE ONLY
|
|
for _,v in next,fs.getDirectoryItems("parts/scenes")do
|
|
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 files & settings
|
|
if fs.getInfo("settings.dat")then
|
|
FILE.loadSetting()
|
|
else
|
|
if MOBILE then
|
|
SETTING.VKSwitch=true
|
|
SETTING.swap=false
|
|
SETTING.vib=2
|
|
SETTING.powerInfo=true
|
|
SETTING.fullscreen=true
|
|
love.window.setFullscreen(true)
|
|
love.resize(love.graphics.getWidth(),love.graphics.getHeight())
|
|
end
|
|
end
|
|
LANG.set(SETTING.lang)
|
|
if SETTING.fullscreen then love.window.setFullscreen(true)end
|
|
|
|
if fs.getInfo("unlock.dat")then FILE.loadUnlock()end
|
|
if fs.getInfo("data.dat")then FILE.loadData()end
|
|
if fs.getInfo("key.dat")then FILE.loadKeyMap()end
|
|
if fs.getInfo("virtualkey.dat")then FILE.loadVK()end
|
|
|
|
if fs.getInfo("tech_ultimate.dat")then fs.remove("tech_ultimate.dat")end
|
|
if fs.getInfo("tech_ultimate+.dat")then fs.remove("tech_ultimate+.dat")end
|
|
|
|
--Update data
|
|
do
|
|
--Check Ranks
|
|
local R=RANKS
|
|
R.sprint_10=R.sprint_10 or 0
|
|
if R.infinite and R.infinite~=6 then
|
|
R.infinite=6
|
|
R.infinite_dig=6
|
|
fs.remove("infinite.dat")
|
|
fs.remove("infinite_dig.dat")
|
|
end
|
|
if not text.modes[STAT.lastPlay]then
|
|
STAT.lastPlay="sprint_10"
|
|
end
|
|
|
|
--Check setting file
|
|
local S=SETTING
|
|
if
|
|
type(S.block)~="boolean"or
|
|
type(S.spawn)~="number"or
|
|
type(S.ghost)~="number"or
|
|
type(S.center)~="number"or
|
|
S.bgm>1 or S.sfx>1 or S.voc>1 or
|
|
S.stereo>1 or S.VKSFX>1 or S.VKAlpha>1
|
|
then
|
|
NOGAME="delSetting"
|
|
fs.remove("settings.dat")
|
|
end
|
|
|
|
--Update data file
|
|
S=STAT
|
|
if S.extraRate then
|
|
S.finesseRate=5*(S.piece-S.extraRate)
|
|
end
|
|
if S.version~=VERSION_NAME then
|
|
S.version=VERSION_NAME
|
|
newVersionLaunch=true
|
|
|
|
if not VERSION_NAME:find("0.12")or VERSION_NAME:find("0.12.0")then
|
|
local function delRecord(n)
|
|
if R[n]then
|
|
R[n]=0
|
|
fs.remove(n..".dat")
|
|
end
|
|
end
|
|
delRecord("solo_1")delRecord("solo_2")delRecord("solo_3")delRecord("solo_4")delRecord("solo_5")
|
|
delRecord("dig_10")delRecord("dig_40")delRecord("dig_100")delRecord("dig_400")
|
|
delRecord("classic_fast")
|
|
end
|
|
|
|
--Try unlock modes which should be unlocked
|
|
for name,rank in next,RANKS do
|
|
if rank and rank>0 then
|
|
for _,mode in next,MODES do
|
|
if mode.name==name and mode.unlock then
|
|
for _,unlockName in next,mode.unlock do
|
|
if not RANKS[unlockName]then
|
|
RANKS[unlockName]=0
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
FILE.saveUnlock()
|
|
FILE.saveData()
|
|
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)
|
|
end
|
|
end |