小游戏jgt增加预览,难度曲线调整

This commit is contained in:
MrZ626
2021-02-19 21:01:21 +08:00
parent 23ccfecad4
commit fd63fe73cd
7 changed files with 44 additions and 13 deletions

View File

@@ -644,6 +644,7 @@ return{
}, },
mg_jgt={ mg_jgt={
reset="Reset", reset="Reset",
next="Next",
blind="Blind", blind="Blind",
}, },
savedata={ savedata={

View File

@@ -558,6 +558,7 @@ return{
}, },
mg_jgt={ mg_jgt={
reset="Réinitialiser", reset="Réinitialiser",
next="Prévisualisations",
blind="Aveugler", blind="Aveugler",
}, },
help={ help={

View File

@@ -643,6 +643,7 @@ return{
}, },
mg_jgt={ mg_jgt={
reset="Resetar", reset="Resetar",
next="Próxima",
blind="Cego", blind="Cego",
}, },
savedata={ savedata={

View File

@@ -560,6 +560,7 @@ return{
}, },
mg_jgt={ mg_jgt={
reset="Reiniciar", reset="Reiniciar",
next="Siguiente",
blind="A ciegas", blind="A ciegas",
}, },
savedata={ savedata={

View File

@@ -486,6 +486,7 @@ return{
}, },
mg_jgt={ mg_jgt={
reset="R", reset="R",
next="",
blind="???", blind="???",
}, },
}, },

View File

@@ -646,6 +646,7 @@ return{
}, },
mg_jgt={ mg_jgt={
reset="重置", reset="重置",
next="预览",
blind="盲打", blind="盲打",
}, },
savedata={ savedata={

View File

@@ -2,13 +2,13 @@ local gc=love.graphics
local setColor,rectangle=gc.setColor,gc.rectangle local setColor,rectangle=gc.setColor,gc.rectangle
local int,rnd=math.floor,math.random local int,rnd=math.floor,math.random
local min=math.min
local format=string.format local format=string.format
local ins,rem=table.insert,table.remove local ins,rem=table.insert,table.remove
local mStr=mStr local mStr=mStr
local scene={} local scene={}
local previewX={245,186,129,78,35}
local tileColor={ local tileColor={
{.39, 1.0, .39}, {.39, 1.0, .39},
{.39, .39, 1.0}, {.39, .39, 1.0},
@@ -24,13 +24,14 @@ local tileColor={
{.12, .12, .51}, {.12, .12, .51},
} }
local board,cx,cy local board,preview,cx,cy
local startTime,time local startTime,time
local maxTile,maxNew local maxTile,maxNew
local state,progress local state,progress
local fallingTimer local fallingTimer
local score local score
local nexts
local blind local blind
local function reset() local function reset()
@@ -40,6 +41,9 @@ local function reset()
time=0 time=0
maxTile=2 maxTile=2
maxNew=2 maxNew=2
for i=1,5 do
preview[i]=rnd(2)
end
for i=1,5 do for j=1,5 do for i=1,5 do for j=1,5 do
board[i][j]=rnd(2) board[i][j]=rnd(2)
end end end end
@@ -49,10 +53,12 @@ end
function scene.sceneInit() function scene.sceneInit()
BG.set("rainbow2") BG.set("rainbow2")
BGM.play("truth") BGM.play("truth")
preview={}
board={{},{},{},{},{}} board={{},{},{},{},{}}
cx,cy=3,3 cx,cy=3,3
startTime=0 startTime=0
blind=false blind=false
nexts=true
reset() reset()
end end
@@ -78,7 +84,7 @@ local function merge()
until not connected[1] until not connected[1]
if count>1 then if count>1 then
board[cy][cx]=chosen+1 board[cy][cx]=chosen+1
local getScore=3^(chosen-1)*min(int(1+count/3),4) local getScore=3^(chosen-1)*math.min(int(.5+count/2),4)
score=score+getScore score=score+getScore
TEXT.show(getScore,cx*128+256,cy*128-40,40,"score") TEXT.show(getScore,cx*128+256,cy*128-40,40,"score")
SYSFX.newRectRipple(2,320+cx*128-128,40+cy*128-128,128,128) SYSFX.newRectRipple(2,320+cx*128-128,40+cy*128-128,128,128)
@@ -130,6 +136,10 @@ function scene.keyDown(key)
elseif key=="r"then elseif key=="r"then
reset() reset()
elseif key=="q"then elseif key=="q"then
if state==0 then
nexts=not nexts
end
elseif key=="w"then
if state==0 then if state==0 then
blind=not blind blind=not blind
end end
@@ -138,8 +148,7 @@ function scene.keyDown(key)
end end
end end
function scene.mouseMove(x,y) function scene.mouseMove(x,y)
cx=int((x-192)/128) cx,cy=int((x-192)/128),int((y+88)/128)
cy=int((y+88)/128)
if cx<1 or cx>5 or cy<1 or cy>5 then cx,cy=false end if cx<1 or cx>5 or cy<1 or cy>5 then cx,cy=false end
end end
function scene.mouseDown(x,y) function scene.mouseDown(x,y)
@@ -168,11 +177,12 @@ function scene.update()
local noNewTile=true local noNewTile=true
for i=1,5 do for i=1,5 do
if board[1][i]==0 then if board[1][i]==0 then
board[1][i]= board[1][i]=rem(preview,1)
preview[5]=
maxTile<=4 and rnd(2)or maxTile<=4 and rnd(2)or
maxTile<=8 and rnd(3)or maxTile<=8 and rnd(1+rnd(2))or
maxTile<=11 and rnd(4)or maxTile<=11 and rnd(2+rnd(2))or
rnd(3+rnd(2)) rnd(2+rnd(3))
noNewTile=false noNewTile=false
end end
end end
@@ -204,14 +214,28 @@ function scene.draw()
gc.print(progress[i],1000,140+30*i) gc.print(progress[i],1000,140+30*i)
end end
--Previews
if nexts then
gc.setColor(0,0,0,.2)
rectangle("fill",20,450,280,75)
gc.setLineWidth(6)
setColor(1,1,1)
rectangle("line",20,450,280,75)
for i=1,5 do
setFont(85-10*i)
gc.setColor(tileColor[preview[i]])
gc.print(preview[i],previewX[i],428+i*7)
end
end
if state==2 then if state==2 then
--Draw no-setting area --Draw no-setting area
setColor(1,0,0,.3) setColor(1,0,0,.3)
gc.rectangle("fill",15,295,285,70) rectangle("fill",15,295,285,70)
end end
gc.setLineWidth(10) gc.setLineWidth(10)
setColor(1,1,1) setColor(1,1,1)
gc.rectangle("line",315,35,650,650) rectangle("line",315,35,650,650)
gc.setLineWidth(4) gc.setLineWidth(4)
setFont(70) setFont(70)
@@ -241,7 +265,7 @@ function scene.draw()
if state<2 and cx then if state<2 and cx then
setColor(1,1,1,.6) setColor(1,1,1,.6)
gc.setLineWidth(10) gc.setLineWidth(10)
gc.rectangle("line",325+cx*128-128,45+cy*128-128,118,118) rectangle("line",325+cx*128-128,45+cy*128-128,118,118)
end end
setFont(50) setFont(50)
setColor(1,1,1) setColor(1,1,1)
@@ -250,7 +274,8 @@ end
scene.widgetList={ scene.widgetList={
WIDGET.newButton{name="reset", x=160,y=100,w=180,h=100,color="lGreen",font=40,code=pressKey"r"}, WIDGET.newButton{name="reset", x=160,y=100,w=180,h=100,color="lGreen",font=40,code=pressKey"r"},
WIDGET.newSwitch{name="blind", x=240,y=330,w=60,font=40,disp=function()return blind end,code=pressKey"q",hide=function()return state==1 end}, WIDGET.newSwitch{name="next", x=240,y=280,font=40,disp=function()return nexts end,code=pressKey"q",hide=function()return state==1 end},
WIDGET.newSwitch{name="blind", x=240,y=340,font=40,disp=function()return blind end,code=pressKey"w",hide=function()return state==1 end},
WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,font=40,code=backScene}, WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,font=40,code=backScene},
} }