summaryrefslogtreecommitdiffhomepage
path: root/not/Decoration.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-03-16 19:05:50 +0100
committerAki <nthirtyone@gmail.com>2017-03-16 19:05:50 +0100
commit84278ed41f61c586dbb38dd99c45ee33e2f58c77 (patch)
treed7661f79901f40464b0b39a9bc5de6f4d5191b3b /not/Decoration.lua
parentbd22a09dc862ac5480426bfd5e0311a97b6cfa77 (diff)
downloadroflnauts-84278ed41f61c586dbb38dd99c45ee33e2f58c77.zip
roflnauts-84278ed41f61c586dbb38dd99c45ee33e2f58c77.tar.gz
roflnauts-84278ed41f61c586dbb38dd99c45ee33e2f58c77.tar.bz2
Moved ? -> not.?; Renamed Player -> Hero
Diffstat (limited to 'not/Decoration.lua')
-rw-r--r--not/Decoration.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/not/Decoration.lua b/not/Decoration.lua
new file mode 100644
index 0000000..7f020e1
--- /dev/null
+++ b/not/Decoration.lua
@@ -0,0 +1,34 @@
+require "not.Sprite"
+Decoration = {
+ world = nil,
+ sprite = nil,
+ x = 0,
+ y = 0
+}
+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)
+ 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)
+ -- locals
+ local offset_x = offset_x or 0
+ local offset_y = offset_y or 0
+ local scale = scale or 1
+ 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
+ -- draw
+ Sprite.draw(self, draw_x, draw_y, 0, scale, scale)
+end \ No newline at end of file