diff options
author | Aki <nthirtyone@gmail.com> | 2017-02-08 19:18:25 +0100 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-02-08 19:18:25 +0100 |
commit | a7b1bcc6872579b0ed8dbce399352d3afca1a80f (patch) | |
tree | cad837f35cc495d42385c3238de06804e8d68d07 /ground.lua | |
parent | 939ef3d25ec3dadba9e86b04ae1e294e789175d0 (diff) | |
parent | f44ce392bc511fdfd24c54a5ee24b09f8ff6836f (diff) | |
download | roflnauts-a7b1bcc6872579b0ed8dbce399352d3afca1a80f.zip roflnauts-a7b1bcc6872579b0ed8dbce399352d3afca1a80f.tar.gz roflnauts-a7b1bcc6872579b0ed8dbce399352d3afca1a80f.tar.bz2 |
Merge branch 'animations'
Diffstat (limited to 'ground.lua')
-rw-r--r-- | ground.lua | 20 |
1 files changed, 8 insertions, 12 deletions
@@ -3,6 +3,7 @@ -- Collision category: [1] -- WHOLE CODE HAS FLAG OF "need a cleanup" +require "animated" -- Metatable of `Ground` -- nils initialized in constructor @@ -11,13 +12,14 @@ Ground = { shape = nil, fixture = nil, world = nil, - sprite = nil } +Ground.__index = Ground +setmetatable(Ground, Animated) + -- Constructor of `Ground` -function Ground:new (game, world, x, y, shape, sprite) +function Ground:new (game, world, x, y, shape, sprite, animations) local o = {} setmetatable(o, self) - self.__index = self o.body = love.physics.newBody(world, x, y) -- MULTIPLE SHAPES NEED TO BE REWRITED! o.shape = {} @@ -37,17 +39,12 @@ function Ground:new (game, world, x, y, shape, sprite) end end -- END HERE - o.sprite = love.graphics.newImage(sprite) + o:setSprite(love.graphics.newImage(sprite)) + o:setAnimationsList(animations) o.world = game return o end --- Destructor of `Ground` -function Ground:delete () - -- body deletion is handled by world deletion - self.sprite = nil -end - -- Position function Ground:getPosition() return self.body:getPosition() @@ -65,8 +62,7 @@ function Ground:draw (offset_x, offset_y, scale, debug) 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, draw_x, draw_y, 0, scale, scale) + Animated.draw(self, draw_x, draw_y, 0, scale, scale) -- debug draw if debug then love.graphics.setColor(255, 69, 0, 140) |