From f394c1e293e0da77514e03441cf3867ff70f6fbc Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 9 Feb 2017 15:00:45 +0100 Subject: Fixed floating characters bug --- player.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/player.lua b/player.lua index b6d4e3f..6195da6 100644 --- a/player.lua +++ b/player.lua @@ -292,9 +292,11 @@ function Player:draw(offset_x, offset_y, scale, debug) local scale = scale or 1 local debug = debug or false local x, y = self:getPosition() - -- pixel grid + -- pixel grid ; `approx` selected to prevent floating characters on certain conditions + local approx = math.floor + if (y - math.floor(y)) > 0.5 then approx = math.ceil end + local draw_y = (approx(y) + offset_y) * scale local draw_x = (math.floor(x) + offset_x) * scale - local draw_y = (math.floor(y) + offset_y) * scale -- sprite draw Animated.draw(self, draw_x, draw_y, self.rotate, self.facing*scale, scale, 12, 15) -- debug draw -- cgit v1.1