diff options
author | Aki <nthirtyone@gmail.com> | 2016-06-03 00:55:56 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2016-06-03 00:55:56 +0200 |
commit | 1027ec0d527d29c5ae47919ae12bcab176b46182 (patch) | |
tree | 57c76cb5c3fbcba05ed72bdcdd07fe18ed2b93ad /decoration.lua | |
parent | 728c8aa62add0310119017615c7e973e35daf146 (diff) | |
download | roflnauts-1027ec0d527d29c5ae47919ae12bcab176b46182.zip roflnauts-1027ec0d527d29c5ae47919ae12bcab176b46182.tar.gz roflnauts-1027ec0d527d29c5ae47919ae12bcab176b46182.tar.bz2 |
Map decorations added
Diffstat (limited to 'decoration.lua')
-rw-r--r-- | decoration.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/decoration.lua b/decoration.lua new file mode 100644 index 0000000..226b7f9 --- /dev/null +++ b/decoration.lua @@ -0,0 +1,30 @@ +Decoration = { + world = nil, + sprite = nil, + x = 0, + y = 0 +} +function Decoration:new(x, y, sprite) + local o = {} + setmetatable(o, self) + self.__index = self + o.sprite = love.graphics.newImage(sprite) + o:setPosition(x,y) + return o +end +function Decoration:setPosition(x, y) + self.x, self.y = x, y +end +function Decoration:getPosition() + return self.x, self.y +end +function Decoration:draw(offset_x, offset_y, scale) + -- defaults + local offset_x = offset_x or 0 + local offset_y = offset_y or 0 + local scale = scale or 1 + -- draw + love.graphics.setColor(255,255,255,255) + local x, y = self:getPosition() + love.graphics.draw(self.sprite, (x+offset_x)*scale, (y+offset_y)*scale, 0, scale, scale) +end
\ No newline at end of file |