From 99d537f66d34c5e87e4e395942a4241eeebd2b12 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 13 Aug 2016 21:13:31 +0200 Subject: Effects draw grid --- effect.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/effect.lua b/effect.lua index 31d20a4..c80ffc7 100644 --- a/effect.lua +++ b/effect.lua @@ -32,6 +32,11 @@ function Effect:new(name, x, y) return o end +-- Position +function Cloud:getPosition() + return self.x, self.y +end + -- Animation and return flag for deletion after completion -- returns true if completed and ready to delete function Effect:update(dt) @@ -49,11 +54,15 @@ end -- Draw me with scale and offsets, senpai function Effect:draw(offset_x, offset_y, scale) - -- defaults + -- locals local offset_x = offset_x or 0 local offset_y = offset_y or 0 local scale = scale or 1 + 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 -- draw love.graphics.setColor(255,255,255,255) - love.graphics.draw(self.sprite, self.quads[self.animation][self.frame], (self.x+offset_x)*scale, (self.y+offset_y)*scale, 0, scale, scale) + love.graphics.draw(self.sprite, self.quads[self.animation][self.frame], draw_x, draw_y, 0, scale, scale) end \ No newline at end of file -- cgit v1.1