From 5c51b6e4d39bc55887f94dc65e58fd1765d86c1c Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 4 Apr 2017 14:30:15 +0200 Subject: First steps to move player-input logics into Player from Hero --- not/Player.lua | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'not/Player.lua') diff --git a/not/Player.lua b/not/Player.lua index fd1613c..373505d 100644 --- a/not/Player.lua +++ b/not/Player.lua @@ -2,6 +2,7 @@ -- Special `not.Hero` controllable by a player. Player = { -- TODO: move functions and properties related to controls from `not.Hero`. + controlSet = --[[Controller.sets.*]]nil, } -- `Player` is a child of `Hero`. @@ -10,13 +11,28 @@ Player.__index = Player setmetatable(Player, Hero) -- Constructor of `Player`. -function Player:new (...) +-- TODO: I'm sure it is a duplicate, but `not.World.create*` methods need to pass proper parameters. +function Player:new (game, world, x, y, name) local o = setmetatable({}, self) - o:init(...) + 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, ...) -end \ No newline at end of file +end + +-- Controller set manipulation. +function Player:assignControlSet (set) + self.controlset = set +end +function Player:getControlSet () + return self.controlset +end -- cgit v1.1