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 end
function Ovella:draw() 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) love.graphics.draw(self.sprite, self.x, self.y)
end
end end
return Ovella return Ovella

View File

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