From bd22a09dc862ac5480426bfd5e0311a97b6cfa77 Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 1 Mar 2017 21:31:11 +0100 Subject: Rename: Animated -> Sprite Rename: getSprite, setSprite -> getImage, setImage --- platform.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'platform.lua') diff --git a/platform.lua b/platform.lua index 908cf73..9d75e66 100644 --- a/platform.lua +++ b/platform.lua @@ -3,7 +3,7 @@ -- Collision category: [1] -- WHOLE CODE HAS FLAG OF "need a cleanup" -require "animated" +require "sprite" -- Metatable of `Platform` -- nils initialized in constructor @@ -14,7 +14,7 @@ Platform = { world = nil, } Platform.__index = Platform -setmetatable(Platform, Animated) +setmetatable(Platform, Sprite) -- Constructor of `Platform` function Platform:new (game, world, x, y, shape, sprite, animations) @@ -39,7 +39,7 @@ function Platform:new (game, world, x, y, shape, sprite, animations) end end -- END HERE - o:setSprite(love.graphics.newImage(sprite)) + o:setImage(love.graphics.newImage(sprite)) o:setAnimationsList(animations) o.world = game return o @@ -62,7 +62,7 @@ function Platform: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 - Animated.draw(self, draw_x, draw_y, 0, scale, scale) + Sprite.draw(self, draw_x, draw_y, 0, scale, scale) -- debug draw if debug then love.graphics.setColor(255, 69, 0, 140) -- cgit v1.1 From 84278ed41f61c586dbb38dd99c45ee33e2f58c77 Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 16 Mar 2017 19:05:50 +0100 Subject: Moved ? -> not.?; Renamed Player -> Hero --- platform.lua | 73 ------------------------------------------------------------ 1 file changed, 73 deletions(-) delete mode 100644 platform.lua (limited to 'platform.lua') diff --git a/platform.lua b/platform.lua deleted file mode 100644 index 9d75e66..0000000 --- a/platform.lua +++ /dev/null @@ -1,73 +0,0 @@ --- `Platform` --- Static platform physical object with a sprite. `Players` can walk on it. --- Collision category: [1] - --- WHOLE CODE HAS FLAG OF "need a cleanup" -require "sprite" - --- Metatable of `Platform` --- nils initialized in constructor -Platform = { - body = nil, - shape = nil, - fixture = nil, - world = nil, -} -Platform.__index = Platform -setmetatable(Platform, Sprite) - --- Constructor of `Platform` -function Platform:new (game, world, x, y, shape, sprite, animations) - local o = {} - setmetatable(o, self) - o.body = love.physics.newBody(world, x, y) - -- MULTIPLE SHAPES NEED TO BE REWRITED! - o.shape = {} - if type(shape[1]) == "number" then - local poly = love.physics.newPolygonShape(shape) - table.insert(o.shape, poly) - o.fixture = love.physics.newFixture(o.body, poly) - o.fixture:setCategory(1) - o.fixture:setFriction(0.2) - else - for i,v in pairs(shape) do - local poly = love.physics.newPolygonShape(v) - table.insert(o.shape, poly) - local fixture = love.physics.newFixture(o.body, poly) - fixture:setCategory(1) - fixture:setFriction(0.2) - end - end - -- END HERE - o:setImage(love.graphics.newImage(sprite)) - o:setAnimationsList(animations) - o.world = game - return o -end - --- Position -function Platform:getPosition() - return self.body:getPosition() -end - --- Draw of `Platform` -function Platform:draw (offset_x, offset_y, scale, debug) - -- 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 - Sprite.draw(self, draw_x, draw_y, 0, scale, scale) - -- debug draw - if debug then - love.graphics.setColor(255, 69, 0, 140) - for i,v in pairs(self.shape) do - love.graphics.polygon("fill", self.world.camera:translatePoints(self.body:getWorldPoints(v:getPoints()))) - end - end -end \ No newline at end of file -- cgit v1.1