summaryrefslogtreecommitdiffhomepage
path: root/ground.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-08-13 18:19:34 +0200
committerAki <nthirtyone@gmail.com>2016-08-13 18:19:34 +0200
commitf7811309bcdb66467aed6a5c8c3870d646b5783a (patch)
tree82895699ffbd3e555f8f3c33b7c451280a4224d2 /ground.lua
parent6018c668087bf49629fd95b3d5ca01213e4cc340 (diff)
downloadroflnauts-f7811309bcdb66467aed6a5c8c3870d646b5783a.zip
roflnauts-f7811309bcdb66467aed6a5c8c3870d646b5783a.tar.gz
roflnauts-f7811309bcdb66467aed6a5c8c3870d646b5783a.tar.bz2
floored grid for players and platforms
Diffstat (limited to 'ground.lua')
-rw-r--r--ground.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/ground.lua b/ground.lua
index 6b0be18..683966b 100644
--- a/ground.lua
+++ b/ground.lua
@@ -34,16 +34,25 @@ function Ground:delete ()
self.sprite = nil
end
+-- Position
+function Ground:getPosition()
+ return self.body:getPosition()
+end
+
-- Draw of `Ground`
function Ground: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.body:getX()+offset_x)*scale, (self.body:getY()+offset_y)*scale, 0, scale, scale)
+ love.graphics.draw(self.sprite, draw_x, draw_y, 0, scale, scale)
-- debug draw
if debug then
love.graphics.setColor(255, 69, 0, 140)