优化两个小游戏体验

This commit is contained in:
MrZ626
2020-09-13 12:00:08 +08:00
parent 2bf7cc4781
commit 10810f3120
2 changed files with 33 additions and 19 deletions

View File

@@ -473,7 +473,7 @@ local Widgets={
},
p15={
newButton({name="reset", x=160,y=100,w=180,h=100,color="lGreen", font=40,code=pressKey("space")}),
newSlider({name="color", x=110,y=250,w=170,unit=4,show=false, font=30,disp=function()return sceneTemp.color end,code=function(v)if sceneTemp.state==0 then sceneTemp.color=v end end,hide=function()return sceneTemp.state==1 end}),
newSlider({name="color", x=110,y=250,w=170,unit=4,show=false, font=30,disp=function()return sceneTemp.color end,code=function(v)if sceneTemp.state~=1 then sceneTemp.color=v end end,hide=function()return sceneTemp.state==1 end}),
newSwitch({name="blind", x=240,y=330,w=60, font=40,disp=function()return sceneTemp.blind end,code=pressKey("b"),hide=function()return sceneTemp.state==1 end}),
newSwitch({name="slide", x=240,y=420,w=60, font=40,disp=function()return sceneTemp.slide end,code=pressKey("s"),hide=function()return sceneTemp.state==1 end}),
newSwitch({name="pathVis", x=240,y=510,w=60, font=40,disp=function()return sceneTemp.pathVis end,code=pressKey("p"),hide=function()return sceneTemp.state==1 or not sceneTemp.slide end}),
@@ -483,8 +483,8 @@ local Widgets={
schulte_G={
newButton({name="reset", x=160,y=100,w=180,h=100,color="lGreen", font=40,code=pressKey("r"),hide=function()return sceneTemp.state==0 end}),
newSlider({name="rank", x=130,y=250,w=150,unit=3,show=false, font=40,disp=function()return sceneTemp.rank-3 end,code=function(v)sceneTemp.rank=v+3 end,hide=function()return sceneTemp.state>0 end}),
newSwitch({name="blind", x=160,y=330,w=60, font=40,disp=function()return sceneTemp.blind end,code=pressKey("b"),hide=function()return sceneTemp.state==1 end}),
newSwitch({name="disappear",x=160,y=410,w=60, font=40,disp=function()return sceneTemp.disappear end,code=pressKey("d"),hide=function()return sceneTemp.state==1 end}),
newSwitch({name="blind", x=200,y=330,w=60, font=40,disp=function()return sceneTemp.blind end,code=pressKey("b"),hide=function()return sceneTemp.state==1 end}),
newSwitch({name="disappear",x=200,y=410,w=60, font=40,disp=function()return sceneTemp.disappear end,code=pressKey("d"),hide=function()return sceneTemp.state==1 end}),
newButton({name="back", x=1140,y=640,w=180,h=80,color="white", font=35,code=BACK}),
},
help={

View File

@@ -289,7 +289,7 @@ do--p15
S.time=0
S.move=0
elseif k=="c"then
if S.state==2 then
if S.state~=1 then
S.color=(S.color+1)%5
end
elseif k=="r"then
@@ -411,9 +411,16 @@ do--p15
gc.print(format("%.3f",S.time),1026,80)
gc.print(S.move,1026,150)
if S.state==2 then gc.setColor(.9,.9,0) --win
elseif S.state==1 then gc.setColor(.9,.9,.9)--game
elseif S.state==0 then gc.setColor(.2,.8,.2)--ready
if S.state==2 then
--Draw no-setting area
gc.setColor(1,0,0,.3)
gc.rectangle("fill",15,300,285,330)
gc.setColor(.9,.9,0)--win
elseif S.state==1 then
gc.setColor(.9,.9,.9)--game
elseif S.state==0 then
gc.setColor(.2,.8,.2)--ready
end
gc.setLineWidth(10)
gc.rectangle("line",313,33,654,654,18)
@@ -463,7 +470,7 @@ do--schulte_G
time=0,
error=0,
state=0,
target=0,
progress=0,
}
end
@@ -485,14 +492,14 @@ do--schulte_G
newBoard()
S.state=1
S.startTime=Timer()
S.target=1
S.progress=0
elseif S.state==1 then
local X=int((x-320)/640*R)
local Y=int((y-40)/640*R)
x=R*Y+X+1
if S.board[x]==S.target then
S.target=S.target+1
if S.target<=R^2 then
if S.board[x]==S.progress+1 then
S.progress=S.progress+1
if S.progress<R^2 then
SFX.play("lock")
else
S.time=Timer()-S.startTime+S.error
@@ -523,7 +530,7 @@ do--schulte_G
S.time=0
S.error=0
S.state=0
S.target=0
S.progress=0
end
elseif key=="z"or key=="x"then
tapBoard(ms.getPosition())
@@ -561,25 +568,32 @@ do--schulte_G
gc.print(S.error,1026,150)
setFont(70)
mStr(S.state==1 and S.target or S.state==0 and"Ready"or S.state==2 and"Win",1130,300)
mStr(S.state==1 and S.progress or S.state==0 and"Ready"or S.state==2 and"Win",1130,300)
if S.state==1 then gc.setColor(.9,.9,.9) --game
elseif S.state==0 then gc.setColor(.2,.8,.2)--ready
elseif S.state==2 then gc.setColor(.9,.9,0) --win
if S.state==2 then
--Draw no-setting area
gc.setColor(1,0,0,.3)
gc.rectangle("fill",60,295,200,150)
gc.setColor(.9,.9,0)--win
elseif S.state==1 then
gc.setColor(.9,.9,.9)--game
elseif S.state==0 then
gc.setColor(.2,.8,.2)--ready
end
gc.setLineWidth(10)
gc.rectangle("line",310,30,660,660)
local rank=S.rank
local width=640/rank
local blind=S.state==0 or S.blind and S.state==1 and S.target>1
local blind=S.state==0 or S.blind and S.state==1 and S.progress>0
gc.setLineWidth(4)
local f=fontSize[rank]
setFont(f)
for i=1,rank do
for j=1,rank do
local N=S.board[rank*(i-1)+j]
if not(S.state==1 and S.disappear and N<S.target)then
if not(S.state==1 and S.disappear and N<=S.progress)then
gc.setColor(.4,.5,.6)
gc.rectangle("fill",320+(j-1)*width,(i-1)*width+40,width,width)
gc.setColor(1,1,1)