summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-08-13 21:13:31 +0200
committerAki <nthirtyone@gmail.com>2016-08-13 21:13:31 +0200
commit99d537f66d34c5e87e4e395942a4241eeebd2b12 (patch)
treefe9ca1482710d32d69ff0c12cb405618179cfa3f
parent9f4ba7732c280ff1ef3bb810942d46378dc21e63 (diff)
downloadroflnauts-99d537f66d34c5e87e4e395942a4241eeebd2b12.zip
roflnauts-99d537f66d34c5e87e4e395942a4241eeebd2b12.tar.gz
roflnauts-99d537f66d34c5e87e4e395942a4241eeebd2b12.tar.bz2
Effects draw grid
-rw-r--r--effect.lua13
1 files 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