summaryrefslogtreecommitdiffhomepage
path: root/not/Player.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-05-26 19:14:27 +0200
committerAki <nthirtyone@gmail.com>2017-05-26 19:14:27 +0200
commit62b67be7882dffebd6de0c8241d253d806a6905c (patch)
tree4b4bc483d4a95f5cb02cc33e41a5600c28cfb49b /not/Player.lua
parentafac3fdc7ce03e03304eec448149f346099cab94 (diff)
downloadroflnauts-62b67be7882dffebd6de0c8241d253d806a6905c.zip
roflnauts-62b67be7882dffebd6de0c8241d253d806a6905c.tar.gz
roflnauts-62b67be7882dffebd6de0c8241d253d806a6905c.tar.bz2
Halfway through with moving to new OOP module
Diffstat (limited to 'not/Player.lua')
-rw-r--r--not/Player.lua34
1 files changed, 10 insertions, 24 deletions
diff --git a/not/Player.lua b/not/Player.lua
index 2a4b2e6..5d108ce 100644
--- a/not/Player.lua
+++ b/not/Player.lua
@@ -1,31 +1,15 @@
+require "not.Hero"
+
--- `Player`
-- Special `not.Hero` controllable by a player.
-Player = {
- -- TODO: move functions and properties related to controls from `not.Hero`.
- controllerSet = --[[Controller.sets.*]]nil,
-}
+-- TODO: move functions and properties related to controls from `not.Hero`.
+Player = Hero:extends()
--- `Player` is a child of `Hero`.
-require "not.Hero"
-Player.__index = Player
-setmetatable(Player, Hero)
+Player.controllerSet =--[[Controller.sets.*]]nil
-- Constructor of `Player`.
-function Player:new (name, game, x, y)
- local o = setmetatable({}, self)
- o:init(name, game, x, y)
- -- Load portraits statically to `not.Hero`.
- -- TODO: this is heresy, put it into `load` method or something similar.
- if Hero.portrait_sprite == nil then
- Hero.portrait_sprite = love.graphics.newImage("assets/portraits.png")
- Hero.portrait_frame = love.graphics.newImage("assets/menu.png")
- end
- return o
-end
-
--- Initializer of `Player`.
-function Player:init (...)
- Hero.init(self, ...)
+function Player:new (name, x, y, world)
+ Player.__super.new(self, name, x, y, world)
end
-- Controller set manipulation.
@@ -43,7 +27,7 @@ end
-- Update of `Player`.
function Player:update (dt)
- Hero.update(self, dt) -- TODO: It would be probably a good idea to add return to update functions to terminate if something goes badly in parent's update.
+ Player.__super.update(self, dt) -- TODO: It would be probably a good idea to add return to update functions to terminate if something goes badly in parent's update.
if self.body:isDestroyed() then return end
local x, y = self:getLinearVelocity()
-- Jumping.
@@ -157,3 +141,5 @@ function Player:controlreleased (set, action, key)
end
end
end
+
+return Player