Integrate player sprites.

This commit is contained in:
Gonzalo Delgado 2023-08-31 08:36:36 -03:00
parent 8299a7c300
commit f4c0dafa31
2 changed files with 9 additions and 8 deletions

View File

@ -89,6 +89,11 @@ function love.load()
end
end
end
player.sprites = love.graphics.newImage("player-sprites.png")
player.quads = {
dude=love.graphics.newQuad(17, 9, 15, 23, player.sprites),
turtle=love.graphics.newQuad(0, 23, 17, 9, player.sprites),
}
end
@ -247,21 +252,17 @@ function love.draw()
if player.dead then
love.graphics.setColor(0.8, 0.1, 0)
else
love.graphics.setColor(0.9, 0.6, 0.1)
love.graphics.setColor(1, 1, 1)
end
local x, y = player.pos.x, player.pos.y
love.graphics.circle("fill", x + game.TILE_SIZE/2, y + game.TILE_SIZE/2, game.TILE_SIZE/2)
love.graphics.setColor(0.2, 0.1, 0.1)
love.graphics.circle("line", x + game.TILE_SIZE/2, y + game.TILE_SIZE/2, game.TILE_SIZE/2)
love.graphics.draw(player.sprites, player.quads.dude, x, y - 8)
x, y = player.turtlePos.x, player.turtlePos.y
love.graphics.setColor(0.2, 0.1, 0.1)
love.graphics.circle("line", x + game.TILE_SIZE/2, y + game.TILE_SIZE/2, game.TILE_SIZE/2)
if player.turtleHit then
love.graphics.setColor(0.8, 0.1, 0)
else
love.graphics.setColor(0, 0.7, 0.2)
love.graphics.setColor(1, 1, 1)
end
love.graphics.circle("fill", x + game.TILE_SIZE/2, y + game.TILE_SIZE/2, game.TILE_SIZE/2)
love.graphics.draw(player.sprites, player.quads.turtle, x, y + 4)
-- </playfield>
love.graphics.pop()
end

BIN
player-sprites.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB