summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-08-13 21:12:17 +0200
committerAki <nthirtyone@gmail.com>2016-08-13 21:12:17 +0200
commit9f4ba7732c280ff1ef3bb810942d46378dc21e63 (patch)
tree5e880d736e983e487f402e26947d68ef9fc2d01e
parentf7811309bcdb66467aed6a5c8c3870d646b5783a (diff)
downloadroflnauts-9f4ba7732c280ff1ef3bb810942d46378dc21e63.zip
roflnauts-9f4ba7732c280ff1ef3bb810942d46378dc21e63.tar.gz
roflnauts-9f4ba7732c280ff1ef3bb810942d46378dc21e63.tar.bz2
Clouds draw grid
-rw-r--r--cloud.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/cloud.lua b/cloud.lua
index 30cb849..c12e236 100644
--- a/cloud.lua
+++ b/cloud.lua
@@ -36,6 +36,11 @@ function Cloud:new(x, y, t, v)
return o
end
+-- Position
+function Cloud:getPosition()
+ return self.x, self.y
+end
+
-- Update of `Cloud`, returns x for world to delete cloud after reaching right corner
function Cloud:update(dt)
self.x = self.x + self.v*dt
@@ -44,11 +49,15 @@ end
-- Draw `Cloud`
function Cloud: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.t], (self.x+offset_x)*scale, (self.y+offset_y)*scale, 0, scale, scale)
+ love.graphics.draw(self.sprite, self.quads[self.t], draw_x, draw_y, 0, scale, scale)
end \ No newline at end of file