diff options
author | Aki <nthirtyone@gmail.com> | 2017-03-19 04:19:59 +0100 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-03-19 04:19:59 +0100 |
commit | cca4d9c1bf4033c79e4bd61a257c6ea02557524c (patch) | |
tree | d26570878c7b912a9d3be6c0d8853b315f1c89a1 /not/Hero.lua | |
parent | 2e352657813b37d17c2215b85189f18a50c099f9 (diff) | |
download | roflnauts-cca4d9c1bf4033c79e4bd61a257c6ea02557524c.zip roflnauts-cca4d9c1bf4033c79e4bd61a257c6ea02557524c.tar.gz roflnauts-cca4d9c1bf4033c79e4bd61a257c6ea02557524c.tar.bz2 |
Moving draw away to abstract classes
Diffstat (limited to 'not/Hero.lua')
-rw-r--r-- | not/Hero.lua | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/not/Hero.lua b/not/Hero.lua index a6facd9..7be3104 100644 --- a/not/Hero.lua +++ b/not/Hero.lua @@ -280,24 +280,23 @@ function Hero:controlreleased (set, action, key) end end +-- TODO: comment them and place them somewhere properly +function Hero:getAngle () + return self.angle +end +function Hero:getHorizontalMirror() + return self.facing +end +function Hero:getOffset () + return 12,15 -- TODO: WHY? How about creating body as polygon and using 0,0 instead. LIKE EVERYWHERE ELSE? Make it obsolete both in here and in `not.Sprite`. +end + -- Draw of `Hero` -- TODO: see `not.PhysicalBody.draw` and `not.Sprite.draw`. function Hero:draw (offset_x, offset_y, scale, debug) - -- draw only alive if not self.alive then return end - -- 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 ; `approx` selected to prevent floating characters on certain conditions - local approx = math.floor - if (y - math.floor(y)) > 0.5 then approx = math.ceil end - local draw_y = (approx(y) + offset_y) * scale - local draw_x = (math.floor(x) + offset_x) * scale - -- sprite draw - Sprite.draw(self, draw_x, draw_y, self.angle, self.facing*scale, scale, 12, 15) + PhysicalBody.draw(self, offset_x, offset_y, scale, debug) + -- debug draw if debug then for _,fixture in pairs(self.body:getFixtureList()) do |