From 90621a1dd90ea0e6ca507130eee7a241e77164da Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Fri, 19 Mar 2021 23:03:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=89=BA=E6=9C=AF=E6=80=A7=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=B8=80=E6=AE=B5goto=E5=BE=88=E5=A4=9A=E7=9A=84=E5=B0=8F?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/app_reflect.lua | 42 +++++++++++------------------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/parts/scenes/app_reflect.lua b/parts/scenes/app_reflect.lua index 23bd90d0..7856cfe3 100644 --- a/parts/scenes/app_reflect.lua +++ b/parts/scenes/app_reflect.lua @@ -30,38 +30,20 @@ function scene.keyDown(key) state=1 ct=60 end - elseif state==2 then - if key=="q"or key=="a"or key=="p"or key=="l"then - if ct>6 then - SFX.play("finesseError") - if key=="q"or key=="a"then goto P2 else goto P1 end + elseif state==2 and #key==1 then + key=("qapl"):find(key) + if key then + --BEAUTIFUL LOGIC BELOW: + + --early = error, [UP-key]==[target is up] = correct sfx, else = wrong sfx + SFX.play(ct>6 and"finesseError"or key%2==1==up and"reach"or"fail") + + --(early && P2-key || not early && [P1-key]==[target is up]) = P1 win, else P2 win + if ct>6 and key>2 or ct<=6 and key%4<2==up then + winner=1;s1=s1+1 else - if key=="q"then - if up then SFX.play("reach")goto P1 - else SFX.play("fail")goto P2 - end - elseif key=="a"then - if up then SFX.play("fail")goto P2 - else SFX.play("reach")goto P1 - end - elseif key=="p"then - if up then SFX.play("reach")goto P2 - else SFX.play("fail")goto P1 - end - else - if up then SFX.play("fail")goto P1 - else SFX.play("reach")goto P2 - end - end + winner=2;s2=s2+1 end - ::P1:: - winner=1 - s1=s1+1 - goto END - ::P2:: - winner=2 - s2=s2+1 - ::END:: state=3 ct=60 end