From 832c09980ab4c6320395980a40d08fea3c33b5d0 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Tue, 13 Apr 2021 00:26:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B0=8F=E7=A8=8B=E5=BA=8F20?= =?UTF-8?q?48=E4=B9=8B=E5=89=8D=E5=9C=A8=E5=88=A0goto=E6=97=B6=E9=80=A0?= =?UTF-8?q?=E6=88=90=E7=9A=84=E9=80=BB=E8=BE=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/app_2048.lua | 49 ++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/parts/scenes/app_2048.lua b/parts/scenes/app_2048.lua index 0e092320..b80d682d 100644 --- a/parts/scenes/app_2048.lua +++ b/parts/scenes/app_2048.lua @@ -128,33 +128,34 @@ local function squash(L) local moved=false while true do p2=p1+1 - while not L[p2]do + while not L[p2]and p2<5 do p2=p2+1 - if p2==5 then - p1=p1+1 - if p1==4 then - return L[1],L[2],L[3],L[4],moved - end - break - end end - if not L[p1]then--air←2 - L[p1],L[p2]=L[p2],false - moved=true - elseif L[p1]==L[p2]then--2←2 - L[p1],L[p2]=L[p1]+1,false - if L[p1]>maxTile then - freshMaxTile() + if p2==5 then + if p1==4 then + return L[1],L[2],L[3],L[4],moved + else + p1=p1+1 + end + else + if not L[p1]then--air←2 + L[p1],L[p2]=L[p2],false + moved=true + elseif L[p1]==L[p2]then--2←2 + L[p1],L[p2]=L[p1]+1,false + if L[p1]>maxTile then + freshMaxTile() + end + L[p2]=false + p1=p1+1 + moved=true + elseif p1+1~=p2 then--2←4 + L[p1+1],L[p2]=L[p2],false + p1=p1+1 + moved=true + else--2,4 + p1=p1+1 end - L[p2]=false - p1=p1+1 - moved=true - elseif p1+1~=p2 then--2←4 - L[p1+1],L[p2]=L[p2],false - p1=p1+1 - moved=true - else--2,4 - p1=p1+1 end end end