From f7811309bcdb66467aed6a5c8c3870d646b5783a Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 13 Aug 2016 18:19:34 +0200 Subject: floored grid for players and platforms --- player.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'player.lua') diff --git a/player.lua b/player.lua index d1ce62e..324f3ef 100644 --- a/player.lua +++ b/player.lua @@ -293,14 +293,18 @@ end -- Draw of `Player` function Player:draw (offset_x, offset_y, scale, debug) - -- defaults + -- locals local offset_x = offset_x or 0 local offset_y = offset_y or 0 local scale = scale or 1 local debug = debug or false + local x, y = self:getPosition() + -- pixel grid + local draw_x = (math.floor(x) + offset_x) * scale + local draw_y = (math.floor(y) + offset_y) * scale -- sprite draw love.graphics.setColor(255,255,255,255) - love.graphics.draw(self.sprite, self.current[self.frame], (self.body:getX()+offset_x)*scale, (self.body:getY()+offset_y)*scale, self.rotate, self.facing*scale, 1*scale, 12, 15) + love.graphics.draw(self.sprite, self.current[self.frame], draw_x, draw_y, self.rotate, self.facing*scale, 1*scale, 12, 15) -- debug draw if debug then love.graphics.setColor(137, 255, 0, 140) -- cgit v1.1