summaryrefslogtreecommitdiffhomepage
path: root/ground.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-05-13 13:11:51 +0200
committerAki <nthirtyone@gmail.com>2016-05-13 13:11:51 +0200
commit7d4251e3a9c08b89d25ef724270752f36649f765 (patch)
tree66ba6060a0b2c6f1a2a93f50f804120955244147 /ground.lua
parent6dc1dc3ace057e3f7ff63f56971fdb432734392b (diff)
downloadroflnauts-7d4251e3a9c08b89d25ef724270752f36649f765.zip
roflnauts-7d4251e3a9c08b89d25ef724270752f36649f765.tar.gz
roflnauts-7d4251e3a9c08b89d25ef724270752f36649f765.tar.bz2
Draw pulled inside the objects
Diffstat (limited to 'ground.lua')
-rw-r--r--ground.lua19
1 files changed, 19 insertions, 0 deletions
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