Added arrows to show which player should play
This commit is contained in:
parent
18101c4f43
commit
b4ea49bee8
BIN
assets/arrows/blue.png
Normal file
BIN
assets/arrows/blue.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 828 B |
BIN
assets/arrows/pink.png
Normal file
BIN
assets/arrows/pink.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.9 KiB |
@ -7,6 +7,12 @@ function gridgen:new(game,x,y,cellsize)
|
|||||||
Grid.sprites = {game:newImage("grid/tile.png"),game:newImage("grid/pink.png"),game:newImage("grid/blue.png")}
|
Grid.sprites = {game:newImage("grid/tile.png"),game:newImage("grid/pink.png"),game:newImage("grid/blue.png")}
|
||||||
Grid.pinkturn = game:newImage("text/turn/pink.png")
|
Grid.pinkturn = game:newImage("text/turn/pink.png")
|
||||||
Grid.blueturn = game:newImage("text/turn/blue.png")
|
Grid.blueturn = game:newImage("text/turn/blue.png")
|
||||||
|
Grid.bluearrows = game:Timer(1)
|
||||||
|
Grid.pinkarrows = game:Timer(1)
|
||||||
|
Grid.bluearrows.loops = -1
|
||||||
|
Grid.pinkarrows.loops = 1
|
||||||
|
Grid.bluearrowsprite = game:newImage("arrows/blue.png")
|
||||||
|
Grid.pinkarrowsprite = game:newImage("arrows/pink.png")
|
||||||
Grid:register("Grid")
|
Grid:register("Grid")
|
||||||
Grid.depth = -1
|
Grid.depth = -1
|
||||||
Grid.turn= 3
|
Grid.turn= 3
|
||||||
@ -35,11 +41,25 @@ function gridgen:new(game,x,y,cellsize)
|
|||||||
if winner~="None" then
|
if winner~="None" then
|
||||||
self:endgame(winner)
|
self:endgame(winner)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.pinkarrows.loops<1 then self.pinkarrows:tick(dt) end
|
||||||
|
if self.bluearrows.loops<1 then self.bluearrows:tick(dt) end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Grid:addturn()
|
function Grid:addturn()
|
||||||
|
local pastturn = self.turn
|
||||||
self.turn = self.turn + 1
|
self.turn = self.turn + 1
|
||||||
self.turn = self.turn%4
|
self.turn = self.turn%4
|
||||||
|
-- Check for arrow animation
|
||||||
|
if math.floor(pastturn/2)%2~=math.floor(self.turn/2)%2 then
|
||||||
|
if self.turn<2 then
|
||||||
|
-- Trigger pink arrows
|
||||||
|
self.pinkarrows.loops = 0
|
||||||
|
else
|
||||||
|
-- Trigger blue arrows
|
||||||
|
self.bluearrows.loops = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
-- Check if a move can be made
|
-- Check if a move can be made
|
||||||
local color = "blue"
|
local color = "blue"
|
||||||
if self.turn%2==1 then
|
if self.turn%2==1 then
|
||||||
@ -49,8 +69,7 @@ function gridgen:new(game,x,y,cellsize)
|
|||||||
end
|
end
|
||||||
local count = 0
|
local count = 0
|
||||||
local i
|
local i
|
||||||
local obj = self.game:findName(color)
|
local obj = self.game:findName(color) for i=1,#obj do
|
||||||
for i=1,#obj do
|
|
||||||
count = count + #obj[i]:findAvailableMoves()
|
count = count + #obj[i]:findAvailableMoves()
|
||||||
end
|
end
|
||||||
if count==0 then
|
if count==0 then
|
||||||
@ -86,6 +105,32 @@ function gridgen:new(game,x,y,cellsize)
|
|||||||
-- Draw "Blue's turn"
|
-- Draw "Blue's turn"
|
||||||
lg.draw(self.blueturn,(self.game.WIDTH-self.blueturn:getWidth())/2,self.game.HEIGHT-self.blueturn:getHeight())
|
lg.draw(self.blueturn,(self.game.WIDTH-self.blueturn:getWidth())/2,self.game.HEIGHT-self.blueturn:getHeight())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Draw arrows
|
||||||
|
local i=0
|
||||||
|
local margin = 50
|
||||||
|
for i=0,1 do
|
||||||
|
local offx = margin
|
||||||
|
if i==1 then offx = game.WIDTH-margin-self.pinkarrowsprite:getWidth() end
|
||||||
|
|
||||||
|
-- Draw pink arrows
|
||||||
|
if self.pinkarrows.loops==0 then
|
||||||
|
local offy = -margin
|
||||||
|
local movement = (game.HEIGHT+margin*2)*self:easing(self.pinkarrows:getratio())
|
||||||
|
lg.draw(self.pinkarrowsprite,offx,offy+movement)
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.bluearrows.loops==0 then
|
||||||
|
local offy = game.HEIGHT+margin
|
||||||
|
local movement = -(game.HEIGHT+margin*2)*self:easing(self.bluearrows:getratio())
|
||||||
|
lg.draw(self.bluearrowsprite,offx,offy+movement)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Grid:easing(x)
|
||||||
|
return 1-(1-x)*(1-x)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Grid
|
return Grid
|
||||||
|
Loading…
Reference in New Issue
Block a user