Solucionado que apareceran as ovellas enriba do cercado

This commit is contained in:
serxoz 2022-07-04 16:34:51 +02:00
parent 8135d6a454
commit bb2e13d34d
2 changed files with 25 additions and 5 deletions

View File

@ -77,8 +77,28 @@ function Ovella:update(pastor, cercado)
end
function Ovella:draw()
love.graphics.draw(self.sprite, self.x, self.y)
function Ovella:draw(cercado)
-- love.graphics.draw(self.sprite, self.x, self.y)
local solapase = false
for y = 1,cercado.filas do
for x = 1,cercado.columnas do
if cercado.tiles[y][x].sprite then
-- print(Helpers:CheckCollision(self, cercado.tiles[y][x]))
-- if Helpers:CheckCollision(futuro, cercado.tiles[y][x]) then
if Helpers:CheckCollision( cercado.tiles[y][x],self) then
solapase = true
-- FIXME movo a ovella en diagonal para quitala de enriba
-- do cercado
self.x = self.x+50
self.y = self.y+50
end
end
end
end
if not solapase then
love.graphics.draw(self.sprite, self.x, self.y)
end
end
return Ovella

View File

@ -63,9 +63,9 @@ function love.draw()
-- ovellas
for i = 1, #ovellas,1 do --itera sobre cada ovella na tabla
-- print(inspect(ovellas[i]))
ovellas[i]:draw()
ovellas[i]:draw(cercado)
end
love.graphics.print("Ovellas recollidas: 0", 10, 10)
end
@ -74,7 +74,7 @@ function love.update(dt)
world:update(dt)
--- update player object
player:update(dt, cercado)
player:update(dt, cercado)
-- update ovella object
for i = 1, #ovellas,1 do --itera sobre cada ovella na tabla
ovellas[i]:update(player, cercado)