summaryrefslogtreecommitdiffhomepage
path: root/not
diff options
context:
space:
mode:
Diffstat (limited to 'not')
-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