From 2ebf8f594196506f7c14d81ee6d54b9f31ef49ce Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Wed, 10 Mar 2021 23:36:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=EF=BC=9Areflect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/app_reflect.lua | 149 +++++++++++++++++++++++++++++++++++ parts/scenes/dict.lua | 1 + 2 files changed, 150 insertions(+) create mode 100644 parts/scenes/app_reflect.lua diff --git a/parts/scenes/app_reflect.lua b/parts/scenes/app_reflect.lua new file mode 100644 index 00000000..70c7eeca --- /dev/null +++ b/parts/scenes/app_reflect.lua @@ -0,0 +1,149 @@ +local gc=love.graphics +local rnd=math.random + +local scene={} + +local state +local ct +local s1,s2 +local up,winner=true + +local function reset() + state=0 + ct=20 + s1,s2=0,0 +end + +function scene.sceneInit() + reset() + BG.set("none") +end + +function scene.keyDown(key) + if state==0 then + if key=="space"then + reset() + 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 + 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 + end + ::P1:: + winner=1 + s1=s1+1 + goto END + ::P2:: + winner=2 + s2=s2+1 + ::END:: + state=3 + ct=60 + end + end +end +function scene.touchDown(x,y) + scene.keyDown( + x<640 and + (y<360 and"q"or"a")or + (y<360 and"p"or"l") + ) +end +function scene.update() + if state==0 then--Menu + if ct>0 then + ct=ct-1 + elseif rnd()<.00626 then + ct=30 + end + elseif state==1 then--Waiting + ct=ct-1 + if ct==0 then + ct=rnd(26,162) + up=rnd()<.5 + state=2 + end + elseif state==2 then--Winking + ct=ct-1 + if ct==0 then ct=6 end + elseif state==3 then + ct=ct-1 + if ct==0 then + if s1==6 or s2==6 then + state=0 + else + state=1 + end + ct=60 + end + end +end +function scene.draw() + --Dividing line + gc.setLineWidth(10) + gc.setColor(1,1,1,.9) + gc.line(640,0,640,720) + gc.setColor(1,1,1,.3) + gc.line(0,360,1280,360) + + --Help + gc.setColor(1,1,1) + setFont(100) + mStr("Q",80,100) + mStr("A",80,480) + mStr("P",1200,100) + mStr("L",1200,480) + + --Score + setFont(80) + gc.printf(s1,50,300,200,"left") + gc.printf(s2,1030,300,200,"right") + + if state==0 then + setFont(40) + mStr(MOBILE and"Touch to Start"or"Press space to Start",640,400) + mStr("Press key on the same side when block appear!",640,500) + if ct>0 then + setFont(100) + gc.setColor(1,1,1,ct/30) + mStr("REFLECT",640,140) + end + elseif state==1 then + gc.setColor(.2,.7,.4,math.min((60-ct)/10,ct/10)*.8) + gc.arc("fill",640,360,260,-1.5708,-1.5708+(ct/60)*6.2832) + elseif state==2 and ct<5 then + gc.setColor(1,ct>2 and 1 or 0,0) + gc.rectangle("fill",640-100,(up and 180 or 540)-100,200,200,10) + elseif state==3 then + local x=(60-ct)*62 + gc.setColor(.4,1,.4,ct/100) + if winner==1 then + gc.rectangle("fill",0,0,x,720) + else + gc.rectangle("fill",1280,0,-x,720) + end + end +end + +return scene \ No newline at end of file diff --git a/parts/scenes/dict.lua b/parts/scenes/dict.lua index 1a887f19..1595d1cd 100644 --- a/parts/scenes/dict.lua +++ b/parts/scenes/dict.lua @@ -54,6 +54,7 @@ local eggInput={ can=goScene"app_cannon", drp=goScene"app_dropper", calc=goScene"app_calc", + refl=goScene"app_reflect", cmd=goScene"app_cmd", }TABLE.reIndex(eggInput) local function search()