summaryrefslogtreecommitdiffhomepage
path: root/not/Decoration.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-04-03 18:32:59 +0200
committerAki <nthirtyone@gmail.com>2017-04-03 18:32:59 +0200
commit93e91c1821087b05f235ae356b7af4d8cfc3cae7 (patch)
treec0127be3f55d460d6c8a622d09baafb00b62fd6b /not/Decoration.lua
parent8fa7ec07a1a9b4307ed9b221770c91a242cd68d9 (diff)
downloadroflnauts-93e91c1821087b05f235ae356b7af4d8cfc3cae7.zip
roflnauts-93e91c1821087b05f235ae356b7af4d8cfc3cae7.tar.gz
roflnauts-93e91c1821087b05f235ae356b7af4d8cfc3cae7.tar.bz2
Decoration properly inherits from Sprite
Diffstat (limited to 'not/Decoration.lua')
-rw-r--r--not/Decoration.lua36
1 files changed, 21 insertions, 15 deletions
diff --git a/not/Decoration.lua b/not/Decoration.lua
index a57c143..80f6653 100644
--- a/not/Decoration.lua
+++ b/not/Decoration.lua
@@ -1,27 +1,33 @@
--- TODO: follow new code template
--- TODO: add comments
-require "not.Sprite"
+--- `Decoration`
+-- Positioned sprite used to decorate maps with additional graphics.
Decoration = {
- world = nil,
- sprite = nil,
+ world = --[[not.World]]nil,
x = 0,
y = 0
}
+
+-- `Decoration` is a child of `Sprite`.
+require "not.Sprite"
Decoration.__index = Decoration
setmetatable(Decoration, Sprite)
-function Decoration:new(x, y, sprite)
- local o = {}
- setmetatable(o, self)
- o:setImage(love.graphics.newImage(sprite))
- o:setPosition(x,y)
+
+-- Constructor of `Decoration`.
+function Decoration:new (x, y, imagePath)
+ local o = setmetatable({}, self)
+ o:init(x, y, imagePath)
return o
end
-function Decoration:setPosition(x, y)
- self.x, self.y = x, y
+
+-- Initializator of `Decoration`.
+function Decoration:init (x, y, imagePath)
+ Sprite.init(self, imagePath)
+ self:setPosition(x, y)
end
-function Decoration:getPosition()
+
+-- Position-related methods.
+function Decoration:getPosition ()
return self.x, self.y
end
-function Decoration:draw(offset_x, offset_y, scale)
- Sprite.draw(self, offset_x, offset_y, scale)
+function Decoration:setPosition (x, y)
+ self.x, self.y = x, y
end \ No newline at end of file