From 7d4251e3a9c08b89d25ef724270752f36649f765 Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 13 May 2016 13:11:51 +0200 Subject: Draw pulled inside the objects --- ground.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'ground.lua') diff --git a/ground.lua b/ground.lua index 1034d71..9f695c8 100644 --- a/ground.lua +++ b/ground.lua @@ -1,6 +1,9 @@ -- `Ground` +-- Static platform physical object with a sprite. `Players` can walk on it. -- Collision category: [1] +-- WHOLE CODE HAS FLAG OF "need a cleanup" + -- Metatable of `Ground` -- nils initialized in constructor Ground = { @@ -21,4 +24,20 @@ function Ground:new (world, x, y, shape, sprite) o.fixture:setCategory(1) o.fixture:setFriction(0.2) return o +end + +-- Draw of `Ground` +function Ground:draw (offset_x, offset_y, debug) + -- defaults + local offset_x = offset_x or 0 + local offset_y = offset_y or 0 + local debug = debug or false + -- sprite draw + love.graphics.setColor(255,255,255,255) + love.graphics.draw(self.sprite, self.body:getX()-math.ceil(self.sprite:getWidth()/2), self.body:getY()) + -- debug draw + if debug then + love.graphics.setColor(220, 220, 220, 100) + love.graphics.polygon("fill", self.body:getWorldPoints(self.shape:getPoints())) + end end \ No newline at end of file -- cgit v1.1