整理代码

This commit is contained in:
MrZ626
2020-10-25 22:10:38 +08:00
parent 6a3f57042f
commit ec23f8f420
4 changed files with 97 additions and 101 deletions

View File

@@ -72,7 +72,6 @@ local wingColor={
}
back.wing={
init=function()
gc.setDefaultFilter("linear","linear")
bar=gc.newCanvas(41,1)
gc.setCanvas(bar)
gc.push("transform")
@@ -354,7 +353,7 @@ back.lightning={
}--Lightning
local blocks=require("parts/mino")
local scs={.5,1.5,.5,1.5,.5,1.5,.5,1.5,.5,1.5,1,1,0,2}
local scs=spinCenters
back.lightning2={
init=function()
t=rnd()*2600
@@ -373,7 +372,7 @@ back.lightning2={
end
local _=colorLib[colorSet[R]]
gc.setColor(_[1],_[2],_[3],.12)
gc.draw(blockImg[R],640,360,t%3.1416*6,400,400,scs[2*R],#blocks[R][0]-scs[2*R-1])
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
@@ -446,12 +445,12 @@ back.space={
--Make BG vars invisible
for _,bg in next,back do
if bg.init then setfenv(bg.init ,BGvars)end
if bg.resize then setfenv(bg.resize ,BGvars)end
if bg.update then setfenv(bg.update ,BGvars)end
if bg.draw then setfenv(bg.draw ,BGvars)end
if bg.event then setfenv(bg.event ,BGvars)end
if bg.discard then setfenv(bg.discard ,BGvars)end
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={
@@ -478,12 +477,12 @@ function BG.set(bg)
BG.cur=bg
bg=back[bg]
BG.init=bg.init or NULL
BG.resize=bg.resize or NULL
BG.update=bg.update or NULL
BG.draw=bg.draw or NULL
BG.event=bg.event or NULL
BG.discard=bg.discard or NULL
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()
end
return BG

View File

@@ -441,7 +441,6 @@ function love.errorhandler(msg)
love.timer.sleep(.2)
end
end
local scs={.5,1.5,.5,1.5,.5,1.5,.5,1.5,.5,1.5,1,1,0,2}
local devColor={
color.white,
color.lMagenta,
@@ -524,7 +523,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,scs[2*R],#blocks[R][0]-scs[2*R-1])
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

View File

@@ -78,7 +78,7 @@ local virtualkeySet={
{20,1210, 50,30},--zangiRight
},--PC key feedback(top&in a row)
}
local CUSlist={
local SLClist={
snap={1,10,20,40,60,80},
drop={0,.125,.25,.5,1,2,3,4,5,6,7,8,9,10,12,14,16,18,20,25,30,40,60,180,1e99},
@@ -159,8 +159,8 @@ local Widgets={
},
main={
newButton({name="play", x=150,y=260,w=200,h=140,color="lRed", font=55,code=goScene("mode")}),
newButton({name="setting", x=370,y=260,w=200,h=140,color="sky",font=45,code=goScene("setting_game")}),
newButton({name="custom", x=590,y=260,w=200,h=140,color="lPurple", font=45,code=goScene("customGame"),hide=function()return not modeRanks.marathon_normal end}),
newButton({name="setting", x=370,y=260,w=200,h=140,color="sky", font=45,code=goScene("setting_game")}),
newButton({name="custom", x=590,y=260,w=200,h=140,color="lPurple",font=45,code=goScene("customGame"),hide=function()return not modeRanks.marathon_normal end}),
newButton({name="help", x=150,y=420,w=200,h=140,color="lYellow",font=50,code=goScene("help")}),
newButton({name="stat", x=370,y=420,w=200,h=140,color="lGreen", font=40,code=goScene("stat")}),
newButton({name="qplay", x=590,y=420,w=200,h=140,color="white", font=45,code=function()SCN.push()loadGame(STAT.lastPlay,true)end}),
@@ -360,7 +360,7 @@ local Widgets={
sceneTemp.sel=nil
LOG.print("[ "..sceneTemp.default.." ]")
end}),
newSelector({name="snap", x=760,y=90,w=200,h=80,color="yellow",list=CUSlist.snap,disp=STPval("snap"),code=STPsto("snap")}),
newSelector({name="snap", x=760,y=90,w=200,h=80,color="yellow",list=SLClist.snap,disp=STPval("snap"),code=STPsto("snap")}),
newButton({name="option", x=520,y=190,w=200,h=80,font=40,
code=function()
SCN.go("setting_touchSwitch")
@@ -430,14 +430,14 @@ local Widgets={
newText({name="noMsn", x=610,y=550,align="L",color="grey",hide=function()return MISSION[1]end}),
--Basic
newSelector({name="drop", x=170, y=150,w=220,color="orange", list=CUSlist.drop, disp=CUSval("drop"),code=CUSsto("drop")}),
newSelector({name="lock", x=170, y=230,w=220,color="red", list=CUSlist.lock, disp=CUSval("lock"),code=CUSsto("lock")}),
newSelector({name="wait", x=410, y=150,w=220,color="green", list=CUSlist.wait, disp=CUSval("wait"),code=CUSsto("wait")}),
newSelector({name="fall", x=410, y=230,w=220,color="yellow", list=CUSlist.fall, disp=CUSval("fall"),code=CUSsto("fall")}),
newSelector({name="drop", x=170, y=150,w=220,color="orange", list=SLClist.drop, disp=CUSval("drop"),code=CUSsto("drop")}),
newSelector({name="lock", x=170, y=230,w=220,color="red", list=SLClist.lock, disp=CUSval("lock"),code=CUSsto("lock")}),
newSelector({name="wait", x=410, y=150,w=220,color="green", list=SLClist.wait, disp=CUSval("wait"),code=CUSsto("wait")}),
newSelector({name="fall", x=410, y=230,w=220,color="yellow", list=SLClist.fall, disp=CUSval("fall"),code=CUSsto("fall")}),
--Else
newSelector({name="bg", x=1070, y=150,w=250,color="yellow", list=CUSlist.bg, disp=CUSval("bg"), code=function(i)customEnv.bg=i BG.set(i)end}),
newSelector({name="bgm", x=1070, y=230,w=250,color="yellow", list=CUSlist.bgm, disp=CUSval("bgm"), code=function(i)customEnv.bgm=i BGM.play(i)end}),
newSelector({name="bg", x=1070, y=150,w=250,color="yellow", list=SLClist.bg, disp=CUSval("bg"), code=function(i)customEnv.bg=i BG.set(i)end}),
newSelector({name="bgm", x=1070, y=230,w=250,color="yellow", list=SLClist.bgm, disp=CUSval("bgm"), code=function(i)customEnv.bgm=i BGM.play(i)end}),
--Copy/Paste/Start
newButton({name="copy", x=1070, y=310,w=310,h=70,color="lRed", font=25,code=pressKey("cC")}),
@@ -446,7 +446,7 @@ local Widgets={
newButton({name="puzzle", x=1070, y=550,w=310,h=70,color="lMagenta",font=35,code=pressKey("return2")}),
--More
newKey({name="advance", x=730, y=190,w=220,h=90,color="red",font=35,code=goScene("custom_advance")}),
newKey({name="advance", x=730, y=190,w=220,h=90,color="red", font=35,code=goScene("custom_advance")}),
newKey({name="field", x=170, y=640,w=240,h=80,color="water", font=25,code=goScene("custom_field")}),
newKey({name="sequence", x=450, y=640,w=240,h=80,color="pink", font=25,code=goScene("custom_sequence")}),
newKey({name="mission", x=730, y=640,w=240,h=80,color="sky", font=25,code=goScene("custom_mission")}),
@@ -481,12 +481,12 @@ local Widgets={
newSwitch({name="noTele", x=910, y=420, font=25, disp=CUSval("noTele"), code=CUSrev("noTele")}),
newSwitch({name="fineKill", x=910, y=490, font=20, disp=CUSval("fineKill"),code=CUSrev("fineKill")}),
newSwitch({name="easyFresh",x=910, y=560, font=20, disp=CUSval("easyFresh"),code=CUSrev("easyFresh")}),
newSelector({name="visible", x=840, y=60,w=260,color="lBlue", list=CUSlist.visible, disp=CUSval("visible"), code=CUSsto("visible")}),
newSelector({name="target", x=840, y=160,w=260,color="green", list=CUSlist.target, disp=CUSval("target"), code=CUSsto("target")}),
newSelector({name="freshLimit", x=840, y=260,w=260,color="purple", list=CUSlist.freshLimit,disp=CUSval("freshLimit"),code=CUSsto("freshLimit")}),
newSelector({name="opponent", x=1120, y=60,w=260,color="red", list=CUSlist.opponent, disp=CUSval("opponent"),code=CUSsto("opponent")}),
newSelector({name="life", x=1120, y=160,w=260,color="red", list=CUSlist.life, disp=CUSval("life"), code=CUSsto("life")}),
newSelector({name="pushSpeed", x=1120, y=260,w=260,color="red", list=CUSlist.pushSpeed, disp=CUSval("pushSpeed"),code=CUSsto("pushSpeed")}),
newSelector({name="visible", x=840, y=60,w=260,color="lBlue", list=SLClist.visible, disp=CUSval("visible"), code=CUSsto("visible")}),
newSelector({name="target", x=840, y=160,w=260,color="green", list=SLClist.target, disp=CUSval("target"), code=CUSsto("target")}),
newSelector({name="freshLimit", x=840, y=260,w=260,color="purple", list=SLClist.freshLimit,disp=CUSval("freshLimit"),code=CUSsto("freshLimit")}),
newSelector({name="opponent", x=1120, y=60,w=260,color="red", list=SLClist.opponent, disp=CUSval("opponent"),code=CUSsto("opponent")}),
newSelector({name="life", x=1120, y=160,w=260,color="red", list=SLClist.life, disp=CUSval("life"), code=CUSsto("life")}),
newSelector({name="pushSpeed", x=1120, y=260,w=260,color="red", list=SLClist.pushSpeed, disp=CUSval("pushSpeed"),code=CUSsto("pushSpeed")}),
newButton({name="back", x=1140, y=640, w=170,h=80, font=40,code=BACK}),
},
@@ -503,13 +503,13 @@ local Widgets={
newButton({name="b7", x=500+65*7, y=200, w=58, color="cyan", code=setPen(7)}),--B7
newButton({name="b8", x=500+65*8, y=200, w=58, color="blue", code=setPen(8)}),--B8
newButton({name="b9", x=500+65*9, y=200, w=58, color="purple", code=setPen(9)}),--B9
newButton({name="b10", x=500+65*10,y=200, w=58, color="magenta", code=setPen(10)}),--B10
newButton({name="b10", x=500+65*10,y=200, w=58, color="magenta",code=setPen(10)}),--B10
newButton({name="b11", x=500+65*11,y=200, w=58, color="pink", code=setPen(11)}),--B11
newButton({name="b12", x=500+65*1, y=270, w=58, color="dGrey", code=setPen(12)}),--Bone
newButton({name="b13", x=500+65*2, y=270, w=58, color="grey", code=setPen(13)}),--GB1
newButton({name="b14", x=500+65*3, y=270, w=58, color="lGrey", code=setPen(14)}),--GB2
newButton({name="b15", x=500+65*4, y=270, w=58, color="dPurple", code=setPen(15)}),--GB3
newButton({name="b15", x=500+65*4, y=270, w=58, color="dPurple",code=setPen(15)}),--GB3
newButton({name="b16", x=500+65*5, y=270, w=58, color="dRed", code=setPen(16)}),--GB4
newButton({name="b17", x=500+65*6, y=270, w=58, color="dGreen", code=setPen(17)}),--GB5
@@ -528,7 +528,7 @@ local Widgets={
newText({name="title", x=520,y=5,font=70,align="R"}),
newText({name="subTitle", x=530,y=50,font=35,align="L",color="grey"}),
newSelector({name="sequence",x=1080,y=60, w=200, color="yellow",list=CUSlist.sequence,disp=CUSval("sequence"),code=CUSsto("sequence")}),
newSelector({name="sequence",x=1080,y=60, w=200, color="yellow",list=SLClist.sequence,disp=CUSval("sequence"),code=CUSsto("sequence")}),
newKey({name="Z", x=100, y=440, w=90, font=50,code=pressKey(1)}),
newKey({name="S", x=200, y=440, w=90, font=50,code=pressKey(2)}),
@@ -667,16 +667,16 @@ local Widgets={
newButton({name="back", x=1140, y=640,w=170,h=80, font=40,code=BACK}),
},
login={
newText({name="title", x=80,y=50,font=70,align="L"}),
newTextBox({name="username",x=380,y=160,w=500,h=60,regex="[0-9A-Za-z_-=+'.<>/{}*]"}),
newTextBox({name="email", x=380,y=260,w=626,h=60,regex="[0-9A-Za-z_@]"}),
newTextBox({name="code", x=380,y=360,w=626,h=60,regex="[0-9A-Za-z]"}),
newTextBox({name="password",x=380,y=460,w=626,h=60,secret=true,regex="[ -~]"}),
newTextBox({name="password2",x=380,y=560,w=626,h=60,secret=true,regex="[ -~]"}),
newText({name="title", x=80, y=50,font=70,align="L"}),
newTextBox({name="username",x=380, y=160,w=500,h=60,regex="[0-9A-Za-z_-=+'.<>/{}*]"}),
newTextBox({name="email", x=380, y=260,w=626,h=60,regex="[0-9A-Za-z_@]"}),
newTextBox({name="code", x=380, y=360,w=626,h=60,regex="[0-9A-Za-z]"}),
newTextBox({name="password",x=380, y=460,w=626,h=60,secret=true,regex="[ -~]"}),
newTextBox({name="password2",x=380, y=560,w=626,h=60,secret=true,regex="[ -~]"}),
newButton({name="back", x=1140, y=640,w=170,h=80,font=40,code=BACK}),
},
account={
newText({name="title", x=80,y=50,font=70,align="L"}),
newText({name="title", x=80, y=50,font=70,align="L"}),
newButton({name="back", x=1140, y=640,w=170,h=80,font=40,code=BACK}),
},
minigame={
@@ -716,10 +716,10 @@ local Widgets={
LOG.print("rad: "..math.floor(SCR.rad*100)*.01)
LOG.print("dpi: "..SCR.dpi)
end}),
newButton({name="reset", x=640,y=380,w=240,h=100,color="orange", font=40,
newButton({name="reset",x=640,y=380,w=240,h=100,color="orange",font=40,
code=function()sceneTemp.reset=true end,
hide=STPval("reset")}),
newButton({name="reset1", x=340,y=480,w=240,h=100,color="red", font=35,
newButton({name="reset1",x=340,y=480,w=240,h=100,color="red",font=35,
code=function()
love.filesystem.remove("unlock.dat")
SFX.play("finesseError_long")
@@ -728,7 +728,7 @@ local Widgets={
TEXT.show("play one game if you regret",640,390,40,"stretch",.4)
end,
hide=function()return not sceneTemp.reset end}),
newButton({name="reset2", x=640,y=480,w=260,h=100,color="red", font=35,
newButton({name="reset2",x=640,y=480,w=260,h=100,color="red",font=35,
code=function()
love.filesystem.remove("data.dat")
SFX.play("finesseError_long")
@@ -737,7 +737,7 @@ local Widgets={
TEXT.show("play one game if you regret",640,390,40,"stretch",.4)
end,
hide=function()return not sceneTemp.reset end}),
newButton({name="reset3", x=940,y=480,w=260,h=100,color="red", font=35,
newButton({name="reset3",x=940,y=480,w=260,h=100,color="red",font=35,
code=function()
local L=love.filesystem.getDirectoryItems("")
for i=1,#L do
@@ -752,10 +752,10 @@ local Widgets={
SCN.back()
end,
hide=function()return not sceneTemp.reset end}),
newButton({name="back", x=640,y=620,w=200,h=80,font=40,code=BACK}),
newButton({name="back",x=640,y=620,w=200,h=80,font=40,code=BACK}),
},
}
local META={
local indexWithName={
__index=function(L,k)
for i=1,#L do
if L[i].name==k then
@@ -765,6 +765,6 @@ local META={
end
}
for _,v in next,Widgets do
setmetatable(v,META)
setmetatable(v,indexWithName)
end
return Widgets

View File

@@ -1672,13 +1672,12 @@ do--setting_key
end
end
do--setting_skin
local scs=spinCenters
function Pnt.setting_skin()
gc.setColor(1,1,1)
for N=1,7 do
local face=SETTING.face[N]
local B=blocks[N][face]
local x,y=-55+140*N-scs[N][face][2]*30,355+scs[N][face][1]*30
local x,y=-55+140*N-spinCenters[N][face][2]*30,355+spinCenters[N][face][1]*30
local col=#B[1]
for i=1,#B do for j=1,col do
if B[i][j]then
@@ -2587,7 +2586,6 @@ do--dict
english=color.green,
name=color.lPurple,
}
local scs={.5,1.5,.5,1.5,.5,1.5,.5,1.5,.5,1.5,1,1,0,2}
function Pnt.dict()
local S=sceneTemp
@@ -2637,7 +2635,7 @@ do--dict
local r=Timer()*2
local R=int(r)%7+1
gc.setColor(1,1,1,1-abs(r%1*2-1))
gc.draw(TEXTURE.miniBlock[R],785,140,Timer()*10%6.2832,15,15,scs[2*R],#blocks[R][0]-scs[2*R-1])
gc.draw(TEXTURE.miniBlock[R],785,140,Timer()*10%6.2832,15,15,spinCenters[R][0][2]+.5,#blocks[R][0]-spinCenters[R][0][1]-.5)
end
end
end
@@ -3033,46 +3031,46 @@ do--p15
end
end
end
function keyDown.p15(k)
function keyDown.p15(key)
local S=sceneTemp
local b=S.board
if k=="up"then
if key=="up"then
tapBoard(S.x,S.y-(S.revKB and 1 or -1),true)
elseif k=="down"then
elseif key=="down"then
tapBoard(S.x,S.y+(S.revKB and 1 or -1),true)
elseif k=="left"then
elseif key=="left"then
tapBoard(S.x-(S.revKB and 1 or -1),S.y,true)
elseif k=="right"then
elseif key=="right"then
tapBoard(S.x+(S.revKB and 1 or -1),S.y,true)
elseif k=="space"then
elseif key=="space"then
shuffleBoard(S,b)
S.state=0
S.time=0
S.move=0
elseif k=="q"then
elseif key=="q"then
if S.state~=1 then
S.color=(S.color+1)%5
end
elseif k=="w"then
elseif key=="w"then
if S.state==0 then
S.blind=not S.blind
end
elseif k=="e"then
elseif key=="e"then
if S.state==0 then
S.slide=not S.slide
if not S.slide then
S.pathVis=false
end
end
elseif k=="r"then
elseif key=="r"then
if S.state==0 and S.slide then
S.pathVis=not S.pathVis
end
elseif k=="t"then
elseif key=="t"then
if S.state==0 then
S.revKB=not S.revKB
end
elseif k=="escape"then
elseif key=="escape"then
SCN.back()
end
end