Fix small errors in player sprite location on <standard size

This commit is contained in:
Juhani Krekelä 2019-06-30 19:46:33 +03:00
parent 32a9d7627a
commit 6740c59e8f
1 changed files with 20 additions and 8 deletions

View File

@ -918,18 +918,30 @@ function drawPlayer()
local rotation = nil
if player_direction == directions.up then
rotation = 0
x = x + scale/2
y = y + scale
if player_animation_flip then
x = x + scale
end
elseif player_direction == directions.left then
rotation = math.pi * 1.5
x = x + scale
y = y + scale/2
if not player_animation_flip then
y = y + scale
end
elseif player_direction == directions.down then
rotation = math.pi
x = x + scale/2
if not player_animation_flip then
x = x + scale
y = y + scale
else
y = y + scale
end
elseif player_direction == directions.right then
rotation = math.pi * 0.5
y = y + scale/2
if not player_animation_flip then
x = x + scale
else
x = x + scale
y = y + scale
end
else
error("Player facing a direction without usable sprite")
end
@ -937,9 +949,9 @@ function drawPlayer()
-- Our sprite image is drawn assuming 16 pixels per tile
love.graphics.setColor(1, 1, 1)
if not player_animation_flip then
love.graphics.draw(sprite, x, y, rotation, scale/16, scale/16, scale/2, scale)
love.graphics.draw(sprite, x, y, rotation, scale/16, scale/16)
else
love.graphics.draw(sprite, x, y, rotation, -scale/16, scale/16, scale/2, scale)
love.graphics.draw(sprite, x, y, rotation, -scale/16, scale/16)
end
end