From 66872d3edf3bb525d27b55fcb300f2ec8d4e755a Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 5 Nov 2020 18:23:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=9C=BA=E5=9C=B0?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E9=A1=B5=E5=BD=B1=E5=93=8D=E6=8B=BC=E5=9B=BE?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E6=9C=89=E6=95=88=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modes/custom_clear.lua | 17 ++++------ parts/scenes/customGame.lua | 63 +++++++++++++++++++++++------------ parts/scenes/custom_field.lua | 2 -- 3 files changed, 48 insertions(+), 34 deletions(-) diff --git a/modes/custom_clear.lua b/modes/custom_clear.lua index 21f022a1..cab06269 100644 --- a/modes/custom_clear.lua +++ b/modes/custom_clear.lua @@ -62,19 +62,14 @@ return{ else modeEnv.mission=nil end - local clearmode - if FIELD[1]then - for y=1,20 do - if notAir(FIELD[1][y])then - clearmode=true - end + modeEnv.dropPiece=PLY.check_lineReach + for y=1,20 do + if notAir(FIELD[1][y])then + --Switch clear mode on + modeEnv.dropPiece=checkClear + break end end - if clearmode then - modeEnv.dropPiece=checkClear - else - modeEnv.dropPiece=PLY.check_lineReach - end PLY.newPlayer(1,340,15) local L=modeEnv.opponent if L~=0 then diff --git a/parts/scenes/customGame.lua b/parts/scenes/customGame.lua index 2a1b6a93..75dc29f9 100644 --- a/parts/scenes/customGame.lua +++ b/parts/scenes/customGame.lua @@ -5,11 +5,23 @@ local Timer=love.timer.getTime local int=math.floor local find,sub=string.find,string.sub +local function notAir(L) + for i=1,10 do + if L[i]>0 then return true end + end +end + local customEnv=customEnv function sceneInit.customGame() destroyPlayers() BG.set(customEnv.bg) BGM.play(customEnv.bgm) + sceneInit={initField=false} + for y=1,20 do + if notAir(FIELD[1][y])then + sceneTemp.initField=true + end + end end function keyDown.customGame(key) @@ -27,7 +39,13 @@ function keyDown.customGame(key) end end SCN.push() - loadGame((key=="return2"or kb.isDown("lalt","lctrl","lshift"))and"custom_puzzle"or"custom_clear",true) + if key=="return2"or kb.isDown("lalt","lctrl","lshift")then + if sceneTemp.initField then + loadGame("custom_puzzle",true) + end + else + loadGame("custom_clear",true) + end elseif key=="f"then SCN.go("custom_field","swipeD") elseif key=="s"then @@ -83,28 +101,30 @@ end function Pnt.customGame() --Field content - gc.push("transform") - gc.translate(95,290) - gc.scale(.5) - gc.setColor(1,1,1) - gc.setLineWidth(3) - gc.rectangle("line",-2,-2,304,604) - local F=FIELD[1] - local cross=puzzleMark[-1] - local texture=SKIN.curText - for y=1,20 do for x=1,10 do - local B=F[y][x] - if B>0 then - gc.draw(texture[B],30*x-30,600-30*y) - elseif B==-1 then - gc.draw(cross,30*x-30,600-30*y) - end - end end - gc.pop() + if sceneTemp.initField then + gc.push("transform") + gc.translate(95,290) + gc.scale(.5) + gc.setColor(1,1,1) + gc.setLineWidth(3) + gc.rectangle("line",-2,-2,304,604) + local F=FIELD[1] + local cross=puzzleMark[-1] + local texture=SKIN.curText + for y=1,20 do for x=1,10 do + local B=F[y][x] + if B>0 then + gc.draw(texture[B],30*x-30,600-30*y) + elseif B==-1 then + gc.draw(cross,30*x-30,600-30*y) + end + end end + gc.pop() + end --Field setFont(40) - if #FIELD>1 then + if sceneTemp.initField and #FIELD>1 then gc.setColor(1,1,int(Timer()*6.26)%2) gc.print("+",275,300) gc.print(#FIELD-1,300,300) @@ -117,6 +137,7 @@ function Pnt.customGame() gc.print(#BAG,360,545) end setFont(30) + gc.setColor(1,1,1) gc.print(customEnv.sequence,330,510) --Sequence @@ -152,7 +173,7 @@ WIDGET.init("customGame",{ WIDGET.newButton({name="copy", x=1070, y=310,w=310,h=70,color="lRed", font=25,code=WIDGET.lnk.pressKey("cC")}), WIDGET.newButton({name="paste", x=1070, y=390,w=310,h=70,color="lBlue", font=25,code=WIDGET.lnk.pressKey("cV")}), WIDGET.newButton({name="clear", x=1070, y=470,w=310,h=70,color="lYellow",font=35,code=WIDGET.lnk.pressKey("return")}), - WIDGET.newButton({name="puzzle",x=1070, y=550,w=310,h=70,color="lMagenta",font=35,code=WIDGET.lnk.pressKey("return2")}), + WIDGET.newButton({name="puzzle",x=1070, y=550,w=310,h=70,color="lMagenta",font=35,code=WIDGET.lnk.pressKey("return2"),hide=function()return not sceneTemp.initField end}), --More WIDGET.newKey({name="advance", x=730, y=190,w=220,h=90,color="red", font=35,code=WIDGET.lnk.goScene("custom_advance")}), diff --git a/parts/scenes/custom_field.lua b/parts/scenes/custom_field.lua index 158fadb0..080869d6 100644 --- a/parts/scenes/custom_field.lua +++ b/parts/scenes/custom_field.lua @@ -5,8 +5,6 @@ local max,min,int=math.max,math.min,math.floor local ins,rem=table.insert,table.remove local sub=string.sub - - local FIELD=FIELD function sceneInit.custom_field() sceneTemp={