重构背景系统(每个背景使用独立文件),全局变量名整理
This commit is contained in:
@@ -1,512 +1,11 @@
|
||||
local gc=love.graphics
|
||||
local int,ceil,rnd=math.floor,math.ceil,math.random
|
||||
local max,min,sin=math.max,math.min,math.sin
|
||||
local ins,rem=table.insert,table.remove
|
||||
|
||||
local function NULL(...)end
|
||||
local SCR=SCR
|
||||
local BGvars={_G=_G,SHADER=SHADER}
|
||||
local BG
|
||||
local back={}
|
||||
back.none={
|
||||
draw=function()
|
||||
gc.clear(.15,.15,.15)
|
||||
end,
|
||||
}
|
||||
back.grey={
|
||||
draw=function()
|
||||
gc.clear(.3,.3,.3)
|
||||
end,
|
||||
}
|
||||
back.glow={
|
||||
init=function()
|
||||
t=rnd()*2600
|
||||
end,
|
||||
update=function(dt)
|
||||
t=t+dt
|
||||
end,
|
||||
draw=function()
|
||||
local t=(sin(t*.5)+sin(t*.7)+sin(t*.9+1)+sin(t*1.5)+sin(t*2+10))*.08
|
||||
gc.clear(t,t,t)
|
||||
end,
|
||||
}--Light-dark
|
||||
back.rgb={
|
||||
init=function()
|
||||
t=rnd()*2600
|
||||
end,
|
||||
update=function(dt)
|
||||
t=t+dt
|
||||
end,
|
||||
draw=function()
|
||||
gc.clear(
|
||||
sin(t*1.2)*.15+.2,
|
||||
sin(t*1.5)*.15+.2,
|
||||
sin(t*1.9)*.15+.2
|
||||
)
|
||||
end,
|
||||
}--Changing pure color
|
||||
back.flink={
|
||||
init=function()
|
||||
t=rnd()*2600
|
||||
end,
|
||||
update=function(dt)
|
||||
t=t+dt
|
||||
end,
|
||||
draw=function()
|
||||
local t=.13-t%3%1.9
|
||||
if t<.2 then gc.clear(t,t,t)
|
||||
else gc.clear(0,0,0)
|
||||
end
|
||||
end,
|
||||
}--Flash after random time
|
||||
|
||||
local wingColor={
|
||||
{0., .9, .9,.626},
|
||||
{.3, 1., .3,.626},
|
||||
{.9, .9, 0.,.626},
|
||||
{1., .5, 0.,.626},
|
||||
{1., .3, .3,.626},
|
||||
{.5, 0., 1.,.626},
|
||||
{.3, .3, 1.,.626},
|
||||
{0., .9, .9,.626},
|
||||
}
|
||||
back.wing={
|
||||
init=function()
|
||||
bar=gc.newCanvas(41,1)
|
||||
gc.setCanvas(bar)
|
||||
gc.push("transform")
|
||||
gc.origin()
|
||||
for x=0,20 do
|
||||
gc.setColor(1,1,1,x/11)
|
||||
gc.rectangle("fill",x,0,1,1)
|
||||
gc.rectangle("fill",41-x,0,1,1)
|
||||
end
|
||||
gc.pop()
|
||||
gc.setCanvas()
|
||||
BG.resize()
|
||||
end,
|
||||
resize=function()
|
||||
crystal={}
|
||||
W,H=SCR.w,SCR.h
|
||||
for i=1,16 do
|
||||
crystal[i]={
|
||||
x=i<9 and W*.05*i or W*.05*(28-i),
|
||||
y=H*.1,
|
||||
a=0,
|
||||
va=0,
|
||||
f=i<9 and .012-i*.0005 or .012-(17-i)*.0005
|
||||
}
|
||||
end
|
||||
end,
|
||||
update=function()
|
||||
for i=1,16 do
|
||||
local B=crystal[i]
|
||||
B.a=B.a+B.va
|
||||
B.va=B.va*.986-B.a*B.f
|
||||
end
|
||||
end,
|
||||
draw=function()
|
||||
gc.clear(.06,.06,.06)
|
||||
local sy=H*.8
|
||||
for i=1,8 do
|
||||
gc.setColor(wingColor[i])
|
||||
local B=crystal[i]
|
||||
gc.draw(bar,B.x,B.y,B.a,1,sy,20,0)
|
||||
B=crystal[17-i]
|
||||
gc.draw(bar,B.x,B.y,B.a,1,sy,20,0)
|
||||
end
|
||||
end,
|
||||
event=function(level)
|
||||
for i=1,8 do
|
||||
local B=crystal[i]
|
||||
B.va=B.va+.001*level*(1+rnd())
|
||||
B=crystal[17-i]
|
||||
B.va=B.va-.001*level*(1+rnd())
|
||||
end
|
||||
end,
|
||||
discard=function()
|
||||
bar,crystal=nil
|
||||
end,
|
||||
}--Flandre's wing
|
||||
|
||||
back.fan={
|
||||
init=function()
|
||||
fan=_G.title_fan
|
||||
t=rnd(2600)
|
||||
petal={}
|
||||
BG.resize()
|
||||
end,
|
||||
resize=function()
|
||||
CX,CY=SCR.w/2,SCR.h/2
|
||||
W,H=SCR.w,SCR.h
|
||||
end,
|
||||
update=function()
|
||||
t=t+1
|
||||
if t%10==0 then
|
||||
ins(petal,{
|
||||
x=SCR.w*rnd(),
|
||||
y=0,
|
||||
vy=2+rnd()*2,
|
||||
vx=rnd()*2-.5,
|
||||
rx=4+rnd()*4,
|
||||
ry=4+rnd()*4,
|
||||
})
|
||||
end
|
||||
for i=#petal,1,-1 do
|
||||
local P=petal[i]
|
||||
P.y=P.y+P.vy
|
||||
if P.y>H then
|
||||
rem(petal,i)
|
||||
else
|
||||
P.x=P.x+P.vx
|
||||
P.vx=P.vx+rnd()*.01
|
||||
P.rx=max(min(P.rx+rnd()-.5,10),2)
|
||||
P.ry=max(min(P.ry+rnd()-.5,10),2)
|
||||
end
|
||||
end
|
||||
end,
|
||||
draw=function()
|
||||
gc.push("transform")
|
||||
gc.translate(CX,CY+20*sin(t*.02))
|
||||
gc.scale(SCR.k)
|
||||
gc.clear(.1,.1,.1)
|
||||
gc.setLineWidth(320)
|
||||
gc.setColor(.3,.2,.3)
|
||||
gc.arc("line","open",0,420,500,-.8*3.1416,-.2*3.1416)
|
||||
|
||||
gc.setLineWidth(4)
|
||||
gc.setColor(.7,.5,.65)
|
||||
gc.arc("line","open",0,420,660,-.799*3.1416,-.201*3.1416)
|
||||
gc.arc("line","open",0,420,340,-.808*3.1416,-.192*3.1416)
|
||||
gc.line(-281,224,-530,30.5)
|
||||
gc.line(281,224,530,30.5)
|
||||
|
||||
gc.setLineWidth(6)
|
||||
gc.setColor(.55,.5,.6)
|
||||
local F=fan
|
||||
for i=1,8 do
|
||||
gc.polygon("line",F[i])
|
||||
end
|
||||
|
||||
gc.setLineWidth(2)
|
||||
gc.setColor(.6,.3,.5)
|
||||
gc.origin()
|
||||
for i=1,#petal do
|
||||
local P=petal[i]
|
||||
gc.ellipse("fill",P.x,P.y,P.rx,P.ry)
|
||||
end
|
||||
gc.pop()
|
||||
end,
|
||||
discard=function()
|
||||
petal=nil
|
||||
end,
|
||||
}
|
||||
|
||||
local video--128x96, 10fps, 2192f
|
||||
back.badapple={
|
||||
init=function()
|
||||
if not video then
|
||||
video=_G.love.data.decompress("string","zlib",_G.love.filesystem.read("Zframework/badapple.dat"))
|
||||
end
|
||||
t=0
|
||||
BG.resize()
|
||||
end,
|
||||
resize=function()
|
||||
local W,H=SCR.w,SCR.h
|
||||
if H/W>=96/128 then
|
||||
K=W/128
|
||||
X,Y=0,(H-W*96/128)*.5
|
||||
else
|
||||
K=H/96
|
||||
X,Y=(W-H*128/96)*.5,0
|
||||
end
|
||||
end,
|
||||
update=function()
|
||||
t=t+1
|
||||
if t==13146 then
|
||||
t=0
|
||||
end
|
||||
end,
|
||||
draw=function()
|
||||
gc.clear(.2,.2,.2)
|
||||
gc.push("transform")
|
||||
gc.origin()
|
||||
gc.translate(X,Y)
|
||||
gc.scale(K)
|
||||
gc.setColor(.4,.4,.4)
|
||||
local t=int(t/6)
|
||||
local bAnd,bRshift=_G.bit.band,_G.bit.rshift
|
||||
for i=0,1535 do
|
||||
local B=video:byte(1536*t+i+1)
|
||||
for j=7,0,-1 do
|
||||
local p=8*i+j
|
||||
if bAnd(B,1)==0 then
|
||||
gc.rectangle("fill",p%128,int(p/128),1,1)
|
||||
end
|
||||
B=bRshift(B,1)
|
||||
end
|
||||
end
|
||||
gc.pop()
|
||||
end,
|
||||
discard=function()
|
||||
video=nil
|
||||
end
|
||||
}
|
||||
|
||||
back.welcome={
|
||||
init=function()
|
||||
t=rnd()*2600
|
||||
txt=gc.newText(_G.getFont(80),"Welcome To Techmino")
|
||||
end,
|
||||
update=function(dt)
|
||||
t=t+dt
|
||||
end,
|
||||
draw=function()
|
||||
if -t%13.55<.1 then
|
||||
gc.clear(.2+.1*sin(t),.2+.1*sin(1.26*t),.2+.1*sin(1.626*t))
|
||||
else
|
||||
gc.clear(.1,.1,.1)
|
||||
end
|
||||
gc.push("transform")
|
||||
gc.replaceTransform(_G.xOy)
|
||||
gc.translate(640,360)
|
||||
if -t%18.26<1 then
|
||||
gc.scale(6.26)
|
||||
gc.translate(-t*400%800-400,0)
|
||||
else
|
||||
gc.scale(1.1626,1.26)
|
||||
end
|
||||
if -t%12.6<.1 then
|
||||
gc.translate(60*sin(t*.26),100*sin(t*.626))
|
||||
end
|
||||
if -t%16.26<.1 then
|
||||
gc.rotate(t+5*sin(.26*t)+5*sin(.626*t))
|
||||
end
|
||||
gc.setColor(.2,.3,.5)
|
||||
gc.draw(txt,-883*.5+4*sin(t*.7942),-110*.5+4*sin(t*.7355))
|
||||
gc.setColor(.4,.6,.8)
|
||||
gc.draw(txt,-883*.5+2*sin(t*.77023),-110*.5+2*sin(t*.7026))
|
||||
gc.setColor(.9,.9,.9)
|
||||
gc.draw(txt,-883*.5+3*sin(t*.7283),-110*.5+3*sin(t*.7626))
|
||||
gc.pop()
|
||||
end,
|
||||
}
|
||||
|
||||
back.aura={
|
||||
init=function()
|
||||
t=rnd()*2600
|
||||
BG.resize(SCR.w,SCR.h)
|
||||
end,
|
||||
resize=function(_,h)
|
||||
SHADER.aura:send("w",SCR.W)
|
||||
SHADER.aura:send("h",h*SCR.dpi)
|
||||
end,
|
||||
update=function(dt)
|
||||
t=t+dt
|
||||
end,
|
||||
draw=function()
|
||||
SHADER.aura:send("t",t)
|
||||
gc.setShader(SHADER.aura)
|
||||
gc.rectangle("fill",0,0,SCR.w,SCR.h)
|
||||
gc.setShader()
|
||||
end,
|
||||
}--Cool liquid background
|
||||
back.bg1={
|
||||
init=function()
|
||||
t=rnd()*2600
|
||||
BG.resize()
|
||||
end,
|
||||
resize=function()
|
||||
SHADER.gradient1:send("w",SCR.W)
|
||||
end,
|
||||
update=function(dt)
|
||||
t=t+dt
|
||||
end,
|
||||
draw=function()
|
||||
SHADER.gradient1:send("t",t)
|
||||
gc.setShader(SHADER.gradient1)
|
||||
gc.rectangle("fill",0,0,SCR.w,SCR.h)
|
||||
gc.setShader()
|
||||
end,
|
||||
}--Horizonal red-blue gradient
|
||||
back.bg2={
|
||||
init=function()
|
||||
t=rnd()*2600
|
||||
BG.resize(nil,SCR.h)
|
||||
end,
|
||||
resize=function(_,h)
|
||||
SHADER.gradient2:send("h",h*SCR.dpi)
|
||||
end,
|
||||
update=function(dt)
|
||||
t=t+dt
|
||||
end,
|
||||
draw=function()
|
||||
SHADER.gradient2:send("t",t)
|
||||
gc.setShader(SHADER.gradient2)
|
||||
gc.rectangle("fill",0,0,SCR.w,SCR.h)
|
||||
gc.setShader()
|
||||
end,
|
||||
}--Vertical red-green gradient
|
||||
back.rainbow={
|
||||
init=function()
|
||||
t=rnd()*2600
|
||||
BG.resize(SCR.w,SCR.h)
|
||||
end,
|
||||
resize=function(_,h)
|
||||
SHADER.rgb1:send("w",SCR.W)
|
||||
SHADER.rgb1:send("h",h*SCR.dpi)
|
||||
end,
|
||||
update=function(dt)
|
||||
t=t+dt
|
||||
end,
|
||||
draw=function()
|
||||
SHADER.rgb1:send("t",t)
|
||||
gc.setShader(SHADER.rgb1)
|
||||
gc.rectangle("fill",0,0,SCR.w,SCR.h)
|
||||
gc.setShader()
|
||||
end,
|
||||
}--Colorful RGB
|
||||
back.rainbow2={
|
||||
init=function()
|
||||
t=rnd()*2600
|
||||
BG.resize(SCR.w,SCR.h)
|
||||
end,
|
||||
resize=function(_,h)
|
||||
SHADER.rgb2:send("w",SCR.W)
|
||||
SHADER.rgb2:send("h",h*SCR.dpi)
|
||||
end,
|
||||
update=function(dt)
|
||||
t=t+dt
|
||||
end,
|
||||
draw=function()
|
||||
SHADER.rgb2:send("t",t)
|
||||
gc.setShader(SHADER.rgb2)
|
||||
gc.rectangle("fill",0,0,SCR.w,SCR.h)
|
||||
gc.setShader()
|
||||
end,
|
||||
}--Blue RGB
|
||||
back.lightning={
|
||||
init=function()
|
||||
t=rnd()*2600
|
||||
end,
|
||||
update=function(dt)
|
||||
t=t+dt
|
||||
end,
|
||||
draw=function()
|
||||
local t=2.5-t%20%6%2.5
|
||||
if t<.3 then gc.clear(t,t,t)
|
||||
else gc.clear(0,0,0)
|
||||
end
|
||||
end,
|
||||
}--Lightning
|
||||
|
||||
local blocks=require("parts/mino")
|
||||
back.lightning2={
|
||||
init=function()
|
||||
t=rnd()*2600
|
||||
colorLib=_G.SKIN.libColor
|
||||
colorSet=_G.SETTING.skin
|
||||
blockImg=_G.TEXTURE.miniBlock
|
||||
scs=_G.spinCenters
|
||||
end,
|
||||
update=function(dt)
|
||||
t=t+dt
|
||||
end,
|
||||
draw=function()
|
||||
local R=7-int(t*.5%7)
|
||||
local T=1.2-t%10%3%1.2
|
||||
if T<.3 then gc.clear(T,T,T)
|
||||
else gc.clear(0,0,0)
|
||||
end
|
||||
local _=colorLib[colorSet[R]]
|
||||
gc.setColor(_[1],_[2],_[3],.12)
|
||||
gc.draw(blockImg[R],640,360,t%3.1416*6,400,400,scs[R][0][2]+.5,#blocks[R][0]-scs[R][0][1]-.5)
|
||||
end,
|
||||
}--Fast lightning + spining tetromino
|
||||
|
||||
local matrixT={}for i=1,50 do matrixT[i]={}for j=1,50 do matrixT[i][j]=love.math.noise(i,j)+2 end end
|
||||
back.matrix={
|
||||
init=function()
|
||||
t=rnd()*2600
|
||||
end,
|
||||
update=function(dt)
|
||||
t=t+dt
|
||||
end,
|
||||
draw=function()
|
||||
gc.clear(.15,.15,.15)
|
||||
gc.push("transform")
|
||||
local k=SCR.k
|
||||
gc.scale(k)
|
||||
local Y=ceil(SCR.h/80/k)
|
||||
for x=1,ceil(SCR.w/80/k)do
|
||||
for y=1,Y do
|
||||
gc.setColor(1,1,1,sin(x+matrixT[x][y]*t)*.1+.1)
|
||||
gc.rectangle("fill",80*x,80*y,-80,-80)
|
||||
end
|
||||
end
|
||||
gc.pop()
|
||||
end,
|
||||
}
|
||||
|
||||
back.space={
|
||||
init=function()
|
||||
stars={}
|
||||
W,H=SCR.w+20,SCR.h+20
|
||||
BG.resize(SCR.w,SCR.h)
|
||||
end,
|
||||
resize=function()
|
||||
local S=stars
|
||||
for i=1,1260,5 do
|
||||
local s=rnd(26,40)*.1
|
||||
S[i]=s*SCR.k --Size
|
||||
S[i+1]=rnd(W)-10 --X
|
||||
S[i+2]=rnd(H)-10 --Y
|
||||
S[i+3]=(rnd()-.5)*.01*s --Vx
|
||||
S[i+4]=(rnd()-.5)*.01*s --Vy
|
||||
end
|
||||
end,
|
||||
update=function()
|
||||
local S=stars
|
||||
--Star moving
|
||||
for i=1,1260,5 do
|
||||
S[i+1]=(S[i+1]+S[i+3])%W
|
||||
S[i+2]=(S[i+2]+S[i+4])%H
|
||||
end
|
||||
end,
|
||||
draw=function()
|
||||
gc.clear(.2,.2,.2)
|
||||
if not stars[1]then return end
|
||||
gc.translate(-10,-10)
|
||||
gc.setColor(.8,.8,.8)
|
||||
for i=1,1260,5 do
|
||||
local s=stars
|
||||
local x,y=s[i+1],s[i+2]
|
||||
s=s[i]
|
||||
gc.rectangle("fill",x,y,s,s)
|
||||
end
|
||||
gc.translate(10,10)
|
||||
end,
|
||||
discard=function()
|
||||
stars=nil
|
||||
end,
|
||||
}
|
||||
|
||||
--Make BG vars invisible
|
||||
for _,bg in next,back do
|
||||
if bg.init then setfenv(bg.init, BGvars)else bg.init=NULL end
|
||||
if bg.resize then setfenv(bg.resize, BGvars)else bg.resize=NULL end
|
||||
if bg.update then setfenv(bg.update, BGvars)else bg.update=NULL end
|
||||
if bg.draw then setfenv(bg.draw, BGvars)else bg.draw=NULL end
|
||||
if bg.event then setfenv(bg.event, BGvars)else bg.event=NULL end
|
||||
if bg.discard then setfenv(bg.discard, BGvars)else bg.discard=NULL end
|
||||
end
|
||||
|
||||
BG={
|
||||
cur="none",
|
||||
local BG={
|
||||
list={},
|
||||
cur="",
|
||||
init=NULL,
|
||||
resize=NULL,
|
||||
update=NULL,
|
||||
draw=back.none.draw,
|
||||
draw=NULL,
|
||||
event=NULL,
|
||||
discard=NULL,
|
||||
}
|
||||
@@ -515,22 +14,22 @@ function BG.send(data)
|
||||
BG.event(data)
|
||||
end
|
||||
end
|
||||
function BG.set(bg)
|
||||
if bg==BG.cur or not SETTING.bg then return end
|
||||
function BG.set(background)
|
||||
if background==BG.cur or not SETTING.bg then return end
|
||||
BG.discard()
|
||||
if not back[bg]then
|
||||
LOG.print("No BG called"..bg,"warn")
|
||||
background=BG.list[background]
|
||||
if not background then
|
||||
LOG.print("No BG called"..background,"warn")
|
||||
return
|
||||
end
|
||||
BG.cur=bg
|
||||
bg=back[bg]
|
||||
BG.cur=background
|
||||
|
||||
BG.init= bg.init
|
||||
BG.resize= bg.resize
|
||||
BG.update= bg.update
|
||||
BG.draw= bg.draw
|
||||
BG.event= bg.event
|
||||
BG.discard= bg.discard
|
||||
BG.init= background.init or NULL
|
||||
BG.resize= background.resize or NULL
|
||||
BG.update= background.update or NULL
|
||||
BG.draw= background.draw or NULL
|
||||
BG.event= background.event or NULL
|
||||
BG.discard= background.discard or NULL
|
||||
BG.init()
|
||||
end
|
||||
return BG
|
||||
@@ -55,7 +55,7 @@ function BGM.loadOne(N)
|
||||
BGM.list[N]:setLooping(true)
|
||||
BGM.list[N]:setVolume(0)
|
||||
else
|
||||
LOG.print("No BGM file: "..N,5,color.orange)
|
||||
LOG.print("No BGM file: "..N,5,COLOR.orange)
|
||||
end
|
||||
end
|
||||
function BGM.loadAll()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local rnd=math.random
|
||||
local sin=math.sin
|
||||
local color={
|
||||
local COLOR={
|
||||
red={1,0,0},
|
||||
green={0,1,0},
|
||||
blue={.2,.2,1},
|
||||
@@ -41,27 +41,27 @@ local color={
|
||||
}
|
||||
local list_norm={"red","green","blue","yellow","magenta","cyan","purple","orange","pink","grass"}
|
||||
local len_list_norm=#list_norm
|
||||
function color.random_norm()
|
||||
return color[list_norm[rnd(len_list_norm)]]
|
||||
function COLOR.random_norm()
|
||||
return COLOR[list_norm[rnd(len_list_norm)]]
|
||||
end
|
||||
|
||||
local list_bright={"lRed","lGreen","lBlue","lYellow","lMagenta","lCyan","lPurple","lOrange"}
|
||||
local len_list_bright=#list_bright
|
||||
function color.random_bright()
|
||||
return color[list_bright[rnd(len_list_bright)]]
|
||||
function COLOR.random_bright()
|
||||
return COLOR[list_bright[rnd(len_list_bright)]]
|
||||
end
|
||||
|
||||
local list_dark={"dRed","dGreen","dBlue","dYellow","dMagenta","dCyan","dPurple","dOrange"}
|
||||
local len_list_dark=#list_dark
|
||||
function color.random_bright()
|
||||
return color[list_dark[rnd(len_list_dark)]]
|
||||
function COLOR.random_bright()
|
||||
return COLOR[list_dark[rnd(len_list_dark)]]
|
||||
end
|
||||
|
||||
function color.rainbow(phase)
|
||||
function COLOR.rainbow(phase)
|
||||
return
|
||||
sin(phase)*.4+.6,
|
||||
sin(phase+2.0944)*.4+.6,
|
||||
sin(phase-2.0944)*.4+.6
|
||||
end
|
||||
|
||||
return color
|
||||
return COLOR
|
||||
@@ -28,7 +28,7 @@ function FILE.saveRecord(N,L)
|
||||
local _,mes=F:write(dumpTable(L))
|
||||
F:flush()F:close()
|
||||
if not _ then
|
||||
LOG.print(text.recSavingError..(mes or"unknown error"),color.red)
|
||||
LOG.print(text.recSavingError..(mes or"unknown error"),COLOR.red)
|
||||
end
|
||||
end
|
||||
function FILE.delRecord(N)
|
||||
@@ -36,7 +36,7 @@ function FILE.delRecord(N)
|
||||
end
|
||||
|
||||
function FILE.exportUnlock()
|
||||
sys.setClipboardText(dumpTable(modeRanks))
|
||||
sys.setClipboardText(dumpTable(RANKS))
|
||||
end
|
||||
function FILE.loadUnlock()
|
||||
local F=files.unlock
|
||||
@@ -47,17 +47,17 @@ function FILE.loadUnlock()
|
||||
F:close()
|
||||
if s then
|
||||
setfenv(s,{})
|
||||
modeRanks=s()
|
||||
RANKS=s()
|
||||
end
|
||||
end
|
||||
end
|
||||
function FILE.saveUnlock()
|
||||
local F=files.unlock
|
||||
F:open("w")
|
||||
local _,mes=F:write(dumpTable(modeRanks))
|
||||
local _,mes=F:write(dumpTable(RANKS))
|
||||
F:flush()F:close()
|
||||
if not _ then
|
||||
LOG.print(text.unlockSavingError..(mes or"unknown error"),color.red)
|
||||
LOG.print(text.unlockSavingError..(mes or"unknown error"),COLOR.red)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -86,7 +86,7 @@ function FILE.saveData()
|
||||
local _,mes=F:write(dumpTable(STAT))
|
||||
F:flush()F:close()
|
||||
if not _ then
|
||||
LOG.print(text.statSavingError..(mes or"unknown error"),color.red)
|
||||
LOG.print(text.statSavingError..(mes or"unknown error"),COLOR.red)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -113,8 +113,8 @@ function FILE.saveSetting()
|
||||
F:open("w")
|
||||
local _,mes=F:write(dumpTable(SETTING))
|
||||
F:flush()F:close()
|
||||
if _ then LOG.print(text.settingSaved,color.green)
|
||||
else LOG.print(text.settingSavingError..(mes or"unknown error"),color.red)
|
||||
if _ then LOG.print(text.settingSaved,COLOR.green)
|
||||
else LOG.print(text.settingSavingError..(mes or"unknown error"),COLOR.red)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -134,8 +134,8 @@ function FILE.saveKeyMap()
|
||||
F:open("w")
|
||||
local _,mes=F:write(dumpTable(keyMap))
|
||||
F:flush()F:close()
|
||||
if _ then LOG.print(text.keyMapSaved,color.green)
|
||||
else LOG.print(text.keyMapSavingError..(mes or"unknown error"),color.red)
|
||||
if _ then LOG.print(text.keyMapSaved,COLOR.green)
|
||||
else LOG.print(text.keyMapSavingError..(mes or"unknown error"),COLOR.red)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -158,8 +158,8 @@ function FILE.saveVK()
|
||||
F:open("w")
|
||||
local _,mes=F:write(dumpTable(VK_org))
|
||||
F:flush()F:close()
|
||||
if _ then LOG.print(text.VKSaved,color.green)
|
||||
else LOG.print(text.VKSavingError..(mes or"unknown error"),color.red)
|
||||
if _ then LOG.print(text.VKSaved,COLOR.green)
|
||||
else LOG.print(text.VKSavingError..(mes or"unknown error"),COLOR.red)
|
||||
end
|
||||
end
|
||||
return FILE
|
||||
@@ -1,21 +1,25 @@
|
||||
color= require("Zframework/color")
|
||||
COLOR= require("Zframework/color")
|
||||
SCN= require("Zframework/scene")
|
||||
LOG= require("Zframework/log")
|
||||
require("Zframework/toolfunc")
|
||||
SHADER= require("Zframework/shader")
|
||||
|
||||
VIB= require("Zframework/vib")
|
||||
SFX= require("Zframework/sfx")
|
||||
sysFX= require("Zframework/sysFX")
|
||||
|
||||
LIGHT= require("Zframework/light")
|
||||
SHADER= require("Zframework/shader")
|
||||
BG= require("Zframework/bg")
|
||||
WIDGET= require("Zframework/widget")
|
||||
TEXT= require("Zframework/text")
|
||||
sysFX= require("Zframework/sysFX")
|
||||
|
||||
IMG= require("Zframework/img")
|
||||
BGM= require("Zframework/bgm")
|
||||
VOC= require("Zframework/voice")
|
||||
|
||||
LANG= require("Zframework/languages")
|
||||
FILE= require("Zframework/file")
|
||||
TEXT= require("Zframework/text")
|
||||
TASK= require("Zframework/task")
|
||||
IMG= require("Zframework/img")
|
||||
WIDGET= require("Zframework/widget")
|
||||
LIGHT= require("Zframework/light")
|
||||
FILE= require("Zframework/file")
|
||||
PROFILE=require("Zframework/profile")
|
||||
|
||||
local ms,kb=love.mouse,love.keyboard
|
||||
@@ -24,6 +28,7 @@ local int,rnd,abs=math.floor,math.random,math.abs
|
||||
local min=math.min
|
||||
local ins,rem=table.insert,table.remove
|
||||
local SCR=SCR
|
||||
local setFont=setFont
|
||||
|
||||
local mx,my,mouseShow=-20,-20,false
|
||||
local touching=nil--First touching ID(userdata)
|
||||
@@ -212,11 +217,11 @@ function love.keypressed(i)
|
||||
elseif i=="f5"then if love._openConsole then love._openConsole()end
|
||||
elseif i=="f6"then if WIDGET.sel then DBP(WIDGET.sel)end
|
||||
elseif i=="f7"then for k,v in next,_G do DBP(k,v)end
|
||||
elseif i=="f8"then devMode=nil LOG.print("DEBUG OFF",color.yellow)
|
||||
elseif i=="f9"then devMode=1 LOG.print("DEBUG 1",color.yellow)
|
||||
elseif i=="f10"then devMode=2 LOG.print("DEBUG 2",color.yellow)
|
||||
elseif i=="f11"then devMode=3 LOG.print("DEBUG 3",color.yellow)
|
||||
elseif i=="f12"then devMode=4 LOG.print("DEBUG 4",color.yellow)
|
||||
elseif i=="f8"then devMode=nil LOG.print("DEBUG OFF",COLOR.yellow)
|
||||
elseif i=="f9"then devMode=1 LOG.print("DEBUG 1",COLOR.yellow)
|
||||
elseif i=="f10"then devMode=2 LOG.print("DEBUG 2",COLOR.yellow)
|
||||
elseif i=="f11"then devMode=3 LOG.print("DEBUG 3",COLOR.yellow)
|
||||
elseif i=="f12"then devMode=4 LOG.print("DEBUG 4",COLOR.yellow)
|
||||
elseif devMode==2 then
|
||||
if WIDGET.sel then
|
||||
local W=WIDGET.sel
|
||||
@@ -250,7 +255,7 @@ function love.keypressed(i)
|
||||
end
|
||||
else
|
||||
devMode=1
|
||||
LOG.print("DEBUG ON",color.yellow)
|
||||
LOG.print("DEBUG ON",COLOR.yellow)
|
||||
end
|
||||
end
|
||||
function love.keyreleased(i)
|
||||
@@ -279,7 +284,7 @@ function love.joystickremoved(JS)
|
||||
for i=1,#joysticks do
|
||||
if joysticks[i]==JS then
|
||||
rem(joysticks,i)
|
||||
LOG.print("Joystick removed",color.yellow)
|
||||
LOG.print("Joystick removed",COLOR.yellow)
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -360,9 +365,9 @@ function love.focus(f)
|
||||
end
|
||||
end
|
||||
function love.errorhandler(msg)
|
||||
local PUMP,POLL=love.event.pump,love.event.poll
|
||||
love.mouse.setVisible(true)
|
||||
ms.setVisible(true)
|
||||
love.audio.stop()
|
||||
|
||||
local err={"Error:"..msg}
|
||||
local trace=debug.traceback("",2)
|
||||
local c=2
|
||||
@@ -379,9 +384,9 @@ function love.errorhandler(msg)
|
||||
end
|
||||
DBP(table.concat(err,"\n"),1,c-2)
|
||||
gc.reset()
|
||||
local CAP
|
||||
local function _(_)CAP=gc.newImage(_)end
|
||||
gc.captureScreenshot(_)
|
||||
|
||||
local errScrShot
|
||||
gc.captureScreenshot(function (_)errScrShot=gc.newImage(_)end)
|
||||
gc.present()
|
||||
|
||||
SFX.fplay("error",SETTING.voc*.8)
|
||||
@@ -390,8 +395,8 @@ function love.errorhandler(msg)
|
||||
local needDraw=true
|
||||
local count=0
|
||||
return function()
|
||||
PUMP()
|
||||
for E,a,b in POLL()do
|
||||
love.event.pump()
|
||||
for E,a,b in love.event.poll()do
|
||||
if E=="quit"or a=="escape"then
|
||||
destroyPlayers()
|
||||
return 1
|
||||
@@ -422,7 +427,7 @@ function love.errorhandler(msg)
|
||||
gc.setColor(1,1,1)
|
||||
gc.push("transform")
|
||||
gc.replaceTransform(xOy)
|
||||
gc.draw(CAP,100,365,nil,512/CAP:getWidth(),288/CAP:getHeight())
|
||||
gc.draw(errScrShot,100,365,nil,512/errScrShot:getWidth(),288/errScrShot:getHeight())
|
||||
setFont(120)gc.print(":(",100,40)
|
||||
setFont(38)gc.printf(text.errorMsg,100,200,1280-100)
|
||||
setFont(20)
|
||||
@@ -437,14 +442,14 @@ function love.errorhandler(msg)
|
||||
gc.present()
|
||||
needDraw=false
|
||||
end
|
||||
love.timer.sleep(.2)
|
||||
love.timer.sleep(.26)
|
||||
end
|
||||
end
|
||||
local devColor={
|
||||
color.white,
|
||||
color.lMagenta,
|
||||
color.lGreen,
|
||||
color.lBlue,
|
||||
COLOR.white,
|
||||
COLOR.lMagenta,
|
||||
COLOR.lGreen,
|
||||
COLOR.lBlue,
|
||||
}
|
||||
local FPS=love.timer.getFPS
|
||||
love.draw,love.update=nil--remove default draw/update
|
||||
@@ -473,6 +478,7 @@ function love.run()
|
||||
else
|
||||
SCN.init("load")
|
||||
end
|
||||
BG.set("none")
|
||||
|
||||
return function()
|
||||
local _
|
||||
@@ -526,7 +532,7 @@ function love.run()
|
||||
local R=int(r)%7+1
|
||||
_=SKIN.libColor[SETTING.skin[R]]
|
||||
gc.setColor(_[1],_[2],_[3],min(1-abs(1-r%1*2),.3))
|
||||
gc.draw(TEXTURE.miniBlock[R],mx,my,Timer()%3.1416*4,20,20,spinCenters[R][0][2]+.5,#blocks[R][0]-spinCenters[R][0][1]-.5)
|
||||
gc.draw(TEXTURE.miniBlock[R],mx,my,Timer()%3.1416*4,20,20,spinCenters[R][0][2]+.5,#BLOCKS[R][0]-spinCenters[R][0][1]-.5)
|
||||
gc.setColor(1,1,1,.5)gc.circle("fill",mx,my,5)
|
||||
gc.setColor(1,1,1)gc.circle("fill",mx,my,3)
|
||||
end
|
||||
@@ -549,7 +555,7 @@ function love.run()
|
||||
--Draw network working
|
||||
if TASK.netTaskCount>0 then
|
||||
setFont(30)
|
||||
gc.setColor(color.rainbow(Timer()*5))
|
||||
gc.setColor(COLOR.rainbow(Timer()*5))
|
||||
gc.print("E",1250,0,.26+.355*math.sin(Timer()*6.26))
|
||||
end
|
||||
|
||||
@@ -563,7 +569,7 @@ function love.run()
|
||||
if devMode then
|
||||
gc.setColor(devColor[devMode])
|
||||
gc.print("Memory:"..gcinfo(),5,_-40)
|
||||
gc.print("Lines:"..freeRow.getCount(),5,_-60)
|
||||
gc.print("Lines:"..FREEROW.getCount(),5,_-60)
|
||||
gc.print("Cursor:"..int(mx+.5).." "..int(my+.5),5,_-80)
|
||||
gc.print("Voices:"..VOC.getCount(),5,_-100)
|
||||
gc.print("Tasks:"..TASK.getCount(),5,_-120)
|
||||
@@ -590,7 +596,7 @@ function love.run()
|
||||
end
|
||||
if gc.getWidth()~=SCR.w then
|
||||
love.resize(gc.getWidth(),gc.getHeight())
|
||||
LOG.print("Screen Resized",color.yellow)
|
||||
LOG.print("Screen Resized",COLOR.yellow)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -41,23 +41,23 @@ function LOG.print(text,T,C)--text,type/time,color
|
||||
local time
|
||||
local his
|
||||
if T=="warn"then
|
||||
C=C or color.yellow
|
||||
C=C or COLOR.yellow
|
||||
his=true
|
||||
time=180
|
||||
elseif T=="error"then
|
||||
C=C or color.red
|
||||
C=C or COLOR.red
|
||||
his=true
|
||||
time=210
|
||||
elseif T=="message"then
|
||||
C=C or color.sky
|
||||
C=C or COLOR.sky
|
||||
his=true
|
||||
elseif type(T)=="number"then
|
||||
C=C or color.white
|
||||
C=C or COLOR.white
|
||||
time=T
|
||||
elseif type(T)=="table"then
|
||||
C,T=T
|
||||
elseif not C then
|
||||
C=color.white
|
||||
C=COLOR.white
|
||||
end
|
||||
if his then
|
||||
ins(debugMesHistory,SCN.cur..": "..tostring(text))
|
||||
@@ -67,6 +67,6 @@ end
|
||||
function LOG.copy()
|
||||
local str=table.concat(debugMesHistory,"\n")
|
||||
love.system.setClipboardText(str)
|
||||
LOG.print("Log copied",color.blue)
|
||||
LOG.print("Log copied",COLOR.blue)
|
||||
end
|
||||
return LOG
|
||||
@@ -30,7 +30,7 @@ function SFX.loadOne(_)
|
||||
if love.filesystem.getInfo(N)then
|
||||
SFX.list[_]={love.audio.newSource(N,"static")}
|
||||
else
|
||||
LOG.print("No SFX file: "..N,5,color.orange)
|
||||
LOG.print("No SFX file: "..N,5,COLOR.orange)
|
||||
end
|
||||
end
|
||||
function SFX.loadAll()
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
local gc=love.graphics
|
||||
local setColor=gc.setColor
|
||||
local setWidth=gc.setLineWidth
|
||||
local rem=table.remove
|
||||
local setColor,setWidth=gc.setColor,gc.setLineWidth
|
||||
local max,min=math.max,math.min
|
||||
local rem=table.remove
|
||||
|
||||
local fx={}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ function TASK.update()
|
||||
TASK.netTaskCount=TASK.netTaskCount-1
|
||||
end
|
||||
rem(tasks,i)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function TASK.new(code,data)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local gc=love.graphics
|
||||
local rnd=math.random
|
||||
local rem=table.remove
|
||||
local mStr=mStr
|
||||
local setFont,mStr=setFont,mStr
|
||||
|
||||
local texts={}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ do--LOADLIB
|
||||
if success then
|
||||
return success
|
||||
else
|
||||
LOG.print("Cannot load "..name..": "..message,"warn",color.red)
|
||||
LOG.print("Cannot load "..name..": "..message,"warn",COLOR.red)
|
||||
end
|
||||
elseif SYSTEM=="Android"then
|
||||
local fs=love.filesystem
|
||||
@@ -37,25 +37,25 @@ do--LOADLIB
|
||||
if success then
|
||||
libFunc,message=package.loadlib(table.concat({fs.getSaveDirectory(),libName.Android},"/"),libName.libFunc)
|
||||
if libFunc then
|
||||
LOG.print(name.." lib loaded","warn",color.green)
|
||||
LOG.print(name.." lib loaded","warn",COLOR.green)
|
||||
break
|
||||
else
|
||||
LOG.print("Cannot load "..name..": "..message,"warn",color.red)
|
||||
LOG.print("Cannot load "..name..": "..message,"warn",COLOR.red)
|
||||
end
|
||||
else
|
||||
LOG.print("Write "..name.."-"..platform[i].." to saving failed: "..message,"warn",color.red)
|
||||
LOG.print("Write "..name.."-"..platform[i].." to saving failed: "..message,"warn",COLOR.red)
|
||||
end
|
||||
else
|
||||
LOG.print("Read "..name.."-"..platform[i].." failed","warn",color.red)
|
||||
LOG.print("Read "..name.."-"..platform[i].." failed","warn",COLOR.red)
|
||||
end
|
||||
end
|
||||
if not libFunc then
|
||||
LOG.print("failed to load "..name,"warn",color.red)
|
||||
LOG.print("failed to load "..name,"warn",COLOR.red)
|
||||
return
|
||||
end
|
||||
return libFunc()
|
||||
else
|
||||
LOG.print("No "..name.." for "..SYSTEM,"warn",color.red)
|
||||
LOG.print("No "..name.." for "..SYSTEM,"warn",COLOR.red)
|
||||
return
|
||||
end
|
||||
return true
|
||||
@@ -180,7 +180,7 @@ do--httpRequest
|
||||
TASK.netTaskCount=TASK.netTaskCount+1
|
||||
end or
|
||||
function()
|
||||
LOG.print("[NO NETlib]",5,color.yellow)
|
||||
LOG.print("[NO NETlib]",5,COLOR.yellow)
|
||||
end
|
||||
end
|
||||
do--json
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
local level={0,0,.015,.02,.03,.04,.05,.06,.07,.08}
|
||||
local _=love.system.vibrate
|
||||
local VIB=love.system.vibrate
|
||||
return function(t)
|
||||
local L=SETTING.vib
|
||||
if L>0 then
|
||||
_(level[L+t])
|
||||
VIB(level[L+t])
|
||||
end
|
||||
end
|
||||
@@ -31,7 +31,7 @@ function VOC.loadOne(name)
|
||||
|
||||
if i==1 then
|
||||
if not loadVoiceFile(N,N)then
|
||||
LOG.print("No VOICE file: "..N,5,color.orange)
|
||||
LOG.print("No VOICE file: "..N,5,COLOR.orange)
|
||||
end
|
||||
end
|
||||
if not VOC.list[N][1]then VOC.list[N]=nil end
|
||||
|
||||
@@ -5,10 +5,8 @@ local max,min=math.max,math.min
|
||||
local sub,format=string.sub,string.format
|
||||
local ins=table.insert
|
||||
|
||||
local color=color
|
||||
local setFont=setFont
|
||||
local Timer=love.timer.getTime
|
||||
local mStr=mStr
|
||||
local setFont,mStr=setFont,mStr
|
||||
|
||||
local Empty={}
|
||||
local widgetList={}
|
||||
@@ -42,7 +40,7 @@ function WIDGET.newText(D)--name,x,y[,color][,font=30][,align="M"][,hide]
|
||||
name= D.name,
|
||||
x= D.x,
|
||||
y= D.y,
|
||||
color= D.color and(color[D.color]or D.color)or color.white,
|
||||
color= D.color and(COLOR[D.color]or D.color)or COLOR.white,
|
||||
font= D.font or 30,
|
||||
align= D.align or"M",
|
||||
hide= D.hide,
|
||||
@@ -161,7 +159,7 @@ function WIDGET.newButton(D)--name,x,y,w[,h][,color][,font],code[,hide]
|
||||
D.x+D.w*.35,D.y+D.h*.35,
|
||||
},
|
||||
|
||||
color= D.color and(color[D.color]or D.color)or color.white,
|
||||
color= D.color and(COLOR[D.color]or D.color)or COLOR.white,
|
||||
font= D.font or 30,
|
||||
code= D.code,
|
||||
hide= D.hide,
|
||||
@@ -236,7 +234,7 @@ function WIDGET.newKey(D)--name,x,y,w[,h][,color][,font],code[,hide]
|
||||
D.x+D.w*.35,D.y+D.h*.35,
|
||||
},
|
||||
|
||||
color= D.color and(color[D.color]or D.color)or color.white,
|
||||
color= D.color and(COLOR[D.color]or D.color)or COLOR.white,
|
||||
font= D.font or 30,
|
||||
code= D.code,
|
||||
hide= D.hide,
|
||||
@@ -567,7 +565,7 @@ function WIDGET.newSelector(D)--name,x,y,w[,color],list,disp,code,hide
|
||||
D.x+D.w,D.y,
|
||||
},
|
||||
|
||||
color= D.color and(color[D.color]or D.color)or color.white,
|
||||
color= D.color and(COLOR[D.color]or D.color)or COLOR.white,
|
||||
list= D.list,
|
||||
disp= D.disp,
|
||||
code= D.code,
|
||||
@@ -870,7 +868,6 @@ function WIDGET.keyPressed(key)
|
||||
local dist=(x-WX)*dir
|
||||
if dist>10 then
|
||||
dist=dist+abs(y-WY)*6.26
|
||||
print(W1.name,dist)
|
||||
if dist<minDist then
|
||||
minDist=dist
|
||||
tar=W1
|
||||
|
||||
Reference in New Issue
Block a user