新增小程序:reflect
This commit is contained in:
149
parts/scenes/app_reflect.lua
Normal file
149
parts/scenes/app_reflect.lua
Normal file
@@ -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
|
||||||
@@ -54,6 +54,7 @@ local eggInput={
|
|||||||
can=goScene"app_cannon",
|
can=goScene"app_cannon",
|
||||||
drp=goScene"app_dropper",
|
drp=goScene"app_dropper",
|
||||||
calc=goScene"app_calc",
|
calc=goScene"app_calc",
|
||||||
|
refl=goScene"app_reflect",
|
||||||
cmd=goScene"app_cmd",
|
cmd=goScene"app_cmd",
|
||||||
}TABLE.reIndex(eggInput)
|
}TABLE.reIndex(eggInput)
|
||||||
local function search()
|
local function search()
|
||||||
|
|||||||
Reference in New Issue
Block a user