diff --git a/assets/gamefunc.lua b/assets/gamefunc.lua index c4fb6b39..03e750da 100644 --- a/assets/gamefunc.lua +++ b/assets/gamefunc.lua @@ -43,7 +43,7 @@ function playSample(...) volume=vol, param={'release',rel*1.0594630943592953^(note-33)}, }) - TASK.new(function () + TASK.new(function() DEBUG.yieldT(len/1000) event:stop(FMOD.FMOD_STUDIO_STOP_ALLOWFADEOUT) end) diff --git a/assets/scene/app_schulteG.lua b/assets/scene/app_schulteG.lua index b5503ea6..eebe8850 100644 --- a/assets/scene/app_schulteG.lua +++ b/assets/scene/app_schulteG.lua @@ -22,10 +22,10 @@ local fontSizes={ local function setState(v) state=v - scene.widgetList.rank._visible=state==0 - scene.widgetList.invis._visible=state~=1 - scene.widgetList.disappear._visible=state~=1 - scene.widgetList.tapFX._visible=state~=1 + scene.widgetList.rank:setVisible(state==0) + scene.widgetList.invis:setVisible(state~=1) + scene.widgetList.disappear:setVisible(state~=1) + scene.widgetList.tapFX:setVisible(state~=1) end function scene.enter() BG.set('space') @@ -42,6 +42,9 @@ function scene.enter() setState(0) end +local function inBoard(x,y) + return MATH.between(x,area.x,area.x+area.w) and MATH.between(y,area.y,area.y+area.h) +end local function newBoard() local L={} for i=1,rank^2 do @@ -52,36 +55,29 @@ local function newBoard() end end local function tapBoard(x,y) - if MATH.between(x,area.x,area.x+area.w) and MATH.between(y,area.y,area.y+area.h) then - if state==0 then - newBoard() - setState(1) - startTime=love.timer.getTime() - progress=0 - elseif state==1 then - local R=rank - local X=math.floor((x-area.x)/area.w*R) - local Y=math.floor((y-area.y)/area.h*R) - x=R*Y+X+1 - if board[x]==progress+1 then - progress=progress+1 - if progress1 and board[y][x-1]==chosen then ins(connected,{y,x-1}) count=count+1 end if x<5 and board[y][x+1]==chosen then ins(connected,{y,x+1}) count=count+1 end if y>1 and board[y-1][x]==chosen then ins(connected,{y-1,x}) count=count+1 end @@ -88,8 +101,8 @@ local function merge() board[cy][cx]=chosen+1 local getScore=3^(chosen-1)*math.min(floor(.5+count/2),4) score=score+getScore - TEXT:add(getScore,cx*128+256,cy*128-40,40,'score') - SYSFX.newRectRipple(.5,320+cx*128-128,40+cy*128-128,128,128) + TEXT:add{text=getScore,x=area.x+area.c*(cx-.5),y=area.y+area.c*(cy-.5)-40,fontSize=60,fontType='bold',style='score'} + SYSFX.rectRipple(.5,area.x+(cx-1)*area.c,area.y+(cy-1)*area.c,area.c,area.c) FMOD.effect('lock') if chosen==maxTile then maxTile=chosen+1 @@ -105,14 +118,14 @@ local function merge() end if chosen>=5 then FMOD.effect( - chosen>=9 and 'ren_mega' or + chosen>=9 and 'spin_4' or chosen>=8 and 'spin_3' or chosen>=7 and 'spin_2' or chosen>=6 and 'spin_1' or 'spin_0' ) end - fallingTimer=fast and 8 or 12 + fallingTimer=fast and 0.1 or 0.2 failPos=false else board[cy][cx]=chosen @@ -158,8 +171,8 @@ function scene.keyDown(key,isRep) return true end function scene.mouseMove(x,y) - cx,cy=floor((x-192)/128),floor((y+88)/128) - if cx<1 or cx>5 or cy<1 or cy>5 then + cx,cy=floor((x-area.x)/area.c)+1,floor((y-area.y)/area.c)+1 + if not (MATH.between(cx,1,5) and MATH.between(cy,1,5)) then cx,cy=false end end @@ -174,12 +187,12 @@ function scene.touchClick(x,y) scene.mouseDown(x,y) end -function scene.update() +function scene.update(dt) if state==1 then time=love.timer.getTime()-startTime if fallingTimer then - fallingTimer=fallingTimer-1 - if fallingTimer==0 then + fallingTimer=fallingTimer-dt + if fallingTimer<=0 then for i=5,2,-1 do for j=1,5 do if board[i][j]==0 then board[i][j]=board[i-1][j] @@ -202,10 +215,10 @@ function scene.update() fallingTimer=false for i=1,4 do for j=1,5 do if board[i][j]==board[i+1][j] then return end end end for i=1,5 do for j=1,4 do if board[i][j]==board[i][j+1] then return end end end - state=2 + setState(2) FMOD.effect('fail') else - fallingTimer=fast and 4 or 5 + fallingTimer=fast and .05 or .1 FMOD.effect('touch') end end @@ -222,34 +235,36 @@ end function scene.draw() setFont(40) gc_setColor(COLOR.L) - gc.print(("%.3f"):format(time),1026,50) - gc.print(score,1026,100) + gc.print(("%.3f"):format(time),1300,50) + gc.print(score,1300,100) -- Progress time list setFont(25) gc_setColor(.7,.7,.7) for i=1,#progress do - gc.print(progress[i],1000,140+30*i) + gc.print(progress[i],1300,140+30*i) end -- Previews if nexts then + gc.translate(30,450) gc.setColor(COLOR.dX) - gc_rectangle('fill',20,450,280,75) + gc_rectangle('fill',0,0,280,75) gc.setLineWidth(6) gc_setColor(COLOR.L) - gc_rectangle('line',20,450,280,75) + gc_rectangle('line',0,0,280,75) for i=1,5 do - setFont(85-10*i) + setFont(previewFont[i]) gc.setColor(tileColor[preview[i]]) gc.print(preview[i],previewX[i],previewY[i]) end + gc.translate(-30,-450) end if state==2 then -- Draw no-setting area gc_setColor(1,0,0,.3) - gc_rectangle('fill',15,200,285,210) + gc_rectangle('fill',40,200,285,210) end gc.setLineWidth(10) gc_setColor(COLOR[ @@ -257,7 +272,7 @@ function scene.draw() state==0 and 'G' or state==2 and 'Y' ]) - gc_rectangle('line',315,35,650,650) + gc_rectangle('line',area.x-5,area.y-5,area.w+10,area.h+10) gc.setLineWidth(4) setFont(70) @@ -267,9 +282,9 @@ function scene.draw() if N>0 then if hide and N>maxNew then gc_setColor(COLOR.lD) - gc_rectangle('fill',320+j*128-128,40+i*128-128,128,128) + gc_rectangle('fill',area.x+(j-1)*area.c,area.y+(i-1)*area.c,area.c,area.c) gc_setColor(1,1,1,.3) - mStr("?",j*128+256,i*128-75) + mStr("?",j*area.c+256,i*area.c-75) else if N<=12 then gc_setColor(tileColor[N]) @@ -278,27 +293,27 @@ function scene.draw() else gc_setColor(0,0,0,1-math.abs(love.timer.getTime()%.5-.25)*6-.25) end - gc_rectangle('fill',320+j*128-128,40+i*128-128,128,128) + gc_rectangle('fill',area.x+(j-1)*area.c,area.y+(i-1)*area.c,area.c,area.c) gc_setColor(1,1,1,.9) - mStr(N,j*128+256,i*128-75) + mStr(N,j*area.c+256,i*area.c-75) end end end end if state<2 and cx then gc_setColor(1,1,1,.6) gc.setLineWidth(10) - gc_rectangle('line',325+cx*128-128,45+cy*128-128,118,118) + gc_rectangle('line',area.x+(cx-1)*area.c+5,area.y+(cy-1)*area.c+5,area.c-10,area.c-10) end setFont(50) gc_setColor(COLOR.L) - mStr("Just Get Ten",160,580) + mStr("Just Get Ten",170,580) end scene.widgetList={ - WIDGET.new{type='button', x=160,y=100,w=180,h=100,color='lG',fontSize=60,text=CHAR.icon.retry,code=WIDGET.c_pressKey'r'}, - WIDGET.new{type='checkBox',x=240,y=235,widthLimit=200,fontSize=40,disp=function() return nexts end,code=WIDGET.c_pressKey'q',visibleTick=function() return state~=1 end}, - WIDGET.new{type='checkBox',x=240,y=305,widthLimit=200,fontSize=40,disp=function() return invis end,code=WIDGET.c_pressKey'w',visibleTick=function() return state~=1 end}, - WIDGET.new{type='checkBox',x=240,y=375,widthLimit=200,fontSize=30,disp=function() return fast end,code=WIDGET.c_pressKey'e',visibleTick=function() return state~=1 end}, + WIDGET.new{type='button', x=160,y=100,w=180,h=100,color='lG',fontSize=60,text=CHAR.icon.retry,code=WIDGET.c_pressKey'r'}, + WIDGET.new{type='checkBox',name='nexts',text="Nexts",x=280,y=235,widthLimit=200,fontSize=40,disp=function() return nexts end,code=WIDGET.c_pressKey'q'}, + WIDGET.new{type='checkBox',name='invis',text="Invis",x=280,y=305,widthLimit=200,fontSize=40,disp=function() return invis end,code=WIDGET.c_pressKey'w'}, + WIDGET.new{type='checkBox',name='fast', text="Fast", x=280,y=375,widthLimit=200,fontSize=40,disp=function() return fast end,code=WIDGET.c_pressKey'e'}, WIDGET.new{type='button', pos={1,1},x=-120,y=-80,w=160,h=80,sound_trigger='button_back',fontSize=60,text=CHAR.icon.back,code=WIDGET.c_backScn()}, } diff --git a/assets/scene/app_triple.lua b/assets/scene/app_triple.lua index 61b9a806..25dc1de2 100644 --- a/assets/scene/app_triple.lua +++ b/assets/scene/app_triple.lua @@ -6,71 +6,80 @@ local ins,rem=table.insert,table.remove local setFont,mStr=FONT.set,GC.mStr -local tileColor={ - [-2]=COLOR.R, -- Bomb - [-1]=COLOR.DL, -- Stone - {.39, 1.0, .39}, -- Tile 1 - {.39, .39, 1.0}, -- Tile 2 - {1.0, .70, .31}, -- Tile 3 - {.94, .31, .31}, -- Tile 4 - {.00, .71, .12}, -- Tile 5 - {.90, .20, .90}, -- Tile 6 - {.94, .47, .39}, -- Tile 7 - {.90, .00, .00}, -- Tile 8 - {.86, .86, .31}, -- Tile 9 - {.78, .31, .00}, -- Tile 10 - {.78, .55, .04}, -- Tile 11 - {.12, .12, .51}, -- Tile 12 -} -local textColor={ - [-2]=COLOR.dR, - [-1]=COLOR.lD, - {.26, .66, .26}, - {.26, .26, .66}, - {.66, .46, .20}, - {.62, .20, .20}, - {.00, .48, .08}, - {.60, .14, .60}, - {.62, .32, .26}, - {.60, .00, .00}, - {.58, .58, .20}, - {.52, .20, .00}, - {.52, .36, .20}, - {.08, .80, .34}, -} local tileTexts=setmetatable({ - [-2]="B", - [-1]="×", -},{__index=function(self,k) self[k]=k return k end}) + [-9]=CHAR.icon.star, + [-7]=CHAR.icon.upload, + [-5]=CHAR.icon.bombBlock, + [-3]=CHAR.icon.star, + [-2]=CHAR.icon.moon, + [-1]=CHAR.icon.sun_strong, +},{__index=function(t,k) t[k]=k return k end}) +local colors=setmetatable({ + [-9]={COLOR.Y,COLOR.DY}, -- Star + [-7]={COLOR.dL,COLOR.LD}, -- Shovel + [-5]={COLOR.R,COLOR.dR}, -- Bomb + [-3]={COLOR.DL,COLOR.lD}, -- Statue lv1 + [-2]={COLOR.DL,COLOR.lD}, -- Statue lv2 + [-1]={COLOR.DL,COLOR.lD}, -- Statue lv3 + {{.39, 1.0, .39},{.26, .66, .26}}, -- Tile 1 + {{.39, .39, 1.0},{.26, .26, .66}}, -- Tile 2 + {{1.0, .70, .31},{.66, .46, .20}}, -- Tile 3 + {{.94, .31, .31},{.62, .20, .20}}, -- Tile 4 + {{.00, .71, .12},{.00, .48, .08}}, -- Tile 5 + {{.90, .20, .90},{.60, .14, .60}}, -- Tile 6 + {{.94, .47, .39},{.62, .32, .26}}, -- Tile 7 + {{.90, .00, .00},{.60, .00, .00}}, -- Tile 8 + {{.86, .86, .31},{.58, .58, .20}}, -- Tile 9 + {{.78, .31, .00},{.52, .20, .00}}, -- Tile 10 +},{ + __index=function(t,k) + t[k]={COLOR.random(5),COLOR.random(4)} + return t[k] + end +}) -local player={x=340,y=90} +local P={x=350,y=50,w=900,h=900} +P.c=P.w/6 -function player:newTile() +function P:getHolyPoint() + local holy=0 + for y=1,6 do for x=1,6 do + local b=self.board[y][x] + if b and b<0 then + holy=holy+(b<=-2 and b+4 or 10) + end + end end + return holy +end +function P:newTile() local r=rnd() - if r<.006 then - return self.maxTile - elseif r<.026 then - return -2 - else + -- do return -3 end + -- do return -5 end + -- do return -7 end + -- do return -9 end + -- Holy point will make value smaller, cause larger probability of special items + r=r*(1-math.min(P:getHolyPoint(),26)*.026) + if r<.005-P:getHolyPoint()*.0005 then -- 0.5% (→0%) chance of statue, each holy point make it 0.05% lower + return -3 + elseif r<.010 then -- 0.5% (→1%) chance of star + return -9 + elseif r<.015 then -- 0.5% chance of shovel + return -7 + elseif r<.026 then -- 1.1% chance of bomb + return -5 + else -- 97.4% chance of normal tile, max at 6 local t=1 - if rnd()<.3 then - t=t+1 - if rnd()<.3 then t=t+1 end - end - if self.maxTile>=4 and rnd()<.3 then - t=t+1 - if self.maxTile>=6 and rnd()<.3 then - t=t+1 - if self.maxTile>=8 and rnd()<.3 then - t=t+1 - end - end - end + if rnd()<.12 then t=t+1 end + if rnd()<.26 then t=t+1 end + if self.maxTile>=4 and rnd()<.26 then t=t+1 end + if self.maxTile>=6 and rnd()<.26 then t=t+1 end + if self.maxTile>=8 and rnd()<.42 then t=t+1 end + if self.maxTile>=10 and rnd()<.62 then t=t+1 end return t end end -function player:reset() +function P:reset() self.progress={} self.state=0 self.time=0 @@ -78,8 +87,6 @@ function player:reset() self.score=0 self.maxTile=3 - self.nexts,self.hold={self:newTile(),self:newTile(),self:newTile()},false - self.selectX,self.selectY=false,false self.board={} for y=1,6 do self.board[y]={} @@ -88,7 +95,10 @@ function player:reset() end end self.board[1][1]=false - for _,n in next,{-1,-1,1,1,2,2,3,3} do + self.nexts,self.holdTile={self:newTile(),self:newTile(),self:newTile()},false + self.selectX,self.selectY=false,false + + for _,n in next,{-3,-3,1,1,2,2,3,3} do local x,y repeat x,y=rnd(6),rnd(6) @@ -97,68 +107,146 @@ function player:reset() end end -function player:merge(b,v,y,x) +local function merge(b,v,x,y,l) if b[y] and v==b[y][x] then - ins(self.mergedTiles,{y,x}) + ins(l,{x,y}) b[y][x]=0 - return 1 - +self:merge(b,v,y,x-1) - +self:merge(b,v,y,x+1) - +self:merge(b,v,y-1,x) - +self:merge(b,v,y+1,x) - else - return 0 + merge(b,v,x,y-1,l) + merge(b,v,x,y+1,l) + merge(b,v,x-1,y,l) + merge(b,v,x+1,y,l) end end -local function availablePos(b,t) +function P:canPlaceAt(x,y) + local old=self.board[y or self.selectY][x or self.selectX] + local new=self.nexts[1] return - t>0 and b==0 or - t==-2 and b~=0 + new==-9 and old==0 or -- Star + new==-7 and old~=0 or -- Shovel + new==-5 and old~=0 or -- Bomb + + new==-3 and old==0 or -- Statue lv1 + new==-2 and old==0 or -- Statue lv2 + new==-1 and old==0 or -- Statue lv3 + + new==0 and false or + + new>0 and old==0 end -local function newMergeFX(y,x,tile) +function P:newMergeFX(x,y,tile) local r,g,b - if tile==-2 then r,g,b=1,.6,.3 end - SYSFX.rect(.26,player.x+100*x-100,player.y+100*y-100,100,100,r,g,b) + if tile==-5 then + -- Bomb + r,g,b=1,.6,.26 + elseif tile==-7 then + -- Shovel + r,g,b=.42,.42,.42 + elseif tile==-9 then + -- Star + r,g,b=1,1,.26 + end + SYSFX.rect(.26,self.x+self.c*(x-1),self.y+self.c*(y-1),self.c,self.c,r,g,b) end -function player:click(y,x) - if y==1 and x==1 then - self.nexts[1],self.hold=self.hold,self.nexts[1] - FMOD.effect('hold') - if not self.nexts[1] then - rem(self.nexts,1) - ins(self.nexts,self:newTile()) - end - elseif y~=self.selectY or x~=self.selectX then - if availablePos(self.board[y][x],self.nexts[1]) then - self.selectX,self.selectY=x,y - else - self.selectX,self.selectY=false,false +function P:select(x,y) + if self:canPlaceAt(x,y) then + self.selectX,self.selectY=x,y + else + self.selectX,self.selectY=false,false + end +end +function P:hold() + self.nexts[1],self.holdTile=self.holdTile,self.nexts[1] + FMOD.effect('hold') + if not self.nexts[1] then + rem(self.nexts,1) + ins(self.nexts,self:newTile()) + end +end +function P:legalTile(x,y) + local b=self.board + local n=b[y] and b[y][x] + return n and n~=0 +end +function P:calculateStar(x,y) -- Star will choose the best tile around + local b=self.board + local choice={} + if self:legalTile(x-1,y) then ins(choice,b[y][x-1]) end + if self:legalTile(x+1,y) then ins(choice,b[y][x+1]) end + if self:legalTile(x,y-1) then ins(choice,b[y-1][x]) end + if self:legalTile(x,y+1) then ins(choice,b[y+1][x]) end + if #choice==0 then + return -3 + else + for i=1,#choice do + local c={tile=choice[i],score=choice[i]} + choice[i]=c + + -- Simulate merging + local b1,mergedTiles=TABLE.copy(self.board),{} + b1[y][x]=c.tile + merge(b1,c.tile,x,y,mergedTiles) + + -- Change to statue 1 if no merging + if #mergedTiles<3 then + c.tile=-3 + c.score=-1e99 + end end - elseif y==self.selectY and x==self.selectX then - if not availablePos(self.board[y][x],self.nexts[1]) then return end + table.sort(choice,function(c1,c2) return c1.score>c2.score end) + return choice[1].tile + end +end +function P:click(x,y) + if x==1 and y==1 then + -- Hold + self:hold() + elseif not (x==self.selectX and y==self.selectY) then + -- Select + self:select(x,y) + else + -- Confirm + if not self:canPlaceAt() then return end if self.state==0 then self.state=1 self.startTime=love.timer.getTime() end - if self.nexts[1]==-2 then + if self.nexts[1]==-5 then + -- Bomb self.board[y][x]=0 FMOD.effect('clear_2') rem(self.nexts,1) ins(self.nexts,self:newTile()) - newMergeFX(y,x,-2) + self:newMergeFX(x,y,-2) + elseif self.nexts[1]==-7 then + -- Shovel + self.nexts[1]=self.board[y][x] + self.board[y][x]=0 + self:newMergeFX(x,y,-3) + FMOD.effect('hold_init') else + -- Normal tile + if self.nexts[1]==-9 then + self.nexts[1]=self:calculateStar(x,y) + print(self.nexts[1]) + FMOD.effect('rotate_special') + end self.board[y][x]=rem(self.nexts,1) - FMOD.effect('touch') + FMOD.effect('move') local cur,merged + local textDY=.42 repeat - local b1=TABLE.copy(self.board) - cur=b1[y][x] - self.mergedTiles={} - local count=self:merge(b1,cur,y,x) - if count>2 then + cur=self.board[y][x] + if cur==0 then -- Possible when merging Statue lv3 + TEXT:add{text=CHAR.zchan.mrz,x=P.x+(self.selectX-.5)*self.c,y=P.y+(self.selectY-.4)*self.c,fontSize=100,style='score',duration=6.26} + break + end + local b1,mergedTiles=TABLE.copy(self.board),{} + merge(b1,cur,x,y,mergedTiles) + local count=#mergedTiles + if count>=3 then merged=true self.board=b1 b1[y][x]=cur+1 @@ -166,16 +254,17 @@ function player:click(y,x) if cur+1>self.maxTile then self.maxTile=cur+1 if self.maxTile>=6 then - ins(self.progress,("%s - %.3fs"):format(self.maxTile,love.timer.getTime()-player.startTime)) + ins(self.progress,("%s - %.3fs"):format(self.maxTile,love.timer.getTime()-P.startTime)) end FMOD.effect('beep_rise') end - local getScore=4^cur*count + local getScore=4^(cur>0 and cur or cur+10)*count self.score=self.score+getScore - TEXT:add(getScore,player.x+self.selectX*100-50,player.y+self.selectY*100-50,40,'score',1.626/math.log(getScore,3)) - for i=1,#self.mergedTiles do - newMergeFX(self.mergedTiles[i][1],self.mergedTiles[i][2],cur+1) + TEXT:add{text=getScore,x=P.x+(self.selectX-.5)*self.c,y=P.y+(self.selectY-.5-textDY)*self.c,fontSize=60,style='score',duration=math.log(getScore,3)/1.626} + textDY=textDY+.26 + for i=1,#mergedTiles do + self:newMergeFX(mergedTiles[i][1],mergedTiles[i][2],cur+1) end end until count<=2 @@ -185,79 +274,89 @@ function player:click(y,x) self.selectX,self.selectY=false,false if merged then - FMOD.effect('lock') + FMOD.effect('touch') if cur>=4 then FMOD.effect( - cur>=8 and 'ren_mega' or + cur>=8 and 'spin_4' or cur>=7 and 'spin_3' or cur>=6 and 'spin_2' or cur>=5 and 'spin_1' or 'spin_0' ) end - else - for i=1,6 do - if TABLE.find(self.board[i],0) then - return - end - end + else -- Alive checking + -- Having bomb? + if self.nexts[1]==-5 or self.holdTile==-5 then return end + + -- Any space? + for i=1,6 do if TABLE.find(self.board[i],0) then return end end + self.state=2 FMOD.effect('fail') end end - else - self.selectX,self.selectY=x,y end end -local function drawTile(x,y,v) - if v and v~=0 then - gc_setColor(tileColor[v]) - gc_rectangle('fill',x*100-100,y*100-100,100,100) - gc_setColor(textColor[v]) - mStr(tileTexts[v],x*100-50,y*100-92) +function P:drawTile(x,y,val,size) + if val and val~=0 then + gc.push('transform') + gc.translate((x-.5)*self.c,(y-.5)*self.c) + gc.scale(size) + gc_setColor(colors[val][1]) + gc_rectangle('fill',-self.c/2,-self.c/2,self.c,self.c) + gc_setColor(colors[val][2]) + mStr(tileTexts[val],0,-50) + gc.pop() end end -function player:drawBoard() +function P:draw() gc.push('transform') - gc.translate(self.x,self.y) - - -- Board background - gc_setColor(COLOR.dX) - gc_rectangle('fill',0,0,600,600) - - - -- Hold slot - gc_setColor(0,1,1,.4) - gc_rectangle('fill',0,0,100,100) - gc.setLineWidth(10) - gc_setColor(COLOR.lC) - gc_rectangle('line',5,5,90,90) - - -- Hold tile - setFont(60) - drawTile(1,1,self.hold) + gc.translate(self.x,self.y) + + -- Board background + gc_setColor(COLOR.dX) + gc_rectangle('fill',0,0,self.w,self.h) + + -- Hold slot + gc_setColor(COLOR.lC) + gc_rectangle('fill',0,0,self.c,self.c) + gc_setColor(COLOR.C) + gc_rectangle('fill',10,10,self.c-20,self.c-20) + + setFont(75) + + -- Hold tile + self:drawTile(1,1,self.holdTile,.7) + + -- Board tiles + local b=self.board + for y=1,6 do for x=1,6 do + self:drawTile(x,y,b[y][x],1) + end end + + -- Board lines + gc_setColor(COLOR.L) + gc.setLineWidth(2) + for x=0,6 do gc.line(x*self.c,0,x*self.c,P.w) end + for y=0,6 do gc.line(0,y*self.c,P.w,y*self.c) end + + -- Cursor + if self.selectX then + local c=colors[self.nexts[1]][1] + gc.setLineWidth(10) + gc_setColor(c[1],c[2],c[3],.6+.3*math.sin(love.timer.getTime()*9.29)) + gc_rectangle('line',(self.selectX-1)*self.c+10,(self.selectY-1)*self.c+10,self.c-20,self.c-20) + end - -- Board tiles - local b=self.board - for y=1,6 do for x=1,6 do - drawTile(x,y,b[y][x]) - end end + -- Previews + self:drawTile(-0.62,2.6,P.nexts[1],.8) + self:drawTile(-0.72,3.4,P.nexts[2],.6) + self:drawTile(-0.82,4.0,P.nexts[3],.4) - -- Board lines - gc_setColor(COLOR.L) - gc.setLineWidth(2) - for x=1,5 do gc.line(x*100,0,x*100,600) end - for y=1,5 do gc.line(0,y*100,600,y*100) end - gc.setLineWidth(6) - gc_rectangle('line',0,0,600,600) - - -- Select box - if self.selectX then - local c=tileColor[self.nexts[1]] - gc_setColor(c[1],c[2],c[3],.6+.3*math.sin(love.timer.getTime()*9.29)) - gc_rectangle('line',self.selectX*100-95,self.selectY*100-95,90,90) - end + setFont(25,'bold') + gc_setColor(COLOR.L) + mStr("Current",-166,220) gc.pop() end @@ -266,45 +365,54 @@ end local scene={} function scene.enter() - player:reset() + P:reset() end -function scene.mouseClick(x,y) - x,y=floor((x-player.x)/100)+1,floor((y-player.y)/100)+1 - if x>=1 and x<=6 and y>=1 and y<=6 then - player:click(y,x) +function scene.mouseMove(x,y) + x,y=floor((x-P.x)/P.c)+1,floor((y-P.y)/P.c)+1 + if MATH.between(x,1,6) and MATH.between(y,1,6) then + P:select(x,y) + end +end +function scene.mouseDown(x,y,k) + if k==1 then + x,y=floor((x-P.x)/P.c)+1,floor((y-P.y)/P.c)+1 + if MATH.between(x,1,6) and MATH.between(y,1,6) then + P:click(x,y) + end + else + P:hold() end end function scene.touchClick(x,y) - scene.mouseClick(x,y) + x,y=floor((x-P.x)/P.c)+1,floor((y-P.y)/P.c)+1 + if MATH.between(x,1,6) and MATH.between(y,1,6) then + P:click(x,y) + end end function scene.keyDown(key,isRep) if isRep then return true end if key=='up' or key=='down' or key=='left' or key=='right' then - if not player.selectX then - player.selectX,player.selectY=3,3 + if not P.selectX then + P.selectX,P.selectY=3,3 else - if key=='up' then player.selectY=math.max(player.selectY-1,1) - elseif key=='down' then player.selectY=math.min(player.selectY+1,6) - elseif key=='left' then player.selectX=math.max(player.selectX-1,1) - elseif key=='right' then player.selectX=math.min(player.selectX+1,6) + if key=='up' then P.selectY=math.max(P.selectY-1,1) + elseif key=='down' then P.selectY=math.min(P.selectY+1,6) + elseif key=='left' then P.selectX=math.max(P.selectX-1,1) + elseif key=='right' then P.selectX=math.min(P.selectX+1,6) end end - elseif key=='x' or key=='space' then - if not player.selectX then - player.selectX,player.selectY=3,3 - else - local y,x=player.selectY,player.selectX - player:click(player.selectY,player.selectX) - player.selectY,player.selectX=y,x + elseif key=='z' then + P:hold() + elseif key=='space' then + if P.selectX then + local y,x=P.selectY,P.selectX + P:click(P.selectX,P.selectY) + P.selectY,P.selectX=y,x end - elseif key=='w' then - love.mousepressed(love.mouse.getPosition()) - elseif key=='z' or key=='q' then - player:click(1,1) elseif key=='r' then - if player.state~=1 or sureCheck('reset') then - player:reset() + if P.state~=1 or sureCheck('reset') then + P:reset() end elseif key=='escape' then if sureCheck('back') then SCN.back() end @@ -313,39 +421,25 @@ function scene.keyDown(key,isRep) end function scene.update() - if player.state==1 then - player.time=love.timer.getTime()-player.startTime + if P.state==1 then + P.time=love.timer.getTime()-P.startTime end end function scene.draw() setFont(40) gc_setColor(1,1,1) - gc.print(("%.3f"):format(player.time),1026,50) - gc.print(player.score,1026,100) + gc.print(STRING.time(P.time),1326,50) + gc.print(P.score,1326,100) -- Progress time list setFont(25) gc_setColor(.7,.7,.7) - for i=1,#player.progress do - gc.print(player.progress[i],1000,140+30*i) + for i=1,#P.progress do + gc.print(P.progress[i],1326,140+30*i) end - gc.push('transform') - gc.translate(745,13) - gc_setColor(COLOR.L) - gc.setLineWidth(4) - gc.rectangle('line',-5,-5,200,70) - for i=1,3 do - gc_setColor(tileColor[player.nexts[i]]) - gc_rectangle('fill',65*i-65,0,60,60) - setFont(40) - gc_setColor(textColor[player.nexts[i]]) - mStr(player.nexts[i],65*i-35,0) - end - gc.pop() - - player:drawBoard() + P:draw() end scene.widgetList={