summaryrefslogtreecommitdiffhomepage
path: root/not
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-03-19 03:09:36 +0100
committerAki <nthirtyone@gmail.com>2017-03-19 03:09:36 +0100
commitb10988b7e8a0c52148b1d3828c3739fb0eeff24e (patch)
treebd6b142db6061d044d81543fe2deee7a4288c707 /not
parenta8551f5da9549453381a0f2daa0ff4aefd06272f (diff)
downloadroflnauts-b10988b7e8a0c52148b1d3828c3739fb0eeff24e.zip
roflnauts-b10988b7e8a0c52148b1d3828c3739fb0eeff24e.tar.gz
roflnauts-b10988b7e8a0c52148b1d3828c3739fb0eeff24e.tar.bz2
No constructors for abstracts
Diffstat (limited to 'not')
-rw-r--r--not/PhysicalBody.lua15
-rw-r--r--not/Sprite.lua5
2 files changed, 17 insertions, 3 deletions
diff --git a/not/PhysicalBody.lua b/not/PhysicalBody.lua
index e726ea3..52e9357 100644
--- a/not/PhysicalBody.lua
+++ b/not/PhysicalBody.lua
@@ -1,5 +1,5 @@
--- `PhysicalBody`
--- Abstract class for drawable body existing in Box2D's physical world.
+-- Abstract class for drawable entity existing in `not.World`.
PhysicalBody = {
body =--[[love.physics.newBody]]nil,
}
@@ -9,14 +9,25 @@ require "not.Sprite"
PhysicalBody.__index = PhysicalBody
setmetatable(PhysicalBody, Sprite)
--- Constructor of `PhysicalBody`.
+--[[ Constructor of `PhysicalBody`.
function PhysicalBody:new (world, x, y, imagePath)
local o = setmetatable({}, self)
o:init(world, x, y, imagePath)
return o
end
+]]
-- Initializator of `PhysicalBody`.
function PhysicalBody:init (world, x, y, imagePath)
Sprite.init(self, imagePath)
end
+
+-- Update of `PhysicalBody`.
+function PhysicalBody:update (dt)
+ Sprite.update(self, dt)
+end
+
+-- Draw of `PhysicalBody`.
+function PhysicalBody:draw (offset_x, offset_y, scale, debug)
+ -- TODO: Move debug part here from `not.Hero.draw`.
+end
diff --git a/not/Sprite.lua b/not/Sprite.lua
index d4cde59..e9eb387 100644
--- a/not/Sprite.lua
+++ b/not/Sprite.lua
@@ -9,12 +9,13 @@ Sprite = {
}
Sprite.__index = Sprite
--- Constructor of `Sprite`.
+--[[ Constructor of `Sprite`.
function Sprite:new (imagePath)
local o = setmetatable({}, self)
o:init(imagePath)
return o
end
+]]
-- Cleans up reference to image on deletion.
function Sprite:delete ()
@@ -89,6 +90,7 @@ function Sprite:draw (...)
else love.graphics.draw(i, ...) end
end
end
+
-- Animation updating.
function Sprite:update (dt)
if self.animations and self.current then
@@ -99,6 +101,7 @@ function Sprite:update (dt)
end
end
end
+
-- Moving to the next frame.
function Sprite:goToNextFrame ()
if self.current.repeated or not (self.frame == self.current.frames) then