调整小程序triple
This commit is contained in:
@@ -7,22 +7,24 @@ local ins,rem=table.insert,table.remove
|
|||||||
local setFont,mStr=FONT.set,GC.mStr
|
local setFont,mStr=FONT.set,GC.mStr
|
||||||
|
|
||||||
local tileColor={
|
local tileColor={
|
||||||
[-1]=COLOR.H,
|
[-2]=COLOR.R, --Bomb
|
||||||
{.39, 1.0, .39},
|
[-1]=COLOR.H, --Stone
|
||||||
{.39, .39, 1.0},
|
{.39, 1.0, .39},--Tile 1
|
||||||
{1.0, .70, .31},
|
{.39, .39, 1.0},--Tile 2
|
||||||
{.94, .31, .31},
|
{1.0, .70, .31},--Tile 3
|
||||||
{.00, .71, .12},
|
{.94, .31, .31},--Tile 4
|
||||||
{.90, .20, .90},
|
{.00, .71, .12},--Tile 5
|
||||||
{.94, .47, .39},
|
{.90, .20, .90},--Tile 6
|
||||||
{.90, .00, .00},
|
{.94, .47, .39},--Tile 7
|
||||||
{.86, .86, .31},
|
{.90, .00, .00},--Tile 8
|
||||||
{.78, .31, .00},
|
{.86, .86, .31},--Tile 9
|
||||||
{.78, .55, .04},
|
{.78, .31, .00},--Tile 10
|
||||||
{.12, .12, .51},
|
{.78, .55, .04},--Tile 11
|
||||||
|
{.12, .12, .51},--Tile 12
|
||||||
}
|
}
|
||||||
local textColor={
|
local textColor={
|
||||||
[-1]=COLOR.D,
|
[-2]=COLOR.dR,
|
||||||
|
[-1]=COLOR.dH,
|
||||||
{.26, .66, .26},
|
{.26, .66, .26},
|
||||||
{.26, .26, .66},
|
{.26, .26, .66},
|
||||||
{.66, .46, .20},
|
{.66, .46, .20},
|
||||||
@@ -43,6 +45,9 @@ local tileTexts=setmetatable({
|
|||||||
local player={x=340,y=90}
|
local player={x=340,y=90}
|
||||||
|
|
||||||
function player:newTile()
|
function player:newTile()
|
||||||
|
if rnd()<.026 then
|
||||||
|
return -2
|
||||||
|
else
|
||||||
local r=1
|
local r=1
|
||||||
if rnd()<.3 then
|
if rnd()<.3 then
|
||||||
r=r+1
|
r=r+1
|
||||||
@@ -58,6 +63,7 @@ function player:newTile()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return r
|
return r
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function player:reset()
|
function player:reset()
|
||||||
@@ -101,6 +107,16 @@ function player:merge(b,v,y,x)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function availablePos(b,t)
|
||||||
|
return
|
||||||
|
t>0 and b==0 or
|
||||||
|
t==-2 and b~=0
|
||||||
|
end
|
||||||
|
local function newMergeFX(y,x,tile)
|
||||||
|
local r,g,b
|
||||||
|
if tile==-2 then r,g,b=1,.6,.3 end
|
||||||
|
SYSFX.newShade(3,player.x+100*x-100,player.y+100*y-100,100,100,r,g,b)
|
||||||
|
end
|
||||||
function player:click(y,x)
|
function player:click(y,x)
|
||||||
if y==1 and x==1 then
|
if y==1 and x==1 then
|
||||||
self.nexts[1],self.hold=self.hold,self.nexts[1]
|
self.nexts[1],self.hold=self.hold,self.nexts[1]
|
||||||
@@ -109,14 +125,26 @@ function player:click(y,x)
|
|||||||
rem(self.nexts,1)
|
rem(self.nexts,1)
|
||||||
ins(self.nexts,self:newTile())
|
ins(self.nexts,self:newTile())
|
||||||
end
|
end
|
||||||
elseif self.board[y][x]~=0 then
|
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
|
self.selectX,self.selectY=false,false
|
||||||
|
end
|
||||||
elseif y==self.selectY and x==self.selectX then
|
elseif y==self.selectY and x==self.selectX then
|
||||||
|
if not availablePos(self.board[y][x],self.nexts[1])then return end
|
||||||
if self.state==0 then
|
if self.state==0 then
|
||||||
self.state=1
|
self.state=1
|
||||||
self.startTime=TIME()
|
self.startTime=TIME()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.nexts[1]==-2 then
|
||||||
|
self.board[y][x]=0
|
||||||
|
SFX.play('clear_2')
|
||||||
|
rem(self.nexts,1)
|
||||||
|
ins(self.nexts,self:newTile())
|
||||||
|
newMergeFX(y,x,-2)
|
||||||
|
else
|
||||||
self.board[y][x]=rem(self.nexts,1)
|
self.board[y][x]=rem(self.nexts,1)
|
||||||
SFX.play('touch')
|
SFX.play('touch')
|
||||||
|
|
||||||
@@ -143,7 +171,7 @@ function player:click(y,x)
|
|||||||
self.score=self.score+getScore
|
self.score=self.score+getScore
|
||||||
TEXT.show(getScore,player.x+self.selectX*100-50,player.y+self.selectY*100-50,40,'score')
|
TEXT.show(getScore,player.x+self.selectX*100-50,player.y+self.selectY*100-50,40,'score')
|
||||||
for i=1,#self.mergedTiles do
|
for i=1,#self.mergedTiles do
|
||||||
SYSFX.newShade(3,player.x+100*self.mergedTiles[i][2]-100,player.y+100*self.mergedTiles[i][1]-100,100,100)
|
newMergeFX(self.mergedTiles[i][1],self.mergedTiles[i][2],cur+1)
|
||||||
end
|
end
|
||||||
goto REPEAT_merge
|
goto REPEAT_merge
|
||||||
end
|
end
|
||||||
@@ -152,7 +180,6 @@ function player:click(y,x)
|
|||||||
|
|
||||||
self.selectX,self.selectY=false,false
|
self.selectX,self.selectY=false,false
|
||||||
|
|
||||||
print('-------------')
|
|
||||||
if merged then
|
if merged then
|
||||||
SFX.play('lock')
|
SFX.play('lock')
|
||||||
if cur>=4 then
|
if cur>=4 then
|
||||||
@@ -167,13 +194,13 @@ function player:click(y,x)
|
|||||||
else
|
else
|
||||||
for i=1,6 do
|
for i=1,6 do
|
||||||
if TABLE.find(self.board[i],0)then
|
if TABLE.find(self.board[i],0)then
|
||||||
print(i,TABLE.find(self.board[i],0))
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.state=2
|
self.state=2
|
||||||
SFX.play('fail')
|
SFX.play('fail')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
self.selectX,self.selectY=x,y
|
self.selectX,self.selectY=x,y
|
||||||
end
|
end
|
||||||
@@ -187,7 +214,6 @@ local function drawTile(x,y,v)
|
|||||||
mStr(tileTexts[v],x*100-50,y*100-92)
|
mStr(tileTexts[v],x*100-50,y*100-92)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function player:drawBoard()
|
function player:drawBoard()
|
||||||
gc.push('transform')
|
gc.push('transform')
|
||||||
gc.translate(self.x,self.y)
|
gc.translate(self.x,self.y)
|
||||||
|
|||||||
Reference in New Issue
Block a user