Animation for position hints
This commit is contained in:
parent
e2b4da9828
commit
18101c4f43
@ -9,16 +9,22 @@ function gen:new(game,x,y,color,grid)
|
||||
Circle.grid = grid
|
||||
Circle.color = color
|
||||
Circle.shadowsprite = game:newImage("circles/shadow.png")
|
||||
Circle.shadowpos = {}
|
||||
Circle.moves = {}
|
||||
Circle.sprites = {game:newImage("circles/regular/"..color..".png"),game:newImage("circles/selected/"..color..".png")}
|
||||
Circle:register("Circle")
|
||||
Circle:register(color)
|
||||
Circle.selected = false
|
||||
Circle:register(color) Circle.selected = false
|
||||
Circle.highlight = false
|
||||
Circle.highlightTimer = game:Timer(0.08)
|
||||
|
||||
function Circle:step(dt)
|
||||
self.drawx = self.drawx + (self.rect.x-self.drawx)/10
|
||||
self.drawy = self.drawy + (self.rect.y-self.drawy)/10
|
||||
local i = 1
|
||||
for i=1,#self.moves do
|
||||
self.shadowpos[i][1]= self.shadowpos[i][1] + (self.moves[i][1]-self.shadowpos[i][1])/10
|
||||
self.shadowpos[i][2]= self.shadowpos[i][2] + (self.moves[i][2]-self.shadowpos[i][2])/10
|
||||
end
|
||||
|
||||
if self.highlight then
|
||||
self.highlightTimer:tick(dt)
|
||||
@ -41,13 +47,14 @@ function gen:new(game,x,y,color,grid)
|
||||
function Circle:draw()
|
||||
local spriteindex = 1
|
||||
if self.selected or self.highlight and self.highlightTimer.loops%2==0 then spriteindex = 2 end
|
||||
lg.draw(self.sprites[spriteindex],self.drawx-self.game.camerax-self.spriteoffx,self.drawy-self.game.cameray-self.spriteoffy)
|
||||
if self.selected then
|
||||
local i
|
||||
for i=1,#self.moves do
|
||||
lg.draw(self.shadowsprite,self.moves[i][1]-self.game.camerax-self.spriteoffx,self.moves[i][2]-self.game.cameray-self.spriteoffy)
|
||||
--lg.draw(self.shadowsprite,self.moves[i][1]-self.game.camerax-self.spriteoffx,self.moves[i][2]-self.game.cameray-self.spriteoffy)
|
||||
lg.draw(self.shadowsprite,self.shadowpos[i][1]-self.game.camerax-self.spriteoffx,self.shadowpos[i][2]-self.game.cameray-self.spriteoffy)
|
||||
end
|
||||
end
|
||||
lg.draw(self.sprites[spriteindex],self.drawx-self.game.camerax-self.spriteoffx,self.drawy-self.game.cameray-self.spriteoffy)
|
||||
end
|
||||
|
||||
function Circle:MouseCallback(x,y,presses)
|
||||
@ -58,11 +65,20 @@ function gen:new(game,x,y,color,grid)
|
||||
for i=1,#c do
|
||||
if c[i]~=self then c[i].selected = false end
|
||||
end
|
||||
local pastselected = self.selected
|
||||
self.selected = not self.selected
|
||||
self.depth = 1
|
||||
if self.selected then
|
||||
self.moves = self:findAvailableMoves()
|
||||
self.depth = 2
|
||||
if not pastselected then
|
||||
self.moves = self:findAvailableMoves()
|
||||
self.shadowpos = {}
|
||||
local i = 1
|
||||
self.shadowpos = {}
|
||||
for i=1,#self.moves do
|
||||
table.insert(self.shadowpos,{self.rect.x,self.rect.y})
|
||||
end
|
||||
self.depth = 2
|
||||
end
|
||||
end
|
||||
else
|
||||
objs = self.game:findName(self:getTurn())
|
||||
|
Loading…
Reference in New Issue
Block a user